diff --git a/system/autoload/Radius.php b/system/autoload/Radius.php
index 7b2d278c..ef8736f9 100644
--- a/system/autoload/Radius.php
+++ b/system/autoload/Radius.php
@@ -130,8 +130,9 @@ class Radius
// we just change the password
$r->value = md5(time() . $username . $radius_pass);
$r->save();
- Radius::disconnectCustomer($username);
+ return Radius::disconnectCustomer($username);
}
+ return '';
}
public static function customerDelete($username)
@@ -158,7 +159,7 @@ class Radius
$p->priority = 1;
$p->save();
}
- if ($plan['type'] == 'HOTSPOT' && $plan['typebp'] == "Limited") {
+ if ($plan['type'] == 'Hotspot' && $plan['typebp'] == "Limited") {
if ($plan['limit_type'] == "Time_Limit") {
if ($plan['time_unit'] == 'Hrs')
$timelimit = $plan['time_limit'] * 60 * 60;
@@ -184,14 +185,17 @@ class Radius
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();
+ $r = Radius::getTableCustomer()->where_equal('username', $customer['username'])->whereEqual('attribute', 'Max-Volume')->findOne();
+ if($r) $r->delete();
+ $r = Radius::getTableCustomer()->where_equal('username', $customer['username'])->whereEqual('attribute', 'Expire-After')->findOne();
+ if($r) $r->delete();
}
// 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();
+ $r = Radius::getTableCustomer()->where_equal('username', $customer['username'])->whereEqual('attribute', 'expiration')->findOne();
+ if($r) $r->delete();
}
return true;
}
@@ -206,7 +210,7 @@ class Radius
Radius::upsertCustomer($customer['username'], 'Cleartext-Password', $customer['password']);
}
Radius::upsertCustomer($customer['username'], 'Simultaneous-Use', ($plan['type'] == 'PPPOE') ? 1 : $plan['shared_users']);
- return false;
+ return true;
}
/**
@@ -246,12 +250,14 @@ class Radius
$nas = Radius::getTableNas()->findMany();
$count = count($nas)*15;
set_time_limit($count);
+ $result = [];
foreach ($nas as $n){
$port = 3799;
if(!empty($n['ports'])){
$port = $n['ports'];
}
- shell_exec("echo 'User-Name = $username' | ".Radius::getClient()." ".trim($n['nasname']).":$port disconnect '".$n['secret']."'");
+ $result[] = $n['nasname'].': '.shell_exec("echo 'User-Name = $username' | ".Radius::getClient()." ".trim($n['nasname']).":$port disconnect '".$n['secret']."'");
}
+ return $result;
}
}
diff --git a/system/boot.php b/system/boot.php
index 353fc16a..141765c2 100644
--- a/system/boot.php
+++ b/system/boot.php
@@ -338,7 +338,7 @@ try {
}
} catch (Exception $e) {
$ui->assign("error_title", "PHPNuxBill Crash");
- $ui->assign("error_message", $e->getMessage());
+ $ui->assign("error_message", $e->getMessage().'
'.$e->getTraceAsString().''); $ui->display('router-error.tpl'); die(); } diff --git a/system/controllers/accounts.php b/system/controllers/accounts.php index 0e2e3064..0dfa4959 100644 --- a/system/controllers/accounts.php +++ b/system/controllers/accounts.php @@ -1,8 +1,11 @@ assign('_title', $_L['My_Account']); $ui->assign('_system_menu', 'accounts'); @@ -11,10 +14,6 @@ $action = $routes['1']; $user = User::_info(); $ui->assign('_user', $user); -use PEAR2\Net\RouterOS; - -require_once 'system/autoload/PEAR2/Autoload.php'; - switch ($action) { case 'change-password': diff --git a/system/controllers/prepaid.php b/system/controllers/prepaid.php index b6094d1d..a227dc1c 100644 --- a/system/controllers/prepaid.php +++ b/system/controllers/prepaid.php @@ -41,21 +41,24 @@ switch ($action) { case 'sync': set_time_limit(-1); $plans = ORM::for_table('tbl_user_recharges')->where('status', 'on')->find_many(); - echo count($plans); $log = ''; $router = ''; foreach ($plans as $plan) { - if ($router != $plan['routers']) { + if ($router != $plan['routers'] && $plan['routers'] != 'radius') { $mikrotik = Mikrotik::info($plan['routers']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $router = $plan['routers']; } $p = ORM::for_table('tbl_plans')->findOne($plan['plan_id']); $c = ORM::for_table('tbl_customers')->findOne($plan['customer_id']); - if ($plan['type'] == 'Hotspot') { - Mikrotik::addHotspotUser($client, $p, $c); - } else if ($plan['type'] == 'PPPOE') { - Mikrotik::addPpoeUser($client, $p, $c); + if($plan['routers'] == 'radius'){ + Radius::customerAddPlan($c, $p, $plans['expiration'].' '.$plans['time']); + }else{ + if ($plan['type'] == 'Hotspot') { + Mikrotik::addHotspotUser($client, $p, $c); + } else if ($plan['type'] == 'PPPOE') { + Mikrotik::addPpoeUser($client, $p, $c); + } } $log .= "DONE : $plan[username], $plan[namebp], $plan[type], $plan[routers]