mirror of
https://github.com/hotspotbilling/phpnuxbill.git
synced 2025-02-24 23:45:38 +08:00
Fix Customer self Deactivate Radius
This commit is contained in:
parent
0c0d7a963e
commit
a5a5969642
3 changed files with 25 additions and 14 deletions
|
@ -132,7 +132,7 @@ class Radius
|
|||
}
|
||||
}
|
||||
|
||||
public static function customerDeactivate($username)
|
||||
public static function customerDeactivate($username, $radiusDisconnect = true) {
|
||||
{
|
||||
global $radius_pass;
|
||||
$r = Radius::getTableCustomer()->where_equal('username', $username)->whereEqual('attribute', 'Cleartext-Password')->findOne();
|
||||
|
@ -141,7 +141,9 @@ class Radius
|
|||
// we just change the password
|
||||
$r->value = md5(time() . $username . $radius_pass);
|
||||
$r->save();
|
||||
return Radius::disconnectCustomer($username);
|
||||
if($radiusDisconnect)
|
||||
return Radius::disconnectCustomer($username);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
@ -307,7 +309,7 @@ class Radius
|
|||
if (!empty($n['ports'])) {
|
||||
$port = $n['ports'];
|
||||
}
|
||||
$result[] = $n['nasname'] . ': ' . 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;
|
||||
}
|
||||
|
|
|
@ -106,14 +106,23 @@ if(isset($_GET['recharge']) && $_GET['recharge'] == 1){
|
|||
}
|
||||
}else if(isset($_GET['deactivate']) && $_GET['deactivate'] == 1){
|
||||
if ($bill) {
|
||||
$mikrotik = Mikrotik::info($bill['routers']);
|
||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
if ($bill['type'] == 'Hotspot') {
|
||||
Mikrotik::removeHotspotUser($client, $bill['username']);
|
||||
Mikrotik::removeHotspotActiveUser($client, $bill['username']);
|
||||
} else if ($bill['type'] == 'PPPOE') {
|
||||
Mikrotik::removePpoeUser($client, $bill['username']);
|
||||
Mikrotik::removePpoeActive($client, $bill['username']);
|
||||
$p = ORM::for_table('tbl_plans')->where('id', $bill['plan_id'])->find_one();
|
||||
if($p['is_radius']){
|
||||
Radius::customerDeactivate($user['username']);
|
||||
}else{
|
||||
try{
|
||||
$mikrotik = Mikrotik::info($bill['routers']);
|
||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
if ($bill['type'] == 'Hotspot') {
|
||||
Mikrotik::removeHotspotUser($client, $bill['username']);
|
||||
Mikrotik::removeHotspotActiveUser($client, $bill['username']);
|
||||
} else if ($bill['type'] == 'PPPOE') {
|
||||
Mikrotik::removePpoeUser($client, $bill['username']);
|
||||
Mikrotik::removePpoeActive($client, $bill['username']);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
//ignore it maybe mikrotik has been deleted
|
||||
}
|
||||
}
|
||||
$bill->status = 'off';
|
||||
$bill->expiration = date('Y-m-d');
|
||||
|
|
|
@ -60,10 +60,10 @@ switch ($action) {
|
|||
$id = $routes['2'];
|
||||
run_hook('delete_pool'); #HOOK
|
||||
$d = ORM::for_table('tbl_pool')->find_one($id);
|
||||
$mikrotik = Mikrotik::info($d['routers']);
|
||||
if ($d) {
|
||||
if ($d['routers'] != 'radius') {
|
||||
try{
|
||||
$mikrotik = Mikrotik::info($d['routers']);
|
||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
Mikrotik::removePool($client, $d['pool_name']);
|
||||
}catch(Exception $e){
|
||||
|
@ -106,9 +106,9 @@ switch ($action) {
|
|||
if ($d) {
|
||||
$msg .= $_L['Pool_already_exist'] . '<br>';
|
||||
}
|
||||
$mikrotik = Mikrotik::info($routers);
|
||||
if ($msg == '') {
|
||||
if ($routers != 'radius') {
|
||||
$mikrotik = Mikrotik::info($routers);
|
||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
Mikrotik::addPool($client, $name, $ip_address);
|
||||
}
|
||||
|
@ -143,9 +143,9 @@ switch ($action) {
|
|||
$msg .= $_L['Data_Not_Found'] . '<br>';
|
||||
}
|
||||
|
||||
$mikrotik = Mikrotik::info($routers);
|
||||
if ($msg == '') {
|
||||
if ($routers != 'radius') {
|
||||
$mikrotik = Mikrotik::info($routers);
|
||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
Mikrotik::setPool($client, $d['pool_name'], $ip_address);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue