<?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'] = 'Участники сообщества';
include_once '../sys/inc/thead.php';

title();
aut();


$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 "<div class='foot'>";
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=mod'>модеры</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 "</div>";




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>';
if($set['set_show_icons']==2){
echo "<td class='icons48' rowspan='2'>";
	echo avatar($users['id']);
echo "</td>";
}
elseif($set['set_show_icon']==1)
{
echo "<td class='icon14'>";
echo '<img src="/style/themes/'.$set['set_them'].'/user/'.$a['pol'].'.png"alt=""/>';
echo "</td>";
}
echo "<td class='p_t'>";
	echo ' <a href="/info.php?id='.$users['id'].'">'.$users['nick'].'</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 "</td>";
echo "</tr>";
echo "<tr>";
if($set['set_show_icon']==1) echo "<td class='p_m' colspan='2'>"; else echo "<td class='p_m'>";


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 '<div class="foot"><img src="/style/themes/'.$set['set_them'].'/icons/default.png"alt=""/>&nbsp;<a href="comm.php?id='.$soo.'">В сообщество</a></div>';
}

include_once '../sys/inc/tfoot.php';
?>