Xproterg^vi Posted October 1, 2008 Share Posted October 1, 2008 The code below presents a dilemma that I've been trying to work through for quite some time. <?php $file2 = 'view-source:http://www.google.com/'; $content=file_get_contents($file2); echo $content; ?> It returns the following error: Warning: file_get_contents(view-source:http://www.google.com/) [function.file-get-contents]: failed to open stream: No such file or directory in /home/lance/public_html/panel/ on line 5 So the file_get_contents is attempting to get the file from /home/lace/public_html/panel/. I want it to draw from the raw url, not my server. In other words, I want file_get_contents(view-source:http://www.google.com/) to return the same content as view-source:http://www.google.com/. Does anyone know how to modify the file_get_contents so that it will return this? ps - I know file_get_contents(http://www.google.com/) works, but that's not I need. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted October 1, 2008 Share Posted October 1, 2008 view-source: is a browser thing....I think you completely misunderstand the concept of URLs. If you grab a URL through file_get_contents, the resulting variable is the source. Quote Link to comment Share on other sites More sharing options...
Xproterg^vi Posted October 1, 2008 Author Share Posted October 1, 2008 ahh... got it finally. Thanks That brings be to my next question. How can one get the source of an iframe that has an external page loaded? Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted October 1, 2008 Share Posted October 1, 2008 run file_get_contents() on the url the iframe is displaying? Quote Link to comment Share on other sites More sharing options...
Xproterg^vi Posted October 1, 2008 Author Share Posted October 1, 2008 <?php $file2 = file_get_contents('http://www.phpfreaks.com/forums/index.php'); echo $file2; ?> If I login and set my session to never expire on http://www.phpfreaks.com/forums/index.php, then use the above code on my server, my session is dead when the page loads. This is what I tried to get around by attempting to load the file locally using the browser command view-source. That obviously doesn't work. I'm looking for something like... <?php $file2 = get_source_of_object(thiswindow.thisdocument.bypass.src); echo $file2; ?> <html> <body> <iframe name='bypass' src='http://www.phpfreaks.com/forums/index.php'> </body> </html> Catch my drift? This one has me stumped. Quote Link to comment Share on other sites More sharing options...
hawkenterprises Posted October 1, 2008 Share Posted October 1, 2008 What is the intended purpose of this? It seems that if we knew the ultimate goal we might be able to help you find a different less complicated route. Any reason this can't user CURL or fsockopen instead? Quote Link to comment Share on other sites More sharing options...
Xproterg^vi Posted October 1, 2008 Author Share Posted October 1, 2008 The intended purpose is a bit complicated. When a user visits my website, the iframe that is on my page will load a number of external websites, keeping the users's previous sessions active. My website then has the ability to save those websites, as the users see them (sessions and all), to files on my server that can be retrieved later by the user. Any method to complete this is appropriate. Quote Link to comment Share on other sites More sharing options...
trq Posted October 1, 2008 Share Posted October 1, 2008 If I login and set my session to never expire on http://www.phpfreaks.com/forums/index.php, then use the above code on my server, my session is dead when the page loads. Your session relates to your browser via cookies. Just because you execute a php script from the same machine does not mean it relates to the same session. curl is probably closer to what you want but it still wont get you what you just described. Short of your users providing you there login details there isn't a way your site can share sessions between itself and other sites. Quote Link to comment Share on other sites More sharing options...
Xproterg^vi Posted October 1, 2008 Author Share Posted October 1, 2008 What can curl do? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 1, 2008 Share Posted October 1, 2008 It sounds a little phishy (fishy) to me Quote Link to comment Share on other sites More sharing options...
trq Posted October 1, 2008 Share Posted October 1, 2008 What can curl do? Given the right credentials it can login to a website and download content amongst other things. Quote Link to comment Share on other sites More sharing options...
Xproterg^vi Posted October 1, 2008 Author Share Posted October 1, 2008 It sounds a little phishy (fishy) to me It should. The whole purpose for this script functioning is to provide a working example in a white paper that I'm writing. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.