View file sdark.mobi/clan/zayavka.php

File size: 2.19Kb
<?php
require_once '../core/system.php';
$header = 'Приглашение в клан';
require_once '../core/head.php';
$req = mysql_query("SELECT * FROM `clan_zayavky` WHERE `id`  = '".intval($_GET['id'])."' and `kogo` = '$user[id]'");
$zayav = mysql_num_rows($req);
$zayav = mysql_fetch_array($req);
if($zayav==0){header('Location: /'); $_SESSION['err'] ='Заявка не найдена'; exit;}

if(isset($_GET['yes'])){
$req = mysql_query("SELECT * FROM `clan_zayavky` WHERE `id`  = '".intval($_GET['id'])."' and `kogo` = '$user[id]'");
$avtog = mysql_num_rows($req);
$zayav = mysql_fetch_array($req);
$req = mysql_query("SELECT * from `clan` where `id` = '$zayav[clan]'");
$clan = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avtog==0){$err='Заявка не найдена';}
if($avto==0){$err='Клан не найден';}
if($user['plem']!=$zayav['plem']){$err='Клан противоположной империи';}
if($user['level']<10){$err='Нужен 10 уровень';}
if(!empty($user['clan'])){$err='Вы уже в клане';}
if($clan['kol']>=$clan['max_kol']){ $err='В клане нет места';}
$t=time();
if(!isset($err)){
mysql_query("INSERT INTO `zur` set `kto` = ".$zayav['kto'].", `kogo` = ".$zayav['kogo'].", `name` = 'пригласил', `time` = '".$t."', `clan`='$zayav[clan]'");
mysql_query("DELETE FROM `clan_zayavky` WHERE `id`  = '".intval($_GET['id'])."' and `kogo` = '$user[id]'");
mysql_query("UPDATE `user` SET `clan` = '$zayav[clan]', `dolz` = 'новобранец', `rukzak`=`rukzak`+$clan[storage_bon], `rating` = '0' where `id`='$user[id]'");
mysql_query("UPDATE `clan` SET `kol` = `kol`+1 where `id`='$zayav[clan]'");
header('Location: /');
$_SESSION['message'] = 'Приглашение принято';
} else {
$_SESSION['err'] = $err;
header('Location: /');
exit;
}
}

if(isset($_GET['otkaz'])){
if($zayav==0){header('Location: /'); $err='Заявка не найдена';}
if(!isset($err)){
mysql_query("DELETE FROM `clan_zayavky` WHERE `id`  = '".intval($_GET['id'])."' and `kogo` = '$user[id]'");
header('Location: /');
$_SESSION['message'] = 'Приглашение отменено';}else{$_SESSION['err'] = $err;}}

require_once '../core/foot.php';
?>