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,47 +42,31 @@ switch ($action) {
$c = ORM::for_table('tbl_user_recharges')->where('username', $user['username'])->find_one();
if ($c) {
$mikrotik = Mikrotik::info($c['routers']);
if ($c['type'] == 'Hotspot') {
if (!$config['radius_enable']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setHotspotUser($client, $c['username'], $npass);
Mikrotik::removeHotspotActiveUser($client, $user['username']);
$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);
}
$d->password = $npass;
$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);
}
}else{
$mikrotik = Mikrotik::info($c['routers']);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
if ($c['type'] == 'Hotspot') {
Mikrotik::setHotspotUser($client, $c['username'], $npass);
Mikrotik::removeHotspotActiveUser($client, $user['username']);
} else if(empty($d['pppoe_password'])){
// only change when pppoe_password empty
Mikrotik::setPpoeUser($client, $c['username'], $npass);
Mikrotik::removePpoeActive($client, $user['username']);
}
$d->password = $npass;
$d->save();
_msglog('s', $_L['Password_Changed_Successfully']);
_log('[' . $user['username'] . ']: Password changed successfully', 'User', $user['id']);
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');
}
$d->password = $npass;
$d->save();
_msglog('s', $_L['Password_Changed_Successfully']);
_log('[' . $user['username'] . ']: Password changed successfully', 'User', $user['id']);
r2(U . 'login');
} else {
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);
$mikrotik = Mikrotik::info($d['routers']);
if ($d) {
if (!$config['radius_enable']) {
if ($d['routers']!='radius') {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePool($client, $d['pool_name']);
}
@ -100,7 +100,7 @@ switch ($action) {
}
$mikrotik = Mikrotik::info($routers);
if ($msg == '') {
if (!$config['radius_enable'] && $routers != 'radius') {
if ($routers != 'radius') {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addPool($client, $name, $ip_address);
}

View File

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