URL이 살아 있는지 체크
페이지 정보
작성자 MintState 댓글 0건 조회 13,849회 작성일 08-11-10 13:15본문
URL이 살아 있는지 체크
<?
function url_live($url)
{
// 000 : only http://
// 001 checkdnsrr error
// 002 fsockopen error
// other : http return code
if ($url == "http://") return "000";
$parsed = parse_url($url);
$host = $parsed["host"];
$path = $parsed["path"];
if (!$path) $path = "/";
if (!(checkdnsrr($host,"A"))) return "001";
$fp = fsockopen ($host, 80,$errno, $errstr, 10) ;
if (!$fp) return "002";
fputs($fp,"GET $path HTTP/1.0\n\n");
$line = fgets($fp, 1024);
if (eregi( "^http/[0-9]+.[0-9]+ ([0-9]{3}) [a-z ]*", $line)) {
$return = trim(eregi_replace( "^http/[0-9]+.[0-9]+ ([0-9]{3}) [a-z ]*", "\\1", $line));
}
else {
$return = "000";
}
fclose($fp);
return $return;
}
echo url_live("http://yesyo.com");
?>|
|
댓글목록
등록된 댓글이 없습니다.





URL이 살아 있는지 체크