#8440 [Com]: fopen on a url returns "success" as an error
| From: | toddg at drpixel dot nospam dot net | Date: | Sat, 21 Dec 2002 20:51:17 +0000 |
| Subject: | #8440 [Com]: fopen on a url returns "success" as an error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-28169@lists.php.net to get a copy of this message | ||
ID: 8440
Comment by: toddg@drpixel.nospam.net
Reported By: david@php.net
Status: Closed
Bug Type: HTTP related
Operating System: Debian Linux 2.2.14
PHP Version: 4.0.4pl1
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2002-04-21 12:40:08] mathieu@hoo-la.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-03-17 16:13:04] jason@unrealtournament.org
Or, just as good, is there an alternate way to open a remote file?
------------------------------------------------------------------------
[2002-03-17 16:07:56] jason@unrealtournament.org
Uggh...is there any way to fix it without waiting a month?
------------------------------------------------------------------------
[2002-03-17 15:34:47] derick@php.net
In about a month.
Derick
------------------------------------------------------------------------
[2002-03-17 15:24:59] jason@unrealtournament.org
When will the 4.2.x branch be out though?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/8440
--
Edit this bug report at http://bugs.php.net/?id=8440&edit=1