<?php

include_once '../../sys/inc/start.php';
include_once '../../sys/inc/compress.php';
include_once '../../sys/inc/sess.php';
include_once '../../sys/inc/home.php';
include_once '../../sys/inc/settings.php';
include_once '../../sys/inc/db_connect.php';
include_once '../../sys/inc/ipua.php';
include_once '../../sys/inc/fnc.php';
include_once '../../sys/inc/user.php';
$set['title'] = 'Гаремы';
include_once '../../sys/inc/thead.php';
title();
aut();

echo '<div class="foot">';
echo '<img src="/style/icons/str2.gif" /> <a href="index.php?">Гаремы</a> | <b>Топ Гаремов</b><br />';
echo '</div>';

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `garem_stat` WHERE `stole` > '0' ORDER BY `stole`"), 0);

if ($k_post == 0)
{
	echo '<div class="mess">';
	echo 'В рейтинге нет пользователей';
	echo '</div>';
}

$set['p_str'] = 9;
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];

$q = mysql_query("SELECT * FROM `garem_stat` WHERE `stole` > '0' ORDER BY `stole` DESC LIMIT $start, $set[p_str]");

echo '<table class="table">';

while ($static = mysql_fetch_array($q)) 
{
	$rab = get_user($static['user_id']);
	
	// Лесенка
	echo '<div class="' . ($num % 2 ? "nav1" : "nav2") . '">';
	$num++;
	
	$count['garem'] = mysql_result(mysql_query("SELECT COUNT(*) FROM `garem` WHERE `thief_id` = '" . $rab['id'] . "'"),0);
	
	echo user::avatar($rab['id'], 0) . '<a href="/plugins/garem/garem.php?id=' .($rab['id']). '">Гарем ' . user::nick($rab['id'], 0) . '</a> (' . $count['garem'] . ')<br />';
	echo 'Рейтинг гарема (' . $static['stole'] . '%)<br />';
	echo 'Цена хозяина (' . $static['cost'] . ' баллов)<br />';
	
	echo '</div>';
}

echo '</table>';

if ($k_page>1){
	str("?",$k_page,$page);
}

require 'links.inc.php';

echo '<div class="foot">';
echo '<img src="/style/icons/str2.gif" /> <a href="index.php?">Гаремы</a> | <b>Топ Гаремов</b><br />';
echo '</div>';

include_once '../../sys/inc/tfoot.php';
?>