Re: [PHP] Writing static file from dynamic PHP page
Chris Bruce wrote: Hi, I am looking for a way to write to a file what the browser would see (raw html) when viewing a dynamic PHP page. I have numerous include files, MySQL db queries, loops etc. and I want to generate the static result of that file and save it as an html page. I have toyed a little with output buffering to no avail. Is there an easy way to do this? Thanks, Chris Here's a great article on the subject from the Zend website: http://www.zend.com/zend/art/scriptcaching.php It's a little more complex than you would hope but is well thought out. --Separate directories is set up to hold the php source and the cached html. --The cached html directory is initially empty. --An Apache ErrorDocument directive is used to intercept the 404 document not found error when someone is requesting a page and to redirect it to a single caching script. --This caching script uses fopen() to open and then read the php script and to write the output to the cached html directory. Hats off to Zend for publishing this. It competes with their Zend Cache product. From the article: If your site contains a few small scripts, you may not need to bother with caching at all. On the other hand, if you rely on complex scripts and fresh data, you should use a much more sophisticated solution, such as the Zend Cache http://www.zend.com/store/products/zend-cache.php. But if you are somewhere in between, I hope this article will be of help to you. If you have any comments, please feel free to email me. (Sorry to take so long to post this. I had remembered reading the article but couldn't find it. Finally thought to do a Google for 404 php cache.) Hope this helps, -John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing static file from dynamic PHP page
sorry for the repost, but my mail server was down from about 11pmEST last night to 9:15am this morning and unable to receive responses. Can someone forward me responses to this post if any? Thanks. Chris Hi, I am looking for a way to write to a file what the browser would see (raw html) when viewing a dynamic PHP page. I have numerous include files, MySQL db queries, loops etc. and I want to generate the static result of that file and save it as an html page. I have toyed a little with output buffering to no avail. Is there an easy way to do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing static file from dynamic PHP page
Chris Bruce wrote: sorry for the repost, but my mail server was down from about 11pmEST last night to 9:15am this morning and unable to receive responses. Can someone forward me responses to this post if any? Thanks. Chris Hi, I am looking for a way to write to a file what the browser would see (raw html) when viewing a dynamic PHP page. I have numerous include files, MySQL db queries, loops etc. and I want to generate the static result of that file and save it as an html page. I have toyed a little with output buffering to no avail. Is there an easy way to do this? Just build the site you want with PHP, and then use wget to suck down the pages into your static directory. Output buffering should have worked, but it's too easy for somebody else to mess up the buffering if they want to use it for something else in their business logic. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing static file from dynamic PHP page
Just an fyi...this would be VERY easy to get online. PHP keeps an archive of all the posts. Here's the link http://marc.theaimsgroup.com/?l=php-general In fact, you may even find other posts similar to yours by searching (that could answer your question?) -Chris On Tue, 18 Jan 2005 09:30:00 -0500, Chris Bruce [EMAIL PROTECTED] wrote: sorry for the repost, but my mail server was down from about 11pmEST last night to 9:15am this morning and unable to receive responses. Can someone forward me responses to this post if any? Thanks. Chris Hi, I am looking for a way to write to a file what the browser would see (raw html) when viewing a dynamic PHP page. I have numerous include files, MySQL db queries, loops etc. and I want to generate the static result of that file and save it as an html page. I have toyed a little with output buffering to no avail. Is there an easy way to do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing static file from dynamic PHP page
On Tuesday 18 January 2005 22:30, Chris Bruce wrote: sorry for the repost, but my mail server was down from about 11pmEST last night to 9:15am this morning and unable to receive responses. Unless your mailserver is seriously buggered then you _will_ receive whatever replies there were eventually -- internet mail is pretty robust. Can someone forward me responses to this post if any? Thanks. Chris archives ... -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing static file from dynamic PHP page
This is a great solution, except I cannot get PHP to exec the file that has the 'wget' command in it. What I have done is to create a file (wget.php) into the directory that I want to wget the page into. I then chmod -R the directory to make everything in it executable. here is what is written to the file: /usr/bin/wget -d http://path/to/file/index.html Then in the PHP function I make a an exec call on that file exec(/path/to/file/wget.php,$out,$err); Everything is cool, except the exec does not happen. The $out array looks like this: Array { } and the $err returns '126' But the exec doesn't happen. If I run the contents of wget.php on the command line, presto, it works. So, what is the deal? Is it a problem with the apache user not having access to wget through PHP?? On Jan 18, 2005, at 11:41 AM, Richard Lynch wrote: Chris Bruce wrote: sorry for the repost, but my mail server was down from about 11pmEST last night to 9:15am this morning and unable to receive responses. Can someone forward me responses to this post if any? Thanks. Chris Hi, I am looking for a way to write to a file what the browser would see (raw html) when viewing a dynamic PHP page. I have numerous include files, MySQL db queries, loops etc. and I want to generate the static result of that file and save it as an html page. I have toyed a little with output buffering to no avail. Is there an easy way to do this? Just build the site you want with PHP, and then use wget to suck down the pages into your static directory. Output buffering should have worked, but it's too easy for somebody else to mess up the buffering if they want to use it for something else in their business logic. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing static file from dynamic PHP page
On Tue, January 18, 2005 2:42 pm, Chris Bruce said: This is a great solution, except I cannot get PHP to exec the file that has the 'wget' command in it. What I have done is to create a file (wget.php) into the directory that I want to wget the page into. I then chmod -R the directory to make everything in it executable. here is what is written to the file: /usr/bin/wget -d http://path/to/file/index.html put this at the begining of wget.php #!/bin/sh HTH -R'twick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing static file from dynamic PHP page
* Christopher Fulton [EMAIL PROTECTED]: Just an fyi...this would be VERY easy to get online. PHP keeps an archive of all the posts. Here's the link http://marc.theaimsgroup.com/?l=php-general Also, try http://news.php.net/php.general Though it's not currently searchable -- you can still find all posts. On Tue, 18 Jan 2005 09:30:00 -0500, Chris Bruce [EMAIL PROTECTED] wrote: sorry for the repost, but my mail server was down from about 11pmEST last night to 9:15am this morning and unable to receive responses. Can someone forward me responses to this post if any? Thanks. Chris Hi, I am looking for a way to write to a file what the browser would see (raw html) when viewing a dynamic PHP page. I have numerous include files, MySQL db queries, loops etc. and I want to generate the static result of that file and save it as an html page. I have toyed a little with output buffering to no avail. Is there an easy way to do this? -- Matthew Weier O'Phinney | mailto:[EMAIL PROTECTED] Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing static file from dynamic PHP page
Chris Bruce wrote: This is a great solution, except I cannot get PHP to exec the file that has the 'wget' command in it. What I have done is to create a file (wget.php) into the directory that I want to wget the page into. I then chmod -R the directory to make everything in it executable. here is what is written to the file: /usr/bin/wget -d http://path/to/file/index.html Then in the PHP function I make a an exec call on that file exec(/path/to/file/wget.php,$out,$err); Everything is cool, except the exec does not happen. The $out array looks like this: Array { } and the $err returns '126' But the exec doesn't happen. If I run the contents of wget.php on the command line, presto, it works. So, what is the deal? Is it a problem with the apache user not having access to wget through PHP?? Almost for sure, yes. Though you've now made it even more complex, because maybe the PHP user doesn't have eXec priveleges for your 'wget.php' file, in addition to not having eXec priveleges to 'wget' in /usr/bin Plus, having PHP able to write the file, and PHP able to eXec the file, wget.php, would be a pretty gaping security hole on a shared server... You've got to make it possible for the PHP user to: A) eXec wget B) Write into the output directory wget will use Honestly, though, wget is *SO* easy, you may want to bypass PHP for that part of it anyway -- A cron job to wget the site or a simple shell script might be easier to work with than running PHP to run wget... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing static file from dynamic PHP page
Chris, I've done something like this to update website's static pages. Basically, in a php script I've replaced all of the print statements with $line.= statements to accumulate all the items you want printed into one long string. I've then ftp'ed this string, along with the name of the html page, to the website where the page is to be viewed. You could also set up an html page with links to a php page that generates the above stuff, and then use a header() command as the last line of the php page to go to the .html page you just generated. Hope this helps. Hugh - Original Message - From: Chris Bruce [EMAIL PROTECTED] To: PHP-General php-general@lists.php.net Sent: Monday, January 17, 2005 7:16 PM Subject: [PHP] Writing static file from dynamic PHP page Hi, I am looking for a way to write to a file what the browser would see (raw html) when viewing a dynamic PHP page. I have numerous include files, MySQL db queries, loops etc. and I want to generate the static result of that file and save it as an html page. I have toyed a little with output buffering to no avail. Is there an easy way to do this? Thanks, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.6.13 - Release Date: 1/16/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.6.13 - Release Date: 1/16/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing static file from dynamic PHP page
On Mon, 2005-01-17 at 21:16, Chris Bruce wrote: Hi, I am looking for a way to write to a file what the browser would see (raw html) when viewing a dynamic PHP page. I have numerous include files, MySQL db queries, loops etc. and I want to generate the static result of that file and save it as an html page. I have toyed a little with output buffering to no avail. Is there an easy way to do this? Interesting requirement. I suppose something other than view source from the browser or wget is needed? Bret -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php