<?php
###############################################
#  by MaZaFaKa                                #
#  ICQ: 449-559                               #
#  E-mail: Dimonnet@inbox.ru                  #
#  Потраченное время: Около 2х недель         #
###############################################
echo(
"</div>\n");
 echo '<div class="header">';
echo("<span style='font-size: 18px'><b>vlog.net</b></span>&nbsp;<sup>
<span style='color: #cccccc; font-size: 9px'>beta</span></sup>'</div>\n");

$adv = @file_get_contents(ROOTPATH."/tmp/adv/head_index");
echo($adv);

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

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

$sql = mysql_query("SELECT * 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">';
	echo("ТОП-100 | <a href='".PATH."/".VERSION."/category/'>Категории</a><br />\n");
	echo '</div>';
   echo '<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 * 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))
	{
	$q = mysql_query("SELECT COUNT(*) FROM `".ONLINE."` WHERE `user_id` = ".$top['id'].";");
    $is_online = mysql_result($q, 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 />\n");
	echo("[".$top['url']."]<br />\n");
	echo($top['about']."<br />\n");


	$c++;
	}

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

?>