From 14ed0236d0b5773f89d5f6eb74a180d4ae86d0ac Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Thu, 7 Sep 2023 09:35:00 +0700 Subject: [PATCH] Remove active user Before remove user --- system/autoload/Package.php | 16 ++++++++++++++++ system/cron.php | 14 ++++++++++++++ system/cron_reminder.php | 28 ++++++++++++++++++++-------- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 4b3a491..7eadb40 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -97,6 +97,8 @@ class Package if ($b) { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotActiveUser($client, $c['username']); + Mikrotik::removePpoeActive($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addHotspotUser($client, $p, $c); @@ -152,6 +154,8 @@ class Package } else { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotActiveUser($client, $c['username']); + Mikrotik::removePpoeActive($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addHotspotUser($client, $p, $c); @@ -197,6 +201,8 @@ class Package if ($b) { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotActiveUser($client, $c['username']); + Mikrotik::removePpoeActive($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addPpoeUser($client, $p, $c); @@ -253,6 +259,8 @@ class Package } else { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotActiveUser($client, $c['username']); + Mikrotik::removePpoeActive($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addPpoeUser($client, $p, $c); @@ -332,6 +340,8 @@ class Package if ($b) { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotActiveUser($client, $c['username']); + Mikrotik::removePpoeActive($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addHotspotUser($client, $p, $c); @@ -339,6 +349,8 @@ class Package } else { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotActiveUser($client, $c['username']); + Mikrotik::removePpoeActive($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addHotspotUser($client, $p, $c); @@ -348,6 +360,8 @@ class Package if ($b) { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotActiveUser($client, $c['username']); + Mikrotik::removePpoeActive($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addPpoeUser($client, $p, $c); @@ -355,6 +369,8 @@ class Package } else { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotActiveUser($client, $c['username']); + Mikrotik::removePpoeActive($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addPpoeUser($client, $p, $c); diff --git a/system/cron.php b/system/cron.php index da89c13..2ab7cc5 100644 --- a/system/cron.php +++ b/system/cron.php @@ -28,6 +28,12 @@ function _autoloader($class) } spl_autoload_register('_autoloader'); + +if(php_sapi_name() !== 'cli'){ + echo "
";
+}
+
+
 require_once '../config.php';
 require_once 'orm.php';
 require_once 'autoload/PEAR2/Autoload.php';
@@ -56,6 +62,14 @@ foreach ($result as $value) {
     $config[$value['setting']] = $value['value'];
 }
 
+echo "PHP Time\t" . date('Y-m-d H:i:s') . "\n";
+$res = ORM::raw_execute('SELECT NOW() AS WAKTU;');
+$statement = ORM::get_last_statement();
+$rows = array();
+while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
+    echo "MYSQL Time\t" . $row['WAKTU'] . "\n";
+}
+
 $_c = $config;
 
 date_default_timezone_set($config['timezone']);
diff --git a/system/cron_reminder.php b/system/cron_reminder.php
index e06e6aa..5a55e18 100644
--- a/system/cron_reminder.php
+++ b/system/cron_reminder.php
@@ -12,16 +12,16 @@ function _autoloader($class)
 {
     if (strpos($class, '_') !== false) {
         $class = str_replace('_', DIRECTORY_SEPARATOR, $class);
-        if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
-            include __DIR__.DIRECTORY_SEPARATOR.'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
+        if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
+            include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
         } else {
             $class = str_replace("\\", DIRECTORY_SEPARATOR, $class);
             if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'))
                 include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
         }
     } else {
-        if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
-            include __DIR__.DIRECTORY_SEPARATOR.'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
+        if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
+            include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
         } else {
             $class = str_replace("\\", DIRECTORY_SEPARATOR, $class);
             if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'))
@@ -31,10 +31,14 @@ function _autoloader($class)
 }
 spl_autoload_register('_autoloader');
 
- require_once '../config.php';
- require_once 'orm.php';
- require_once 'autoload/PEAR2/Autoload.php';
- include "autoload/Hookers.php";
+if(php_sapi_name() !== 'cli'){
+    echo "
";
+}
+
+require_once '../config.php';
+require_once 'orm.php';
+require_once 'autoload/PEAR2/Autoload.php';
+include "autoload/Hookers.php";
 
 ORM::configure("mysql:host=$db_host;dbname=$db_name");
 ORM::configure('username', $db_user);
@@ -65,6 +69,14 @@ $d = ORM::for_table('tbl_user_recharges')->where('status', 'on')->find_many();
 run_hook('cronjob_reminder'); #HOOK
 
 
+echo "PHP Time\t" . date('Y-m-d H:i:s') . "\n";
+$res = ORM::raw_execute('SELECT NOW() AS WAKTU;');
+$statement = ORM::get_last_statement();
+$rows = array();
+while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
+    echo "MYSQL Time\t" . $row['WAKTU'] . "\n";
+}
+
 
 $day7 = date('Y-m-d', strtotime("+7 day"));
 $day3 = date('Y-m-d', strtotime("+3 day"));