Файл: test.masteram.us/duel/index.php
Строк: 148
<?
include '../Core.php';
only_reg();
$set['title']='Дуэли'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
include_once 'inc.php';
if (isset($_POST['golos']) && isset($_POST['duel_id']) && isset($user))
{
$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[id]"),0)!=0){$err = 'Вы уже голосовали за эту дуэль';}
elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `duel` WHERE (`user`='$user[id]' OR `opponent`='$user[id]') AND `id` = $id"),0)!=0){$err = 'Нельзя голосовать за свою дуэль';}
if(!isset($err)){
mysql_query("INSERT INTO `duel_vote` (`id_user`, `id_opponent`, `id_duel`, `man`) VALUES ('".$user['id']."', '".$opp."', '".$id."', '".$user['pol']."')");
$msg = 'За вас проголосовали в [url=/duel/myduels.php]дуэле[/url]';
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '".$opp."', '".$msg."', '".$time."')");
}
}
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[id]"),0)!=0){$err = 'Вы уже голосовали за эту дуэль';}
elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `duel` WHERE (`user`='$user[id]' OR `opponent`='$user[id]') AND `id` = $id"),0)!=0){$err = 'Нельзя голосовать за свою дуэль';}
if(!isset($err)){
mysql_query("INSERT INTO `duel_vote` (`id_user`, `id_opponent`, `id_duel`, `man`) VALUES ('".$user['id']."', '0', '".$id."', '".$user['pol']."')");
}
}
err();
$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[id]') = 0 AND `duel`.`act` = '1' AND `opponent` != '$user[id]' AND `user` != '$user[id]'"),0);
if($num!=0){
$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[id]') = 0 AND `act` = '1' AND `opponent` != '$user[id]' AND `user` != '$user[id]' ORDER by rand()"));
$rand = rand(1000,9999);
echo "<div class='tmn'>";
echo "<a href="index.php?$rand">Следующая >></a> $num<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>Категория:</b> <u><b>$cat</b></u><br/>";
echo "</div>";
$us = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `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[id]'"),0);
$man=mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = '$post[id]' AND `id_opponent` = '$us[id]' AND `man` = '1'"),0);
$woman=mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = '$post[id]' AND `id_opponent` = '$us[id]' AND `man` = '0'"),0);
echo "<div class='linechat'>n";
echo "Оппонент: <a href="/info.php?id=$us[id]">$us[nick]</a><br/>n";
avatar($post['user']);
echo "<br/>---<br/>n";
echo "<b>Голосов:</b> $vote (".@round($vote/$count*100,1)."%) <br />n";
echo "M: (".@round($man/$vote*100,1)."%) / Ж: (".@round($woman/$vote*100,1)."%)<br />n";
echo "<form action="index.php?$rand" method="post">n";
echo "<input type="hidden" name="vote_user" value="$us[id]"/>n";
echo "<input type="hidden" name="duel_id" value="$post[id]"/>n";
echo "<input type="submit" name="golos" class="form" value="Голосовать"/>n";
echo "</form>n";
echo "</div>n";
echo "<div class='menu_razd'>n";
echo "<a href="index.php?no=$post[id]">Затрудняюсь ответить >></a><br/>n";
echo "</div>n";
$us2 = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '".$post['opponent']."' LIMIT 1"));
$vote2=mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = '$post[id]' AND `id_opponent` = '$us2[id]'"),0);
$man2=mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = '$post[id]' AND `id_opponent` = '$us2[id]' AND `man` = '1'"),0);
$woman2=mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = '$post[id]' AND `id_opponent` = '$us2[id]' AND `man` = '0'"),0);
echo "<div class='linechat'>n";
echo "Оппонент: <a href="/info.php?id=$us2[id]">$us2[nick]</a><br/>n";
avatar($post['opponent']);
echo "<br/>---<br/>n";
echo "<b>Голосов:</b> $vote2 (".@round($vote2/$count*100,1)."%) <br />n";
echo "M: (".@round($man2/$vote2*100,1)."%) / Ж: (".@round($woman2/$vote2*100,1)."%)<br />n";
echo "<form action="index.php?$rand" method="post">n";
echo "<input type="hidden" name="vote_opponent" value="$us2[id]"/>n";
echo "<input type="hidden" name="duel_id" value="$post[id]"/>n";
echo "<input type="submit" name="golos" class="form" value="Голосовать"/>n";
echo "</form>n";
echo "</div>n";
echo '<div class="linechat">Время окончания: <strong>'.vremja($post['time']).'</strong></div>';
}
else
{
echo '<div class="linechat">Нет активных дуэлей для голосований</div>';
}
echo '<div class="menu_razd">
- <a href="myduels.php">Моя дуэль</a><br/>
- <a href="voted.php">Активные (Вы голосовали)</a><br/>
- <a href="finished.php">Завершенные</a><br/></div>';
include_once '../sys/inc/tfoot.php';
?>