<?php

include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';

if(isset($_GET['id']) && isset($_GET['uid'])){
	$soo = intval($_GET['id']);
	$uid = intval($_GET['uid']);
	}else{
		header("Location: /index.php");
		}

$admin = mysql_fetch_array(mysql_query("SELECT * FROM `community_user_incomm` WHERE `cid` = '$soo' AND `uid` = '".$user['id']."'"));
$set['title'] = 'Удаление участника сообщества &amp; '.$_SERVER['HTTP_HOST'];
include_once '../sys/inc/thead.php';

title();
aut();

echo '<div class="menu">';

$comm = mysql_fetch_array(mysql_query('SELECT * FROM `community_comm` WHERE `id` = '.$soo.' LIMIT 1'));
$user_comm = mysql_fetch_array(mysql_query('SELECT * FROM `community_user_incomm` WHERE `cid` = '.$soo.' AND `uid` = '.$uid.' LIMIT 1'));

if(!isset($user)){
	echo '<div class="err">Доступ закрыт.</div>';
	}else if($soo==0 || $soo<0){
		echo '<div class="err">Иди нахуй! Хакер недоношеный!</div>';
		}else if($uid==0 || $uid<0){
			echo '<div class="err">Иди нахуй! Хакер недоношеный!</div>';
			}else if($soo!=$comm['id']){
				echo '<div class="err">Сообщество не найдено.</div>';
				}else if($admin['priv']!=2){
					echo '<div class="err">Вы не админ.</div>';
					}else if($user_comm['uid']!=$uid){
						echo '<div class="err">Данный пользователь не участвует в сообществе</div>';
						}else if(mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_ban` WHERE `id_user` = '$user[id]' AND `id_comm` = '$soo' AND `time` > '$time'"), 0)!=0){
							header('Location: ban.php?id='.$soo);
							}else{

mysql_query("DELETE FROM `community_user_incomm` WHERE `uid` = '$uid' AND `cid` = '$soo' LIMIT 1");
mysql_query("DELETE FROM `comm_ban` WHERE `id_user = '$uid' AND `id_comm` = '$soo'");
mysql_query("OPTIMIZE TABLE `community_user_incomm`, `comm_ban`");
header("Location: list_user.php?id=$soo&del");
}

echo '</div>';
include_once '../sys/inc/tfoot.php';
?>