<?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'])){
	$soo = intval($_GET['id']);
	}else{
		header("Location: /index.php");
		}

$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` = '.$user['id'].' LIMIT 1'));
if(!isset($user)){
	echo '<div class="err">Доступ закрыт.</div>';
	}else if($soo==0 || $soo<0){
		echo '<div class="err">Иди нахуй! Хакер недоношеный!</div>';
		}else if($soo!=$comm['id']){
			echo '<div class="err">Сообщество не найдено.</div>';
			}else if($user_comm['uid']!=$user['id']){
				echo '<div class="err">Вы не участвуйте в этом сообществе.</div>';
				}else if($comm['id_author']==$user['id']){
					echo '<div class="err">Создатель не может покинуть своё сообщество.</div>';
					}else{
						mysql_query("DELETE FROM `community_user_incomm` WHERE `uid` = '$user[id]' AND `cid` = '$soo'");
						header("Location: comm.php?id=$soo&ok_out");
						}

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