Radius name reserved

This commit is contained in:
Ibnu Maksum 2023-10-04 16:25:21 +07:00
parent b2a99def98
commit 0bb20d4a16
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
3 changed files with 30 additions and 42 deletions

View File

@ -42,30 +42,24 @@ switch ($action) {
$c = ORM::for_table('tbl_user_recharges')->where('username', $user['username'])->find_one(); $c = ORM::for_table('tbl_user_recharges')->where('username', $user['username'])->find_one();
if ($c) { if ($c) {
$p = ORM::for_table('tbl_plans')->where('id', $c['plan_id'])->find_one();
if($p['is_radius']){
if($c['type'] == 'Hotspot' || ($c['type'] == 'PPPOE' && empty($d['pppoe_password']))){
Radius::customerAdd($d, $p);
}
}else{
$mikrotik = Mikrotik::info($c['routers']); $mikrotik = Mikrotik::info($c['routers']);
if ($c['type'] == 'Hotspot') {
if (!$config['radius_enable']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
if ($c['type'] == 'Hotspot') {
Mikrotik::setHotspotUser($client, $c['username'], $npass); Mikrotik::setHotspotUser($client, $c['username'], $npass);
Mikrotik::removeHotspotActiveUser($client, $user['username']); Mikrotik::removeHotspotActiveUser($client, $user['username']);
} } else if(empty($d['pppoe_password'])){
$d->password = $npass; // only change when pppoe_password empty
$d->save();
_msglog('s', $_L['Password_Changed_Successfully']);
_log('[' . $user['username'] . ']: Password changed successfully', 'User', $user['id']);
r2(U . 'login');
} else {
if (!$config['radius_enable']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
if(!empty($d['pppoe_password'])){
Mikrotik::setPpoeUser($client, $c['username'], $d['pppoe_password']);
}else{
Mikrotik::setPpoeUser($client, $c['username'], $npass); Mikrotik::setPpoeUser($client, $c['username'], $npass);
}
Mikrotik::removePpoeActive($client, $user['username']); Mikrotik::removePpoeActive($client, $user['username']);
} }
}
}
$d->password = $npass; $d->password = $npass;
$d->save(); $d->save();
@ -73,16 +67,6 @@ switch ($action) {
_log('[' . $user['username'] . ']: Password changed successfully', 'User', $user['id']); _log('[' . $user['username'] . ']: Password changed successfully', 'User', $user['id']);
r2(U . 'login'); r2(U . 'login');
}
} else {
$d->password = $npass;
$d->save();
_msglog('s', $_L['Password_Changed_Successfully']);
_log('[' . $user['username'] . ']: Password changed successfully', 'User', $user['id']);
r2(U . 'login');
}
} else { } else {
r2(U . 'accounts/change-password', 'e', $_L['Incorrect_Current_Password']); r2(U . 'accounts/change-password', 'e', $_L['Incorrect_Current_Password']);
} }

View File

@ -60,7 +60,7 @@ switch ($action) {
$d = ORM::for_table('tbl_pool')->find_one($id); $d = ORM::for_table('tbl_pool')->find_one($id);
$mikrotik = Mikrotik::info($d['routers']); $mikrotik = Mikrotik::info($d['routers']);
if ($d) { if ($d) {
if (!$config['radius_enable']) { if ($d['routers']!='radius') {
$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']);
} }
@ -100,7 +100,7 @@ switch ($action) {
} }
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
if ($msg == '') { if ($msg == '') {
if (!$config['radius_enable'] && $routers != 'radius') { if ($routers != 'radius') {
$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);
} }

View File

@ -88,10 +88,12 @@ switch ($action) {
if ($d) { if ($d) {
$msg .= $_L['Router_already_exist'] . '<br>'; $msg .= $_L['Router_already_exist'] . '<br>';
} }
if (strtolower($name) == 'radius') {
Mikrotik::getClient($ip_address, $username, $password); $msg .= '<b>Radius</b> name is reserved<br>';
}
if ($msg == '') { if ($msg == '') {
Mikrotik::getClient($ip_address, $username, $password);
run_hook('add_router'); #HOOK run_hook('add_router'); #HOOK
$d = ORM::for_table('tbl_routers')->create(); $d = ORM::for_table('tbl_routers')->create();
$d->name = $name; $d->name = $name;
@ -146,11 +148,13 @@ switch ($action) {
} }
} }
if (strtolower($name) == 'radius') {
Mikrotik::getClient($ip_address, $username, $password); $msg .= '<b>Radius</b> name is reserved<br>';
}
if ($msg == '') { if ($msg == '') {
Mikrotik::getClient($ip_address, $username, $password);
run_hook('router_edit'); #HOOK run_hook('router_edit'); #HOOK
$d->name = $name; $d->name = $name;
$d->ip_address = $ip_address; $d->ip_address = $ip_address;