|
Posted by Hanjo Grόίner on 09/28/05 19:32
Am Wed, 28 Sep 2005 16:08:30 +0200 schrieb alex <alex@nospam.org>:
>
> try fopen function.
>
>> More, I want to know and keep its original filetime.
>
> do you mean date/time on last modification ?
> do you want it locally or remotely ?
>
Hello,
and thanks.
I already solved it.
As you proposed, the existence of the file by fopen,
to get the original filetime of the file I had to access the HTTP-HEAD.
I succeeded so:
function filemtime_remote($uri)
{
$uri = parse_url($uri);
$handle = @fsockopen($uri['host'],80);
if(!$handle)
return 0;
fputs($handle,"GET $uri[path] HTTP/1.1\r\nHost: $uri[host]\r\n\r\n");
$result = 0;
while(!feof($handle))
{
$line = fgets($handle,1024);
if(!trim($line))
break;
$col = strpos($line,':');
if($col !== false)
{
$header = trim(substr($line,0,$col));
$value = trim(substr($line,$col+1));
if(strtolower($header) == 'last-modified')
{
$result = strtotime($value);
break;
}
}
}
fclose($handle);
return $result;
}
I returns the original filetime as an Unix-timestamp.
Greetings from the baltic sea
Hanjo
--
Software & Seminar-Kontor Hans-Joachim GrΓΌΓner
Glasholz
D-24369 Waabs
http://www.gruessner.de
[Back to original message]
|