<?php 

define('H', $_SERVER['DOCUMENT_ROOT'].'/');
include_once H.'sys/inc/start.php';
include_once H.'sys/inc/compress.php';
include_once H.'sys/inc/sess.php';
include_once H.'sys/inc/settings.php';
include_once H.'sys/inc/db_connect.php';
include_once H.'sys/inc/ipua.php';
include_once H.'sys/inc/fnc.php';
include_once H.'sys/inc/user.php';

require 'config.php';

$ID = (isset($_GET['id']) ? (int) $_GET['id'] : 0);
$sex = (isset($_GET['sex']) && preg_match('/^([A-z]+)$/', $_GET['sex']) ? $_GET['sex'] : 'male');

$set['title'] = 'Участники битвы №' . $ID;
include_once H.'sys/inc/thead.php';
title();
aut();
?>
<link rel="stylesheet" href="css/main.css" type="text/css" />
<?
$k_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `sexwars_users` WHERE `id_tournament` = '$ID' AND `sex` = '" . my_esc($sex) . "'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];

?>
<table class="post">
<?

if ($k_post == 0)
{
	?>
  <div class="mess" id="no_object">
	Нет участников
	</div>
  <?
}

$q = mysql_query("SELECT * FROM `sexwars_users` WHERE `id_tournament` = '$ID' AND `sex` = '" . my_esc($sex) . "' ORDER BY count_weapon DESC LIMIT $start, $set[p_str]");

$num = 0;


while ($post = mysql_fetch_assoc($q))
{
	?>
  <div class="post-<?= $post['sex']?>">
  <?
	$num++;
    
	echo user::avatar($post['id_user'], 2) . user::nick($post['id_user'], 1, 1, 1);
	?>
  <?= des2num($post['count_weapon'], array('очко', 'очка', 'очков'))?>
	</div>
  <?
}

?></table><?

if ($k_page > 1) {
  str('?id=' . $ID . '&amp;sex=' . $sex . '&amp;', $k_page, $page);
}
?>
<div class="foot">
  &laquo; <a href="wars.php">В игру</a> / Участники
</div>
<?
include_once H.'sys/inc/tfoot.php';