From 29c8cb3ea16b1f8b02f452fd834834d7ceae6b27 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 10 Jun 2024 16:53:10 +0700 Subject: [PATCH] fix burst --- system/devices/MikrotikHotspot.php | 20 ++++++++++++++------ system/devices/radius.php | 11 +++++++---- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/system/devices/MikrotikHotspot.php b/system/devices/MikrotikHotspot.php index a2d88c38..5968401d 100644 --- a/system/devices/MikrotikHotspot.php +++ b/system/devices/MikrotikHotspot.php @@ -63,17 +63,21 @@ class MikrotikHotspot } $mikrotik = $this->info($plan['routers']); $client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - if ($plan['rate_down_unit'] == 'Kbps') { + $bw = ORM::for_table("tbl_bandwidth")->find_one($plan['id_bw']); + if ($bw['rate_down_unit'] == 'Kbps') { $unitdown = 'K'; } else { $unitdown = 'M'; } - if ($plan['rate_up_unit'] == 'Kbps') { + if ($bw['rate_up_unit'] == 'Kbps') { $unitup = 'K'; } else { $unitup = 'M'; } - $rate = $plan['rate_up'] . $unitup . "/" . $plan['rate_down'] . $unitdown; + $rate = $bw['rate_up'] . $unitup . "/" . $bw['rate_down'] . $unitdown; + if(!empty(trim($bw['burst']))){ + $rate .= ' '.$bw['burst']; + } $addRequest = new RouterOS\Request('/ip/hotspot/user/profile/add'); $client->sendSync( $addRequest @@ -154,17 +158,21 @@ class MikrotikHotspot if (empty($profileID)) { $this->add_plan($new_plan); } else { - if ($new_plan['rate_down_unit'] == 'Kbps') { + $bw = ORM::for_table("tbl_bandwidth")->find_one($new_plan['id_bw']); + if ($bw['rate_down_unit'] == 'Kbps') { $unitdown = 'K'; } else { $unitdown = 'M'; } - if ($new_plan['rate_up_unit'] == 'Kbps') { + if ($bw['rate_up_unit'] == 'Kbps') { $unitup = 'K'; } else { $unitup = 'M'; } - $rate = $new_plan['rate_up'] . $unitup . "/" . $new_plan['rate_down'] . $unitdown; + $rate = $bw['rate_up'] . $unitup . "/" . $bw['rate_down'] . $unitdown; + if(!empty(trim($bw['burst']))){ + $rate .= ' '.$bw['burst']; + } $setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set'); $client->sendSync( $setRequest diff --git a/system/devices/radius.php b/system/devices/radius.php index b1cadb39..0d559674 100644 --- a/system/devices/radius.php +++ b/system/devices/radius.php @@ -38,18 +38,21 @@ class Radius { function add_plan($plan) { - if ($plan['rate_down_unit'] == 'Kbps') { + $bw = ORM::for_table("tbl_bandwidth")->find_one($plan['id_bw']); + if ($bw['rate_down_unit'] == 'Kbps') { $unitdown = 'K'; } else { $unitdown = 'M'; } - if ($plan['rate_up_unit'] == 'Kbps') { + if ($bw['rate_up_unit'] == 'Kbps') { $unitup = 'K'; } else { $unitup = 'M'; } - $rate = $plan['rate_up'] . $unitup . "/" . $plan['rate_down'] . $unitdown; - + $rate = $bw['rate_up'] . $unitup . "/" . $bw['rate_down'] . $unitdown; + if(!empty(trim($bw['burst']))){ + $rate .= ' '.$bw['burst']; + } $rates = explode('/', $rate); ##burst fixed if (strpos($rate, ' ')) {