Файл: moduls/duel/index.php
Строк: 130
<?
/**
* @package Prime Social
* @link http://primesocial.ru
* @copyright Copyright (C) 2016 Prime Social
* @author BoB | http://primesocial.ru/about
*/
require_once('../../core/start.php');
include_once 'inc.php';
check_auth();
head('Duellar');
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 = 'Bunday duel yo`q';
} elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = $id AND `id_user` = $user[user_id]"),0) !=0 ) {
$err = 'Siz bu duelga ovoz bergansiz';
} 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 = 'O`zingiz ishtrok etayotgan duelga ovoz bera olmaysiz';
}
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">Duelda</a> sizga ovoz berishdilar';
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 = 'Bunday duel yo`q';
} elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = $id AND `id_user` = $user[user_id]"),0) != 0) {
$err = 'Siz ushbu duel uchun ovoz bergansiz';
} 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 = 'O`zingiz ishtirok etayotgan duelga ovoz bera olmaysiz';
}
if(empty($err)){
mysql_query("INSERT INTO `duel_vote` (`id_user`, `id_opponent`, `id_duel`, `man`) VALUES ('".$user['user_id']."', '0', '".$id."', '".$user['gender']."')");
}
}
/* Asosiy sahifa */
$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).'">Keyingi >></a><br />';
if($post['rubric'] == 1) $cat = 'Kim chiroyli?';
if($post['rubric'] == 2) $cat = 'Kim kuchli?';
if($post['rubric'] == 3) $cat = 'Kim modni?';
if($post['rubric'] == 4) $cat = 'Kim yosh ko`rinadi?';
if($post['rubric'] == 5) $cat = 'Kim kulguli?';
if($post['rubric'] == 6) $cat = 'Kimning qaddi qomati chiroyli?';
if($post['rubric'] == 7) $cat = 'Kim jinni?';
if($post['rubric'] == 8) $cat = 'Kim glamurli?';
if($post['rubric'] == 9) $cat = 'Kim yoqimtoy?';
echo 'Bo`lim: <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 'Ishtrokchi: <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>Ovozlar:</b> '.$vote.' ('.round($vote/$count*100,1).'%)<br />
Erkak: ('.round($man/$vote*100,1).'%) / Ayol: ('.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="Ovoz berish"/></form>';
echo '<br /><a href="index.php?no='.$post['id'].'">Ovoz berishga qiynalyapman, boshqa duelga >></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 'Ishtrokchi: <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>Ovozlar:</b> '.$vote2.' ('.round($vote2/$count*100,1).'%)<br />
Erkak: ('.round($man2/$vote2*100,1).'%) / Ayol: ('.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="Ovoz berish"/></form>';
echo CLOSE_DIV;
echo DIV_LI . '<center>Duel tugaydigan vaqti: <strong>'.vrem($post['time']).'</strong></center>' . CLOSE_DIV;
} else {
echo DIV_AUT . 'Ovoz berishga faol duellar yo`q' . CLOSE_DIV;
}
echo DIV_LI . '<a href="'.HOME.'/duel/myduels/">Mening duelim</a>' . CLOSE_DIV
. DIV_LI . '<a href="'.HOME.'/duel/voted/">Faollar</a>' . CLOSE_DIV
. DIV_LI . '<a href="'.HOME.'/duel/finished/">Tugallanganlar</a>' . CLOSE_DIV;
$array = array();
nav($array);
require_once('../../core/stop.php');
?>