<?php
if(!function_exists('get_http_header'))
{
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function get_http_header(
$host, # eg: 'www.mySite.com'
$doc, # eg: '/downloads/file.zip'
$all='', # [all] to get the entire page
# or any other value to get only the header
$ary='' # [ary] to get the result as an array
# or any other value to get a string
)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
if(substr($doc,0,1)!='/') { $doc='/'.$doc; }
$fp=@fsockopen($host,80,$errno,$errstr,30);
if(!$fp)
{
if($_SESSION[misc][location]!='w') { echo($errstr.' ('.$errno.') '."\n"); }
return;
}
else
{
@fputs($fp,'GET '.$doc.' HTTP/1.0'."\r\n".'Host: '.$host."\r\n\r\n");
while(!feof($fp))
{
$httpresult=@fgets($fp,1024);
$raw.=$httpresult;
if($all!='all') { if(ereg("^\r\n",$httpresult)) break; }
}
@fclose($fp);
}
if($ary=='ary')
{
$tmpArray=explode("\n",$raw); $size=count($tmpArray);
for ($i=0;$i<$size;$i++)
{
@list($name,$value)=explode(':',$tmpArray[$i],2);
$array[trim($name)]=trim($value);
}
return($array);
}
return($raw);
}
}
?>