<?php
	
	include_once __DIR__ . '/include/common.php';
	include_once __DIR__ . '/include/general_functions.php';
	include_once __DIR__ . '/include/utils.php';	
	include_once __DIR__ . '/include/user.php';
	
	if ( ! @$user)
			redirect('/');
	
	$params	=	[];
	$params['title']	=	'Модераторы';
	
	ob_start();
	
	include_once __DIR__ . '/include/header.php';
	
	?>
	<div class='title'>Модераторы</div>
	<?php
	
		$sql	=	
			'SELECT
					*
				FROM
					`users`
				WHERE
					`accesslevel`	>	0';
		
		$items	=	@mysql_num_rows(@mysql_query($sql));
		
		$items_per_page	=	10;
		
		$pages	=	c_page($items, $items_per_page);
		
		$page	=	page($pages);
		
		$sql	.=	'
				ORDER BY
					`lastActive`	DESC,
					`accesslevel`	DESC,
					`id`	DESC';
		
		$at		=	($page	-	1)	*	$items_per_page;
		$sql	.=	sprintf(
			'
				LIMIT
					%d, %d',
			$at,
			$items_per_page
		);
		
		$query	=	@mysql_query($sql);
		if ($items != 0)
		{
	?>
	<div class='container'>
	<?php
			while	(
				$info	=	@mysql_fetch_assoc($query)
			)
			{
			
	?>
		<?=player($info['id'])?><br />
	<?php
			}
			
			if ($pages > 1)
			{
				
				pagenation	(
					'/moderators/',
					$pages,
					$page
				);
				
			}
			
	?>
	</div>
	<?php
		}
		else
		{
	?>
		
	<?php
		}
	?>
	</div>
	<?php
	
	include_once __DIR__ . '/include/footer.php';
	
	setContentType('text/html; charset=UTF-8');
	render(
		__DIR__ . '/include/template.php',
		ob_get_clean(),
		$params
	);
	
	?>
