wieso funst des net?
hier der link: http://tipp.free.pages.at/test.php
hier der link: http://tipp.free.pages.at/test.php
PHP-Code:
<?php
____error_reporting(E_ALL);
$last_modified = stream_last_modified('http://rudmanns.home.pages.at/__tipnew/tipnews.htm');
if (!is_null($last_modified))
_ if ($last_modified < time()-3600) //Older than an hour
_ _ _echo 'URL is older than an hour.';
_ else
_ _ _echo 'URL is fairly new.';
else
_ echo 'Invalid URL!';
function stream_last_modified($url)
{
_ if (function_exists('version_compare') && version_compare(phpversion(), '4.3.0') > 0)
_ {
_ _ _if (!($fp = fopen($url, 'r')))
_ _ _ _ return NULL;
_ _ _$meta = stream_get_meta_data($fp);
_ _ _for ($j = 0; isset($meta['wrapper_data'][$j]); $j++)
_ _ _{
_ _ _ _ if (strstr(strtolower($meta['wrapper_data'][$j]), 'last-modified'))
_ _ _ _{
_ _ _ _ _ _$modtime = substr($meta['wrapper_data'][$j], 15);
_ _ _ _ _ break;
_ _ _ _ }
_ _ _}
_ _ _fclose($fp);
_ }
_else
_ {
_ _ _$parts = parse_url($url);
_ _ _$host _= $parts['host'];
_ _ _$path _= $parts['path'];
_ _ _if (!($fp = fsockopen($host, 80)))
_ _ _ _ return NULL;
_ _ _$req = "HEAD $path HTTP/1.0\r\nUser-Agent: PHP/".phpversion()."\r\nHost: $host:80\r\nAccept: */*\r\n\r\n";
_ _ _fputs($fp, $req);
_ _ _while (!feof($fp))
_ _ _{
_ _ _ _ $str = fgets($fp, 4096);
_ _ _ _ if (strstr(strtolower($str), 'last-modified'))
_ _ _ _ {
_ _ _ _ _ $modtime = substr($str, 15);
_ _ _ _ _ _break;
_ _ _ _ }
_ _ }
_ _ _fclose($fp);
_}
_ return isset($modtime) ? strtotime($modtime) : time();
}
?>
Kommentar