From ced0d487e7f257d0ceaa7c8d29912258f28c1421 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 14 Aug 2024 09:11:11 +0700 Subject: [PATCH] Fix rad_acct --- radius.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/radius.php b/radius.php index 24fb5784..09e09bff 100644 --- a/radius.php +++ b/radius.php @@ -264,7 +264,7 @@ try { } header("HTTP/1.1 200 ok"); $d = ORM::for_table('rad_acct') - ->whereRaw("BINARY `code` = '$username'") + ->whereRaw("BINARY `username` = '$username'") ->where('acctstatustype', _post('acctStatusType')) ->findOne(); if (!$d) { @@ -275,7 +275,7 @@ try { if (_post('acctStatusType') == 'Stop') { // log in the Start only $start = ORM::for_table('rad_acct') - ->whereRaw("BINARY `code` = '$username'") + ->whereRaw("BINARY `username` = '$username'") ->where('acctstatustype', 'Start') ->findOne(); if (!$start) { @@ -288,6 +288,17 @@ try { $start->acctOutputOctets = 0; $start->acctInputOctets = 0; } + $start->acctsessionid = _post('acctSessionId'); + $start->username = $username; + $start->realm = _post('realm'); + $start->nasipaddress = _post('nasip'); + $start->nasid = _post('nasid'); + $start->nasportid = _post('nasPortId'); + $start->nasporttype = _post('nasPortType'); + $start->framedipaddress = _post('framedIPAddress'); + $start->acctstatustype = _post('acctStatusType'); + $start->macaddr = _post('macAddr'); + $start->dateAdded = date('Y-m-d H:i:s'); $start->save(); $d->acctOutputOctets = 0; $d->acctInputOctets = 0; @@ -392,7 +403,7 @@ function process_radiust_rest($tur, $code) if ($plan['typebp'] == "Limited") { if ($plan['limit_type'] == "Data_Limit" || $plan['limit_type'] == "Both_Limit") { - $raddact = ORM::for_table('rad_acct')->whereRaw("BINARY `code` = '$tur[username]'")->where('acctstatustype', 'Start')->find_one(); + $raddact = ORM::for_table('rad_acct')->whereRaw("BINARY `username` = '$tur[username]'")->where('acctstatustype', 'Start')->find_one(); $totalUsage = intval($raddact['acctOutputOctets']) + intval($raddact['acctInputOctets']); $attrs['reply:Mikrotik-Total-Limit'] = Text::convertDataUnit($plan['data_limit'], $plan['data_unit']) - $totalUsage; if ($attrs['reply:Mikrotik-Total-Limit'] < 0) {