Файл: inc/tools/position_dc_checker/functions.php
Строк: 15
<?php
function check_dc_position($datacenter, $url, $s_query, $r_count, $rls)
{
for($r=0; $r<$r_count; $r=$r+100)
{
$url=str_replace('http://','',$url);
$url=str_replace('www.','',$url);
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://'.$datacenter.'/search?hl='.$rls.'&rls='.$rls.'&num=100&start='.$r.'&q='.$s_query);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1)');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$data = curl_exec($ch);
curl_close($ch);
preg_match_all("|<h2 class=r><a href="(.*)"|Ui", $data, $matches);
for($u=1; $u<=count($matches[1]); $u++)
{
if(substr_count($matches[1][$u], $url))
return $r+$u;
}
}
return ('N/A');
}
?>