server = $s; $this->cookies = $c; $this->userAgent = $ua; } function http_request($m, $f, $d = "", $host = null, $c = "", $port = 80, $referer = null) { if ($host == null) $host = $this->server; if (($fp = fsockopen($host, $port, $errno, $errstr, 120))) { $out = strtoupper($m) ." /". $f ." HTTP/1.1\r\n"; $out .= "Host: ". $host ."\r\n"; if ($referer) $out .= "Referer: ". $referer ."\r\n"; $out .= "Cookie: ". $this->cookies; if ($c != "") $out .= "; ". $c; $out .= "\r\n"; $out .= "User-Agent: ". $this->userAgent ."\r\n"; if (strtolower($m) == "post") { $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; $out .= "Content-Length: ". strlen($d) ."\r\n"; } $out .= "Connection: Close\r\n\r\n"; if (strtolower($m) == "post") $out .= $d ."\r\n\r\n"; //echo "request ". $host ."/". $f ."

\n\n"; @ob_flush(); flush(); //echo $out; fwrite($fp, $out); $returnVal = ""; while (!feof($fp)) $returnVal .= fgets($fp, 128); fclose($fp); return $returnVal; } } } ?>