View file sdark.mobi/hiking/ghost-trail/add.php

File size: 1.85Kb
<?php
require_once'../../core/system.php';
$header = 'Приглашение в команду';
require_once '../../core/head.php';
mysql_query("DELETE FROM `hik_otk` WHERE `time`<='".$time."'");


if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '".intval($_GET['id'])."'"),0) == true){
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`  = '".intval($_GET['id'])."'"));
} else {
$_SESSION['err'] = "Игрок не найден";
header('Location: /');
exit();
}

$req = mysql_query("SELECT * FROM `hiking` where `lider`='".$user['id']."'");
$hik = mysql_fetch_array($req);

if($user['id']!=$hik['lider']){
$_SESSION['err'] = "Ошибка";
header('Location: /');
exit();
}

$avto = mysql_num_rows($req);
if($avto==0){
$_SESSION['err'] = "Команда не найдена";
header('Location: /');
exit();
}

if($ank['team']==1 && $ank['level']<50 &&  $ank['kom']==1 && $ank['mesto']=='Бой' && $ank['online'] < ($_SERVER['REQUEST_TIME']-1000)){
$_SESSION['err'] = "Игрок недоступен";
header('Location: /user/'.$ank['id'].'/');
exit();
}

$req = mysql_query("SELECT * from `hik_zay` where `kogo` = '".$ank['id']."'");
$kol = mysql_num_rows($req);

if($hik['kol']>=4){
	header('Location: /user/'.$ank['id'].'/'); $err='В команде нет места'; 
	exit();}
	
if($kol>0){
	header('Location: /user/'.$ank['id'].'/'); $err='Игрок имеет приглашение'; 
	exit();}

if($hik['status']==1){
$_SESSION['err'] = "Поход уже пройден";
header('Location: /');
exit();
}

mysql_query("INSERT INTO `hik_zay` SET `hiking` = '".$hik['id']."', `pohod`='4', `kto` = '".$user['id']."', `kogo`='".$ank['id']."', `time` = '".time()."'");
header('Location: /user/'.$ank['id'].'/');
$_SESSION['message'] = 'Приглашение отправлено';
require_once '../../core/foot.php';
?>