diff --git a/admin_index.php b/admin_index.php
index 6547a2c7..bd77fa7a 100644
--- a/admin_index.php
+++ b/admin_index.php
@@ -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') {
diff --git a/lib/Froxlor/PhpHelper.php b/lib/Froxlor/PhpHelper.php
index fdc508c5..a303f6b1 100644
--- a/lib/Froxlor/PhpHelper.php
+++ b/lib/Froxlor/PhpHelper.php
@@ -1,4 +1,5 @@
$value) {
- if ((! is_array($fields) || empty($fields)) || (is_array($fields) && ! empty($fields) && in_array($field, $fields))) {
+ if ((!is_array($fields) || empty($fields)) || (is_array($fields) && !empty($fields) && in_array($field, $fields))) {
// Just call ourselve to manage multi-dimensional arrays
$subject[$field] = self::htmlentitiesArray($subject[$field], $fields, $quote_style, $charset);
}
@@ -90,7 +91,7 @@ class PhpHelper
if (is_array($subject)) {
$fields = self::arrayTrim(explode(' ', $fields));
foreach ($subject as $field => $value) {
- if ((! is_array($fields) || empty($fields)) || (is_array($fields) && ! empty($fields) && in_array($field, $fields))) {
+ if ((!is_array($fields) || empty($fields)) || (is_array($fields) && !empty($fields) && in_array($field, $fields))) {
$subject[$field] = str_replace($search, $replace, $subject[$field]);
}
}
@@ -108,18 +109,17 @@ 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)) {
+ if (!(error_reporting() & $errno)) {
// This error code is not included in error_reporting
return;
}
- if (! isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) {
+ if (!isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) {
// prevent possible file-path-disclosure
$errfile = str_replace(\Froxlor\Froxlor::getInstallDir(), "", $errfile);
// build alert
@@ -129,16 +129,16 @@ class PhpHelper
} elseif ($errno = E_WARNING) {
$type = 'warning';
}
- $err_display = '
';
+ $err_display = '
';
$err_display .= '
#' . $errno . ' ' . $errstr . ' ';
$err_display .= $errfile . ':' . $errline;
// later depended on whether to show or now
- $err_display .= '
';
- $debug = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
- foreach ($debug as $dline) {
- $err_display .= $dline['function'] . '() called at [' . str_replace(\Froxlor\Froxlor::getInstallDir(), '', $dline['file']) . ':' . $dline['line'] . '] ';
- }
- $err_display .= ' ';
+ $err_display .= '
';
+ $debug = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
+ foreach ($debug as $dline) {
+ $err_display .= $dline['function'] . '() called at [' . str_replace(\Froxlor\Froxlor::getInstallDir(), '', $dline['file']) . ':' . $dline['line'] . '] ';
+ }
+ $err_display .= ' ';
// end later
$err_display .= '
';
// check for more existing errors
@@ -154,23 +154,19 @@ class PhpHelper
public static function phpExceptionHandler(\Throwable $exception)
{
- if (! isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) {
- $err_display = '
';
- $err_display .= '
#' . $exception->getCode() . ' ' . $exception->getMessage() . ' ';
- // later depended on whether to show or now
- $err_display .= '
';
- $debug = $exception->getTrace();
- foreach ($debug as $dline) {
- $err_display .= $dline['function'] . '() called at [' . str_replace(\Froxlor\Froxlor::getInstallDir(), '', $dline['file']) . ':' . $dline['line'] . '] ';
- }
- $err_display .= ' ';
- // end later
- $err_display .= '
';
- // 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;
+ if (!isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) {
+ // 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();
}
}
@@ -194,7 +190,7 @@ class PhpHelper
// we assume that this is a list of
// setting-groups to be selected
$selection = null;
- for ($x = 0; $x < $numargs; $x ++) {
+ for ($x = 0; $x < $numargs; $x++) {
$arg = func_get_arg($x);
if (is_array($arg) && isset($arg[0])) {
$selection = $arg;
@@ -211,7 +207,7 @@ class PhpHelper
if (is_dir($data_dirname)) {
$data_dirhandle = opendir($data_dirname);
while (false !== ($data_filename = readdir($data_dirhandle))) {
- if ($data_filename != '.' && $data_filename != '..' && $data_filename != '' && substr($data_filename, - 4) == '.php') {
+ if ($data_filename != '.' && $data_filename != '..' && $data_filename != '' && substr($data_filename, -4) == '.php') {
$data_files[] = $data_dirname . $data_filename;
}
}
@@ -367,7 +363,7 @@ class PhpHelper
$i = 0;
while ($size >= $sys['size'] && $i < $depth) {
$size /= $sys['size'];
- $i ++;
+ $i++;
}
return sprintf($retstring, $size, $sys['prefix'][$i]);
@@ -390,7 +386,7 @@ class PhpHelper
$matches = array();
if (count($vars) > 0 && preg_match_all($pattern, $text, $matches)) {
- for ($i = 0; $i < count($matches[1]); $i ++) {
+ for ($i = 0; $i < count($matches[1]); $i++) {
$current = $matches[1][$i];
if (isset($vars[$current])) {
@@ -444,7 +440,7 @@ class PhpHelper
'ssl_default_vhostconf_domain',
'filecontent'
];
- if (isset($global) && ! empty($global)) {
+ if (isset($global) && !empty($global)) {
$tmp = $global;
foreach ($tmp as $index => $value) {
if (!in_array($index, $ignored_fields)) {
diff --git a/lib/Froxlor/System/Cronjob.php b/lib/Froxlor/System/Cronjob.php
index 71f86e81..29cae5ee 100644
--- a/lib/Froxlor/System/Cronjob.php
+++ b/lib/Froxlor/System/Cronjob.php
@@ -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']);
- }
-
- $text = $lng['crondesc'][$row['desc_lng_key']];
- $value = $lastrun;
-
- eval("\$cronjobs_last_run .= \"" . \Froxlor\UI\Template::getTemplate("index/overview_item") . "\";");
+ $cronjobs_last_run[] = [
+ 'title' => $lng['crondesc'][$row['desc_lng_key']],
+ 'lastrun' => $row['lastrun']
+ ];
}
-
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 = '
';
- $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 .= '' . $task_desc . ' ';
- }
+ $tasks[] = $task;
}
- if (trim($tasks) == '') {
- $value .= '' . $lng['tasks']['noneoutstanding'] . ' ';
- } else {
- $value .= $tasks;
+ if (empty($tasks)) {
+ $tasks = [['desc' => $lng['tasks']['noneoutstanding']]];
}
- $value .= ' ';
$text = $lng['tasks']['outstanding_tasks'];
- eval("\$outstanding_tasks = \"" . \Froxlor\UI\Template::getTemplate("index/overview_item") . "\";");
-
- return $outstanding_tasks;
+ return $tasks;
}
/**
diff --git a/templates/Froxlor/base.html.twig b/templates/Froxlor/base.html.twig
index f9913783..6e185c5a 100644
--- a/templates/Froxlor/base.html.twig
+++ b/templates/Froxlor/base.html.twig
@@ -8,11 +8,19 @@
- {{ theme_css|raw }}
+ {% if theme_css is empty %}
+
+ {% else %}
+ {{ theme_css|raw }}
+ {% endif %}
{% block custom_css %}{% endblock %}
- {{ theme_js|raw }}
+ {% if theme_js is empty %}
+
+ {% else %}
+ {{ theme_js|raw }}
+ {% endif %}
{% block custom_js %}{% endblock %}
Froxlor
{% if page_title %}
diff --git a/templates/Froxlor/user/index.html.twig b/templates/Froxlor/user/index.html.twig
index 6bad5acd..5fe0e87b 100644
--- a/templates/Froxlor/user/index.html.twig
+++ b/templates/Froxlor/user/index.html.twig
@@ -110,6 +110,31 @@
+ {% if userinfo.adminsession == 1 %}
+ {# froxlor-details #}
+