Файл: DARK WARS/dark_war/clans/voting/voting_view.php
Строк: 75
<?php
include_once '../../start.php';
$doc = new document();
$doc->title('Голосования');
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
$doc->err('Ошибка, не выбран элемент');
exit();
}
$id = (int)$_GET['id'];
if (!isset($_GET['id_clan']) || !is_numeric($_GET['id_clan'])) {
$doc->err('Ошибка, не выбран клан');
exit();
}
$id_clan = (int)$_GET['id_clan'];
$q = mysql_query("SELECT * FROM `dark_war_clan_voting` WHERE id='$id' LIMIT 1");
if (!mysql_num_rows($q)) {
$doc->err('Запрос к не существующему элементу');
exit();
}
$admin = mysql_fetch_assoc(mysql_query("SELECT * FROM `dark_war_clans_us` WHERE id_player='{$player->id}' AND `id_clan` = '$id_clan' LIMIT 1"));
$count_golosa = mysql_result(mysql_query("SELECT COUNT(*) FROM `dark_war_clan_vote` WHERE `id_voting` = '$id' "),0);
$count_vote = mysql_result(mysql_query("SELECT COUNT(*) FROM `dark_war_clan_vote` WHERE `id_player`='{$player->id}' AND `id_voting`='$id' "),0);
$dispatch = array();
$q=mysql_query("SELECT * FROM `dark_war_clan_candidates` WHERE `id_clan` = '$id_clan' AND `id_voting` = '$id' ORDER BY id DESC ");
while ($post = mysql_fetch_array($q)) {
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `dark_war_clan_vote` WHERE `id_candi` = '$post[id]' "),0);
$its_result = round($count * 100 / $count_golosa);
$action = array();
$list = $post['name'];
$descrip = "<img src='percent.php?id=$its_result' title='$its_result процентов' alt='$its_result' />";
if ($count_vote == 0) {
$action[] = array('link' => 'vote.php?id='.$post['id'].'&id_clan='.$id_clan.'&voting='.$id.'', 'name' => 'Голосовать');
}
$action[] = array('link' => 'delete_candi.php?id='.$post['id'].'&id_clan='.$id_clan.'&voting='.$id.'', 'name' => 'Удалить');
$dispatch[] = array ('title' => $list, 'descrip' => $descrip, 'action' => $action);
}
if (!$dispatch) {
$dispatch[] = array ('title' => 'Нет кандидатов');
}
$doc->assign('post', $dispatch);
$doc->display('view_list_plus_img.tpl');
if ($count_vote > 0) {
$doc->act("/dark_war/clans/voting/dump.php?id=$id&id_clan=$id_clan", 'Сбросить');
}
if ($player->admin >= 2) {
$doc->act("/dark_war/clans/voting/add.php?id=$id&id_clan=$id_clan", 'Добавить');
$doc->act("/dark_war/clans/voting/delete_voting.php?id=$id&id_clan=$id_clan", 'Удалить голосования');
}
$doc->ret("/dark_war/clans/voting/?id=$id_clan", 'Голосования');
?>