<?php
require_once('../wu-engine/wu_init.php');
$page_name = 'История авторизаций';
$page_keys = 'авторизации';
$page_desc = 'История авторизаций пользователей';
$prevurl_1 = '/'.ADMINPATH.'/';
$prevname_1 = 'Панель управления';
$online_title = 'В панели управления';
$online_url = '/';
$page_right = '<div class="header-buttons"><div class="collapse" id="header-buttons"><div class="well"><a data-toggle="modal" role="button" href="#modal_clear" class="btn btn-primary">Очистить</a></div></div></div>';
include('../wu-engine/wu_header.php');
include('../wu-engine/wu-functions/wu_pagination.php');
include('../wu-engine/wu-functions/wu_functions.php');
if(!USER_LOGGED) { header ("Location: /"); exit; }
mysqli_query($connect_db, "UPDATE ".DB_PREFIX."_adm_auth SET new = '0' WHERE new = '1'");
?>

<div id="modal_clear" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title"><i class="icon-remove"></i> Очистка истории авторизаций</h4>
</div>
<div class="modal-body with-padding">
<div class="alert alert-danger"><center>Внимание! История авторизаций будет очищена.</center></div>
</div>
<div class="modal-footer">
<label style="margin-right: 5px;">
<input type="checkbox" class="styled" id="tolog" />
Сохранить в лог
</label>
<button type="button" id="act_clear" class="btn btn-danger" data-loading-text="<i class='icon-spinner7 spin'></i> Очищаем">Очистить</button>
<button type="button" class="btn btn-warning" data-dismiss="modal">Отмена</button>
</div>
</div>
</div>
</div>

<?php
$num = 20; //Сколько выводить на странице
if (isset($_GET['page'])) { $page = intval($_GET['page']); if ($page == 0) { $page = 1; } } else { $page = 1; }
$qu = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT count(`id`) AS `c` FROM `".DB_PREFIX."_adm_auth`"));
$co = $qu['c'];
$total = intval(($co - 1) / $num) + 1;
$page = intval($page);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$qr = mysqli_query($connect_db, "SELECT id,st,msg,dt FROM `".DB_PREFIX."_adm_auth` ORDER BY id DESC LIMIT $start, $num");
if ($co > 0) {
while($row = mysqli_fetch_assoc($qr)) {
$st = $row['st'];
?>
<div class="fulln">
<span class="alert-notice"><?php echo wudatenorm($row['dt']); ?></span>
<div class="alert alert-<?php if($st == 0) { echo 'info'; } if($st == 1) { echo 'danger'; } if($st == 2) { echo 'success'; } ?> fade in block-inner">
<i class="icon-<?php if($st == 0) { echo 'enter'; } if($st == 1) { echo 'warning'; } if($st == 2) { echo 'user-plus3'; } ?>"></i> <?php echo htmlspecialchars($row['msg']); ?>
</div></div>
<?php
}
$pageNav = new SimPageNav();
$pages = ceil($co/$num);
echo $pageNav->getLinks($pages, 1, $page, 10, 'page');
} else { echo '<div class="alert alert-info fade in"><i class="icon-info"></i> История пуста</div>'; }
?>

<script type="text/javascript">
//Очистка активности
$('#act_clear').click(function(){
var tolog = $('#tolog').prop('checked');
var data = {'tolog': tolog};
wu_response('/wu-engine/wu-actions/adm_activity_auth_clear.php', data, 'act_clear', '1', function(wu_result) {
if (wu_result == '1') {
$(location).attr('href','/<?php echo ADMINPATH; ?>/activity_auth');
}
});
});
</script>

<?php include('../wu-engine/wu_footer.php'); ?>