Файл: inc/tools/alexa_checker/index.php
Строк: 69
<?php
function getPage($url){
$site = fopen('http://www.alexa.com/data/details/main?url='.urlencode("http://".$url),'r');
while($cont = fread($site,1024657)){
$buffer .= $cont;
}
return $buffer;
}
function checkAlexa($url){
$cssUrl = 'http://client.alexa.com/common/css/scramble.css';
$cssResult = file_get_contents($cssUrl);
$position = strpos($cssResult,".",$position);
if ($position ===false){
echo "CSS error";
exit();
}
preg_match_all("/.([0-9A-Za-z]+)/", $cssResult, $ceseseuri);
$startUrl = 'http://www.alexa.com/data/details/traffic_details?url=http%3A%2F%2F';
$result = getPage($startUrl.$url);
$iposition = strpos($result,"rank of");
$position=strpos($result, "Service.-->", $iposition)+11;
$endhn=strpos($result,"<!-- google", $position);
$texttosearch=substr($result, $position, $endhn-$position);
foreach ($ceseseuri[1] as $invis)
{
if (preg_match("/<span class="".$invis."">([0-9,]+)</span>/", $texttosearch, $sekas))
{
$texttosearch=preg_replace ("/<span class="".$invis."">([0-9,]+)</span>/", "", $texttosearch);
}
}
return strip_tags($texttosearch);
}
function get_alexa_rank($siteUrl) {
$value = checkAlexa($siteUrl);
if ($value) return $value; else return "NO DATA";
}
?>
<form id="form1" name="form1" method="post" action="">
<table width="100%" border="0" align="center" class="ttable">
<tr>
<td bgcolor="#D4D0C8"><strong>Массовая проверка Alexa Rank </strong></td>
</tr>
<tr>
<td align="center">список URLS:
<label></label><div align="center"></div></td>
</tr>
<tr>
<td align="center"><textarea name="urls" cols="70" rows="10" id="urls"></textarea></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Проверить Alexa Rank" /></td>
</tr>
<tr>
<td><?php
if($_POST['urls'])
{
$urllist=explode("n", $_POST['urls']);
$url_count=count($urllist);
echo 'Количество URL для проверки: <b>'.$url_count.'</b><br><br>';
if($url_count)
{
echo '<table width="100%">';
for($i=0; $i<$url_count; $i++)
{
ob_flush(); flush();
$url=trim($urllist[$i]);
echo '<tr><td><b>URL:</b> '.$url.'</td><td>AlexaRank: <b>'.get_alexa_rank($url).'</b></td></tr>';
usleep(10);
}
echo '</table>';
}
}
?></td>
</tr>
</table>
</form>