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

$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'));
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 "Сорт:<br />";
echo "<a href='list_user.php?id=".$soo."&amp;page=".$page."&amp;sort=admin'>админ</a> \n";
echo "<a href='list_user.php?id=".$soo."&amp;page=".$page."&amp;sort=uid'>перв.вст.</a> \n";

echo "<a href='list_user.php?id=".$soo."&amp;page=".$page."&amp;sort=id'>посл.вст.</a> \n";




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

if($k_page==0){
	echo '<tr><td class="p_t">Нет пользователей.</td></tr>';
	}
$priv = '`uid`';
$por = 'DESC';
if(isset($_GET['sort']) && $_GET['sort']=='admin'){
	$priv = '`priv`';

       }else if(isset($_GET['sort']) && $_GET['sort']=='id'){
			$priv = '`uid`';

			}
			else if(isset($_GET['sort']) && $_GET['sort']=='uid'){
			$priv = '`id`';
            $por='ASC';
			}

$q=mysql_query("SELECT * FROM `community_user_incomm` WHERE `cid` = '$soo' ORDER BY ".$priv." $por 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='.$users['id'].'"><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']).' ';
		}


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'].'">бан</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'].'&amp;act=adm">дать админа</a> ';
		}else if($user_comm['priv']==2){
			echo '<a href="pov_user.php?id='.$soo.'&amp;uid='.$user_comm['uid'].'&amp;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'].'&amp;act=mod">дать модера</a>';
		}else{
			echo '<a href="pov_user.php?id='.$soo.'&amp;uid='.$user_comm['uid'].'&amp;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';
?>