You are here: Re: Check if URL exists « PHP Programming Language « IT news, forums, messages
Re: Check if URL exists

Posted by VS on 10/26/05 00:34

theboss3@gmail.com wrote:
> Thanks! I wasn't sure if fsockopen would be good enough or not, but I
> think it will be. I just need to catch the error.
>
> That being said, is there a way to retrieve headers from another page,
> like getheaders('http://example.com/') ?

I'm quite new to PHP, but I found and adpated this for getting the Time
Stamp of a URL, perhaps you can change it for what you need:

function filemtime_remote($uri)
{
$uri = parse_url($uri);
$uri['port'] = isset($uri['port']) ? $uri['port'] : 80;

// TimeOut
$tout = 10;
$handle = @fsockopen($uri['host'], $uri['port'], $errno, $errstr,
$tout);
if(!$handle)
return 0;

fputs($handle,"HEAD $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;
}

--
VS

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация