Version: beta 1

Type: Full Script

Category: HTTP

License: GNU General Public License

Description: This is a dirty page I threw together to validate an URL by actually checking the DNS rexcord fro the site supplied and then checking wether I get an 404 for the supplied path or file. The page does not look pretty, alter it to your likings.



<?php

$url = "http://dir.yahoo.com/Computers_and_Internet/Software/";
$parsed = parse_url($url);
$fullpath = "$parsed[scheme]://$parsed[host]$parsed[path]";

if ((checkdnsrr($parsed["host"],"A")) == true) {
	$good_dns = true;
	if (url_live($parsed["host"], $fullpath)) {
		$good_url = true;
	}
}

if (!$good_dns || !$good_url){
	print "<p align=\"center\"><font face=\"arial\" size=\"5\"><b>Page Not Found.</b></font><br><br>";
	if ($good_dns && !$good_url){
		print "<font face=\"arial\" size=\"3\"><b>Your Domain is correct but the directory/file doesn't exist.</b></font></p>";
	}else{
		print "<font face=\"arial\" size=\"3\"><b>If you feel this is in error, you may need to check your DNS.</b></font></p>";
	}
	die();
}


/* Functions */

function url_live($host, $path){
	$fp = fsockopen ($host, 80);
	fputs($fp,"GET $path HTTP/1.0\n\n");
	$line = fgets($fp, 1024);
	if (stristr($line, '200 OK')) {
		$end = true;
	}else{
		$end = false;
	}
	fclose($fp);
	return $end;
}

?>