File size: 2.73Kb
<?
require_once'../../core/system.php';
echo only_reg();
echo ban();
echo blok();
$header='Обитель Драконов';
require_once'../../core/head.php';
mysql_query("DELETE FROM `hik_otk` WHERE `time`<='".$time."'");
mysql_query("UPDATE `user` set `mesto` = 'Поиск команд', `battle` = '0' where `id` = '".$user['id']."'");
if($user['level'] < 80){
header('location: /');
$_SESSION['err'] = 'Доступно только с 80 уровня';
exit;
}
$req = mysql_query("SELECT * FROM `hiking` where (`lider`='".$user['id']."' || `usr1`='".$user['id']."' || `usr2`='".$user['id']."' || `usr3`='".$user['id']."') and `status`=''");
$avto = mysql_num_rows($req);
if($avto>0){
header('location: /hiking/abode-dragons/');
exit;
}
$req = mysql_query("SELECT * FROM `hiking` where (`lider`='".$user['id']."' || `usr1`='".$user['id']."' || `usr2`='".$user['id']."' || `usr3`='".$user['id']."') and `status`>'0'");
$avto = mysql_num_rows($req);
if($avto>0){
header('location: /');
$_SESSION['err'] = 'Ошибка';
exit;
}
$req = mysql_query("SELECT * FROM `hiking` where `id`='".intval($_GET['id'])."'");
$hik = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto==0 or $id<=0){
header('location: /');
$_SESSION['err'] = 'Ошибка';
exit;
}
if($hik['fight']==1){
header('location: /');
$_SESSION['err'] = 'Команда уже в бою!';
exit;
}
$avo = mysql_num_rows(mysql_query("SELECT id FROM `hik_otk` WHERE `usr`='".$user['id']."' and `hiking`='6'"));
if($avo > 0) {
$_SESSION['err'] = "Поход уже пройден!";
header('Location: /');
exit;
}
$rek = mysql_query("SELECT id FROM `hik_zay` WHERE `kogo` = '".$user['id']."'");
$zavky = mysql_fetch_array($rek);
if($hik['open']==1 && $zavky==0){
header('location: /');
$_SESSION['err'] = 'Команда закрыта!';
exit;
}
if(empty($hik['usr1'])){
mysql_query("UPDATE `hiking` SET `usr1` = '".$user['id']."', `kol`=`kol`+'1' WHERE `id`='".intval($_GET['id'])."'");
mysql_query("UPDATE `user` set `team`='1' where `id` = '".$user['id']."'");
}
elseif(empty($hik['usr2'])){
mysql_query("UPDATE `hiking` SET `usr2` = '".$user['id']."', `kol`=`kol`+'1' WHERE `id`='".intval($_GET['id'])."'");
mysql_query("UPDATE `user` set `team`='1' where `id` = '".$user['id']."'");
}
elseif(empty($hik['usr3'])){
mysql_query("UPDATE `hiking` SET `usr3` = '".$user['id']."', `kol`=`kol`+'1' WHERE `id`='".intval($_GET['id'])."'");
mysql_query("UPDATE `user` set `team`='1' where `id` = '".$user['id']."'");
} else {
header('location: /');
$_SESSION['err'] = 'Команда заполнена!';
exit;
}
if($zavky>0){
mysql_query("DELETE FROM `hik_zay` WHERE `kogo` = '".$user['id']."'");
}
header("Location: /hiking/abode-dragons/");
exit();
require_once'../../core/foot.php';
?>