last update.php
PHP-Code:
<?
function getRawHttpHeader($host,$doc)
{
$httpheader = "";
$fp = fsockopen ($host, 80, $errno, $errstr, 30);
if (!$fp)
{
echo "$errstr ($errno) \n";
}
else
{
fputs ($fp, "GET $doc HTTP/1.0\r\nHost: " . $host. "\r\n\r\n");
while (!feof($fp))
{
$httpresult = fgets ($fp,1024);
$httpheader = $httpheader.$httpresult;
if (ereg("^\r\n",$httpresult))
break;
}
fclose ($fp);
}
return $httpheader;
}
function getArrayHttpHeader($url)
{
$url = ereg_replace("http://","",$url);
$endHostPos = strpos($url,"/");
if (!$endHostPos)
$endHostPos = strlen($url);
$host = substr($url,0,$endHostPos);
$doc = substr($url,$endHostPos,strlen($url)-$endHostPos);
if ($doc=="")
$doc = "/";
$raw = getRawHttpHeader($host,$doc);
$tmpArray = explode("\n",$raw);
for ($i=0;$i<sizeof($tmpArray); $i++)
{
@list($name, $value) = explode(':', $tmpArray[$i], 2);
$array[trim($name)]=trim($value);
}
return $array;
}
$array = (getArrayHttpHeader("http://ip-to-country.webhosting.info/downloads/ip-to-country.csv.zip"));
// print_r($array);
// Display last updated timestamp
echo date("j F Y",strtotime($array['Last-Modified']));
?>
interessant ist dabei, dass die zeit auch als timestamp zur verfügung steht!
wget -q -N -P /tmp http://ip-to-country.webhosting.info...ountry.csv.zip
ist auch ganz nett lädt das file runter in tmp, wenn eine neue version verfügbar ist.
Gruß