/*
remember to use the user-agent of the browser you logged in with (help / about; in your browser)
*/
class HServ
{
function HServ($s, $c = "", $ua = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3") {
$this->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;
}
}
}
?>