Re: fsockopen: fetching url

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



branimir.topic@xxxxxxxxxxxxxxxxxxx wrote:
>
> 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."

Do *ANY* PHP scripts work on that server?

<?php phpinfo();?>

is a good example to try.

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

Are you using any of those functions?...

I don't see them in your code.

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


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux