<?php
switch($act){
	case "admin":{
		$name = "Администраторы";
		$_m = "Администраторов";
		$where = " AND `access` > 3";
		break;
	}
	case "moder":{
		$name = "Модераторы";
		$_m = "Модераторов";
		$where = " AND `access` > 2";
		break;
	}
	case "vip":{
		$name = "VIP-пользователи";
		$_m = "VIP-пользователей";
		$where = " AND `access` = 2";
		break;
	}
	case "online":{
		$name = "Люди онлайн";
		$_m = "Пользователей в сети";
		$where = " AND `lastVisit` > '".(time()-300)."'";
		break;
	}
	default:{
		$name = "Пользователи";
		$_m = "Пользователей";
		$act = "users";
		$where = "";
		break;
	}
}

$k_post = $db->Count("users","WHERE `sid` = '".$site->id."'".$where);
$max 	= $VarIO->DefS("items_per_page", 10);
$k_page = $core->k_page($k_post, $max);
$page   = $core->page($k_page);
$start  = $max * $page - $max;

$elements = [];
$data = $db->Query("SELECT `id` FROM `users` WHERE `sid` = '".$site->id."' ".$where." ORDER BY `id` DESC LIMIT $start, $max"); 
while ($elem = mysqli_fetch_assoc($data)){
	$usr = getUserInfo($elem["id"]);
	$elements[$elem["id"]] = getUserInfo($elem["id"]);
}

twig("/users.lm", ["block"	=>	$act, "title" => $name, "elems" => $elements, "pages" => [
	"elemsCount"	=> $k_post,
	"api"	=>	$core->twig_page_mod($k_page, $page),
]]);

include_once 'core/foot.php';
?>