Reply to fsockopen: fetching url

Your name:

Reply:


Posted by Branimir Topic on 02/11/05 19:04

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;
}
----------------------------------------------------------------------------------------------------------------

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация