Bug #1455: Passing URL to fopen() sometimes gives bogus results.

From: Date: Wed, 26 May 1999 19:49:44 +0000
Subject: Bug #1455: Passing URL to fopen() sometimes gives bogus results.
Groups: php.dev 
Request: Send a blank email to php-dev+get-6038@lists.php.net to get a copy of this message
From: vic@altoona.net Operating system: Red Hat Linux 5.2 PHP version: 3.0.7 PHP Bug Type: Misbehaving function Bug description: Passing URL to fopen() sometimes gives bogus results. Hi, The following code often works, however, on some URLs it fails with the following strange error: Warning: fopen("http://www.lysator.liu.se/mit-guide/mit-guide.html","r") - Success in /home/vic/public_html/mywall/bug.phtml on line 9 Even though it says success, it's acting like its timing out and the handle returned is null. I can telnet to the server and issue a get command by hand and it works fine, so I am guessing that it is a problem with PHP. I haven't had time to look at the PHP source code but I thought I'd at least let you know about the problem. If it matters, I am using this with Apache 1.3.6 and postgresql. function GetTitle($url) { $cnt=3; while (!($fp=fopen($url, "r"))) { $cnt--; if (!$cnt) break; sleep(5); echo "Failed opening ".$url; } if ($fp) { $buf=fread($fp, 4096); if ($s=strpos(strtoupper($buf), "<TITLE>")) { $s+=7; $e=strpos(strtoupper($buf), "</TITLE>"); $title=trim(substr($buf, $s, $e-$s)); } else { $title="no title"; } fclose($fp); } else { $title="WARNING: Couldn't open ".$url; } return($title); } echo GetTitle("http://www.lysator.liu.se/mit-guide/mit-guide.html"); -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#6038) next »