Файл: moduls/duel/add.php
Строк: 74
<?
/**
* @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('Duelga chaqirish');
include_once 'inc.php';
$id = intval($_GET['id']);
if (empty($_GET['id'])) {
$err = 'ID noto`g`ri ko`rsatilgan!';
}
$ank = mysql_fetch_array(mysql_query("SELECT * FROM ".USERS." WHERE `user_id` = $id LIMIT 1"));
if (!$ank) {
$err = 'Bunday foydalanuvchi ma`lumotlar bazasida yo`q';
}
if ($user['user_id'] == $id) {
$err = 'O`zingizni duelga chaqira olmaysiz))';
}
if ($user['balls'] < 100) {
$err = 'Ballar yetarlicha emas';
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `duel` WHERE (`user`='$id' OR `opponent`='$id') AND `act`='1'"),0) == TRUE) {
$err = 'Ushbu foydalanuvchi hozir duelda qatnashyapti';
} elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `duel` WHERE (`user`='$user[user_id]' OR `opponent`='$user[user_id]') AND `act`='1'"),0) == TRUE) {
$err = 'Siz hozir boshqa duelda ishtrok etyapsiz, duelni tugashini kuting.';
}
if (!empty($err)) {
echo DIV_ERROR . $err . CLOSE_DIV;
} else {
if (!empty($_POST)) {
$rubric = min(max(@intval($_POST['rubric']),1),9);
mysql_query("INSERT INTO `duel` (`user`, `opponent`, `rubric`, `time`) VALUES ('".$user['user_id']."', '".$id."', '".$rubric."', '".(time()+14400)."')");
$duel = mysql_insert_id();
$msg = '<a href="'.HOME.'/id'.$user['user_id'].'">'.$user['nick'].'</a> sizni duelga chaqirdi, chaqiruvni <a href="'.HOME.'/duel/myduels/yes/'.$duel.'/"><b>qabul qilish</b></a> yoki <a href="'.HOME.'/duel/myduels/noy/'.$duel.'/"><b>rad etish</b></a> ?';
lenta($msg, $ank['user_id']);
mysql_query("UPDATE ".USERS." SET `balls` = '".($user['balls'] - 100)."' WHERE `id` = '$user[user_id]' LIMIT 1");
header("Location: ".HOME."/duel/ok/");
} else {
echo DIV_AUT . 'Duel* - bu ikkita anketaning musobaqasidir. Kim belgilangan vaqt ichida ko`proq ovoz to`plasa o`sha g`olib bo`ladi.
Bo`limni tanlang va raqibingizga chaqiruv tashang.<br />
<b>Baxo:</b> 100 ball. Raqibingizga duel bepul bo`ladi.<br />
<b>Sizning raqibingiz:</b> <a href="'.HOME.'/id'.$ank['user_id'].'">' . $ank['nick'] . '</a>';
echo '<form action="#" method="POST">
<b>Bo`limni tanlang:</b><br />';
echo '<select name="rubric">';
$key = 1;
foreach ($cat AS $key => $value) {
echo '<option value="'.$key.'">' . $value . '</option>';
}
echo '</select>';
echo '<br />Duel 24 soat davom etadi, albatta singing raqibingiz chaqiruvni qabul qilgandan so`ng . Raqibingiz qabul qilishini kutish vaqti 4 soat.<br /><br />
<input type="submit" value="Duelga chaqirish"/></form></div>';
}
}
require_once('../../core/stop.php');
?>