#native_company# #native_desc#

URL Validation

By Dean Householder
on December 13, 2002

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.


$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>";
		print "<font face="arial" size="3"><b>If you feel this is in error, you may need to check your DNS.</b></font></p>";

/* Functions */

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