<?php

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

$title = 'Люди';
require_once '../incfiles/head.php';

$act = htmlentities(trim($_GET['act']));

echo '<div class="title">
	<a '. ($act == false?'class="title_a_hover"':'') .' href="'.URL.'/people/" onclick="Page.Go(this.href); return false">Люди</a>
	<a '. ($act == 'online'?'class="title_a_hover"':'') .' href="'.URL.'/people/?act=online" onclick="Page.Go(this.href); return false">Онлайн</a>
	<a '. ($act == 'search'?'class="title_a_hover"':'') .' href="'.URL.'/people/?act=search" onclick="Page.Go(this.href); return false">'.lang('Поиск','Пошук').'</a>
	</div>';

switch($act)
{
default:

echo '<div class="title">'.lang('VIP пользователи','VIP користувачі').'</div>';
//Вивід нового користувача)))
$all = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `access_best` = 0"),0);
if ($all > 0)
{
	$cp = ceil($all/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;
	$res = mysql_query("SELECT * FROM `users` WHERE `access_best` = 0 ORDER BY  RAND() DESC LIMIT $start,1");
	while ($array = mysql_fetch_array($res)) echo '<div class="block"><img src="'.URL.'/design/img/vip.png"/> '.user_name($array['id'],1,1).'</div>';
}


echo '<div class="title">'.lang('Люди','Люди').'</div>';
$all = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `ban` = 0"),0);
if ($all > 0)
{
	$cp = ceil($all/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;
	$res = mysql_query("SELECT * FROM `users` WHERE `ban` = 0 ORDER by `regtime` DESC LIMIT $start,10");
while ($array = mysql_fetch_array($res)) echo '<div class="block">'.user_name($array['id'],1,1).'</div>';
	navi($p,$cp,'/people/?');
}
break;



case 'online':


echo '<div class="title">'.lang('VIP пользователи','VIP користувачі').'</div>';
//Вивід нового користувача)))
$all = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `access_best` = 0"),0);
if ($all > 0)
{
	$cp = ceil($all/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;
	$res = mysql_query("SELECT * FROM `users` WHERE `access_best` = 0 ORDER BY  RAND() DESC LIMIT $start,1");
	while ($array = mysql_fetch_array($res)) echo '<div class="block"><img src="'.URL.'/design/img/vip.png"/> '.user_name($array['id'],1,1).'</div>';
}





echo '<div class="title">'.lang('Люди онлайн','Люди онлайн').'</div>';

$all = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `online` = 1"),0);
if ($all > 0)
{
	$cp = ceil($all/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;
	$res = mysql_query("SELECT * FROM `users` WHERE `online` = 1 ORDER by `visit` DESC LIMIT $start,10");
	while ($array = mysql_fetch_array($res)) echo '<div class="block">'.user_name($array['id'],1,1).'</div>';
	navi($p,$cp,'/people/?act=online&');
}
break;



case 'search':

if (!empty($_GET['r']) && is_numeric($_GET['r']) && mysql_result(mysql_query("SELECT COUNT(`id`) FROM `region` WHERE `id` = '".abs(intval($_GET['r']))."' LIMIT 1"),0) == true) $arr = mysql_fetch_array(mysql_query("SELECT * FROM `region` WHERE `id` = '".abs(intval($_GET['r']))."' LIMIT 1"));

if (!empty($arr))
{
	$all = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `region` = '".$arr['id']."' AND `ban` = 0"),0);
	
	echo '<div class="title"><div class="right">'.$all.'</div>'.lang($arr['ru_name'],$arr['ua_name']).' обл.</div>';

	if ($all > 0)
	{
		$cp = ceil($all/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;

		$res = mysql_query("SELECT * FROM `users` WHERE `region` = '".$arr['id']."' AND `ban` = 0 ORDER by `visit` DESC LIMIT $start,10");
		while ($array = mysql_fetch_array($res)) echo '<div class="block">'.user_name($array['id'],1,2).'</div>';
		navi($p,$cp,'/people/?act=search&r='.$arr['id'].'&');
	}
}
else
{
	$res = mysql_query("SELECT * FROM `region` ORDER by `id`");
	while ($array = mysql_fetch_array($res))
	{
		$all_r = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `region` = '".$array['id']."' AND `ban` = 0"),0);
		echo '<div class="block"><a href="'.URL.'/people/?act=search&r='.$array['id'].'" onclick="Page.Go(this.href); return false"><b>'.lang($array['ru_name'],$array['ua_name']).' обл.</b></a> '.($all_r>0?'('.people($all_r).')':'').'</div>';
	}
}
break;
}


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

?>