<html>
<head>
<title>Link-Check</title>
</head>
<body>
<?php
require_once("../classes/httpconnection.class.php");
function google($keywords,$url,$maxpages,$locale="int")
{
if ($locale=="de")
{
$http=new httpconnection("www.google.de",80,false,"Mozilla/5.0");
}
else
{
$http=new httpconnection("www.google.com",80,false,"Mozilla/5.0");
}
$x=0;
while (($x<$maxpages) && ($found==false))
{
$start=$x*10;
$data=$http->get("search","q=".$keywords."&start=".$start);
if ((strpos($data['body'],'//'.$url.'/')!=false) || (strpos($data['body'],'//'.$url.' ')!=false))
{
$found=true;
}
else
{
$found=false;
}
$x++;
}
$data=$http->get("search","q=link:http://".$url);
if ($locale=="de")
{
$nomatchstring="Es wurden keine";
}
else
{
$nomatchstring="did not match";
}
if (strpos($data['body'],$nomatchstring)!=false)
{
$backlinks=0;
}
else
{
if ($locale=="de")
{
$startpos=strpos($data['body'],"von",strpos($data['body'],"Ergebnisse"))+4;
$endpos=strpos($data['body'],",",$startpos);
$aboutword="ungefähr";
}
else
{
$startpos=strpos($data['body'],"of",strpos($data['body'],"Results"))+3;
$endpos=strpos($data['body'],"linking",$startpos)-1;
$aboutword="about";
}
$backlinks=substr($data['body'],$startpos,$endpos-$startpos);
if (substr($backlinks,0,1)==substr($aboutword,0,1))
{
$backlinks=substr($backlinks,3+strlen($aboutword)+1,-4);
}
else
{
$backlinks=substr($backlinks,3,-4);
}
}
unset($http);
echo '<b>Google:</b><br>';
if ($found==true)
{
echo $url.' was found on page '.$x.'<br>';
}
else
{
echo $url.' was not found on the first '.$x.' Pages of results<br>';
}
echo 'Backlinks to '.$url.': '.$backlinks;
echo '<hr>';
}
function altavista($keywords,$url,$maxpages,$locale="int")
{
if ($locale=="de")
{
$http=new httpconnection("de.altavista.com",80,false,"Mozilla/5.0");
}
else
{
$http=new httpconnection("www.altavista.com",80,false,"Mozilla/5.0");
}
$x=0;
while (($x<$maxpages) && ($found==false))
{
$start=$x*10;
$data=$http->get("web/results","q=".$keywords."&stq=".$start);
if ((strpos($data['body'],'//'.$url.'/')!=false) || (strpos($data['body'],'//'.$url.' ')!=false))
{
$found=true;
}
else
{
$found=false;
}
$x++;
}
$data=$http->get("web/results","q=link:http://".$url);
if ($locale=="de")
{
$nomatchstring="Es wurden";
}
else
{
$nomatchstring="We found";
}
if (strpos($data['body'],$nomatchstring)!=false)
{
$backlinks=0;
}
else
{
if ($locale=="de")
{
$startpos=strpos($data['body'],"AltaVista fand")+15;
$endpos=strpos($data['body'],"Ergebnisse",$startpos)-1;
}
else
{
$startpos=strpos($data['body'],"AltaVista found")+16;
$endpos=strpos($data['body'],"results",$startpos)-1;
}
$backlinks=substr($data['body'],$startpos,$endpos-$startpos);
}
unset($http);
echo '<b>Altavista:</b><br>';
if ($found==true)
{
echo $url.' was found on page '.$x.'<br>';
}
else
{
echo $url.' was not found on the first '.$x.' Pages of results<br>';
}
echo 'Backlinks to '.$url.': '.$backlinks;
echo '<hr>';
}
function yahoo($keywords,$url,$maxpages,$locale="int")
{
if ($locale=="de")
{
$http=new httpconnection("de.search.yahoo.com",80,false,"Mozilla/5.0");
}
else
{
$http=new httpconnection("search.yahoo.com",80,false,"Mozilla/5.0");
}
$x=0;
while (($x<$maxpages) && ($found==false))
{
$start=$x*10+1;
$data=$http->get("search","p=".$keywords."&b=".$start);
if ((strpos($data['body'],'%2F%2F'.$url.'%2F')!=false) || (strpos($data['body'],'%F%F'.$url.' ')!=false))
{
$found=true;
}
else
{
$found=false;
}
$x++;
}
$data=$http->get("search","p=link:http://".$url);
if ($locale=="de")
{
$nomatchstring="Es wurden keine";
}
else
{
$nomatchstring="did not find";
}
if (strpos($data['body'],$nomatchstring)!=false)
{
$backlinks=0;
}
else
{
if ($locale=="de")
{
$startpos=strpos($data['body'],"von",strpos($data['body'],"Ergebnisse <",$startpos))+4;
$endpos=strpos($data['body'],"f".chr(252)."r",$startpos)-1;
$aboutword="ungef".chr(228)."hr";
}
else
{
$startpos=strpos($data['body'],"of",strpos($data['body'],"Results <",$startpos))+3;
$endpos=strpos($data['body'],"for",$startpos)-1;
$aboutword="about";
}
$backlinks=substr($data['body'],$startpos,$endpos-$startpos);
if (substr($backlinks,0,1)==substr($aboutword,0,1))
{
$backlinks=substr($backlinks,8+strlen($aboutword)+1,-9);
}
else
{
$backlinks=substr($backlinks,8,-9);
}
}
unset($http);
echo '<b>Yahoo:</b><br>';
if ($found==true)
{
echo $url.' was found on page '.$x.'<br>';
}
else
{
echo $url.' was not found on the first '.$x.' Pages of results<br>';
}
echo 'Backlinks to '.$url.': '.$backlinks;
echo '<hr>';
}
function msn($keywords,$url,$maxpages,$locale="int")
{
if ($locale=="de")
{
$http=new httpconnection("search.msn.de",80,false,"Mozilla/5.0");
}
else
{
$http=new httpconnection("search.msn.com",80,false,"Mozilla/5.0");
}
$x=0;
while (($x<$maxpages) && ($found==false))
{
$start=$x*10+1;
$data=$http->get("results.aspx","q=".$keywords."&first=".$start);
if ((strpos($data['body'],'//'.$url.'/')!=false) || (strpos($data['body'],'//'.$url.' ')!=false))
{
$found=true;
}
else
{
$found=false;
}
$x++;
}
$data=$http->get("results.aspx","q=link:http://".$url);
if ($locale=="de")
{
$nomatchstring="Es wurden";
}
else
{
$nomatchstring="We found";
}
if (strpos($data['body'],$nomatchstring)!=false)
{
$backlinks=0;
}
else
{
if ($locale=="de")
{
$startpos=strpos($data['body'],"von",strpos($data['body'],"Webergebnisse"))+4;
$endpos=strpos($data['body'],"Ergebnissen",$startpos)-1;
}
else
{
$startpos=strpos($data['body'],"of",strpos($data['body'],"Web Results"))+3;
$endpos=strpos($data['body'],"results",$startpos)-1;
}
$backlinks=substr($data['body'],$startpos,$endpos-$startpos);
}
unset($http);
echo '<b>MSN:</b><br>';
if ($found==true)
{
echo $url.' was found on page '.$x.'<br>';
}
else
{
echo $url.' was not found on the first '.$x.' Pages of results<br>';
}
echo 'Backlinks to '.$url.': '.$backlinks;
echo '<hr>';
}
function dmoz($keywords,$url,$maxpages)
{
$http=new httpconnection("search.dmoz.org",80,false,"Mozilla/5.0");
$x=0;
while (($x<$maxpages) && ($found==false))
{
$start=$x*20+1;
$data=$http->get("cgi-bin/search","search=".$keywords."&start=".$start);
if ((strpos($data['body'],'//'.$url.'/')!=false) || (strpos($data['body'],'//'.$url.' ')!=false))
{
$found=true;
}
else
{
$found=false;
}
$x++;
}
unset($http);
echo '<b>Open Directory Project:</b><br>';
if ($found==true)
{
echo $url.' was found on page '.$x.'<br>';
}
else
{
echo $url.' was not found on the first '.$x.' Pages of results<br>';
}
echo 'Backlinks to '.$url.': not available';
echo '<hr>';
}
if ((isset($_POST['check'])) && (!empty($_POST['keywords'])) && (!empty($_POST['url'])))
{
echo '<b>Keywords:</b> '.$_POST['keywords'].'<br><br>';
flush();
if (isset($_POST['google']))
{
google(urlencode($_POST['keywords']),$_POST['url'],$_POST['maxpages'],$_POST['location']);
flush();
}
if (isset($_POST['altavista']))
{
altavista(urlencode($_POST['keywords']),$_POST['url'],$_POST['maxpages'],$_POST['location']);
flush();
}
if (isset($_POST['yahoo']))
{
yahoo(urlencode($_POST['keywords']),$_POST['url'],$_POST['maxpages'],$_POST['location']);
flush();
}
if (isset($_POST['msn']))
{
msn(urlencode($_POST['keywords']),$_POST['url'],$_POST['maxpages'],$_POST['location']);
flush();
}
if (isset($_POST['dmoz']))
{
dmoz(urlencode($_POST['keywords']),$_POST['url'],$_POST['maxpages']);
flush();
}
}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table>
<tr><td>Keywords:</td><td>
<?php
echo '<input type="text" name="keywords"';
if (isset($_POST['keywords']))
{
echo ' value="'.$_POST['keywords'].'"';
}
echo '>';
?>
</td></tr>
<tr><td>URL:</td><td>
<?php
echo '<input type="text" name="url"';
if (isset($_POST['url']))
{
echo ' value="'.$_POST['url'].'"';
}
echo '>';
?>
</td></tr>
<tr><td>Max pages:</td><td><select name="maxpages">
<?php
for ($x=0;$x<10;$x++)
{
echo '<option value="'.($x+1).'"';
if (((isset($_POST['maxpages'])) && ($_POST['maxpages']==$x+1)) || ((!isset($_POST['maxpages'])) && ($x==4)))
{
echo ' selected';
}
echo '>'.($x+1).'</option>';
}
?>
</select></td></tr>
<?php
echo '<tr>';
echo '<td>Google:</td>';
echo '<td><input type="checkbox" name="google"';
if (isset($_POST['google']))
{
echo ' checked';
}
echo '></td>';
echo '</tr>';
echo '<tr>';
echo '<td>Altavista:</td>';
echo '<td><input type="checkbox" name="altavista"';
if (isset($_POST['altavista']))
{
echo ' checked';
}
echo '></td>';
echo '</tr>';
echo '<tr>';
echo '<td>Yahoo:</td>';
echo '<td><input type="checkbox" name="yahoo"';
if (isset($_POST['yahoo']))
{
echo ' checked';
}
echo '></td>';
echo '</tr>';
echo '<tr>';
echo '<td>MSN:</td>';
echo '<td><input type="checkbox" name="msn"';
if (isset($_POST['msn']))
{
echo ' checked';
}
echo '></td>';
echo '</tr>';
echo '<tr>';
echo '<td>Open Directory Project:</td>';
echo '<td><input type="checkbox" name="dmoz"';
if (isset($_POST['dmoz']))
{
echo 'checked';
}
echo '></td>';
echo '</tr>';
?>
<tr><td>Search Location:</td><td><select name="location">
<?php
echo '<option value="int"';
if (((isset($_POST['location'])) && ($_POST['location']=="int")) || (!isset($_POST['location'])))
{
echo ' selected';
}
echo '>International</option>';
echo '<option value="de"';
if ((isset($_POST['location'])) && ($_POST['location']=="de"))
{
echo ' selected';
}
echo '>Germany</option>';
?>
</select></td></tr>
</table>
<input type="submit" name="check" value="Check">
</form>
</body>
</html>