<?php
###########################################
###       Сообщества для соц. сети      ###
###       Автор: Неизвестен             ###
###    Доделка и переделка: WapStyle    ###
###          НЕ ДЛЯ ПРОДАЖИ             ###
### НЕ ДЛЯ БЕСПЛАТНОГО РАСПРОСТРАНЕНИЯ  ###
###########################################

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");
		}

$admin = mysql_fetch_array(mysql_query("SELECT * FROM `community_user_incomm` WHERE `cid` = '$soo' AND `uid` = '".$user['id']."'"));
$set['title'] = 'Участники сообщества '.mysql_result(mysql_query("SELECT `name` FROM `community_comm` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1"),0); // заголовок страницы
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'));
if($soo==0 || $soo<0){
	echo '<div class="err">Иди нахуй! Хакер недоношеный!</div>';
	}else if($soo!=$comm['id']){
		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{

$k_page=mysql_result(mysql_query("SELECT COUNT(id) FROM `community_user_incomm` WHERE `cid` = '$soo'"),0);
$k_page=k_page($k_page,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];

echo '<form action="list_user.php?id='.$soo.'&amp;page='.$page.'" method="post">';
echo '<div class="str"><b>Сорт</b>:&nbsp;<select name="sort"><option value="admin">Админы</option><option value="moder">Модераторы</option><option value="user">Пользователи</option></select>';
echo '<input type="submit" value="ok"></div></form>';

echo '<table class="post">';

if($k_page==0){
	echo '<tr><td class="p_t">Нет пользователей.</td></tr>';
	}

if($_POST['sort']=='admin'){
	$priv = 'AND `priv` = 2';
	}else if($_POST['sort']=='moder'){
		$priv = 'AND `priv` = 1';
		}else if($_POST['sort']=='user'){
			$priv = 'AND `priv` = 0';
			}

$q=mysql_query("SELECT * FROM `community_user_incomm` WHERE `cid` = '$soo' $priv LIMIT $start, $set[p_str]");
while($user_comm = mysql_fetch_array($q)){
	$users = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$user_comm[uid]' LIMIT 1"));
	echo '<tr><td class="icon14">';
	echo avatar($users['id']);
	echo '</td><td class="p_m">';
	echo '<a href="/info.php?id='.$user_comm['uid'].'"><span style="color:'.$users['ncolor'].'">'.$users['nick'].'</span></a> ';

if(mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_ban` WHERE `id_user` = '$user_comm[uid]' AND `id_comm` = '$soo' AND `time` > '$time'"),0)!=0){
	echo '<span class="off">Забанен(а)</span>';
	}else{
		echo online($user_comm['uid']).' ';
		}

echo '('.$user_comm['postov'].'/'.$user_comm['them'].'/'.$user_comm['files'].')<br/>';

if(isset($user) && $admin['priv']==2){

if(mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_ban` WHERE `id_user` = '$user_comm[uid]' AND `id_comm` = '$soo' AND `time` > '$time'"), 0)!=1){
	echo '[<a href="ban_user.php?id='.$soo.'&amp;uid='.$user_comm['uid'].'">ban.</a>]';
	}

echo '[<a href="del_user.php?id='.$soo.'&amp;uid='.$user_comm['uid'].'">удал.</a>]<br/>';

echo 'Статус: ';
if($user_comm['priv']!=1){
	if($user_comm['priv']!=2){
		echo '<a href="pov_user.php?id='.$soo.'&amp;uid='.$user_comm['uid'].'&act=adm">дать админа</a> ';
		}else if($user_comm['priv']==2){
			echo '<a href="pov_user.php?id='.$soo.'&amp;uid='.$user_comm['uid'].'&act=del_adm">снять с админа</a> ';
			}
			}

if($user_comm['priv']!=2){
	if($user_comm['priv']!=1){
		echo '<a href="pov_user.php?id='.$soo.'&amp;uid='.$user_comm['uid'].'&act=mod">дать модера</a>';
		}else{
			echo '<a href="pov_user.php?id='.$soo.'&amp;uid='.$user_comm['uid'].'&act=del_mod">снять с модера</a>';
			}
			}
			}
echo '</td></tr>';
}

echo '</table>';

if($k_page>1){
	str('list_user.php?id='.$soo.'&amp;sort='.$priv.'&amp;',$k_page,$page);
	}

echo '&#187;&nbsp;<a href="comm.php?id='.$soo.'">В сообщество</a><br/>';
}

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