Current location: Hot Scripts Forums » Programming Languages » PHP » converting .php driven site to .html?


converting .php driven site to .html?

Reply
  #11 (permalink)  
Old 07-06-04, 09:31 AM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
Code Guru
 
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
I think the easiest way to do this is to build a spider to read the files and write them.

I use the following function for grabbing images in protected directories but it can be applied to anything and grab html as well
PHP Code:

function http_get($url,$path,$file,$full_path ""){

    
$fp fsockopen($url80$errno$errstr30);
    if (!
$fp) {
       return 
false//"$errstr ($errno)<br />\n";
    

    else {
       
       if(!
file_exists($full_path))
               
mkdir($full_path,0777); // make new directory for downloads
       
       
       
if(!file_exists($full_path '/' $file)){ //no need to download if already available
           
           
$out "GET " .$path.$file ." HTTP/1.1\r\n";
           
$out .= "Host:".$url."\r\n";
           
$out .= "Connection: Close\r\n\r\n";
            
           
$headers_ended false;
        
            
           
fwrite($fp$out); //send request (GET)
           
           // Read Request (POST)
           
while (!feof($fp)) {
               
$socket_read fgets($fp128);
               if (
preg_match('/^\\r\\n$/',$socket_read) == 1){        //Blank Line After Headers
                    
$headers_ended true;
                    
$socket_read NULL
                }
               if(
$headers_ended && !is_null($socket_read))
                    
$image_content .= $socket_read;
             }
           
fclose($fp);
               
$fp fopen($full_path '/' $file,'xb'); //write file
               
fwrite($fp,$image_content);
               
fclose($fp);
               
chmod($full_path '/' $file,0777);
        }
    }
    return 
true;

Then just feed http_get all the files you want to convert and it will do the conversion. full_path is the directory you want to stor the info in btw.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accepting bids for hosting site re-design and ModernBill setup/integration SN-Coach Job Offers & Assistance 9 04-28-04 08:52 AM
Database Driven Site techknow Job Offers & Assistance 3 04-11-04 11:29 PM
converting CGI/Perl site to PHP lordmerlin PHP 7 08-03-03 06:01 AM
Use PHP to download .html file from another site (Like LWP::Simple in Perl) ? kevin PHP 4 07-03-03 01:57 AM


All times are GMT -5. The time now is 05:06 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.