Re: [PHP] **** Converting dynamic webpages into static HTML pages
Easy and intuitive are all the programs that allow you to download the whole website http://download.com.com/3150-2071-0.html?tag=dir Ron Stagg wrote: I have an interesting challenge. I have built an online product catalog that is driven entirely by the contents of the product database (MySQL). The entire catalog is implemented in a single PHP script (catalog.php). The dynamic nature of this implementation allows the catalog script to generate hundreds of product description pages. Now, my client has requested that I give him the ability to generate a static version of the catalog so that he can burn it onto a CD for distribution at trade shows. He wants the CD to be a snapshot of the catalog. Furthermore, he wants to be able to generate this snapshot frequently so that pricing info on the CD will be current. To accommodate this, the process for generating the snapshot must be easy and intuitive. My plan of attack is to generate static HTML files by running the catalog script once for each product in the database. Here is my quandary; instead of echoing the output to a buffer for Apache to send off to the client, I need the script to output to a file. I do not want to write a second version of catalog.php that writes everything to file. There must be an easier way to do this. Is there a way I can access the output buffer that Apache sends to the client? Any other ideas? Thanks, Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] **** Converting dynamic webpages into static HTML pages
Compile php as a static binary (CGI execution mode?) and add something liek the following to your code at the top: #!/usr/local/bin/php $arg_count = 1; while ($arg_count count($argv)) { $argument = $argv[$arg_count]; $arg_split = split(=,$argument); $variable = trim($arg_split[0]); $value = trim($arg_split[1]); if ($variable != $value != ) $$variable = $value; $arg_count = $arg_count + 1; } Make catalog.php executable, then run it as such: (assuming product_type and product_seq are the vars you use) ./catalog.php product_type=1 product_seq=2 products.html Matt - Original Message - From: Ron Stagg [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 27, 2002 2:18 PM Subject: [PHP] Converting dynamic webpages into static HTML pages I have an interesting challenge. I have built an online product catalog that is driven entirely by the contents of the product database (MySQL). The entire catalog is implemented in a single PHP script (catalog.php). The dynamic nature of this implementation allows the catalog script to generate hundreds of product description pages. Now, my client has requested that I give him the ability to generate a static version of the catalog so that he can burn it onto a CD for distribution at trade shows. He wants the CD to be a snapshot of the catalog. Furthermore, he wants to be able to generate this snapshot frequently so that pricing info on the CD will be current. To accommodate this, the process for generating the snapshot must be easy and intuitive. My plan of attack is to generate static HTML files by running the catalog script once for each product in the database. Here is my quandary; instead of echoing the output to a buffer for Apache to send off to the client, I need the script to output to a file. I do not want to write a second version of catalog.php that writes everything to file. There must be an easier way to do this. Is there a way I can access the output buffer that Apache sends to the client? Any other ideas? Thanks, Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] **** Converting dynamic webpages into static HTML pages
I'm not sure... I always echo... I don't really like embedded code... gets confusing when one part of the page is one thing and another is another. At the very least you coudl try it, I know its farily easy to build a script which will rip through the script to fix it to make it all php friendly. The other alternative is to have a script require() the php file, just set your variables in the script, then require('catalog.php'); All code will be executed as if it were part of the script. Matt - Original Message - From: Ron Stagg [EMAIL PROTECTED] To: Matt Vos [EMAIL PROTECTED] Sent: Wednesday, November 27, 2002 2:49 PM Subject: RE: [PHP] Converting dynamic webpages into static HTML pages I like your direction. When running PHP as a static binary, how does it handle text (HTML code) that falls outsize of the ?PHP ? tags. Is the text ignored or outputted? Ron -Original Message- From: Matt Vos [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 27, 2002 12:42 PM To: Ron Stagg; [EMAIL PROTECTED] Subject: Re: [PHP] Converting dynamic webpages into static HTML pages Compile php as a static binary (CGI execution mode?) and add something liek the following to your code at the top: #!/usr/local/bin/php $arg_count = 1; while ($arg_count count($argv)) { $argument = $argv[$arg_count]; $arg_split = split(=,$argument); $variable = trim($arg_split[0]); $value = trim($arg_split[1]); if ($variable != $value != ) $$variable = $value; $arg_count = $arg_count + 1; } Make catalog.php executable, then run it as such: (assuming product_type and product_seq are the vars you use) ./catalog.php product_type=1 product_seq=2 products.html Matt - Original Message - From: Ron Stagg [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 27, 2002 2:18 PM Subject: [PHP] Converting dynamic webpages into static HTML pages I have an interesting challenge. I have built an online product catalog that is driven entirely by the contents of the product database (MySQL). The entire catalog is implemented in a single PHP script (catalog.php). The dynamic nature of this implementation allows the catalog script to generate hundreds of product description pages. Now, my client has requested that I give him the ability to generate a static version of the catalog so that he can burn it onto a CD for distribution at trade shows. He wants the CD to be a snapshot of the catalog. Furthermore, he wants to be able to generate this snapshot frequently so that pricing info on the CD will be current. To accommodate this, the process for generating the snapshot must be easy and intuitive. My plan of attack is to generate static HTML files by running the catalog script once for each product in the database. Here is my quandary; instead of echoing the output to a buffer for Apache to send off to the client, I need the script to output to a file. I do not want to write a second version of catalog.php that writes everything to file. There must be an easier way to do this. Is there a way I can access the output buffer that Apache sends to the client? Any other ideas? Thanks, Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] **** Converting dynamic webpages into static HTML pages
Thank you! This is just what I was looking for. I was not aware of the output control functions. Using the ob_ functions will make this child's play. Thanks again, Ron -Original Message- From: Michael Hazelden [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 27, 2002 12:29 PM To: Ron Stagg Subject: RE: [PHP] Converting dynamic webpages into static HTML pages While this does involve the creation of a second script - it's only a small change: do an Ob_start at the beginning of the script ... Then use ob_get_contents to output to a file at the end ... Two or three commands (including the fopen) which you'd have to add ... How's that? Michael. -Original Message- From: Ron Stagg [mailto:[EMAIL PROTECTED]] Sent: 27 November 2002 19:19 To: [EMAIL PROTECTED] Subject: [PHP] Converting dynamic webpages into static HTML pages I have an interesting challenge. I have built an online product catalog that is driven entirely by the contents of the product database (MySQL). The entire catalog is implemented in a single PHP script (catalog.php). The dynamic nature of this implementation allows the catalog script to generate hundreds of product description pages. Now, my client has requested that I give him the ability to generate a static version of the catalog so that he can burn it onto a CD for distribution at trade shows. He wants the CD to be a snapshot of the catalog. Furthermore, he wants to be able to generate this snapshot frequently so that pricing info on the CD will be current. To accommodate this, the process for generating the snapshot must be easy and intuitive. My plan of attack is to generate static HTML files by running the catalog script once for each product in the database. Here is my quandary; instead of echoing the output to a buffer for Apache to send off to the client, I need the script to output to a file. I do not want to write a second version of catalog.php that writes everything to file. There must be an easier way to do this. Is there a way I can access the output buffer that Apache sends to the client? Any other ideas? Thanks, Ron _ This message has been checked for all known viruses by the MessageLabs Virus Control Centre. This message has been checked for all known viruses by the MessageLabs Virus Control Centre. * Notice: This email is confidential and may contain copyright material of Ocado Limited (the Company). Opinions and views expressed in this message may not necessarily reflect the opinions and views of the Company. If you are not the intended recipient, please notify us immediately and delete all copies of this message. Please note that it is your responsibility to scan this message for viruses. Company reg. no. 3875000. Swallowdale Lane, Hemel Hempstead HP2 7PY * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] **** Converting dynamic webpages into static HTML pages
I'll have to pseudo code this, but following on from Matt's suggestion of a standalone php script to generate the necessary files, let the database do the work. allproducts.php select whatever fields are necessary from the database as parameters for catalog.php work down the result set from the above query create file for output naming it for the product number, e.g $prd_num.'html execute catalog.php, (which you already have) passing it necessary params, directing output to file handle for $prd_num.'html' close the file loop create file index.php (or whatever) write necessary header and initial content work down the result set from the query a second time write the description, embed image, product number as URL pointing to $prd_num.html loop If allproducts.php was to create one huge file of products, then abandon the second loop, just keep writing to the first file. (Or if using Matt's code, use instead of .) Caveat - watch out for a table which may accidentally surround the whole of the output - this would bring NS 4.x to its knees. HTH - Miles Thompson At 02:57 PM 11/27/2002 -0500, Matt Vos wrote: I'm not sure... I always echo... I don't really like embedded code... gets confusing when one part of the page is one thing and another is another. At the very least you coudl try it, I know its farily easy to build a script which will rip through the script to fix it to make it all php friendly. The other alternative is to have a script require() the php file, just set your variables in the script, then require('catalog.php'); All code will be executed as if it were part of the script. Matt - Original Message - From: Ron Stagg [EMAIL PROTECTED] To: Matt Vos [EMAIL PROTECTED] Sent: Wednesday, November 27, 2002 2:49 PM Subject: RE: [PHP] Converting dynamic webpages into static HTML pages I like your direction. When running PHP as a static binary, how does it handle text (HTML code) that falls outsize of the ?PHP ? tags. Is the text ignored or outputted? Ron -Original Message- From: Matt Vos [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 27, 2002 12:42 PM To: Ron Stagg; [EMAIL PROTECTED] Subject: Re: [PHP] Converting dynamic webpages into static HTML pages Compile php as a static binary (CGI execution mode?) and add something liek the following to your code at the top: #!/usr/local/bin/php $arg_count = 1; while ($arg_count count($argv)) { $argument = $argv[$arg_count]; $arg_split = split(=,$argument); $variable = trim($arg_split[0]); $value = trim($arg_split[1]); if ($variable != $value != ) $$variable = $value; $arg_count = $arg_count + 1; } Make catalog.php executable, then run it as such: (assuming product_type and product_seq are the vars you use) ./catalog.php product_type=1 product_seq=2 products.html Matt - Original Message - From: Ron Stagg [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 27, 2002 2:18 PM Subject: [PHP] Converting dynamic webpages into static HTML pages I have an interesting challenge. I have built an online product catalog that is driven entirely by the contents of the product database (MySQL). The entire catalog is implemented in a single PHP script (catalog.php). The dynamic nature of this implementation allows the catalog script to generate hundreds of product description pages. Now, my client has requested that I give him the ability to generate a static version of the catalog so that he can burn it onto a CD for distribution at trade shows. He wants the CD to be a snapshot of the catalog. Furthermore, he wants to be able to generate this snapshot frequently so that pricing info on the CD will be current. To accommodate this, the process for generating the snapshot must be easy and intuitive. My plan of attack is to generate static HTML files by running the catalog script once for each product in the database. Here is my quandary; instead of echoing the output to a buffer for Apache to send off to the client, I need the script to output to a file. I do not want to write a second version of catalog.php that writes everything to file. There must be an easier way to do this. Is there a way I can access the output buffer that Apache sends to the client? Any other ideas? Thanks, Ron -- 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] **** Converting dynamic webpages into static HTML pages
When running PHP as a static binary, how does it handle text (HTML code) that falls outsize of the ?PHP ? tags. Is the text ignored or outputted? Outputted. This can be very handy. One thing I use it for is customizing configuration files where only a small percentage of the overall text needs to be modified. Using ?=$Varname? in the text makes it very powerful. Now, my client has requested that I give him the ability to generate a static version of the catalog so that he can burn it onto a CD for distribution at trade shows. He wants the CD to be a snapshot of the catalog. Furthermore, he wants to be able to generate this snapshot frequently so that pricing info on the CD will be current. To accommodate this, the process for generating the snapshot must be easy and intuitive. If you are lucky, and the web site has links that will get you to all the products without searching or other form based activity, just point wget -kr at the site, and you will end up with a directory containing flat HTML files for all the database generated pages in the site. Be sure the destination directory is in the same path as you want it to appear from the root directory of the CD. You won't be able to put it in the root directory. If you don't have good links in the program, you can use -i input_file to name all the pages you need to grab. Try man wget for details. I haven't tried making this something that can be accessed from a CD using file:// based URLs, but I have been able to grab entire web sites to be hosted with Apache. You may need to use sed or something to clean up the A href= tags. Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php