Share
ShareSidebar

Broken Link Checker

/************************
SEO Toolkit (c) 2008 TUFaT.com
All Rights Reserved.
Please do not re-distribute or
re-sell this software. Help
us keep these SEO Tools cheap
by not re-selling them.

More info about these tools:
http://www.tufat.com/script214.htm
************************/

ob_start();
session_name(md5(dirname(__FILE__)));
session_start();
$yahooID = "bIpqc43V34G.6UQFQGZVHGYdwJEKr10H9DcBvfFbrB1au6uVZA1jVHkV9wJubMSTjZG9Ma4wpoA-";

function checkImage()
{
if(@$_SESSION['image'])
{
return true;
}
if(@$_POST['image'])
{
if(@$_SESSION['chkimage']==@$_POST['image'])
{
$_SESSION['image'] = true;
}
else
{
$_SESSION['image'] = false;
}

}
//return @$_SESSION['image'];
return true;
}

?>

/************************
SEO Toolkit (c) 2008 TUFaT.com
All Rights Reserved.
Please do not re-distribute or
re-sell this software. Help
us keep these SEO Tools cheap
by not re-selling them.

More info about these tools:
http://www.tufat.com/script214.htm
************************/

function StrToNum($Str, $Check, $Magic)
{
$Int32Unit = 4294967296;

$length = strlen($Str);
for ($i = 0; $i < $length; $i++) {
$Check *= $Magic;
if ($Check >= $Int32Unit) {
$Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit));
$Check = ($Check < -2147483648) ? ($Check + $Int32Unit) : $Check;
}
$Check += ord($Str{$i});
}
return $Check;
}
function HashURL($String)
{
$Check1 = StrToNum($String, 0x1505, 0x21);
$Check2 = StrToNum($String, 0, 0x1003F);

$Check1 >>= 2;
$Check1 = (($Check1 >> 4) & 0×3FFFFC0 ) | ($Check1 & 0×3F);
$Check1 = (($Check1 >> 4) & 0×3FFC00 ) | ($Check1 & 0×3FF);
$Check1 = (($Check1 >> 4) & 0×3C000 ) | ($Check1 & 0×3FFF);

$T1 = (((($Check1 & 0×3C0) << 4) | ($Check1 & 0x3C)) <<2 ) | ($Check2 & 0xF0F );
$T2 = (((($Check1 & 0xFFFFC000) << 4) | ($Check1 & 0x3C00)) << 0xA) | ($Check2 & 0xF0F0000 );

return ($T1 | $T2);
}
function CheckHash($Hashnum)
{
$CheckByte = 0;
$Flag = 0;

$HashStr = sprintf('%u', $Hashnum) ;
$length = strlen($HashStr);

for ($i = $length - 1; $i >= 0; $i –) {
$Re = $HashStr{$i};
if (1 === ($Flag % 2)) {
$Re += $Re;
$Re = (int)($Re / 10) + ($Re % 10);
}
$CheckByte += $Re;
$Flag ++;
}

$CheckByte %= 10;
if (0 !== $CheckByte) {
$CheckByte = 10 - $CheckByte;
if (1 === ($Flag % 2) ) {
if (1 === ($CheckByte % 2)) {
$CheckByte += 9;
}
$CheckByte >>= 1;
}
}

return ‘7′.$CheckByte.$HashStr;
}

