Файл: inc/tools/yahoo_position_checker/functions.php
Строк: 14
<?php
function check_position($url, $s_query, $r_count)
{
$pstart=0;
for($r=1; $r<=$r_count; $r=$r+10)
{
$url=str_replace('http://','',$url);
$url=str_replace('www.','',$url);
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://search.yahoo.com/search?b='.$r.'&pstart='.$pstart.'&p='.$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("|<span class=url>(.*)</span>|Ui", $data, $matches);
$pstart=$pstart+5;
for($u=0; $u<=count($matches[1]); $u++)
{
if(substr_count(strip_tags($matches[1][$u]), $url))
return $r+$u;
}
}
return ('N/A');
}
?>