/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// File to download $remoteFile = 'http://www.yahoo.com/'; // Local file for saving $localFile = "YahooHome.htm"; // Time to cache in hours $cacheTime = 24; // Connection time out $connTimeout = 10; }else{ $host = $url['host']; $path .= '?' . $url['query']; } if(!$fp){ // If connection failed, return the cached file } }else{ // Header Info $header = "GET $path HTTP/1.0 "; $header .= "Host: $host "; $header .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6 "; $header .= "Accept: */* "; $header .= "Accept-Language: en-us,en;q=0.5 "; $header .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 "; $header .= "Keep-Alive: 300 "; $header .= "Connection: keep-alive "; $header .= "Referer: http://$host "; $response = ''; // Get the file content $response .= $line; } // Remove Header Info "); echo $response; // Save the file content // Create the file, if it doesn't exist already } } } } }