class NrRes
{
/*function curl_string ($url)
{
$ch = curl_init();
$user_agent = "Mozilla/4.0";
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt ($ch, CURLOPT_COOKIEJAR, "c:\cookie.txt");
curl_setopt ($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
$result = curl_exec ($ch);
curl_close($ch);
return $result;
}*/
function get_content($url)
{
$numberOfSeconds=4;
$tmp=parse_url($url);
$domain=$tmp['host'];
$resourcePath=str_replace('http://','',$url);
$resourcePath=str_replace($domain,'',$resourcePath);
$socketConnection = fsockopen($domain, 80, $errno, $errstr, $numberOfSeconds);
$res = '';
fputs($socketConnection, "GET $resourcePath HTTP/1.0\r\nHost: $domain\r\n\r\n");
while (!feof($socketConnection))
$res .= fgets($socketConnection, 128);
fclose ($socketConnection);
return($res);
}
function getRes2Array($url)
{
$result=array();
$result['url']=trim($url);
$result['google']=$this->getResGoogle($url);
$result['yahoo']=$this->getResYahoo($url);
$result['alltheweb']=$this->getResAllTheWeb($url);
//$result['altavista']=$this->getResAltaVista($url);
//$result['hotbot']=$this->getResHotBot($url);
$result['msn']=$this->getResMSN($url);
$tmp=$result['google']+$result['yahoo']+$result['alltheweb']+$result['altavista']+$result['hotbot']+$result['msn'];
$result['total']=$tmp;
return $result;
}
function getResGoogle($url)
{
$url="http://www.google.com/search?hl=en&lr=&ie=ISO-8859-1&safe=off&q=site%3A".urlencode($url)."+inurl%3A".urlencode($url);
$page=$this->get_content($url);
$results=$this->get_value($page,'of about ','')+$this->get_value($page,'of ','');
return $results;
}
function getResYahoo($url)
{
$url="http://siteexplorer.search.yahoo.com/search?ei=UTF-8&p=".urlencode("").urlencode($url)."&bwm=p&bwms=p&searchbwm=Explore+URL";
$page=$this->get_content($url);
$results=$this->get_value($page,'Pages (',')');
return $results;
}
function getResAllTheWeb($url)
{
$url="http://www.alltheweb.com/search?avkw=fogg&cat=web&cs=utf-8&q=".urlencode("domain:").urlencode($url)."&_sb_lang=any";
$page=$this->get_content($url);
$results=$this->get_value($page,'of ','');
return $results;
}
function getResAltaVista($url)
{
$url="http://www.altavista.com/web/results?q=".urlencode("host:").urlencode($url)."&kgs=0&kls=0&avkw=qtrp";
$page=$this->get_content($url);
$results=$this->get_value($page,'AltaVista found ',' results');
return $results;
}
function getResHotBot($url)
{
$url="http://www.hotbot.com/adv.asp?prov=HotBot&query=*&loc=searchbox&tab=web&dfi=".urlencode($url)."&wfc=2&dateop=after";
$page=$this->get_content($url);
$results=$this->get_value($page,' of ',')');
return $results;
}
function getResMSN($url)
{
$url="http://search.msn.com/results.aspx?q=site%3A".urlencode($url)."&FORM=QBNO";
$page=$this->get_content($url);
$value=ereg_replace(",","",$value);
$value=ereg_replace("\.","",$value);
$results=$this->get_value($page,'10 ',' ')+$this->get_value($page,'10 of ',' ');
return $results;
}
function get_value($contents,$begin,$end)
{
$first=strpos($contents,$begin);
$first=$first+strlen($begin);
$contents=substr($contents,$first,strlen($contents)-$first);
$last=strpos($contents,$end);
$length=$last;
$value=substr($contents,0,$length);
$value=ereg_replace(",","",$value);
$value=ereg_replace("\.","",$value);
if(is_numeric($value)) { return $value; }
else { return 0; }
}
}
?>