From 5867a0c9caaab3b395a3bcf0a3a8c3da58fc89cd Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 15 Jan 2024 10:22:03 +0700 Subject: [PATCH] Fix Cron for --- CHANGELOG.md | 4 ++++ system/boot.php | 19 ++++++++++++------- system/cron.php | 24 ++++++++++++++++-------- system/cron_reminder.php | 8 +++++++- version.json | 2 +- 5 files changed, 40 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1be54699..2453b43a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ # CHANGELOG +## 2024.1.15 + +- Fix cron job for Plan only for admin by @Focuslinkstech + ## 2024.1.11 - Add Plan only for admin by @Focuslinkstech diff --git a/system/boot.php b/system/boot.php index 56ed2d60..5bd9fdb6 100644 --- a/system/boot.php +++ b/system/boot.php @@ -118,7 +118,7 @@ try { $ui->assign("error_title", "PHPNuxBill Crash"); if (isset($_SESSION['uid'])) { $ui->assign("error_message", $e->getMessage() . '
'); - }else{ + } else { $ui->assign("error_message", $e->getMessage() . '
' . $e->getTraceAsString() . '
'); } $ui->display('router-error.tpl'); @@ -130,13 +130,13 @@ function _notify($msg, $type = 'e') $_SESSION['ntype'] = $type; $_SESSION['notify'] = $msg; } -if(empty($config['language'])){ +if (empty($config['language'])) { $config['language'] = 'english'; } $lan_file = File::pathFixer('system/lan/' . $config['language'] . '/common.lan.php'); -if(file_exists($lan_file)){ +if (file_exists($lan_file)) { require $lan_file; -}else{ +} else { die("$lan_file not found"); } @@ -190,7 +190,11 @@ $_notifmsg_default = json_decode(file_get_contents(File::pathFixer('system/uploa //register all plugin foreach (glob(File::pathFixer("system/plugin/*.php")) as $filename) { - include $filename; + try { + include $filename; + } catch (Throwable $e) { + } catch (Exception $e) { + } } @@ -293,7 +297,8 @@ function time_elapsed_string($datetime, $full = false) } } - if (!$full) $string = array_slice($string, 0, 1); + if (!$full) + $string = array_slice($string, 0, 1); return $string ? implode(', ', $string) . ' ago' : 'just now'; } @@ -340,7 +345,7 @@ try { } } catch (Exception $e) { if (!isset($_SESSION['aid']) || empty($_SESSION['aid'])) { - r2(U . 'home' , 'e', $e->getMessage()); + r2(U . 'home', 'e', $e->getMessage()); } $ui->assign("error_message", $e->getMessage() . '
' . $e->getTraceAsString() . '
'); $ui->assign("error_title", "PHPNuxBill Crash"); diff --git a/system/cron.php b/system/cron.php index cac928ab..eda037d0 100644 --- a/system/cron.php +++ b/system/cron.php @@ -35,16 +35,16 @@ if (php_sapi_name() !== 'cli') { echo "
";
 }
 
-if(!file_exists('../config.php')){
+if (!file_exists('../config.php')) {
     die("config.php file not found");
 }
 
 
-if(!file_exists('orm.php')){
+if (!file_exists('orm.php')) {
     die("orm.php file not found");
 }
 
-if(!file_exists('uploads/notifications.default.json')){
+if (!file_exists('uploads/notifications.default.json')) {
     die("uploads/notifications.default.json file not found");
 }
 
@@ -68,7 +68,13 @@ $_notifmsg_default = json_decode(file_get_contents('uploads/notifications.defaul
 
 //register all plugin
 foreach (glob(File::pathFixer("plugin/*.php")) as $filename) {
-    include $filename;
+    try{
+        include $filename;
+    } catch(Throwable $e){
+        //ignore plugin error
+    }catch(Exception $e){
+        //ignore plugin error
+    }
 }
 
 $result = ORM::for_table('tbl_appconfig')->find_many();
@@ -137,7 +143,7 @@ foreach ($d as $ds) {
 
             // autorenewal from deposit
             if ($config['enable_balance'] == 'yes' && $c['auto_renewal']) {
-                if ($p && $p['enabled'] && $c['balance'] >= $p['price'] && $p['allow_purchase'] =='yes') {
+                if ($p && $p['enabled'] && $c['balance'] >= $p['price'] && $p['allow_purchase'] == 'yes') {
                     if (Package::rechargeUser($ds['customer_id'], $p['routers'], $p['id'], 'Customer', 'Balance')) {
                         // if success, then get the balance
                         Balance::min($ds['customer_id'], $p['price']);
@@ -156,7 +162,8 @@ foreach ($d as $ds) {
             } else {
                 echo "no renewall | balance $config[enable_balance] auto_renewal $c[auto_renewal]\n";
             }
-        } else echo " : ACTIVE \r\n";
+        } else
+            echo " : ACTIVE \r\n";
     } else {
         $date_now = strtotime(date("Y-m-d H:i:s"));
         $expiration = strtotime($ds['expiration'] . ' ' . $ds['time']);
@@ -191,7 +198,7 @@ foreach ($d as $ds) {
 
             // autorenewal from deposit
             if ($config['enable_balance'] == 'yes' && $c['auto_renewal']) {
-                if ($p && $p['enabled'] && $c['balance'] >= $p['price']&& $p['allow_purchase'] =='yes') {
+                if ($p && $p['enabled'] && $c['balance'] >= $p['price'] && $p['allow_purchase'] == 'yes') {
                     if (Package::rechargeUser($ds['customer_id'], $p['routers'], $p['id'], 'Customer', 'Balance')) {
                         // if success, then get the balance
                         Balance::min($ds['customer_id'], $p['price']);
@@ -206,6 +213,7 @@ foreach ($d as $ds) {
                     }
                 }
             }
-        } else echo " : ACTIVE \r\n";
+        } else
+            echo " : ACTIVE \r\n";
     }
 }
diff --git a/system/cron_reminder.php b/system/cron_reminder.php
index 1b77aac8..d15fa953 100644
--- a/system/cron_reminder.php
+++ b/system/cron_reminder.php
@@ -67,7 +67,13 @@ $_notifmsg_default = json_decode(file_get_contents('uploads/notifications.defaul
 
 //register all plugin
 foreach (glob(File::pathFixer("plugin/*.php")) as $filename) {
-    include $filename;
+    try{
+        include $filename;
+    } catch(Throwable $e){
+        //ignore plugin error
+    }catch(Exception $e){
+        //ignore plugin error
+    }
 }
 
 $result = ORM::for_table('tbl_appconfig')->find_many();
diff --git a/version.json b/version.json
index 9fdb534f..8cd16b4f 100644
--- a/version.json
+++ b/version.json
@@ -1,3 +1,3 @@
 {
-    "version": "2024.1.11"
+    "version": "2024.1.15"
 }
\ No newline at end of file