<?php

require_once '../incfiles/core.php';
require_once '../incfiles/func.php';
require_once '../incfiles/auth.php';
require_once '../incfiles/user.php';


if (!empty($_GET['id']) && is_numeric($_GET['id']))
{
	$id = abs(intval($_GET['id']));
	$result = mysql_query("SELECT * FROM `users` WHERE `id` = '".$id."' LIMIT 1");
	if (mysql_num_rows($result) == true) $arr_user = mysql_fetch_array($result);
		else go(URL);

}
else go(URL.'/');

$title = $arr_user['name'].' '.$arr_user['surname'].' :: '.lang('Мои Сообщества','Мої Спільноти');
require_once '../incfiles/head.php';

echo user_access_page($arr_user);

echo '<div class="title">
	<a href="'.URL.'/?id='.$id.'" onclick="Page.Go(this.href); return false">'.$arr_user['name'].' '.$arr_user['surname'].'</a>
	<a class="title_a_hover" href="'.URL.'/groups/my.php?id='.$id.'" onclick="Page.Go(this.href); return false">'.lang('Сообщества','Спільноти').'</a> ';
	if (!empty($user_id) && $user_id == $id) echo '<a href="'.URL.'/groups/admin.php" onclick="Page.Go(this.href); return false">'.lang('Управление','Керування').'</a>';
	echo '</div>';

	$result = mysql_query("SELECT * FROM `my_groups` WHERE `user_id` = '".$id."' LIMIT 1");
	if (mysql_num_rows($result) == true)
	{
		$arr = mysql_fetch_array($result);
		if (!empty($arr['groups']))
		{
			$q = explode("||", substr($arr['groups'], 1, -1));
			$count = count($q);
			$cp = ceil($count/10);
			$p = (isset($_GET['p']) and is_numeric($_GET['p']) and $_GET['p']>1 and $_GET['p']<=$cp) ? $_GET['p'] : 1;
			$start = $p*10-10;

			for ($i = $start; $i < ($p*10) && $i < $count; $i++) echo '<div class="block">'.group_name($q[$i]).'</div>';
			navi($p,$cp,''.URL.'/groups/my.php?id='.$arr_user['id'].'&');
		}
	}

	
require_once '../incfiles/foot.php';

?>