From 723e99ebedc231e502707621ec169cd1da57aa57 Mon Sep 17 00:00:00 2001 From: Focuslinkstech <45756999+Focuslinkstech@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:19:13 +0100 Subject: [PATCH] fix panel headers in css, add cron job monitor to check if cron is running, has run, or not setup --- system/controllers/dashboard.php | 6 +++ system/cron.php | 69 ++++++++++++++++++-------------- ui/ui/dashboard.tpl | 17 ++++++++ ui/ui/sections/header.tpl | 30 ++++++++++++-- 4 files changed, 87 insertions(+), 35 deletions(-) diff --git a/system/controllers/dashboard.php b/system/controllers/dashboard.php index 4d1c9849..9f1185b0 100644 --- a/system/controllers/dashboard.php +++ b/system/controllers/dashboard.php @@ -214,6 +214,12 @@ if ($config['router_check']) { $ui->assign('routeroffs', $routeroffs); } +$timestampFile = "$UPLOAD_PATH/cron_last_run.txt"; +if (file_exists($timestampFile)) { + $lastRunTime = file_get_contents($timestampFile); + $ui->assign('run_date', date('Y-m-d h:i:s A', $lastRunTime)); +} + // Assign the monthly sales data to Smarty $ui->assign('start_date', $start_date); $ui->assign('current_date', $current_date); diff --git a/system/cron.php b/system/cron.php index e4e6719c..81d9f423 100644 --- a/system/cron.php +++ b/system/cron.php @@ -1,6 +1,27 @@ where('enabled', '1')->find_many(); if (!$routers) { echo "No active routers found in the database.\n"; @@ -186,14 +187,20 @@ if ($config['router_check']) { Message::SendEmail($adminEmail, $subject, $message); sendTelegram($message); } - - if (defined('PHP_SAPI') && PHP_SAPI === 'cli') { - echo "Cronjob finished\n"; - } else { - echo ""; - } - - flock($lock, LOCK_UN); - fclose($lock); - unlink($lockFile); + echo "Router monitoring finished\n"; } + + +if (defined('PHP_SAPI') && PHP_SAPI === 'cli') { + echo "Cronjob finished\n"; +} else { + echo ""; +} + +flock($lock, LOCK_UN); +fclose($lock); +unlink($lockFile); + +$timestampFile = "$UPLOAD_PATH/cron_last_run.txt"; +file_put_contents($timestampFile, time()); + diff --git a/ui/ui/dashboard.tpl b/ui/ui/dashboard.tpl index eb6788da..7a998ba8 100644 --- a/ui/ui/dashboard.tpl +++ b/ui/ui/dashboard.tpl @@ -194,6 +194,23 @@ {/if} + {if $run_date} + {if $current_time - $run_time > 3600} +