php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8440 fopen on a url returns "success" as an error
Submitted: 2000-12-27 13:28 UTC Modified: 2002-03-17 15:34 UTC
From: david@php.net Assigned:
Status: Closed Package: HTTP related
PHP Version: 4.0.4pl1 OS: Debian Linux 2.2.14
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: david@php.net
New email:
PHP Version: OS:

 

 [2000-12-27 13:28 UTC] david@php.net
fopen("http://my-url/","r") - Success

is the error returned. Attempting to use the filehandle return gives "is not a valid FileHandle resource", of course.

A "lynx -dump" from the server at the same time the error occurs shows that the url is fine and the connection to that web server is also fine.

Doesn't happen all the time, on every execution, but when it does happen is disastrous, any ideas? thanks.

PHP Version 4.0.3pl1

System          Linux shell.eshirt.net 2.2.14 #3 SMP Sat Jan 8 23:22:14 EST 2000 i686 unknown
Build Date      Oct 23 2000
Configure Command
                       './configure' '--with-mysql' '--disable-debug' '--with-apxs=/www/bin/apxs'
                       '--with-config-file-path=/www/conf' '--enable-track-vars' '--with-gd=../gd-1.7.3'
                       '--with-ttf' '--enable-rule=EAPI' '--enable-versioning' '--with-swf=../dist'
 Server API    Apache

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-07 14:23 UTC] venaas@php.net
The reason might be that fopen()  doesn't handle redirects. I hope
to add redirect support again though. To check if this is the reason,
check the contents of $http_response_header right after the
fopen() call and see if it contains a redirect.

 [2001-01-18 20:36 UTC] david@php.net
It's nothing to do with redirects, no. It doesn't return a redirect response.
 [2001-04-27 21:56 UTC] sniper@php.net
Any example scripts? Works just fine for me with latest CVS.

--Jani

 [2001-04-27 22:09 UTC] david@php.net
I don't believe it has happened since the Apache MaxRequestsPerChild was reduced. I shall suspend this until I have a chance to test more thoroughly.
 [2001-10-18 15:21 UTC] sander@php.net
Any news on this yet?
 [2001-11-09 14:46 UTC] sander@php.net
Reopened.
 [2001-12-07 09:02 UTC] sterling@php.net
Its been awhile, reopen if still present, and you have a concrete setup/example of how it fails
 [2002-03-16 17:29 UTC] jason at unrealtournament dot org
Warning: fopen("ftp://ftp.edome.net/mirror/seriously/general/wallpapers/samwallpaper9_800x600.zip", "r") - Success in /home/serioussam/cgi-bin/files/admin/functions.php on line 184


*groan*  I get this error a lot, and it seems to be only from certain servers, only some of the time.  It's really driving me and my site's users/admins crazy.  Anyone know how to fix it?  The file is obviously there, and it happens for more than one server.  I'm running PHP 4.1.2.
 [2002-03-16 18:02 UTC] derick@php.net
You can try a snapshot from snaps.php.net, I beilieve it's fixed in the PHP 4.2.x branch.

Derick
 [2002-03-17 15:24 UTC] jason at unrealtournament dot org
When will the 4.2.x branch be out though?
 [2002-03-17 15:34 UTC] derick@php.net
In about a month.

Derick
 [2002-03-17 16:07 UTC] jason at unrealtournament dot org
Uggh...is there any way to fix it without waiting a month?
 [2002-03-17 16:13 UTC] jason at unrealtournament dot org
Or, just as good, is there an alternate way to open a remote file?
 [2002-04-21 12:40 UTC] mathieu at hoo-la dot com
you can open a remote file with the fsockopen command

I use this function when I had this problem

/**********************************************************/
function sendToHost($host,$method,$path,$data,$useragent=0)
{
	// Supply a default method of GET if the one passed was empty
	if (empty($method))
		$method = 'GET';
	$method = strtoupper($method);
	$fp = fsockopen($host,80);
	if ($method == 'GET')
		$path .= '?' . $data;
	fputs($fp, "$method $path HTTP/1.1\n");
	fputs($fp, "Host: $host\n");
	fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
	fputs($fp, "Content-length: " . strlen($data) . "\n");
	if ($useragent)
		fputs($fp, "User-Agent: MSIE\n");
	fputs($fp, "Connection: close\n\n");
	if ($method == 'POST')
		fputs($fp, $data);

	while (!feof($fp))
		$buf .= fgets($fp,128);
	fclose($fp);
	return $buf;
}
/**********************************************************/
 [2002-12-21 14:51 UTC] toddg at drpixel dot nospam dot net
I was pulling my hair out trying to figure this one out myself for a while.  I finally noticed that my users were submitting a space character on a form, that sent its value to a php script that used that value in a file() call.

It made my url end up looking like this: http://www.mysite.com?i=1&t=2&x= 5&m=4

I know this is lazy coding on my part that caused this, but I have now fixed it.  Just a heads up to double check your data that gets sent into the function for silly little stuff like this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 23:01:28 2024 UTC