<?php
###############################################
#  by MaZaFaKa                                #
#  ICQ: 449-559                               #
#  E-mail: Dimonnet@inbox.ru                  #
#  Потраченное время: Около 2х недель         #
###############################################

echo '</div>
<div class="header">
<span style="font-size: 18px"><strong>'.$_SERVER['HTTP_HOST'].'</strong></span> <sup>
<span style="color: #cccccc; font-size: 9px">beta</span></sup></div>';

echo @file_get_contents(ROOTPATH.'/tmp/adv/head_index');

//ADVERTISEMENT LINKS 1
$file = trim(@file_get_contents(ROOTPATH."/tmp/adv/head_index_like"));
$file = explode("\t", $file);
echo($file[mt_rand(0, sizeof($file)-1)]);

//ADVERTISEMENT LIKS 2
$file = trim(@file_get_contents(ROOTPATH."/tmp/adv/head_index_like2"));
$file = explode("\t", $file);
echo($file[mt_rand(0, sizeof($file)-1)]);

$sql = mysql_query("SELECT 1 FROM `".USERS."` WHERE `status` <> 'locked' AND `hosts` > 0 AND `hits` > 0 ORDER BY `hosts` DESC, `hits` DESC;");
$all = mysql_num_rows($sql);

if($all > 0)
{
echo '<div class="rh">
ТОП-100 | <a href="'.PATH.'/'.VERSION.'/category/">Категории</a><br />
</div>
<div class="rb">';

$max_page = ceil($all / PAGE);

	$page = (int) $_REQUEST['page'];
	if(empty($page) || $page < 1 || $page > $max_page) $page = 1;

	if($page > 1) $from = ($page - 1) * PAGE;
	else $from = 0;

	$sql = mysql_query("SELECT `id`,`name`,`hosts`,`hits`,`url`,`about` FROM `".USERS."` WHERE `status` != 'locked' AND `hosts` > 0 AND `hits` > 0 ORDER BY `hosts` DESC, `hits` DESC LIMIT ".$from.", ".PAGE.";");

	$c = $from + 1;

	while($top = mysql_fetch_assoc($sql))
	{
    $is_online = mysql_result(mysql_query("SELECT COUNT(*) FROM `".ONLINE."` WHERE `user_id` = ".$top['id'].";"), 0);

echo $c.'. <a href="'.PATH.'/'.VERSION.'/out/'.$top['id'].'">'.$top['name'].'</a>
<span class="g">('.$top['hosts'].'/'.$top['hits'].')</span>
<a href="'.PATH.'/'.VERSION.'/info/'.$top['id'].'">(?)</a><br />
['.$top['url'].']<br />
'.$top['about'].'<br />';

$c++;
	}

//NAVIGATION
echo(pages($page, $max_page, PATH.'/'.VERSION, VERSION));
}
else
{
echo 'Активных сайтов, учавствующих в рейтинге, не найдено.<br />';
}
echo '</div>
<div class="rh">
<a href="'.PATH.'/'.VERSION.'/rules/?new=1">Регистрация</a>
|
<a href="'.PATH.'/'.VERSION.'/search/?'.SESSION.'">Поиск</a><br />
</div>';
echo @file_get_contents(ROOTPATH.'/tmp/adv/foot_index');
?>