<?php

	# mark core  v1.0
    # author Drk in
	# date 24.10.19 	

	# core

	require_once ( $_SERVER['DOCUMENT_ROOT']."/_core/system.php" );

	$s =  isset( $_GET['s'] ) ? system::abs($_GET['s']): 0;

	# meta

	$title = 'Пользователи » Мобильные WAP сайты';
	$description = system::check($config['description']);
	$keywords = system::check($config['keywords']);
	$tl = 'Пользователи';
	
	# adm

	system::adm();

	# head

	require_once ( head );

	echo '<div class ="touch"> <a href ="?"> Все</a> | <a href ="?&s=1"> Пользователи</a> |  <a href ="?&s=2"> Админы</a>  |  <a href ="?&s=3"> Заблокированные</a></div>';

	if ($s == 1)$sr = 'WHERE admin = 0'; 
	if ($s == 2)$sr = 'WHERE admin = 1'; 
	if ($s == 3)$sr = 'WHERE ban = 1';
	if ($s == 0)$sr =  null;

	$cn = DB :: $dbh -> querySingle("SELECT count(id) FROM user {$sr} ");	

	if($cn == 0)echo '<div class="err">Cписок пуст!</div>';

	$page = new page($cn);

	$limit = $cn > $page -> elements ? $page -> limit : null;

	$query = DB :: $dbh -> query("SELECT CK FROM user {$sr} ORDER BY id  {$limit}");

	while ($act = $query -> fetch()):

	$act = cache_user::check($act['CK']);	

	$pf = DB :: $dbh -> querySingle("SELECT count(id) FROM platforms  WHERE user = ?;", array($act['id']));	

	echo '
	<div class = "touch">
	<img src ="'.ico.'us/'.($act['admin'] == 0 ? 'man_on.gif':'anime.png').'" style ="    vertical-align: baseline;"> '.system::check($act['login']).'
	[ID: '.$act['id'].' '.($act['admin'] == 1 ? '| <font color="red"> ADM </font>':'').' '.($act['ban'] == 1 ? '| <font color="red"> BAN </font>':'').' | сайтов: <font color="green">'.$pf.'</font>
	| E-mail '.($act['email_act'] == 0 ? '<font color="blue">подтвержден</font>':'<font color="red">не подтвержден</font>').']
	<br>
	<a href ="'.site.'admin/users/edit/id'.$act['id'].'">Изменить</a> |
	'.($act['ban'] == 1 ? '<a href ="'.site.'admin/users/ban/id'.$act['id'].'">Разблокировать</a>':'<a href ="'.site.'admin/users/ban/id'.$act['id'].'">Заблокировать</a>').'
	| <a href ="'.site.'admin/users/link/id'.$act['id'].'">Сайты</a> 
	| <a href ="'.site.'admin/users/mult/id'.$act['id'].'">Мульты</a>
	</div>
	';	

	endwhile;	

	$page -> get($s == 0 ? '?':'?&s='.$s.'&');

	echo '
	<a href="'.site.'admin" class="touch">« Назад</a>
	';

	# foot

	require_once ( foot ) ;
?>