From 4d6041f614e1b7738aa53ab12aeb8708c8c8804e Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 22 Apr 2024 10:16:21 +0700 Subject: [PATCH] send Telegram for Extend --- system/controllers/home.php | 17 +++++++++++------ update.php | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/system/controllers/home.php b/system/controllers/home.php index ecb6aaaa..7e56f9a4 100644 --- a/system/controllers/home.php +++ b/system/controllers/home.php @@ -148,16 +148,18 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) { $router = $tur['routers']; } $p = ORM::for_table('tbl_plans')->findOne($tur['plan_id']); - $c = ORM::for_table('tbl_customers')->findOne($tur['customer_id']); + if(!$p){ + r2(U . 'home', '3', "Plan Not Found"); + } if ($tur['routers'] == 'radius') { - Radius::customerAddPlan($c, $p, $tur['expiration'] . ' ' . $tur['time']); + Radius::customerAddPlan($user, $p, $tur['expiration'] . ' ' . $tur['time']); } else { if ($tur['type'] == 'Hotspot') { - Mikrotik::removeHotspotUser($client, $c['username']); - Mikrotik::addHotspotUser($client, $p, $c); + Mikrotik::removeHotspotUser($client, $user['username']); + Mikrotik::addHotspotUser($client, $p, $user); } else if ($tur['type'] == 'PPPOE') { - Mikrotik::removePpoeUser($client, $c['username']); - Mikrotik::addPpoeUser($client, $p, $c); + Mikrotik::removePpoeUser($client, $user['username']); + Mikrotik::addPpoeUser($client, $p, $user); } } // make customer cannot extend again @@ -169,6 +171,9 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) { App::setToken(_get('stoken'), $id); file_put_contents($path, $m); _log("Customer $tur[customer_id] $tur[username] extend for $days days", "Customer", $user['id']); + Message::sendTelegram("#u$c[username] #extend #".$p['type']." \n" . $p['name_plan'] . + "\nLocation: " . $p['routers'] . + "\nNew Expired: " . Lang::dateAndTimeFormat($expiration, $tur['time'])); r2(U . 'home', 's', "Extend until $expiration"); }else{ r2(U . 'home', 'e', "Plan is not expired"); diff --git a/update.php b/update.php index b5eb0e06..fa60c5d3 100644 --- a/update.php +++ b/update.php @@ -141,12 +141,12 @@ function r2($to, $ntype = 'e', $msg = '') { if ($msg == '') { header("location: $to"); - exit; + die(); } $_SESSION['ntype'] = $ntype; $_SESSION['notify'] = $msg; header("location: $to"); - exit; + die(); } function copyFolder($from, $to, $exclude = [])