diff --git a/system/autoload/Radius.php b/system/autoload/Radius.php index 687ae82e..11862658 100644 --- a/system/autoload/Radius.php +++ b/system/autoload/Radius.php @@ -1,5 +1,8 @@ where_equal('username', $customer['username'])->findOne(); if ($p) { // if exists $p->groupname = "plan_" . $plan['id']; - return $p->save(); + $p->save(); } else { $p = Radius::getTableUserPackage()->create(); $p->username = $customer['username']; $p->groupname = "plan_" . $plan['id']; $p->priority = 1; - return $p->save(); + $p->save(); } - //expired - if ($plan['type'] == 'HOTSPOT') { - + if ($plan['type'] == 'HOTSPOT' && $plan['typebp'] == "Limited") { + if ($plan['limit_type'] == "Time_Limit") { + if ($plan['time_unit'] == 'Hrs') + $timelimit = $plan['time_limit'] * 60 * 60; + else + $timelimit = $plan['time_limit'] * 60; + Radius::upsertCustomer($customer['username'], 'Expire-After', $timelimit); + } else if ($plan['limit_type'] == "Data_Limit") { + if ($plan['data_unit'] == 'GB') + $datalimit = $plan['data_limit'] . "000000000"; + else + $datalimit = $plan['data_limit'] . "000000"; + Radius::upsertCustomer($customer['username'], 'Max-Volume', $datalimit); + } else if ($plan['limit_type'] == "Both_Limit") { + if ($plan['time_unit'] == 'Hrs') + $timelimit = $plan['time_limit'] * 60 * 60; + else + $timelimit = $plan['time_limit'] . ":00"; + if ($plan['data_unit'] == 'GB') + $datalimit = $plan['data_limit'] . "000000000"; + else + $datalimit = $plan['data_limit'] . "000000"; + Radius::upsertCustomer($customer['username'], 'Max-Volume', $datalimit); + Radius::upsertCustomer($customer['username'], 'Expire-After', $timelimit); + } + }else{ + Radius::getTableCustomer()->where_equal('username', $customer['username'])->whereEqual('attribute', 'Max-Volume')->delete(); + Radius::getTableCustomer()->where_equal('username', $customer['username'])->whereEqual('attribute', 'Expire-After')->delete(); } - Radius::upsertCustomer($customer['username'], 'expiration', date('d M Y H:i:s', strtotime($expired))); + // expired user + if($expired!=null){ + Radius::upsertCustomer($customer['username'], 'expiration', date('d M Y H:i:s', strtotime($expired))); + }else{ + Radius::getTableCustomer()->where_equal('username', $customer['username'])->whereEqual('attribute', 'expiration')->delete(); + } + return true; } return false; } diff --git a/system/controllers/settings.php b/system/controllers/settings.php index 6d44be51..eb6ce970 100644 --- a/system/controllers/settings.php +++ b/system/controllers/settings.php @@ -23,6 +23,14 @@ switch ($action) { $logo = 'system/uploads/logo.default.png'; } $ui->assign('logo', $logo); + if(empty($_c['radius_client'])){ + try{ + $_c['radius_client'] = shell_exec('which radclient'); + $ui->assign('_c', $_c); + }catch(Exception $e){ + //ignore + } + } run_hook('view_app_settings'); #HOOK $ui->display('app-settings.tpl'); break; @@ -234,6 +242,7 @@ switch ($action) { $http_proxy = _post('http_proxy'); $http_proxyauth = _post('http_proxyauth'); $radius_enable = _post('radius_enable'); + $radius_client = _post('radius_client'); run_hook('save_settings'); #HOOK @@ -448,6 +457,17 @@ switch ($action) { $d->save(); } + $d = ORM::for_table('tbl_appconfig')->where('setting', 'radius_client')->find_one(); + if ($d) { + $d->value = $radius_client; + $d->save(); + } else { + $d = ORM::for_table('tbl_appconfig')->create(); + $d->setting = 'radius_client'; + $d->value = $radius_client; + $d->save(); + } + $note = _post('note'); $d = ORM::for_table('tbl_appconfig')->where('setting', 'note')->find_one(); $d->value = $note; diff --git a/ui/ui/app-settings.tpl b/ui/ui/app-settings.tpl index 67fe3ce3..0c9bd223 100644 --- a/ui/ui/app-settings.tpl +++ b/ui/ui/app-settings.tpl @@ -82,6 +82,12 @@
Radius Not Yet Ready
+