10) $res=100; else $res*=10; $url="http://www.google.com/ie?q=".urlencode($keyword).'&num=100'; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_USERAGENT, $this->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); $result=str_replace('

Did you mean:','',$result); curl_close($ch); if(!$result) {return 'error';} return $result; } function get_values(&$contents,$website) { $first=strpos($contents,''); $first=$first+6; $contents=substr($contents,$first,strlen($contents)-$first); //echo $contents; $last=strpos($contents,''); $length=$last; $value=substr($contents,0,$length); //echo "\n\n\n".$value ; return $value; } function get_url($content) { /*$first=strpos($content,'href='); $last=strpos($content,'>'); $url=substr($content,$first+5,$last-$first+5); */ $tmp=$this->my_preg_match_all_clean('href=','>',$content); $url=$tmp[0]; //echo "\nURL:" .$url; return $url; } function get_title($content,$url) { /* $first=strpos($content,'$url'); $first+=strlen($url)+1; $content=substr($content,$first,strlen($contents)-$first); $first=strpos($content,''); $title=substr($content,0,$first); */ $tmp=$this->my_preg_match_all_clean('>','',$content); $title=$tmp[0]; //echo "\nTITLE:".$title; return $title; } function is_in_url($url,$website) { $website=ereg_replace(strtolower("www."),strtolower(""),strtolower($website)); $website=ereg_replace(strtolower("http://"),strtolower(""),strtolower($website)); $tmp1=parse_url($url); $tmp1=str_replace("www.","",$tmp1['host']); if(trim(strtolower($tmp1))==trim(strtolower($website))) return 1; else return 0; } function remove_header($content) { $first=strpos($content,'

'); return substr($content,$first,strlen($content)-$first); } function getResGoogle_sesat($url) { $tmp=parse_url($url); $url=$tmp['host']; $url=str_replace('www.','',$url); $page=$this->curl_string("site:$url"); if($page==='error') return 'error'; $results=$this->get_value($page,'of about ',''); return $results; } function getResByQuery($query) { $page=$this->curl_string($query); if($page==='error') return 'error'; $results=$this->get_value($page,'of about ',''); return $results; } function getResGoogle_linkpop($url) { /* $tmp=parse_url($url); $url=$tmp['host'];*/ $url=str_replace('http://','',$url); //$url=str_replace('www.','',$url); //echo "
".$url; $page=$this->curl_string("link: $url"); if($page==='error') return 'error'; $page=str_replace("about ","",$page); $results=$this->get_value($page,'of ',''); return $results; } function getTopResults($keyword,$x) { $string = $this->curl_string($keyword); $string=$this->remove_header($string); $res=array(); for($i=1;$i<=$x;$i++) { $rezultat=$this->get_values($string,$_POST[website]); $res[]=$this->get_url($rezultat); } return $res; } 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); if(is_numeric($value)) return $value; else return 0; } //.. FUNCTIONS function my_preg_match_all($start,$end,$string) { $res=array(); while(strpos($string,$start)!==FALSE && strpos($string,$end)!==FALSE) { $first=strpos($string,$start); $string=substr($string,$first); $last=strpos($string,$end); $res[]=substr($string,0,$last+strlen($end)); $length=$last; $string=substr($string,$length); } return $res; } function my_preg_match_all_clean($start,$end,$string) { $res=array(); while(strpos($string,$start)!==FALSE && strpos($string,$end)!==FALSE) { $first=strpos($string,$start); $string=substr($string,$first); $last=strpos($string,$end); $res[]=substr($string,strlen($start),$last-strlen($start)); $length=$last+strlen($end); $string=substr($string,$length); } return $res; } } ?>