<html>
<head>
<title>Link-Check</title>
</head>
<body>
<?php
require_once("httpconnection.class.php");
function google($keywords,$url,$maxpages,$locale="int")
{
if ($locale=="de")
{
$http=new httpconnection("www.google.de");
}
else
{
$http=new httpconnection("www.google.com");
}
$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++;
}
unset($http);
echo '<b>Google:</b><br>';
if ($found==true)
{
echo $url.' was found on page '.$x.'<hr>';
}
else
{
echo $url.' was not found on the first '.$x.' Pages of results<hr>';
}
}
function altavista($keywords,$url,$maxpages,$locale="int")
{
if ($locale=="de")
{
$http=new httpconnection("de.altavista.com");
}
else
{
$http=new httpconnection("www.altavista.com");
}
$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++;
}
unset($http);
echo '<b>Altavista:</b><br>';
if ($found==true)
{
echo $url.' was found on page '.$x.'<hr>';
}
else
{
echo $url.' was not found on the first '.$x.' Pages of results<hr>';
}
}
function yahoo($keywords,$url,$maxpages,$locale="int")
{
if ($locale=="de")
{
$http=new httpconnection("de.search.yahoo.com");
}
else
{
$http=new httpconnection("search.yahoo.com");
}
$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++;
}
unset($http);
echo '<b>Yahoo:</b><br>';
if ($found==true)
{
echo $url.' was found on page '.$x.'<hr>';
}
else
{
echo $url.' was not found on the first '.$x.' Pages of results<hr>';
}
}
function msn($keywords,$url,$maxpages,$locale="int")
{
if ($locale=="de")
{
$http=new httpconnection("search.msn.de");
}
else
{
$http=new httpconnection("search.msn.com");
}
$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++;
}
unset($http);
echo '<b>MSN:</b><br>';
if ($found==true)
{
echo $url.' was found on page '.$x.'<hr>';
}
else
{
echo $url.' was not found on the first '.$x.' Pages of results<hr>';
}
}
if ((isset($_POST['check'])) && (!empty($_POST['keywords'])) && (!empty($_POST['url'])))
{
echo '<b>Keywords:</b> '.$_POST['keywords'].'<br><br>';
flush();
google(urlencode($_POST['keywords']),$_POST['url'],$_POST['maxpages']);
flush();
altavista(urlencode($_POST['keywords']),$_POST['url'],$_POST['maxpages']);
flush();
yahoo(urlencode($_POST['keywords']),$_POST['url'],$_POST['maxpages']);
flush();
msn(urlencode($_POST['keywords']),$_POST['url'],$_POST['maxpages']);
}
?>
<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>
</table>
<input type="submit" name="check" value="Check">
</form>
</body>
</html>