Allow delete Pool and plan when Router already deleted
This commit is contained in:
parent
1583068f57
commit
c69b43dbf6
@ -16,15 +16,15 @@ class Mikrotik
|
|||||||
public static function getClient($ip, $user, $pass)
|
public static function getClient($ip, $user, $pass)
|
||||||
{
|
{
|
||||||
global $ui;
|
global $ui;
|
||||||
try {
|
//try {
|
||||||
$iport = explode(":", $ip);
|
$iport = explode(":", $ip);
|
||||||
return new RouterOS\Client($iport[0], $user, $pass, ($iport[1]) ? $iport[1] : null);
|
return new RouterOS\Client($iport[0], $user, $pass, ($iport[1]) ? $iport[1] : null);
|
||||||
} catch (Exception $e) {
|
// } catch (Exception $e) {
|
||||||
$ui->assign("error_title", "Mikrotik Connection Error");
|
// $ui->assign("error_title", "Mikrotik Connection Error");
|
||||||
$ui->assign("error_message", "Unable to connect to the router : $ip<br>" . $e->getMessage() . '<br><pre>' . $e->getTraceAsString() . '</pre>');
|
// $ui->assign("error_message", "Unable to connect to the router : $ip<br>" . $e->getMessage() . '<br><pre>' . $e->getTraceAsString() . '</pre>');
|
||||||
$ui->display('router-error.tpl');
|
// $ui->display('router-error.tpl');
|
||||||
die();
|
// die();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isUserLogin($client, $username)
|
public static function isUserLogin($client, $username)
|
||||||
|
@ -63,8 +63,12 @@ switch ($action) {
|
|||||||
$mikrotik = Mikrotik::info($d['routers']);
|
$mikrotik = Mikrotik::info($d['routers']);
|
||||||
if ($d) {
|
if ($d) {
|
||||||
if ($d['routers'] != 'radius') {
|
if ($d['routers'] != 'radius') {
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
try{
|
||||||
Mikrotik::removePool($client, $d['pool_name']);
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
|
Mikrotik::removePool($client, $d['pool_name']);
|
||||||
|
}catch(Exception $e){
|
||||||
|
//ignore exception, it means router has already deleted
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$d->delete();
|
$d->delete();
|
||||||
|
|
||||||
|
@ -167,9 +167,13 @@ switch ($action) {
|
|||||||
if ($d['is_radius']) {
|
if ($d['is_radius']) {
|
||||||
Radius::planDelete($d['id']);
|
Radius::planDelete($d['id']);
|
||||||
} else {
|
} else {
|
||||||
$mikrotik = Mikrotik::info($d['routers']);
|
try{
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$mikrotik = Mikrotik::info($d['routers']);
|
||||||
Mikrotik::removeHotspotPlan($client, $d['name_plan']);
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
|
Mikrotik::removeHotspotPlan($client, $d['name_plan']);
|
||||||
|
}catch(Exception $e){
|
||||||
|
//ignore exception, it means router has already deleted
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$d->delete();
|
$d->delete();
|
||||||
@ -427,9 +431,13 @@ switch ($action) {
|
|||||||
if ($d['is_radius']) {
|
if ($d['is_radius']) {
|
||||||
Radius::planDelete($d['id']);
|
Radius::planDelete($d['id']);
|
||||||
} else {
|
} else {
|
||||||
$mikrotik = Mikrotik::info($d['routers']);
|
try{
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$mikrotik = Mikrotik::info($d['routers']);
|
||||||
Mikrotik::removePpoePlan($client, $d['name_plan']);
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
|
Mikrotik::removePpoePlan($client, $d['name_plan']);
|
||||||
|
}catch(Exception $e){
|
||||||
|
//ignore exception, it means router has already deleted
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$d->delete();
|
$d->delete();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user