<?php
require_once 'inc/core.php'; //ядро
$page = 'in';
$siteQuery = mysql_query("SELECT `id`,`refid`,`in`,`hosts` FROM `site` WHERE `id` = '$id'");
if (isset($id) && mysql_num_rows($siteQuery) == 1)
{
$siteData = mysql_fetch_array($siteQuery);
$positionIn100 = mysql_num_rows(mysql_query("SELECT `id` FROM `site` WHERE `hosts` > '".$siteData['hosts']."';"))+1;
$page = round($positionIn100/$onPage);
if (mysql_num_rows(mysql_query("SELECT `id` FROM `in` WHERE `ip` = '$ip' AND `date` > '".($realtime - 24*60*60)."' AND `refid` = '$id';")) == 0)
{
$referer = (!empty($_SERVER['HTTP_REFERER']) ? (preg_replace('/http:\/\//si','',mysql_escape_string(htmlspecialchars($_SERVER['HTTP_REFERER'])))) : 'неизвестно');
mysql_query("INSERT INTO `in` SET
`date` = '$realtime',
`refid` = '$id',
`ip` = '$ip',
`agent` = '$agent',
`referer` = '$referer',
`brovser` = '".(browser($agent,1))."',
`os` = '".(browser($agent,2))."';");
mysql_query("UPDATE `site` SET `in` = '".($siteData['in']+1)."' WHERE `id` = '$id';");
header('Location: '.$path.'?page='.$page.'');
} else header('Location: '.$path.'?page='.$page.'');
}
else header('Location: '.$path.'index.php');
?>