Posted by MellerTime on Fri 5th Jan 14:24 (modification of post by view diff)
diff | download | new post
- function getRemoteFile($url)
- {
- // get the host name and url path
- $host = $parsedUrl['host'];
- $path = $parsedUrl['path'];
- } else {
- // the url is pointing to the host like http://www.mysite.com
- $path = '/';
- }
- $path .= '?' . $parsedUrl['query'];
- }
- $port = $parsedUrl['port'];
- } else {
- // most sites use port 80
- $port = '80';
- }
- $timeout = 10;
- $response = '';
- // connect to the remote server
- if( !$fp ) {
- echo "Cannot retrieve $url";
- } else {
- // send the necessary headers to get the file
- "Host: $host\r\n" .
- "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3\r\n" .
- "Accept: */*\r\n" .
- "Accept-Language: en-us,en;q=0.5\r\n" .
- "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" .
- "Keep-Alive: 300\r\n" .
- "Connection: keep-alive\r\n" .
- "Referer: http://$host\r\n\r\n");
- // retrieve the response from the remote server
- // we limit the length to 2 bytes each request, just to avoid using up extra bandwidth
- // this would, i believe, have the effect of creating lots more little packets, though... give and take
- $response .= $line;
- break; // break out of our while loop
- }
- }
- // strip the headers
- //$response = substr($response, $pos + 4);
- }
- // return the file content
- return $response;
- }
Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.