Файл: mods/contests/users.php
Строк: 100
<?php
/*
Автор: WIZART
Сайт: WizartWM.RU
E-mail автора: bi3apt@gmail.com
*/
include_once '../../sys/inc/home.php';
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';
$c = mysql_fetch_assoc(mysql_query("SELECT * FROM `contests` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `contests` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1"),0)==0){header("Location: /index.php?".SID);exit;}
$set['title']="Конкурс - ".htmlspecialchars($c['name'])." - Участники";
include_once H.'sys/inc/thead.php';
title();
aut();
if (isset($_GET['del']) && isset($user) && $user['level']>1 && mysql_result(mysql_query("SELECT COUNT(*) FROM `contests_users` WHERE `id_contest` = '$c[id]' AND `id` = '".intval($_GET['del'])."' LIMIT 1"),0)!=0){
mysql_query("DELETE FROM `contests_users` WHERE `id_contest` = '$c[id]' AND `id` = '".intval($_GET['del'])."' LIMIT 1");
mysql_query("DELETE FROM `contests_golos` WHERE `id_contest` = '$c[id]' AND `id` = '".intval($_GET['del'])."' LIMIT 1");
if (is_file(H.'mods/contests/img/photo/'.intval($_GET['del']).'.png'))@unlink(H."mods/contests/img/photo/".intval($_GET['del']).".png");
msg("Участник успешно удален");
}
if (isset($_GET['golos']) && isset($user) && $c['ntime']<$time && $c['ktime']>$time && $user['id']!=intval($_GET['golos']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `contests_golos` WHERE `id_contest` = '$c[id]' AND `id_user` = '".intval($_GET['golos'])."' AND `id_golos` = '$user[id]' LIMIT 1"),0)==0){
mysql_query("INSERT INTO `contests_golos` (`id_user`, `id_contest`, `id_golos`, `golos`) VALUES ('".intval($_GET['golos'])."','$c[id]','$user[id]','1')");
$cu = mysql_fetch_assoc(mysql_query("SELECT * FROM `contests_users` WHERE `id` = '".intval($_GET['golos'])."' LIMIT 1"));
mysql_query("UPDATE `contests_users` SET `golos` = '".($cu['golos']+1)."' WHERE `id` = '".intval($_GET['golos'])."' LIMIT 1");
msg("Голос успешно принят");
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `contests_users` WHERE `id_contest` = '$c[id]'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0)echo "<div class='msg'>Пока нет участников.</div>";
$q=mysql_query("SELECT * FROM `contests_users` WHERE `id_contest` = '$c[id]' ORDER BY `golos` DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_array($q)){
if ($num==0){echo "<div class='nav1'>"; $num=1;}elseif ($num==1){echo "<div class='nav2'>"; $num=0;}
$ank=get_user($post['id_user']);
if ($user['level']>1)echo "<span style='float:right;'><a href='?id=$c[id]&del=$post[id]' title='Удалить'><img src='img/icons/del.png' alt='del'></a></span>";
echo uslist($ank['id'])."<br/>";
if ($c['type']==1)echo output_text($post['text']);
else if ($c['type']==2)echo "<img src='img/photo/$post[id].png' alt='photo'>";
if ($c['ntime']<$time && $c['ktime']>$time){
echo "<br/><b>Голосов $post[golos] </b>";
if (isset($user) && $user['id']!=$post['id_user'] && mysql_result(mysql_query("SELECT COUNT(*) FROM `contests_golos` WHERE `id_contest` = '$c[id]' AND `id_user` = '$post[id]' AND `id_golos` = '$user[id]' LIMIT 1"),0)==0)echo "<a href='?id=$c[id]&golos=$post[id]'>Голосовать</a>";
}
echo "</div>";
}
if ($k_page>1)str("?id=$c[id]&",$k_page,$page);
echo "<div class='foot'><img src='/style/icons/str.gif' alt=''><a href='/mods/contests/contest.php?id=$c[id]'> ".htmlspecialchars($c['name'])."</a></div>";
echo "<div class='foot'><img src='/style/icons/str.gif' alt=''><a href='/mods/contests/'> Конкурсы</a></div>";
include_once H.'sys/inc/tfoot.php';
?>