logs viewer
This commit is contained in:
parent
f806960ead
commit
915108a1ae
67
system/controllers/logs.php
Normal file
67
system/controllers/logs.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
_admin();
|
||||
$ui->assign('_title', 'PHPNuxBill Logs');
|
||||
$ui->assign('_system_menu', 'logs');
|
||||
|
||||
$action = $routes['1'];
|
||||
$admin = Admin::_info();
|
||||
$ui->assign('_admin', $admin);
|
||||
|
||||
if ($admin['user_type'] != 'Admin') {
|
||||
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
|
||||
}
|
||||
|
||||
|
||||
switch ($action) {
|
||||
case 'list':
|
||||
$name = _post('name');
|
||||
$keep = _post('keep');
|
||||
if (!empty($keep)) {
|
||||
ORM::raw_execute("DELETE FROM tbl_logs WHERE date < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL $keep DAY))");
|
||||
r2(U . "logs/list/", 's', "Delete logs older than $keep days");
|
||||
}
|
||||
if ($name != '') {
|
||||
$paginator = Paginator::bootstrap('tbl_logs', 'description', '%' . $name . '%');
|
||||
$d = ORM::for_table('tbl_logs')->where_like('description', '%' . $name . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
} else {
|
||||
$paginator = Paginator::bootstrap('tbl_logs');
|
||||
$d = ORM::for_table('tbl_logs')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
}
|
||||
|
||||
$ui->assign('name', $name);
|
||||
$ui->assign('d', $d);
|
||||
$ui->assign('paginator', $paginator);
|
||||
$ui->display('logs.tpl');
|
||||
break;
|
||||
case 'radius':
|
||||
$name = _post('name');
|
||||
$keep = _post('keep');
|
||||
$page = (isset($routes['2']) ? intval($routes['2']) : 0);
|
||||
$pageNow = $page * 20;
|
||||
if (!empty($keep)) {
|
||||
ORM::raw_execute("DELETE FROM radpostauth WHERE UNIX_TIMESTAMP(authdate) < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL $keep DAY))", [], 'radius');
|
||||
r2(U . "logs/radius/", 's', "Delete logs older than $keep days");
|
||||
}
|
||||
if ($name != '') {
|
||||
$d = ORM::for_table('radpostauth', 'radius')->where_like('username', '%' . $name . '%')->offset($pageNow)->limit(10)->order_by_desc('id')->find_many();
|
||||
} else {
|
||||
$d = ORM::for_table('radpostauth', 'radius')->offset($pageNow)->limit(10)->order_by_desc('id')->find_many();
|
||||
}
|
||||
|
||||
$ui->assign('page', $page);
|
||||
$ui->assign('name', $name);
|
||||
$ui->assign('d', $d);
|
||||
$ui->assign('paginator', $paginator);
|
||||
$ui->display('logs-radius.tpl');
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
r2(U . 'logs/list/', 's', '');
|
||||
}
|
71
ui/ui/logs-radius.tpl
Normal file
71
ui/ui/logs-radius.tpl
Normal file
@ -0,0 +1,71 @@
|
||||
{include file="sections/header.tpl"}
|
||||
<!-- pool -->
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-hovered mb20 panel-primary">
|
||||
<div class="panel-heading">
|
||||
Radius
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="text-center" style="padding: 15px">
|
||||
<div class="col-md-4">
|
||||
<form id="site-search" method="post" action="{$_url}logs/radius/">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">
|
||||
<span class="fa fa-search"></span>
|
||||
</div>
|
||||
<input type="text" name="name" class="form-control" value="{$name}"
|
||||
placeholder="{$_L['Search_by_Name']}...">
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-success" type="submit">{$_L['Search']}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<form class="form-inline" method="post" action="{$_url}logs/radius/">
|
||||
<div class="input-group has-error">
|
||||
<span class="input-group-addon">Keep Logs </span>
|
||||
<input type="text" name="keep" class="form-control" placeholder="90" value="90">
|
||||
<span class="input-group-addon">Days</span>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-danger btn-sm"
|
||||
onclick="return confirm('Clear old logs?')">Clean Logs</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-striped table-condensed">
|
||||
<tbody>
|
||||
{foreach $d as $ds}
|
||||
<tr>
|
||||
<td width="30px">{$ds['id']}</td>
|
||||
<td width="200px">{Lang::dateTimeFormat($ds['authdate'])}</td>
|
||||
<td width="100px">{$ds['username']}</td>
|
||||
<td width="10px"><input type="password" value="{$ds['pass']}"
|
||||
style="width:300px;border: 0px; text-align: right;" class="pull-right"
|
||||
onmouseleave="this.type = 'password'" onmouseenter="this.type = 'text'"
|
||||
onclick="this.select()"></td>
|
||||
<td>{$ds['reply']}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<nav aria-label="...">
|
||||
<ul class="pager">
|
||||
{if $page > 0}
|
||||
<li class="previous "><a href="{$_url}logs/radius/{$page-1}"><span
|
||||
aria-hidden="true">←</span> Newer</a></li>
|
||||
{/if}
|
||||
<li class="next"><a href="{$_url}logs/radius/{$page+1}">Older <span
|
||||
aria-hidden="true">→</span></a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{include file="sections/footer.tpl"}
|
@ -4,22 +4,17 @@
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-hovered mb20 panel-primary">
|
||||
<div class="panel-heading">
|
||||
<div class="btn-group pull-right">
|
||||
<a class="btn btn-primary btn-xs" title="save" href="{$_url}pool/sync"
|
||||
onclick="return confirm('This will sync/send IP Pool to Mikrotik?')"><span
|
||||
class="glyphicon glyphicon-refresh" aria-hidden="true"></span> sync</a>
|
||||
</div>
|
||||
{$_L['Pool']}
|
||||
PhpNuxBill
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="md-whiteframe-z1 mb20 text-center" style="padding: 15px">
|
||||
<div class="col-md-8">
|
||||
<form id="site-search" method="post" action="{$_url}pool/list/">
|
||||
<div class="text-center" style="padding: 15px">
|
||||
<div class="col-md-4">
|
||||
<form id="site-search" method="post" action="{$_url}logs/radius/">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">
|
||||
<span class="fa fa-search"></span>
|
||||
</div>
|
||||
<input type="text" name="name" class="form-control"
|
||||
<input type="text" name="name" class="form-control" value="{$name}"
|
||||
placeholder="{$_L['Search_by_Name']}...">
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-success" type="submit">{$_L['Search']}</button>
|
||||
@ -27,36 +22,29 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<a href="{$_url}pool/add" class="btn btn-primary btn-block waves-effect"><i
|
||||
class="ion ion-android-add"> </i> {$_L['New_Pool']}</a>
|
||||
<div class="col-md-8">
|
||||
<form class="form-inline" method="post" action="{$_url}logs/radius/">
|
||||
<div class="input-group has-error">
|
||||
<span class="input-group-addon">Keep Logs </span>
|
||||
<input type="text" name="keep" class="form-control" placeholder="90" value="90">
|
||||
<span class="input-group-addon">Days</span>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-danger btn-sm"
|
||||
onclick="return confirm('Clear old logs?')">Clean Logs</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-striped table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>{$_L['Pool_Name']}</th>
|
||||
<th>{$_L['Range_IP']}</th>
|
||||
<th>{$_L['Routers']}</th>
|
||||
<th>{$_L['Manage']}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{$no = 1}
|
||||
{foreach $d as $ds}
|
||||
<tr>
|
||||
<td align="center">{$no++}</td>
|
||||
<td>{$ds['pool_name']}</td>
|
||||
<td>{$ds['range_ip']}</td>
|
||||
<td>{$ds['routers']}</td>
|
||||
<td align="center">
|
||||
<a href="{$_url}pool/edit/{$ds['id']}" class="btn btn-info btn-xs">{$_L['Edit']}</a>
|
||||
<a href="{$_url}pool/delete/{$ds['id']}" id="{$ds['id']}"
|
||||
onclick="return confirm('{$_L['Delete']}?')"
|
||||
class="btn btn-danger btn-xs">{$_L['Delete']}</a>
|
||||
</td>
|
||||
<td>{$ds['id']}</td>
|
||||
<td>{Lang::dateTimeFormat($ds['date'])}</td>
|
||||
<td>{$ds['type']}</td>
|
||||
<td>{$ds['ip']}</td>
|
||||
<td style="overflow-x: scroll;">{$ds['description']}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
|
@ -264,8 +264,7 @@
|
||||
</ul>
|
||||
</li>
|
||||
{$_MENU_AFTER_SETTINGS}
|
||||
<li
|
||||
class="{if $_system_menu eq 'logs' }active{/if} treeview">
|
||||
<li class="{if $_system_menu eq 'logs' }active{/if} treeview">
|
||||
<a href="#">
|
||||
<i class="ion ion-clock"></i> <span>{Lang::T('Logs')}</span>
|
||||
<span class="pull-right-container">
|
||||
@ -273,10 +272,16 @@
|
||||
</span>
|
||||
</a>
|
||||
<ul class="treeview-menu">
|
||||
<li {if $_routes[1] eq 'phpnuxbill'}class="active" {/if}><a
|
||||
<li {if $_routes[1] eq 'list'}class="active" {/if}><a
|
||||
href="{$_url}logs/phpnuxbill">PhpNuxBill</a></li>
|
||||
{$_MENU_LOGS}
|
||||
</ul>
|
||||
{if $_c['radius_enable']}
|
||||
<ul class="treeview-menu">
|
||||
<li {if $_routes[1] eq 'radius'}class="active" {/if}><a href="{$_url}logs/radius">Radius</a>
|
||||
</li>
|
||||
</ul>
|
||||
{/if}
|
||||
{$_MENU_LOGS}
|
||||
</li>
|
||||
{$_MENU_AFTER_LOGS}
|
||||
<li {if $_system_menu eq 'community'}class="active" {/if}>
|
||||
|
Loading…
x
Reference in New Issue
Block a user