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