Файл: soc-set/moduls/duel/index.php
Строк: 107
<?
require_once('../../core/start.php');
include_once 'inc.php';
check_auth();
head('Дуэли');
panel();
if (!empty($_POST['golos']) && !empty($_POST['duel_id'])) {
$id = intval($_POST['duel_id']);
if (isset($_POST['vote_user'])) {
$opp = intval($_POST['vote_user']);
} elseif (isset($_POST['vote_opponent'])) {
$opp = intval($_POST['vote_opponent']);
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `duel` WHERE `id` = $id"),0) == 0) {
$err = 'Нет такой дуэли';
} elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = $id AND `id_user` = $user[user_id]"),0) !=0 ) {
$err = 'Вы уже голосовали за эту дуэль';
} elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `duel` WHERE (`user`='$user[user_id]' OR `opponent`='$user[user_id]') AND `id` = $id"),0) != 0) {
$err = 'Нельзя голосовать за свою дуэль';
}
if(empty($err)) {
mysql_query("INSERT INTO `duel_vote` (`id_user`, `id_opponent`, `id_duel`, `man`) VALUES ('".$user['user_id']."', '".$opp."', '".$id."', '".$user['gender']."')");
$msg = 'За вас проголосовали в <a href="'.HOME.'/duel">дуэле</a>';
lenta($msg, $opp);
balls_operation(5);
}
}
if (isset($_GET['no']) && isset($user)) {
$id = intval($_GET['no']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `duel` WHERE `id` = $id"),0) == 0) {
$err = 'Нет такой дуэли';
} elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = $id AND `id_user` = $user[user_id]"),0) != 0) {
$err = 'Вы уже голосовали за эту дуэль';
} elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `duel` WHERE (`user`='$user[user_id]' OR `opponent`='$user[user_id]') AND `id` = $id"),0) != 0) {
$err = 'Нельзя голосовать за свою дуэль';
}
if(empty($err)){
mysql_query("INSERT INTO `duel_vote` (`id_user`, `id_opponent`, `id_duel`, `man`) VALUES ('".$user['user_id']."', '0', '".$id."', '".$user['gender']."')");
}
}
/* Основная страница */
$num = mysql_result(mysql_query("SELECT COUNT(*) FROM `duel` WHERE (SELECT COUNT(*) FROM `duel_vote` WHERE `duel_vote`.`id_duel` = `duel`.`id` AND `id_user` = '$user[user_id]') = 0 AND `duel`.`act` = '1' AND `opponent` != '$user[user_id]' AND `user` != '$user[user_id]'"),0);
if(!empty($num)) {
$post = mysql_fetch_array(mysql_query("SELECT * FROM `duel` WHERE (SELECT COUNT(*) FROM `duel_vote` WHERE `duel`.`id` = `duel_vote`.`id_duel` AND `id_user` = '$user[user_id]') = 0 AND `act` = '1' AND `opponent` != '$user[user_id]' AND `user` != '$user[user_id]' ORDER by rand()"));
echo DIV_AUT;
echo '<a href="index.php?'.rand(1000,9999).'">Следующая >></a><br />';
if($post['rubric'] == 1) $cat = 'Кто красивее?';
if($post['rubric'] == 2) $cat = 'Кто сильнее?';
if($post['rubric'] == 3) $cat = 'Кто моднее?';
if($post['rubric'] == 4) $cat = 'Кто выглядит моложе?';
if($post['rubric'] == 5) $cat = 'Кто смешнее?';
if($post['rubric'] == 6) $cat = 'У кого лучше фигура?';
if($post['rubric'] == 7) $cat = 'Кто сексуальнее?';
if($post['rubric'] == 8) $cat = 'Кто гламурнее?';
if($post['rubric'] == 9) $cat = 'Кто аппетитнее?';
echo 'Категория: <b>'.$cat.'</b><br />';
echo CLOSE_DIV;
$us = mysql_fetch_array(mysql_query("SELECT * FROM ".USERS." WHERE `user_id` = '".$post['user']."' LIMIT 1"));
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = '$post[id]'"),0);
$vote = mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = '$post[id]' AND `id_opponent` = '$us[user_id]'"),0);
$man = mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = '$post[id]' AND `id_opponent` = '$us[user_id]' AND `man` = '1'"),0);
$woman = mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = '$post[id]' AND `id_opponent` = '$us[user_id]' AND `man` = '0'"),0);
echo DIV_AUT;
echo 'Оппонент: <a href="'.HOME.'/id'.$us['user_id'].'">'.$us['nick'].'</a><br />';
echo (empty($us['photo']) ? '<img src="'.HOME.'/style/img/empty_photo.gif"/>' : '<a href="'.HOME.'/files/photo/'.$us['photo'].'"><img src="'.HOME.'/files/photo/mini_'.$us['photo'].'"/></a>');
echo '<br /><b>Голосов:</b> '.$vote.' ('.round($vote/$count*100,1).'%)<br />
M: ('.round($man/$vote*100,1).'%) / Ж: ('.round($woman/$vote*100,1).'%)<br />
<form action="'.HOME.'/duel/?'.rand(1,9999).'" method="post">
<input type="hidden" name="vote_user" value="'.$us['user_id'].'"/>
<input type="hidden" name="duel_id" value="'.$post['id'].'"/>
<input type="submit" name="golos" value="Голосовать"/></form>';
echo '<br /><a href="index.php?no='.$post['id'].'">Затрудняюсь ответить >></a><br /><br />';
$us2 = mysql_fetch_array(mysql_query("SELECT * FROM ".USERS." WHERE `user_id` = '".$post['opponent']."' LIMIT 1"));
$vote2=mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = '$post[id]' AND `id_opponent` = '$us2[user_id]'"),0);
$man2=mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = '$post[id]' AND `id_opponent` = '$us2[user_id]' AND `man` = '1'"),0);
$woman2=mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = '$post[id]' AND `id_opponent` = '$us2[user_id]' AND `man` = '0'"),0);
echo 'Оппонент: <a href="'.HOME.'/id'.$us2['user_id'].'">'.$us2['nick'].'</a><br />';
echo (empty($us2['photo']) ? '<img src="'.HOME.'/style/img/empty_photo.gif"/>' : '<a href="'.HOME.'/files/photo/'.$us2['photo'].'"><img src="'.HOME.'/files/photo/mini_'.$us2['photo'].'"/></a>');
echo '<br /><b>Голосов:</b> '.$vote2.' ('.round($vote2/$count*100,1).'%)<br />
M: ('.round($man2/$vote2*100,1).'%) / Ж: ('.round($woman2/$vote2*100,1).'%)<br />
<form action="'.HOME.'/duel/?'.rand(1,9999).'" method="post">
<input type="hidden" name="vote_user" value="'.$us2['user_id'].'"/>
<input type="hidden" name="duel_id" value="'.$post['id'].'"/>
<input type="submit" name="golos" value="Голосовать"/></form>';
echo CLOSE_DIV;
echo DIV_LI . '<center>Время окончания: <strong>'.vrem($post['time']).'</strong></center>' . CLOSE_DIV;
} else {
echo DIV_AUT . 'Нет активных дуэлей для голосований' . CLOSE_DIV;
}
echo DIV_LI . '<a href="'.HOME.'/duel/myduels/">Моя дуэль</a>' . CLOSE_DIV
. DIV_LI . '<a href="'.HOME.'/duel/voted/">Активные (Вы голосовали)</a>' . CLOSE_DIV
. DIV_LI . '<a href="'.HOME.'/duel/finished/">Завершенные</a>' . CLOSE_DIV;
$array = array();
nav($array);
require_once('../../core/stop.php');
?>