2016-09-01 23:13:23 +02:00
|
|
|
<?php
|
|
|
|
/*****************************************************************************
|
|
|
|
* ManageErrors.php
|
|
|
|
* Contains the controller for managing errors.
|
|
|
|
*
|
|
|
|
* Kabuki CMS (C) 2013-2015, Aaron van Geffen
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
class ManageErrors extends HTMLController
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
// Ensure it's just admins at this point.
|
|
|
|
if (!Registry::get('user')->isAdmin())
|
|
|
|
throw new NotAllowedException();
|
|
|
|
|
2024-12-19 15:00:00 +01:00
|
|
|
// Clearing, are we?
|
|
|
|
if (isset($_POST['clear']) && Session::validateSession('get'))
|
2016-09-02 11:45:13 +02:00
|
|
|
{
|
2016-09-01 23:13:23 +02:00
|
|
|
ErrorLog::flush();
|
2016-09-02 11:45:13 +02:00
|
|
|
header('Location: ' . BASEURL . '/manageerrors/');
|
2017-11-05 16:27:12 +01:00
|
|
|
exit;
|
2016-09-02 11:45:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Session::resetSessionToken();
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
$options = [
|
|
|
|
'title' => 'Error log',
|
|
|
|
'form' => [
|
2016-09-02 11:45:13 +02:00
|
|
|
'action' => BASEURL . '/manageerrors/?' . Session::getSessionTokenKey() . '=' . Session::getSessionToken(),
|
2016-09-01 23:13:23 +02:00
|
|
|
'method' => 'post',
|
2023-03-11 14:24:17 +01:00
|
|
|
'class' => 'col-md-6 text-end',
|
2016-09-01 23:13:23 +02:00
|
|
|
'buttons' => [
|
2024-12-19 15:00:00 +01:00
|
|
|
'clear' => [
|
2016-09-01 23:13:23 +02:00
|
|
|
'type' => 'submit',
|
|
|
|
'caption' => 'Delete all',
|
2023-03-11 14:24:17 +01:00
|
|
|
'class' => 'btn-danger',
|
2016-09-01 23:13:23 +02:00
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'columns' => [
|
2024-12-19 15:00:00 +01:00
|
|
|
'id_entry' => [
|
2016-09-01 23:13:23 +02:00
|
|
|
'value' => 'id_entry',
|
|
|
|
'header' => '#',
|
|
|
|
'is_sortable' => true,
|
|
|
|
],
|
|
|
|
'message' => [
|
|
|
|
'parse' => [
|
|
|
|
'type' => 'function',
|
|
|
|
'data' => function($row) {
|
2021-03-10 17:09:01 +01:00
|
|
|
return $row['message'] . '<br>' .
|
|
|
|
'<div><a onclick="this.parentNode.childNodes[1].style.display=\'block\';this.style.display=\'none\';">Show debug info</a>' .
|
|
|
|
'<pre style="display: none">' . htmlspecialchars($row['debug_info']) .
|
|
|
|
'</pre></div>' .
|
|
|
|
'<small><a href="' . BASEURL .
|
|
|
|
htmlspecialchars($row['request_uri']) . '">' .
|
|
|
|
htmlspecialchars($row['request_uri']) . '</a></small>';
|
2016-09-01 23:13:23 +02:00
|
|
|
}
|
|
|
|
],
|
|
|
|
'header' => 'Message / URL',
|
|
|
|
'is_sortable' => false,
|
|
|
|
],
|
|
|
|
'file' => [
|
|
|
|
'value' => 'file',
|
|
|
|
'header' => 'File',
|
|
|
|
'is_sortable' => true,
|
|
|
|
],
|
|
|
|
'line' => [
|
|
|
|
'value' => 'line',
|
|
|
|
'header' => 'Line',
|
|
|
|
'is_sortable' => true,
|
|
|
|
],
|
|
|
|
'time' => [
|
|
|
|
'parse' => [
|
|
|
|
'type' => 'timestamp',
|
|
|
|
'data' => [
|
|
|
|
'timestamp' => 'time',
|
|
|
|
'pattern' => 'long',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'header' => 'Time',
|
|
|
|
'is_sortable' => true,
|
|
|
|
],
|
|
|
|
'ip' => [
|
|
|
|
'value' => 'ip_address',
|
|
|
|
'header' => 'IP',
|
|
|
|
'is_sortable' => true,
|
|
|
|
],
|
|
|
|
'uid' => [
|
|
|
|
'header' => 'UID',
|
|
|
|
'is_sortable' => true,
|
|
|
|
'parse' => [
|
2022-05-07 13:25:19 +02:00
|
|
|
'link' => BASEURL . '/edituser/?id={ID_USER}',
|
2016-09-01 23:13:23 +02:00
|
|
|
'data' => 'id_user',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
2024-12-19 15:00:00 +01:00
|
|
|
'default_sort_order' => 'id_entry',
|
|
|
|
'default_sort_direction' => 'down',
|
|
|
|
'start' => $_GET['start'] ?? 0,
|
|
|
|
'sort_order' => $_GET['order'] ?? '',
|
|
|
|
'sort_direction' => $_GET['dir'] ?? '',
|
2016-09-01 23:13:23 +02:00
|
|
|
'no_items_label' => "No errors to display -- we're all good!",
|
|
|
|
'items_per_page' => 20,
|
2023-03-11 14:24:17 +01:00
|
|
|
'index_class' => 'col-md-6',
|
2016-09-01 23:13:23 +02:00
|
|
|
'base_url' => BASEURL . '/manageerrors/',
|
|
|
|
'get_count' => 'ErrorLog::getCount',
|
2024-12-19 15:00:00 +01:00
|
|
|
'get_data' => function($offset, $limit, $order, $direction) {
|
|
|
|
assert(in_array($order, ['id_entry', 'file', 'line', 'time', 'ipaddress', 'id_user']));
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2024-12-19 15:00:00 +01:00
|
|
|
return Registry::get('db')->queryAssocs('
|
2016-09-01 23:13:23 +02:00
|
|
|
SELECT *
|
|
|
|
FROM log_errors
|
|
|
|
ORDER BY {raw:order}
|
|
|
|
LIMIT {int:offset}, {int:limit}',
|
|
|
|
[
|
|
|
|
'order' => $order . ($direction === 'up' ? ' ASC' : ' DESC'),
|
|
|
|
'offset' => $offset,
|
|
|
|
'limit' => $limit,
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
$error_log = new GenericTable($options);
|
|
|
|
parent::__construct('Error log - Page ' . $error_log->getCurrentPage() .' - ' . SITE_TITLE);
|
|
|
|
$this->page->adopt(new TabularData($error_log));
|
|
|
|
}
|
|
|
|
}
|