From 6a6434b39c044f1ff332e9216fd1fa43aa1f0c88 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 16 Oct 2023 10:15:45 +0700 Subject: [PATCH] radius move to expired pool --- system/autoload/Radius.php | 2 +- system/cron.php | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/system/autoload/Radius.php b/system/autoload/Radius.php index ae0d3592..c89a188a 100644 --- a/system/autoload/Radius.php +++ b/system/autoload/Radius.php @@ -283,7 +283,7 @@ class Radius /** * To insert or update existing customer Attribute */ - private static function upsertCustomerAttr($username, $attr, $value, $op = ':=') + public static function upsertCustomerAttr($username, $attr, $value, $op = ':=') { $r = Radius::getTableCustomerAttr()->where_equal('username', $username)->whereEqual('attribute', $attr)->find_one(); if (!$r) { diff --git a/system/cron.php b/system/cron.php index 3636ceff..38036596 100644 --- a/system/cron.php +++ b/system/cron.php @@ -103,8 +103,13 @@ foreach ($d as $ds) { $p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one(); if ($p['is_radius']) { - echo Radius::customerDeactivate($c['username']); - }else{ + if (!empty($p['pool_expired'])) { + print_r(Radius::customerDeactivate($c['username'])); + } else { + Radius::upsertCustomerAttr($c['username'], 'Framed-Pool', $plan['pool_expired'], ':='); + print_r(Radius::disconnectCustomer($c['username'])); + } + } else { $client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); if (!empty($p['pool_expired'])) { Mikrotik::setHotspotUserPackage($client, $c['username'], 'EXPIRED NUXBILL ' . $p['pool_expired']); @@ -152,8 +157,13 @@ foreach ($d as $ds) { $p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one(); if ($p['is_radius']) { - echo Radius::customerDeactivate($c['username']); - }else{ + if (!empty($p['pool_expired'])) { + print_r(Radius::customerDeactivate($c['username'])); + } else { + Radius::upsertCustomerAttr($c['username'], 'Framed-Pool', $plan['pool_expired'], ':='); + print_r(Radius::disconnectCustomer($c['username'])); + } + } else { $client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); if (!empty($p['pool_expired'])) { Mikrotik::setPpoeUserPlan($client, $c['username'], 'EXPIRED NUXBILL ' . $p['pool_expired']);