Jump to content

[SOLVED] PHP to Static HTML


ravix76

Recommended Posts

Hi, I'm trying to dump my PHP code to Static HTML and have followed this tutorial:

 

http://www.phpfreaks.com/tutorials/29/4.php

 

However, the static file is only partially complete which I suspect is due to the fread limit?  I note at the bottom of that tutorial that a fellow user had the same problem but the links to the responses don't seem to work (probably as it's 3 years old!).

 

Can anyone help me with a work around to get my PHP fully dumped?

 

Thanks

 

Ravix76

Link to comment
https://forums.phpfreaks.com/topic/39957-solved-php-to-static-html/
Share on other sites

It's pretty much identical to that in the tutorial:

 

$url = "xxxx URL With-held xxxx";
$sourcepage = "$url/data/dynamicfiles/showproductpage.php?id=1";
$tempfilename = "../data/dynamicfiles/temp_suppfile.html";
$targetfilename = "../data/".$branddir.$productfilename.".html"; 
$dynamic_source = fopen($sourcepage, 'r'); 
if (!$dynamic_source) {
echo "<strong>Unable to load $sourcepage
- Static page! Update Failed!</strong>";
exit();
}

$htmldata = fread($dynamic_source, 1280*1280);
fclose($dynamic_source);
$tempfile = fopen($tempfilename, 'w');

if (!$tempfile) {
echo"<strong>Unable to open temporary file $tempfilename for writing!
Static page update aborted!</strong>";
exit();
}

fwrite($tempfile, $htmldata);
fclose($tempfile);

copy($tempfilename, $targetfilename);
unlink($tempfilename);

echo "<strong>Static HTML Page Built!</strong>";

 

It appears to run fine, but the source of the static page is incomplete, hence half the page is missing.

well here's the thing, I tested it on a page just now and it works fine for a short file like u said, so to truly understand the problem one would need to see the url you hid to see why exactly it is getting cut off and at what file size, etc..

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.