Re: What should I do if fopen is restricted?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: What should I do if fopen is restricted?

From: <typingcat@gmail.com>
Date: Tue Oct 25 2005 - 17:27:08 CEST

I've found that file() and file_get_contents() generates the same
error. However, I found a working way by searching the internet. I can
achieve what I wanted, but I have to deal with dirty HTTP protocal.
Here is the code. I hope this would help the others too.

$fp = fsockopen("www.google.com", 80, $errno, $errstr, 30);
if (!$fp) {
   echo "$errstr ($errno)<br />\n";
} else {
   $out = "GET / HTTP/1.1\r\n";
   $out .= "Host: www.google.com\r\n";
   $out .= "Connection: Close\r\n\r\n";

   fwrite($fp, $out);
   while (!feof($fp)) {
       echo fgets($fp, 128);
   }
   fclose($fp);
}

Ramon wrote:
> oops, I meant to say file(); not fopen()
>
> Sorry :S
Received on Mon Nov 21 02:49:52 2005