Background Top Border Background Middle Border

Broken Link Checker

Broken link checker
Scans a web page that you specify and checks all of the links on that page to see if any are broken.

Check URL   

if(@$_REQUEST['url'] && checkImage())
{
$url = trim($_REQUEST['url']);
$url = preg_match("#^https?://#i",$url) ? $url : "http://".$url;
$_REQUEST['url'] = $url;
$url = parse_url($url);
$url['path'] = @$url['path'] ? $url['path'] : "/";

$baseurl = $url['scheme']."://";
$unp = @$url['user'] ? urlencode($url['user']) : "";
$unp .= @$url['pass'] ? (":".urlencode($url['pass'])) : "";
$unp = $unp ? "$unp@" : "";

$baseurl .= $unp . $url['host'];
$dirurl = $baseurl.dirname($url['path']);

$content = fetch($_REQUEST['url']);
$content = preg_replace("#]*>.*?#ims","",$content);
$basehref = false;

if(preg_match("#]*>|\s+>|>)#si",$content,$matches))
{
$basehrefurl = $matches[1];
$basehrefurl = preg_match("#^('|")(.*)\1#i",$basehrefurl,$m) ? $m[2] : $basehrefurl;
if(!preg_match("#^https?://#i",$basehrefurl))
{
if(strpos($basehrefurl,"/")===0)
{
$basehrefurl = $basehrefurl.$dirurl;
}
else
{
$basehrefurl = (strrpos($basehrefurl,"/")===strlen($basehrefurl)-1 ? $basehrefurl : $basehrefurl."/" ).$dirurl;
}
}
preg_match("#(^.+?://.+?)(/.*$|$)#",$basehrefurl,$basehrefroot);
$basehrefroot = $basehrefroot[1];
$basehref = true;
}

preg_match_all("#<(\w+) [^>]*?(href|src)=(\S*?)(?:\s+[^>]*>|\s+>|>)#si",$content,$matches);
$resources = array();
foreach($matches[2] as $k=>$v)
{
$resources[$v][] = preg_match("#^('|")(.*)\1#i",$matches[3][$k],$m) ? $m[2] : $matches[3][$k];
}

$total = 0;
foreach($resources as $i=>$res)
{
foreach($res as $k=>$v)
{
if(preg_match("#^(\w+?)://#",$v))
{
continue;
}

if(preg_match("#^(\w+?):#",$v))
{
unset($resources[$i][$k]);
continue;
}

if(strpos($v,"?")===0)
{
$resources[$i][$k] = $basehref ? $basehrefurl.$v : $baseurl.$url['path'].$v;
continue;
}

if(strpos($v,"/")===0)
{
$resources[$i][$k] = $basehref ? $basehrefroot.$v : $baseurl.$v;
continue;
}
else
{
$resources[$i][$k] = $basehref ? $basehrefurl.$v : $baseurl."/".$v;
continue;
}
}

$total += count($res);
}

echo "
Total is: $total

";
foreach($resources as $i=>$res)
{
foreach($res as $k=>$v)
{
$i = strtoupper($i);
$ve = urlencode($v);
echo <<

EOF;
}
}
echo "

($i)
$v
 Broken Link Checker

";
}
?>

This entry was posted in Web Tools and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Background Bottom Border
Background Top Border Background Middle Border Background Bottom Border
None :P None :P

Rendered template: single.php

112 SQL queries done. Page generation took 0.288 seconds.