$largest) $largest = $b; if($c > $largest) $largest = $c; if($d > $largest) $largest = $d; $least = $largest; if(($a < $least) && ($a != 0)) $least = $a; if(($b < $least) && ($b != 0)) $least = $b; if(($c < $least) && ($c != 0)) $least = $c; if(($d < $least) && ($d != 0)) $least = $d; return $least; } ?>
"> URL of page to check : >
0) { $url = rawurldecode($url); $fd = @fopen($url, 'r'); } else { $fd = ""; } # Find the base of this URL for relative links. if(strrpos($url, "/")) { $baseurl = substr($url, 0, strrpos($url, "/") + 1); } else { $baseurl = $url; } $parsed = parse_url($url); $server = $parsed["scheme"] . "://" . $parsed["host"]; if($fd) { $inq = 0; print('
'); /* We'd better not have files bigger than a megabyte! */ $rawtext = fread($fd, 1024 * 1024); # First, change tag openers and closers to entities. $text = htmlspecialchars($rawtext); # Substitute
tags for newlines to make things # human-readable. */ $text = ereg_replace("\n", "
\n", $text); # Search for things that look like links. $foo = $text; while($pos = lesser(strpos($foo, "href=""), strpos($foo, " src=""), strpos($foo, "HREF=""), strpos($foo, " SRC=""))) { # Isolate the text before the '????="'. $pre = substr($foo, 0, $pos + 11); # Skip to the start of the URL. $foo = substr($foo, $pos + 11); # Find the closing quote and extract the URL. $closepos = strpos($foo, """); $testurl = substr($foo, 0, $closepos); # Skip past the end of the URL. $foo = substr($foo, $closepos); # Print text up to the URL. print($pre); # Determine if the URL is relative or absolute. if(eregi("^mailto:", $testurl)) { # mailto: -> don't touch $realurl = $testurl; } elseif(eregi("^/", $testurl)) { # first char is "/", so use server $realurl = $server . $testurl; } elseif ((strpos($testurl,":")>0) && (strpos($testurl,":") < strpos($testurl,"/"))){ # has ':' before '/' -> punt absolute $realurl = $testurl; } else { # go for relative $realurl = $baseurl . $testurl; } # Now check the link's validity by # trying to open it. $class = "bad"; if(eregi("^mailto:", $realurl)) { $class = "good"; } elseif(eregi("^http:", $realurl) || eregi("^ftp:", $realurl)) { if($checkfd = @fopen($realurl, 'r')) { fclose($checkfd); $class = "good"; } } # Now print the link inside of a span tag. print("'); print(""); print($testurl . ""); print(""); } # Print text after the last URL (or all of the text, # if there are none). # print("bugaboo"); print($foo); print("
"); } else { if(strlen($url) > 0) { print("There was a problem reading ". "$url. If the URL ". "points to a directory, be sure to add ". "the final /, ". "because the code on this page isn't ". "advanced enough to deal with the ". "redirects."); print("This page is also limited to ". "http and ". "ftp URLs. It also ". "flat-out lies about ". "mailto URLs.\n"); } } } ?>
Send comments, suggestions, and bug reports to Nalin.
Page last modified 15 April 2000