fsockopen: fetching url

From: Date: Fri, 11 Feb 2005 17:04:46 +0000
Subject: fsockopen: fetching url
Groups: php.general 
Request: Send a blank email to php-general+get-208522@lists.php.net to get a copy of this message
I'm using code below to fetch content from the url. This code was worked properly on two servers I tested but it want worked on the designated one, so after getting error message I figure it out it may be php.ini settings limitation ---------------------------------------------------------------------------------------------------------------- "The server encountered an internal error or misconfiguration and was unable to complete your request." "Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request." ---------------------------------------------------------------------------------------------------------------- So here's the settings I found as possible reason for limitation on code execution. ---------------------------------------------------------------------------------------------------------------- disable_functions: readfile, system, passthru, shell_exec, shell_exec, system, execreadfile, system, passthru, shell_exec, shell_exec, system, exec ---------------------------------------------------------------------------------------------------------------- Does anybody hava any tip how to workarround on this? CODE ---------------------------------------------------------------------------------------------------------------- function fetchURL( $url ) { $url_parsed = parse_url($url); $host = isset($url_parsed["host"]) ? $url_parsed["host"]: ""; $port = isset($url_parsed["port"]) ? $url_parsed["port"]: 0; if ($port==0) $port = 80; $path = $url_parsed["path"]; $query = isset($url_parsed["query"]) ? $url_parsed["query"]: ""; if ($query != "") $path .= "?" . $query; $out = "GET $path HTTP/1.0\r\nHost: $host\r\n\r\n"; $fp = fsockopen($host, $port, $errno, $errstr, 30); fwrite($fp, $out); $body = false; $in = ""; while (!feof($fp)) { $s = fgets($fp, 1024); if ( $body ) $in .= $s; if ( $s == "\r\n" ) $body = true; } fclose($fp); return $in; } ----------------------------------------------------------------------------------------------------------------

« previous php.general (#208522) next »