Jump to content

Setting parameters in file_get_contents.


Xproterg^vi

Recommended Posts

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.

 

 

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.