<?php

$title = 'Управление пользователями';
require ($_SERVER['DOCUMENT_ROOT'].'/core/sys.php');

if($user['id'] != 1){
header('Location: /');
exit;
}

require ($_SERVER['DOCUMENT_ROOT'].'/core/head.php');
?><div class="col-md-6 mt-4">
					<h3><?=$title?></h3>
				</div><?

$k = $db->prepare("SELECT * FROM `users`");
$k->execute();
$k_post = $k->rowCount();
$max = 10;
$k_page = k_page($k_post,$max);
$page = page($k_page);
$start = $max*$page-$max;
$all = $db->prepare("SELECT * FROM `users` ORDER BY `online` DESC LIMIT $start, $max");
$all -> execute();
$all = $all -> fetchAll();
if(is_array($all)){
foreach($all as $us){
$who_auth = $db->prepare("SELECT * FROM `history_logs` WHERE `us` = ? ORDER BY `id` DESC LIMIT 1");
$who_auth -> execute([$us['id']]);
$who_auth = $who_auth -> fetch(PDO :: FETCH_ASSOC);
?>
<div class="col-md-16 mt-4">
<div class="card">
<div class="card-body">
<strong>Логин : </strong> <?=nick($us['id']);?> [ID:<?=$us['id']?>]<br />
<strong>Д/C :</strong> <?=$us['money']?> руб.<br />
<strong>Online :</strong> <?=vremja($us['online'])?><br />
<strong>IP :</strong> <?=$who_auth['ip']?> <br />
<strong>Agent :</strong> <br />
<?=$who_auth['soft']?><br />
<b>Время последний авторизации:</b> <?=vremja($who_auth['time'])?>
<br />
<br />
<a href="/panel/my/us.edit.aspx?id=<?=$us['id']?>" class="btn btn-success my-2 my-sm-0">Редактирование</a>
</div>
</div></div>
<?
}
}
if($k_post == 0){
?><div class="box"> Пусто </div><?
}
if($k_page >1){
echo str('/panel/my/us.view.aspx',$k_page,$page);
}
require ($_SERVER['DOCUMENT_ROOT'].'/core/foot.php');
?>