function getpr($url)
{
$ch = CheckHash(HashURL($url));
$content = fetch(”http://www.google.com/search?client=navclient-auto&features=Rank:&q=info:”.urlencode($url).”&ch=$ch”);
preg_match(”#.*?:.*?:(.*?)$#”,$content,$pr);
return @$pr[1] ? $pr[1] : “0″;
}

function getdcpr($url,$dc=”www.google.com”)
{
$ch = CheckHash(HashURL($url));
$content = fetch(”http://$dc/search?client=navclient-auto&features=Rank:&q=info:”.urlencode($url).”&ch=$ch”);
preg_match(”#.*?:.*?:(.*?)$#”,$content,$pr);
return @$pr[1] ? $pr[1] : “Datacenter down”;
}

function getPageRank($url,$dc=”www.google.com”)
{
$ch = CheckHash(HashURL($url));

$fp = @fsockopen($dc, 80, $errno, $errstr, 3);
if (!$fp) {
//echo “$errstr ($errno)
\n”;
return “Datacenter down”;
} else {
$out = “GET /search?client=navclient-auto&ch=” . $ch . “&features=Rank&q=info:” . $url . ” HTTP/1.1\r\n” ;
$out .= “Host: $dc\r\n” ;
$out .= “Connection: Close\r\n\r\n” ;
fwrite($fp, $out);
while (!feof($fp)) {
$data = fgets($fp, 128);
$pos = strpos($data, “Rank_”);
if($pos === false){
}else{
$pagerank = trim(substr($data, $pos + 9));
}
}
fclose($fp);
return (isset($pagerank)?$pagerank : “Datacenter down”);
}
}

function fetch($url)
{
$content = @file_get_contents($url);
/*
$db = DB::getInstance();

// Get cached version of url request
$page = $db->select(”cache”,array(”url”=>$url));

// page found in cache. return file contents from cache, by id from DB
if(@$page[0])
{
$dir = dirname(__FILE__);
$filename = “$dir/../cache/{$page[0]['id']}”;
$content = @file_get_contents($filename);
}
else
{
$insert['time'] = time();
$insert['url'] = $url;
// Save in DB time of request and url, get request id
$id = $db->insert(”cache”,$insert);

$content = @file_get_contents($url);
$dir = dirname(__FILE__);
$filename = “$dir/../cache/$id”;
// Save file in cache
file_put_contents($filename,$content);
}
*/
if (function_exists(’iconv’)) {
if(preg_match(”#)#”,$content,$charset))
{
if(@$charset[1] && strtolower($charset[1])!=”utf-8″)
{
$content = iconv($charset[1],”UTF-8″,$content);
}
}
}
return $content;
}

function getAlexa($dom)
{
if(!$html = @file_get_contents(”http://alexa.com/xml/dad?url=”.$dom)) return ”;

// alexa rank
if (preg_match(’/POPULARITY URL=”[a-z0-9\\-\\.\\/]{1,}” TEXT=”([0-9]{1,12})”/’, $html, $regs))
return (int)$regs[1];

//old is commeted (maybe will be usefull in future)
/*
$dominfo = fetch(”http://www.alexa.com/data/details/main?q=&url=$dom”);
$scramble = @file_get_contents(”http://client.alexa.com/common/css/scramble.css”);
preg_match_all(”#\\.(\\S+)#”,$scramble,$classes);

$dominfo = preg_replace(”#.*?#”,”",$dominfo);
preg_match(”#(.*?)#”,$dominfo,$alexarank);
return strip_tags(@$alexarank[1]);
*/
}

function circle($values=array(”#F4F4F4″,”#ffffff”))
{
static $i;
if($i == count($values))
{
$i = 0;
}
$i++;
return $values[$i-1];
}

?>

/************************
SEO Toolkit (c) 2008 TUFaT.com
All Rights Reserved.
Please do not re-distribute or
re-sell this software. Help
us keep these SEO Tools cheap
by not re-selling them.

More info about these tools:
http://www.tufat.com/script214.htm
************************/

class whois
{
var $_SERVERS = array(
//"com"=>“whois.markmonitor.com”,
//”com”=>”whois.arin.net”,
“com”=>”whois.enom.com”,
“net”=>”whois.crsnic.net”,
“edu”=>”whois.educause.net”,
“org”=>”whois.publicinterestregistry.net”,
“arpa”=>”whois.arin.net”,
“ripe”=>”whois.ripe.net”,
“mil”=>”whois.nic.mil”,
“coop”=>”whois.nic.coop”,
“museum”=>”whois.museum”,
“biz”=>”whois.neulevel.biz”,
“info”=>”whois.afilias.net”,
“name”=>”whois.nic.name”,
“gov”=>”whois.nic.gov”,
“aero”=>”whois.information.aero”,
“ns”=>”whois.internic.net”,
“ip”=>”whois.ripe.net”,
“ad”=>”whois.ripe.net”,
“al”=>”whois.ripe.net”,
“am”=>”whois.ripe.net”,
“as”=>”whois.gdns.net”,
“at”=>”whois.nic.at”,
“au”=>”box2.aunic.net”,
“az”=>”whois.ripe.net”,
“ba”=>”whois.ripe.net”,
“be”=>”whois.dns.be”,
“bg”=>”whois.ripe.net”,
“br”=>”whois.nic.br”,
“by”=>”whois.ripe.net”,
“ca”=>”eider.cira.ca”,
“cc”=>”whois.nic.cc”,
“ch”=>”domex.switch.ch”,
“ck”=>”whois.ck-nic.org.ck”,
“cl”=>”nic.cl”,
“cn”=>”whois.cnnic.net.cn”,
“cx”=>”whois.nic.cx”,
“cy”=>”whois.ripe.net”,
“cz”=>”dc1.eunet.cz”,
“de”=>”whois.denic.de”,
“dk”=>”whois.dk-hostmaster.dk”,
“do”=>”ns.nic.do”,
“dz”=>”whois.ripe.net”,
“ee”=>”whois.ripe.net”,
“eg”=>”whois.ripe.net”,
“es”=>”whois.ripe.net”,
“fi”=>”whois.ripe.net”,
“fo”=>”whois.ripe.net”,
“fr”=>”winter.nic.fr”,
“ga”=>”whois.ripe.net”,
“gb”=>”whois.ripe.net”,
“ge”=>”whois.ripe.net”,
“gl”=>”whois.ripe.net”,
“gm”=>”whois.ripe.net”,
“gr”=>”whois.ripe.net”,
“gs”=>”whois.adamsnames.tc”,
“hk”=>”whois.hkdnr.net.hk”,
“hr”=>”whois.ripe.net”,
“hu”=>”whois.nic.hu”,
“id”=>”muara.idnic.net.id”,
“ie”=>”whois.domainregistry.ie”,
“il”=>”whois.isoc.org.il”,
“in”=>”whois.ncst.ernet.in”,
“is”=>”horus.isnic.is”,
“it”=>”whois.nic.it”,
“jo”=>”whois.ripe.net”,
“jp”=>”whois.nic.ad.jp”,
“kg”=>”whois.domain.kg”,
“kh”=>”whois.nic.net.kh”,
“kr”=>”whois.krnic.net”,
“la”=>”whois.nic.la”,
“li”=>”domex.switch.ch”,
“lk”=>”arisen.nic.lk”,
“lt”=>”ns.litnet.lt”,
“lu”=>”whois.dns.lu”,
“lv”=>”whois.ripe.net”,
“ma”=>”whois.ripe.net”,
“mc”=>”whois.ripe.net”,
“md”=>”whois.ripe.net”,
“mm”=>”whois.nic.mm”,
“ms”=>”whois.adamsnames.tc”,
“mt”=>”whois.ripe.net”,
“mx”=>”whois.nic.mx”,
“nl”=>”whois.domain-registry.nl”,
“no”=>”ask.norid.no”,
“nu”=>”whois.worldnames.net”,
“nz”=>”akl-iis.domainz.net.nz”,
“pl”=>”nazgul.nask.waw.pl”,
“pt”=>”whois.ripe.net”,
“ro”=>”whois.rotld.ro”,
“ru”=>”whois.ripn.net”,
“se”=>”ear.nic-se.se”,
“sg”=>”qs.nic.net.sg”,
“sh”=>”whois.nic.sh”,
“si”=>”whois.arnes.si”,
“sk”=>”whois.ripe.net”,
“sm”=>”whois.ripe.net”,
“st”=>”whois.nic.st”,
“su”=>”whois.ripn.net”,
“tc”=>”whois.adamsnames.tc”,
“tf”=>”whois.adamsnames.tc”,
“th”=>”whois.thnic.net”,
“tj”=>”whois.nic.tj”,
“tn”=>”whois.ripe.net”,
“to”=>”whois.tonic.to”,
“tr”=>”whois.ripe.net”,
“tw”=>”whois.twnic.net”,
“tv”=>”whois.nic.tv”,
“ua”=>”whois.net.ua”,
“uk”=>”whois.nic.uk”,
“us”=>”whois.nic.us”,
“va”=>”whois.ripe.net”,
“vg”=>”whois.adamsnames.tc”,
“ws”=>”whois.worldsite.ws”,
“yu”=>”whois.ripe.net”,
“za”=>”apies.frd.ac.za”,
“xn--p1ag”=>”ru.whois.i-dns.net”,
“xn--p1ag”=>”ru.whois.i-dns.net”,
“xn--j1ae”=>”whois.i-dns.net”,
“xn--e1ap”=>”whois.i-dns.net”,
“xn--c1av”=>”whois.i-dns.net”,
“net.ru”=>”whois.ripn.net”,
“org.ru”=>”whois.ripn.net”,
“pp.ru”=>”whois.ripn.net”,
“spb.ru”=>”whois.relcom.ru”,
“msk.ru”=>”whois.relcom.ru”,
“ru.net”=>”whois.relcom.ru”,
“yes.ru”=>”whois.regtime.net”,
“uk.com”=>”whois.centralnic.com”,
“uk.net”=>”whois.centralnic.com”,
“gb.com”=>”whois.centralnic.com”,
“gb.net”=>”whois.centralnic.com”,
“eu.com”=>”whois.centralnic.com”);

/**
* @return whois
*/
function getInstance()
{
static $instance;
if(!$instance)
{
$instance = new whois();
}

return $instance;
}
function getdomaininfo($domain)
{

preg_match(”#([\\w-]+\\.)+([\\w]+)$#”,$domain,$root);
$domain=$root[1].$root[2];

if (strtoupper(substr(PHP_OS, 0, 5)) === ‘LINUX’) return `whois $domain`;

$domain = strtolower($domain);
preg_match(”#([\\w-]+\\.)+([\\w]+)$#”,$domain,$root);

$server = @$this->_SERVERS[$root[2]] ? $this->_SERVERS[$root[2]] : “whois.arin.net”;
//$server = “whois.markmonitor.com”;
//$server = “whois.enom.com”;

$sock = fsockopen ($server,43,$errno,$errstr);

if (!$sock) {
echo(”$errno($errstr)”);
return;
}
else {
fputs($sock,”$domain\r\n”);
$return = “”;

while (!feof($sock)) {
$return .= fgets ($sock,128);
}
}
fclose ($sock);
return $return;
}
}
$datacenters = array();
$datacenters[] = “72.14.219.104″;
$datacenters[] = “72.14.207.104″;
$datacenters[] = “209.85.133.104″;
$datacenters[] = “64.233.179.104″;
$datacenters[] = “72.14.221.104″;
$datacenters[] = “209.85.129.104″;
$datacenters[] = “72.14.223.104″;
$datacenters[] = “72.14.223.104″;
$datacenters[] = “66.102.1.104″;
$datacenters[] = “64.233.189.104″;
$datacenters[] = “72.14.215.104″;
$datacenters[] = “66.249.91.104″;
$datacenters[] = “72.14.211.104″;
$datacenters[] = “64.233.187.104″;
$datacenters[] = “72.14.209.104″;
$datacenters[] = “64.233.185.104″;
$datacenters[] = “209.85.135.104″;
$datacenters[] = “64.233.183.104″;
$datacenters[] = “64.233.163.104″;
$datacenters[] = “64.233.161.104″;
$datacenters[] = “72.14.253.104″;
$datacenters[] = “209.85.139.104″;
$datacenters[] = “66.249.83.104″;
$datacenters[] = “72.14.205.104″;
$datacenters[] = “64.233.169.104″;
$datacenters[] = “64.233.171.104″;
$datacenters[] = “72.14.203.104″;
$datacenters[] = “72.14.217.104″;
$datacenters[] = “66.249.81.104″;
$datacenters[] = “72.14.255.104″;
$datacenters[] = “209.85.143.104″;
$datacenters[] = “72.14.235.104″;
$datacenters[] = “66.249.93.104″;
$datacenters[] = “64.233.179.104″;
$datacenters = array_values(array_unique($datacenters));
?>

/************************
SEO Toolkit (c) 2008 TUFaT.com
All Rights Reserved.
Please do not re-distribute or
re-sell this software. Help
us keep these SEO Tools cheap
by not re-selling them.

More info about these tools:
http://www.tufat.com/script214.htm
************************/

$desc = "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.”;
$title = “Broken link checker”;
print ‘

‘;
?>

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;
$site_url = get_bloginfo(’url’);
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);
$link = substr($v,0,85);
echo <<

EOF;
}
}
echo “

($i)
$link

“;
}
?>

eXTReMe Tracker