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

$s =  mysql_result(mysql_query('SELECT COUNT(id) FROM `user` WHERE `id` = '.$id.' LIMIT 1'),0);

if($s==0){
	header("Location: /index.php");
	exit;
	}

$nick = mysql_result(mysql_query("SELECT `nick` FROM `user` WHERE `id` = '".$id."' LIMIT 1"),0);
$set['title']='Сообщества пользователя';
include_once '../sys/inc/thead.php';

title();
aut();


if($id==0 || $id<0){
	echo '<div class="err">Иди нахуй! Хакер недоношеный!</div>';
	}else{

$k_users = mysql_num_rows(mysql_query("SELECT `id` FROM `community_user_incomm` WHERE `uid` = '".$id."'"));
$k_page = k_page($k_users,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];

if($k_users == 0){
	echo "<div class='msg'>Обитатель не входит ни в одно сообщество</div>";
	}

$q = mysql_query("SELECT * FROM `community_user_incomm` WHERE `uid` = '".$id."' ORDER BY `time` DESC LIMIT $start,$set[p_str]");
while($comm = mysql_fetch_array($q)){

$n++;
if(is_integer($n/2))
{ echo "<div class=\"p_t\">"; } else { echo "<div class=\"p_m\">"; }

$name_comm = mysql_fetch_array(mysql_query("SELECT * FROM `community_comm` WHERE `id` = '$comm[cid]' LIMIT 1"));
echo '<img src="/style/icons/link.png"alt=""/>&nbsp;<a href="comm.php?id='.$comm['cid'].'">'.esc(trim(stripcslashes(htmlspecialchars($name_comm['name'])))).'</a> ('.$comm['postov'].'/'.$comm['files'].')&nbsp;';

if($comm['priv']==0){
	echo '';
	}else if($comm['priv']==1){
		echo '(Мод)';
		}else if($comm['priv']==2){
			echo '(Адм)';
			}

echo '</div>';
}



if($k_page>1){
	str('user.php?id='.$id,$k_page,$page);
	}

echo '<div class="str"><img src="/style/icons/link.png"alt=""/>&nbsp;<a href="/info.php?id='.$id.'">Назад</a></div>';
}

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