mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-27 01:39:22 +02:00
Move Admin Logs and Reports into Twig
This commit is contained in:
parent
8115cc5ecc
commit
711027e450
@ -8,108 +8,74 @@
|
|||||||
* @link https://my-aac.org
|
* @link https://my-aac.org
|
||||||
*/
|
*/
|
||||||
defined('MYAAC') or die('Direct access not allowed!');
|
defined('MYAAC') or die('Direct access not allowed!');
|
||||||
$title = 'Logs viewer';
|
$title = 'Logs Viewer';
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="box">
|
$files = array();
|
||||||
<div class="box-header">
|
$aac_path_logs = BASE . 'system/logs/';
|
||||||
<h3 class="box-title">Logs:</h3>
|
foreach (scandir($aac_path_logs, SCANDIR_SORT_ASCENDING) as $f) {
|
||||||
</div>
|
if ($f[0] === '.' || is_dir($aac_path_logs . $f)) {
|
||||||
<div class="box-body">
|
continue;
|
||||||
<div class="row">
|
}
|
||||||
<div class="col-sm-12">
|
|
||||||
<table id="tb_logs">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Log name</th>
|
|
||||||
<th>Last updated</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php
|
|
||||||
$files = array();
|
|
||||||
$aac_path_logs = BASE . 'system/logs/';
|
|
||||||
foreach (scandir($aac_path_logs) as $f) {
|
|
||||||
if ($f[0] == '.' || $f == '..' || is_dir($aac_path_logs . $f))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
$files[] = array($f, $aac_path_logs);
|
$files[] = array($f, $aac_path_logs);
|
||||||
}
|
}
|
||||||
|
|
||||||
$server_path_logs = $config['server_path'] . 'logs/';
|
$server_path_logs = $config['server_path'] . 'logs/';
|
||||||
if (!file_exists($server_path_logs)) {
|
if (!file_exists($server_path_logs)) {
|
||||||
$server_path_logs = $config['data_path'] . 'logs/';
|
$server_path_logs = $config['data_path'] . 'logs/';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($server_path_logs)) {
|
if (file_exists($server_path_logs)) {
|
||||||
foreach (scandir($server_path_logs) as $f) {
|
foreach (scandir($server_path_logs, SCANDIR_SORT_ASCENDING) as $f) {
|
||||||
if ($f[0] == '.' || $f == '..')
|
if ($f[0] === '.') {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_dir($server_path_logs . $f)) {
|
if (is_dir($server_path_logs . $f)) {
|
||||||
foreach (scandir($server_path_logs . $f) as $f2) {
|
foreach (scandir($server_path_logs . $f, SCANDIR_SORT_ASCENDING) as $f2) {
|
||||||
if ($f2[0] == '.' || $f2 == '..')
|
if ($f2[0] === '.') {
|
||||||
continue;
|
continue;
|
||||||
$files[] = array($f . '/' . $f2, $server_path_logs);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
$files[] = array($f . '/' . $f2, $server_path_logs);
|
||||||
}
|
}
|
||||||
|
|
||||||
$files[] = array($f, $server_path_logs);
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$i = 0;
|
$files[] = array($f, $server_path_logs);
|
||||||
foreach ($files as $f) {
|
}
|
||||||
?>
|
}
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<a href="<?php echo ADMIN_URL . '?p=logs&file=' . $f[0]; ?>"><?php echo $f[0]; ?></a>
|
|
||||||
</td>
|
|
||||||
<td><?php echo date("Y-m-d H:i:s", filemtime($f[1] . $f[0])); ?></td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</tbody>
|
|
||||||
<tfoot>
|
|
||||||
<th>Log name</th>
|
|
||||||
<th>Last updated</th>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
foreach ($files as &$f) {
|
||||||
|
$f['mtime'] = filemtime($f[1] . $f[0]);
|
||||||
|
$f['name'] = $f[0];
|
||||||
|
}
|
||||||
|
unset($f);
|
||||||
|
|
||||||
$file = isset($_GET['file']) ? $_GET['file'] : NULL;
|
$twig->display('admin.logs.html.twig', array('files' => $files));
|
||||||
|
|
||||||
|
define('EXIST_NONE', 0);
|
||||||
|
define('EXIST_SERVER_LOG', 1);
|
||||||
|
define('EXIST_AAC_LOG', 2);
|
||||||
|
|
||||||
|
$exist = EXIST_NONE;
|
||||||
|
$file = isset($_GET['file']) ? $_GET['file'] : null;
|
||||||
if (!empty($file)) {
|
if (!empty($file)) {
|
||||||
if (!preg_match('/[^A-z0-9\' _\/\-\.]/', $file)) {
|
if (!preg_match('/[^A-z0-9\' _\/\-\.]/', $file)) {
|
||||||
if (file_exists($aac_path_logs . $file)) {
|
if (file_exists($aac_path_logs . $file)) {
|
||||||
echo '
|
$exist = EXIST_AAC_LOG;
|
||||||
<div class="box">
|
|
||||||
<div class="box-header">
|
|
||||||
<h3 class="box-title"><b>' . $file . '</b></h3>
|
|
||||||
</div>
|
|
||||||
<div class="box-body">';
|
|
||||||
echo nl2br(file_get_contents($aac_path_logs . $file));
|
|
||||||
echo '</div>
|
|
||||||
</div>';
|
|
||||||
} else if (file_exists($server_path_logs . $file)) {
|
} else if (file_exists($server_path_logs . $file)) {
|
||||||
echo '<div class="box"><div class="box-header"><h3 class="box-title"><b>' . $file . '</b></h3></div><div class="box-body">';
|
$exist = EXIST_SERVER_LOG;
|
||||||
echo nl2br(file_get_contents($server_path_logs . $file));
|
} else {
|
||||||
echo '</div></div>';
|
|
||||||
} else
|
|
||||||
echo 'Specified file does not exist.';
|
echo 'Specified file does not exist.';
|
||||||
} else
|
}
|
||||||
|
|
||||||
|
if ($exist !== EXIST_NONE) {
|
||||||
|
$content = nl2br(file_get_contents(($exist === EXIST_SERVER_LOG ? $server_path_logs : $aac_path_logs) . $file));
|
||||||
|
$twig->display('admin.logs.view.html.twig', array('file' => $file, 'content' => $content));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
echo 'Invalid file name specified.';
|
echo 'Invalid file name specified.';
|
||||||
}
|
}
|
||||||
?>
|
}
|
||||||
<script>
|
|
||||||
$(function () {
|
|
||||||
$('#tb_logs').DataTable()
|
|
||||||
})
|
|
||||||
</script>
|
|
@ -8,84 +8,54 @@
|
|||||||
* @link https://my-aac.org
|
* @link https://my-aac.org
|
||||||
*/
|
*/
|
||||||
defined('MYAAC') or die('Direct access not allowed!');
|
defined('MYAAC') or die('Direct access not allowed!');
|
||||||
$title = 'Report viewer';
|
$title = 'Report Viewer';
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="box">
|
$files = array();
|
||||||
<div class="box-header">
|
$server_path_reports = $config['data_path'] . 'reports/';
|
||||||
<h3 class="box-title">Reports:</h3>
|
|
||||||
</div>
|
|
||||||
<div class="box-body">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12">
|
|
||||||
<table id="tb_reports">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Report name</th>
|
|
||||||
<th>Last updated</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php
|
|
||||||
$files = array();
|
|
||||||
$server_path_reports = $config['data_path'] . 'reports/';
|
|
||||||
|
|
||||||
if (file_exists($server_path_reports)) {
|
if (file_exists($server_path_reports)) {
|
||||||
foreach (scandir($server_path_reports) as $f) {
|
foreach (scandir($server_path_reports, SCANDIR_SORT_ASCENDING) as $f) {
|
||||||
if ($f[0] == '.' || $f == '..')
|
if ($f[0] === '.') {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_dir($server_path_reports . $f)) {
|
if (is_dir($server_path_reports . $f)) {
|
||||||
foreach (scandir($server_path_reports . $f) as $f2) {
|
foreach (scandir($server_path_reports . $f, SCANDIR_SORT_ASCENDING) as $f2) {
|
||||||
if ($f2[0] == '.' || $f2 == '..')
|
if ($f2[0] === '.') {
|
||||||
continue;
|
continue;
|
||||||
$files[] = array($f . '/' . $f2, $server_path_reports);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
$files[] = array($f . '/' . $f2, $server_path_reports);
|
||||||
}
|
}
|
||||||
|
|
||||||
$files[] = array($f, $server_path_reports);
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$i = 0;
|
$files[] = array($f, $server_path_reports);
|
||||||
foreach ($files as $f) {
|
}
|
||||||
?>
|
}
|
||||||
<tr>
|
|
||||||
<td>
|
foreach ($files as &$f) {
|
||||||
<a href="<?php echo ADMIN_URL . '?p=reports&file=' . $f[0]; ?>"><?php echo $f[0]; ?></a>
|
$f['mtime'] = filemtime($f[1] . $f[0]);
|
||||||
</td>
|
$f['name'] = $f[0];
|
||||||
<td><?php echo date("Y-m-d H:i:s", filemtime($f[1] . $f[0])); ?></td>
|
}
|
||||||
</tr>
|
|
||||||
<?php
|
unset($f);
|
||||||
}
|
|
||||||
?>
|
$twig->display('admin.reports.html.twig', array('files' => $files));
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$file = isset($_GET['file']) ? $_GET['file'] : NULL;
|
$file = isset($_GET['file']) ? $_GET['file'] : NULL;
|
||||||
if (!empty($file)) {
|
if (!empty($file)) {
|
||||||
if (!preg_match('/[^A-z0-9\' _\/\-\.]/', $file)) {
|
if (!preg_match('/[^A-z0-9\' _\/\-\.]/', $file)) {
|
||||||
if (file_exists($server_path_reports . $file)) {
|
if (file_exists($server_path_reports . $file)) {
|
||||||
echo '<div class="box"><div class="box-header"><h3 class="box-title"><b>' . $file . '</b></h3></div><div class="box-body">';
|
$content = nl2br(file_get_contents($server_path_reports . $file));
|
||||||
echo nl2br(file_get_contents($server_path_reports . $file));
|
|
||||||
echo '</div></div>';
|
|
||||||
} else
|
|
||||||
echo 'Specified file does not exist.';
|
|
||||||
} else
|
|
||||||
echo 'Invalid file name specified.';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<script>
|
|
||||||
$(document).ready(function () {
|
|
||||||
$('#tb_reports').DataTable();
|
|
||||||
|
|
||||||
});
|
$twig->display('admin.logs.view.html.twig', array('file' => $file, 'content' => $content));
|
||||||
</script>
|
} else {
|
||||||
|
echo 'Specified file does not exist.';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo 'Invalid file name specified.';
|
||||||
|
}
|
||||||
|
}
|
41
system/templates/admin.logs.html.twig
Normal file
41
system/templates/admin.logs.html.twig
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<div class="box">
|
||||||
|
<div class="box-header">
|
||||||
|
<h3 class="box-title">Logs:</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<table id="tb_logs">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Log name</th>
|
||||||
|
<th>Last updated</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for file in files %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="{{ constant('ADMIN_URL') }}?p=logs&file={{ file.name }}">{{ file.name }}</a>
|
||||||
|
</td>
|
||||||
|
<td>{{ file.mtime|date('Y-m-d H:i:s') }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<th>Log name</th>
|
||||||
|
<th>Last updated</th>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(function () {
|
||||||
|
$('#tb_logs').DataTable()
|
||||||
|
})
|
||||||
|
</script>
|
8
system/templates/admin.logs.view.html.twig
Normal file
8
system/templates/admin.logs.view.html.twig
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<div class="box">
|
||||||
|
<div class="box-header">
|
||||||
|
<h3 class="box-title"><b>{{ file }}</b></h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body">
|
||||||
|
{{ content|raw }}
|
||||||
|
</div>
|
||||||
|
</div>
|
41
system/templates/admin.reports.html.twig
Normal file
41
system/templates/admin.reports.html.twig
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<div class="box">
|
||||||
|
<div class="box-header">
|
||||||
|
<h3 class="box-title">Reports:</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<table id="tb_reports">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Report name</th>
|
||||||
|
<th>Last updated</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for file in files %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="{{ constant('ADMIN_URL') }}?p=reports&file={{ file.name }}">{{ file.name }}</a>
|
||||||
|
</td>
|
||||||
|
<td>{{ file.mtime|date('Y-m-d H:i:s') }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<th>Report name</th>
|
||||||
|
<th>Last updated</th>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('#tb_reports').DataTable();
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
x
Reference in New Issue
Block a user