<?php
/*
- NTLCMS v 18.1 19.08.2017 г
- Автор скрипта Александр (NTL)
- Скрипт клик клуба v 18.0
- Оф.сайт http://clicks24.ru
- Контакты ntl-jt@mail.ru
- Все права принадлежат разработчику
- Вы не имеете право вносить изменения в код скрипта
- Данный скрипт запрещено распространять
*/
define('NTLCMS', 1);
$module = 'vote';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
include ('../system/head.php');
################################################################################
if (!$active){
header('Location: '.URL);
$_SESSION['fail'] = 'Вы не авторизированы!';
exit;
}
################################################################################
/*if ($set['news'] == '1' && $_USER['admin'] != '1'){
echo '<div class="title"><center>Новости системы</center></div>';
echo '<div class="post"><center>'.image('fail.png','16|16').' Модуль закрыт администратором!</center></div>';
echo '<div class="block">'.image('home.png','18|18').' <a href="'.URL.'/cabinet">В кабинет</a></div>';
include ('../system/foot.php');
exit;
}*/
################################################################################
$id = isset($_GET['id']) ? filter_int($_GET['id']) : '0';
$where = 'and `status` = \'2\'';
if ($_USER['admin'] != '1') $where = null;
//if (DB :: run() -> querySingle("select (`id`) from `votes` where `id` = '".$id."' $where") == 0) header('Location: '.URL.'/polls');
$vote = DB :: run() -> query("select * from `votes` where `id` = ?", array($id)) -> fetch();
################################################################################
echo '<div class="title"><center>Голосование</center></div>';
################################################################################
echo '<div class="post"><center><b>'.checkout($vote['name']).'</b></center></div>';
################################################################################
if (DB :: run() -> querySingle("select (`id`) from `voices` where `vid` = '".$id."' and `login` = '".$ulogin."'") > 0 || $vote['status'] < 2){
$count = DB :: run() -> querySingle("select count(`id`) from `voices` where `vid` = '".$id."'");
if ($count != $vote['cv']) DB :: run() -> query("update `votes` set `cv` = '".$count."' where `id` = '".$id."'");
$answers = array();
$res = DB :: run() -> query("select response, count(*) as count from `voices` where `vid` = '".$id."' group by `response` order by count(*) desc");
while ($voice = $res -> fetch()){
$answers[$voice['response']] = $voice['count'];
}
for ($i = 1; $i <= 10; $i ++){
if (empty($vote['response'.$i])){
if (isset($answers[$i])) DB :: run() -> query("delete from `voices` where `vid` = '".$id."' and `response` = '".$i."'");
continue;
}
$ca = (!empty($answers[$i])) ? $answers[$i] : 0;
echo '<div class="menu"><b>'.$i.'.</b> <b>'.$vote['response'.$i].'</b>: '.word($ca, 'голос', 'голоса', 'голосов').' | <span style="color:red">'.round(($ca / $count) * 100).' %</span><br/>';
echo '<img src="'.URL.'/str/scale.php?get='.round(($ca / $count) * 100).'" alt="'.round(($ca / $count) * 100).'%"/>';
if ($ca > 0/* && $_USER['admin'] == '1'*/) echo '<br />» <a href="'.URL.'/vstat'.$id.'/'.$i.'">Кто голосовал?</a>';
echo '</div>';
}
} else {
for ($i = 1; $i <= 10; $i ++){
if (!empty($vote['response'.$i])) echo '<div class="menu"><b>'.$i.'.</b> <a href="'.URL.'/voice'.$id.'/'.$i.'">'.$vote['response'.$i].'</a></div>';
}
}
if ($_USER['admin'] == '1'){
echo '<div class="menu">'.image('votes.png','18|18').' ';
if ($vote['cv'] > 0) echo ' <a href="'.URL.'/cleanvote'.$id.'">Сбросить</a> | ';
echo ' <a href="'.URL.'/delvote'.$id.'">Удалить</a></div>';
}
echo '<div class="block">'.image('home.png','18|18').' '.(isset($active) ? '<a href="'.URL.'/cabinet">В кабинет</a>' : '<a href="'.URL.'">На главную</a>').' | <a href="'.URL.'/polls">Голосования</a></div>';
include ('../system/foot.php');
?>