Jump to content

Source of a local iframe as a php variable to be saved to txt file.


Recommended Posts

Yes it does, and I can get that to work. I need to get around the same domain policy to work with local files. I'm writing a whitepaper on this particular security idea.

 

<?php $DEFAULT_FILE = "index.php"; ?>
<?php $url=fopen("url.txt","r"); ?>
<?php $file = fgets($url); ?>
<?php
  if (isset($file)) {
    $file2 = $file;
    echo "<div class=\"source\">\n";
    $content=file_get_contents($file2);
    echo $content;
    echo "</div>\n";
    } else {
    $file = $DEFAULT_FILE;
  }
?>


<?php
$filename = substr($file2,7) . ".html";

if (is_writable($filename)) {

if (!$handle = fopen($filename, 'w')) {
        echo "Cannot open file ($filename)";
        exit;
  }

   if (fwrite($handle, $content) === FALSE) {
       echo "Cannot write to file ($filename)";
       exit;
   }

   echo "Success, wrote ($content) to file ($filename)";

   fclose($handle);

} else {
   echo "The file $filename is not writable";
}
?>

 

As you can see, the code works. However, if I use this script, it will not keep the session that I have with the external site alive because the IP is from my server and not from myself. So I'm looking to do this through other avenues. The view-source:http://site.com/ is one of those avenues.

How would view-source sort the problem? I don't actually think view-source is anything more than a browser command? (Though it's not actually supported in IE) .. I think sending view-source at the start of the file_get_contents function would just cause it to fail?

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.