RE: [PHP] fsockopen
| From: | Alastair Battrick | Date: | Tue, 26 Mar 2002 12:53:04 +0000 |
| Subject: | RE: [PHP] fsockopen | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-90174@lists.php.net to get a copy of this message | ||
There are a few things that it could be.
Change the ereg_replace to str_replace
Try adding Host: $server_name on the line after the GET:
fputs ($fp, "GET / HTTP/1.0\r\nHost: $server_name\r\n\r\n");
iirc, if the server uses virtual hosts, the GET won't work properly without
it.
If that's not it, try adding this instead of your single echo line:
while (!feof ($fp)) {
$line = fgets($fp, 4096);
echo $line;
}
As that will return and echo all the page, not just the header.
Alastair
> -----Original Message-----
> From: Christoph Starkmann [mailto:kiko@nfq.de]
> Sent: 26 March 2002 12:48
> To: 'al@battrick.org'; Christoph Starkmann; php-general@lists.php.net
> Subject: RE: [PHP] fsockopen
>
>
> Hi!
>
> > Is $tempPort set ?
>
> Yes... 80 as default...
>
> > > $tempUrl = ereg_replace("http://",
> > > "", $url);
> > >
> > > $fp = fsockopen ($tempUrl, $tempPort, &$errno, &$errstr, 30);
> > >
> > > if (!$fp)
> > > {
> > > echo "<br>error opening $url: \$errstr=$errstr,
> > \$errno=$errno<br>\n";
> > > }
> > > else
> > > {
> > > fputs ($fp, "GET / HTTP/1.0\r\n\r\n");
> > > echo "<br>s>>>" . fgets($fp,1024);
> > > fclose($fp);
> > > }
>
> Cheers...
> Kiko
>
> -----
> It's not a bug, it's a feature.
> christoph starkmann
> mailto:kiko@nfq.de
> http://www.fh-augsburg.de/~kiko
> ICQ: 100601600
> -----