kinda fix error-handlers; more work on admin-dashboard
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -186,7 +186,9 @@ if ($page == 'overview') {
|
||||
UI::Twig()->addGlobal('userinfo', $userinfo);
|
||||
UI::TwigBuffer('user/index.html.twig', [
|
||||
'sysinfo' => $sysinfo,
|
||||
'overview' => $overview
|
||||
'overview' => $overview,
|
||||
'outstanding_tasks' => $outstanding_tasks,
|
||||
'cron_last_runs' => $cron_last_runs
|
||||
]);
|
||||
UI::TwigOutputBuffer();
|
||||
} elseif ($page == 'change_password') {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Froxlor;
|
||||
|
||||
class PhpHelper
|
||||
@@ -108,11 +109,10 @@ class PhpHelper
|
||||
* @param string $errstr
|
||||
* @param string $errfile
|
||||
* @param int $errline
|
||||
* @param array $errcontext
|
||||
*
|
||||
* @return void|boolean
|
||||
*/
|
||||
public static function phpErrHandler($errno, $errstr, $errfile, $errline, $errcontext = array())
|
||||
public static function phpErrHandler($errno, $errstr, $errfile, $errline)
|
||||
{
|
||||
if (!(error_reporting() & $errno)) {
|
||||
// This error code is not included in error_reporting
|
||||
@@ -155,22 +155,18 @@ class PhpHelper
|
||||
public static function phpExceptionHandler(\Throwable $exception)
|
||||
{
|
||||
if (!isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) {
|
||||
$err_display = '<div class="alert alert-danger my-1" role="alert">';
|
||||
$err_display .= '<strong>#' . $exception->getCode() . ' ' . $exception->getMessage() . '</strong><br>';
|
||||
// later depended on whether to show or now
|
||||
$err_display .= '<br><p><pre>';
|
||||
$debug = $exception->getTrace();
|
||||
foreach ($debug as $dline) {
|
||||
$err_display .= $dline['function'] . '() called at [' . str_replace(\Froxlor\Froxlor::getInstallDir(), '', $dline['file']) . ':' . $dline['line'] . ']<br>';
|
||||
}
|
||||
$err_display .= '</pre></p>';
|
||||
// end later
|
||||
$err_display .= '</div>';
|
||||
// check for more existing errors
|
||||
$errors = isset(\Froxlor\UI\Panel\UI::Twig()->getGlobals()['global_errors']) ? \Froxlor\UI\Panel\UI::Twig()->getGlobals()['global_errors'] : "";
|
||||
\Froxlor\UI\Panel\UI::Twig()->addGlobal('global_errors', $errors . $err_display);
|
||||
// return true to ignore php standard error-handler
|
||||
return true;
|
||||
// show
|
||||
\Froxlor\UI\Panel\UI::initTwig(true);
|
||||
\Froxlor\UI\Panel\UI::Twig()->addGlobal('install_mode', '1');
|
||||
\Froxlor\UI\Panel\UI::TwigBuffer('misc/alert_nosession.html.twig', [
|
||||
'page_title' => 'Uncaught exception',
|
||||
'heading' => 'Uncaught exception',
|
||||
'type' => 'danger',
|
||||
'alert_msg' => $exception->getCode() . ' ' . $exception->getMessage(),
|
||||
'alert_info' => $exception->getTraceAsString()
|
||||
]);
|
||||
echo \Froxlor\UI\Panel\UI::TwigOutputBuffer();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -193,6 +193,11 @@ class Cronjob
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an array of all cronjobs and when they last were executed
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getCronjobsLastRun()
|
||||
{
|
||||
global $lng;
|
||||
@@ -200,20 +205,13 @@ class Cronjob
|
||||
$query = "SELECT `lastrun`, `desc_lng_key` FROM `" . TABLE_PANEL_CRONRUNS . "` WHERE `isactive` = '1' ORDER BY `cronfile` ASC";
|
||||
$result = Database::query($query);
|
||||
|
||||
$cronjobs_last_run = '';
|
||||
$cronjobs_last_run = [];
|
||||
while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
|
||||
|
||||
$lastrun = $lng['cronjobs']['notyetrun'];
|
||||
if ($row['lastrun'] > 0) {
|
||||
$lastrun = date('d.m.Y H:i:s', $row['lastrun']);
|
||||
$cronjobs_last_run[] = [
|
||||
'title' => $lng['crondesc'][$row['desc_lng_key']],
|
||||
'lastrun' => $row['lastrun']
|
||||
];
|
||||
}
|
||||
|
||||
$text = $lng['crondesc'][$row['desc_lng_key']];
|
||||
$value = $lastrun;
|
||||
|
||||
eval("\$cronjobs_last_run .= \"" . \Froxlor\UI\Template::getTemplate("index/overview_item") . "\";");
|
||||
}
|
||||
|
||||
return $cronjobs_last_run;
|
||||
}
|
||||
|
||||
@@ -231,6 +229,11 @@ class Cronjob
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an array of tasks that are queued to be run by the cronjob
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getOutstandingTasks()
|
||||
{
|
||||
global $lng;
|
||||
@@ -238,8 +241,7 @@ class Cronjob
|
||||
$query = "SELECT * FROM `" . TABLE_PANEL_TASKS . "` ORDER BY `type` ASC";
|
||||
$result = Database::query($query);
|
||||
|
||||
$value = '<ul class="cronjobtask">';
|
||||
$tasks = '';
|
||||
$tasks = [];
|
||||
while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
|
||||
|
||||
if ($row['data'] != '') {
|
||||
@@ -249,41 +251,35 @@ class Cronjob
|
||||
$task_id = $row['type'];
|
||||
if (\Froxlor\Cron\TaskId::isValid($task_id)) {
|
||||
$task_constname = \Froxlor\Cron\TaskId::convertToConstant($task_id);
|
||||
$task_desc = isset($lng['tasks'][$task_constname]) ? $lng['tasks'][$task_constname] : $task_constname;
|
||||
|
||||
$task = [
|
||||
'desc' => isset($lng['tasks'][$task_constname]) ? $lng['tasks'][$task_constname] : $task_constname
|
||||
];
|
||||
if (is_array($row['data'])) {
|
||||
// task includes loginname
|
||||
if (isset($row['data']['loginname'])) {
|
||||
$loginname = $row['data']['loginname'];
|
||||
$task_desc = str_replace('%loginname%', $loginname, $task_desc);
|
||||
$task['desc'] = str_replace('%loginname%', $loginname, $task['desc']);
|
||||
}
|
||||
// task includes domain data
|
||||
if (isset($row['data']['domain'])) {
|
||||
$domain = $row['data']['domain'];
|
||||
$task_desc = str_replace('%domain%', $domain, $task_desc);
|
||||
$task['desc'] = str_replace('%domain%', $domain, $task['desc']);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// unknown
|
||||
$task_desc = "ERROR: Unknown task type '" . $row['type'] . "'";
|
||||
$task = ['desc' => "ERROR: Unknown task type '" . $row['type'] . "'"];
|
||||
}
|
||||
|
||||
if ($task_desc != '') {
|
||||
$tasks .= '<li>' . $task_desc . '</li>';
|
||||
}
|
||||
$tasks[] = $task;
|
||||
}
|
||||
|
||||
if (trim($tasks) == '') {
|
||||
$value .= '<li>' . $lng['tasks']['noneoutstanding'] . '</li>';
|
||||
} else {
|
||||
$value .= $tasks;
|
||||
if (empty($tasks)) {
|
||||
$tasks = [['desc' => $lng['tasks']['noneoutstanding']]];
|
||||
}
|
||||
|
||||
$value .= '</ul>';
|
||||
$text = $lng['tasks']['outstanding_tasks'];
|
||||
eval("\$outstanding_tasks = \"" . \Froxlor\UI\Template::getTemplate("index/overview_item") . "\";");
|
||||
|
||||
return $outstanding_tasks;
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,11 +8,19 @@
|
||||
<meta name="googlebot" content="nosnippet"/>
|
||||
|
||||
<!-- CSS -->
|
||||
{% if theme_css is empty %}
|
||||
<link href="templates/Froxlor/assets/css/main.css" rel="stylesheet" type="text/css" />
|
||||
{% else %}
|
||||
{{ theme_css|raw }}
|
||||
{% endif %}
|
||||
{% block custom_css %}{% endblock %}
|
||||
|
||||
<!-- Scripts -->
|
||||
{% if theme_js is empty %}
|
||||
<script type="text/javascript" src="templates/Froxlor/assets/js/main.js"></script>
|
||||
{% else %}
|
||||
{{ theme_js|raw }}
|
||||
{% endif %}
|
||||
{% block custom_js %}{% endblock %}
|
||||
<title>Froxlor
|
||||
{% if page_title %}
|
||||
|
||||
@@ -110,6 +110,31 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if userinfo.adminsession == 1 %}
|
||||
{# froxlor-details #}
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<i class="fa-solid fa-wrench"></i>
|
||||
{{ lng('admin.froxlordetails') }}
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item d-flex justify-content-between align-items-start">
|
||||
<div class="ms-2 me-auto">
|
||||
<div class="fw-bold">{{ lng('tasks.outstanding_tasks') }}</div>
|
||||
{% for task in outstanding_tasks %}
|
||||
<i class="fa-regular fa-clock"></i> {{ task.desc }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</li>
|
||||
{% for cronrun in cron_last_runs %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-start">
|
||||
<div class="ms-2 me-auto">{{ cronrun.title }}</div>
|
||||
<span class="badge bg-primary">{% if cronrun.lastrun > 0 %}{{ cronrun.lastrun|date('d.m.Y H:i') }}{% else %}{{ lng('cronjobs.notyetrun') }}{% endif %}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if userinfo.adminsession == 1 %}
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user