forked from kevinowino869/mitrobill
Show error, and fix IP Port custom
This commit is contained in:
@ -19,7 +19,7 @@ use PEAR2\Net\RouterOS;
|
||||
require_once 'system/autoload/PEAR2/Autoload.php';
|
||||
|
||||
switch ($action) {
|
||||
|
||||
|
||||
case 'change-password':
|
||||
$ui->display('user-change-password.tpl');
|
||||
break;
|
||||
@ -32,7 +32,7 @@ switch ($action) {
|
||||
$d_pass = $d['password'];
|
||||
$npass = _post('npass');
|
||||
$cnpass = _post('cnpass');
|
||||
|
||||
|
||||
if(Password::_uverify($password,$d_pass) == true){
|
||||
if(!Validator::Length($npass,15,2)){
|
||||
r2(U.'accounts/change-password','e','New Password must be 3 to 14 character');
|
||||
@ -46,20 +46,21 @@ switch ($action) {
|
||||
$mikrotik = Router::_info($c['routers']);
|
||||
if($c['type'] == 'Hotspot'){
|
||||
try {
|
||||
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
$iport = explode(":",$mikrotik['ip_address']);
|
||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
||||
} catch (Exception $e) {
|
||||
die('Unable to connect to the router.');
|
||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||
}
|
||||
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
|
||||
$printRequest->setArgument('.proplist', '.id');
|
||||
$printRequest->setQuery(RouterOS\Query::where('name', $user['username']));
|
||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||
|
||||
|
||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/set');
|
||||
$setRequest->setArgument('numbers', $id);
|
||||
$setRequest->setArgument('password', $npass);
|
||||
$client->sendSync($setRequest);
|
||||
|
||||
|
||||
//remove hotspot active
|
||||
$onlineRequest = new RouterOS\Request('/ip/hotspot/active/print');
|
||||
$onlineRequest->setArgument('.proplist', '.id');
|
||||
@ -69,31 +70,32 @@ switch ($action) {
|
||||
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
|
||||
$removeRequest->setArgument('numbers', $id);
|
||||
$client->sendSync($removeRequest);
|
||||
|
||||
|
||||
$d->password = $npass;
|
||||
$d->save();
|
||||
|
||||
|
||||
_msglog('s',$_L['Password_Changed_Successfully']);
|
||||
_log('['.$user['username'].']: Password changed successfully','User',$user['id']);
|
||||
|
||||
|
||||
r2(U.'login');
|
||||
|
||||
|
||||
}else{
|
||||
try {
|
||||
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
$iport = explode(":",$mikrotik['ip_address']);
|
||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
||||
} catch (Exception $e) {
|
||||
die('Unable to connect to the router.');
|
||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||
}
|
||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
||||
$printRequest->setArgument('.proplist', '.id');
|
||||
$printRequest->setQuery(RouterOS\Query::where('name', $user['username']));
|
||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||
|
||||
|
||||
$setRequest = new RouterOS\Request('/ppp/secret/set');
|
||||
$setRequest->setArgument('numbers', $id);
|
||||
$setRequest->setArgument('password', $npass);
|
||||
$client->sendSync($setRequest);
|
||||
|
||||
|
||||
//remove pppoe active
|
||||
$onlineRequest = new RouterOS\Request('/ppp/active/print');
|
||||
$onlineRequest->setArgument('.proplist', '.id');
|
||||
@ -103,25 +105,25 @@ switch ($action) {
|
||||
$removeRequest = new RouterOS\Request('/ppp/active/remove');
|
||||
$removeRequest->setArgument('numbers', $id);
|
||||
$client->sendSync($removeRequest);
|
||||
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
r2(U.'accounts/change-password','e',$_L['Incorrect_Current_Password']);
|
||||
}
|
||||
@ -134,7 +136,7 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
case 'profile':
|
||||
|
||||
|
||||
$id = $_SESSION['uid'];
|
||||
$d = ORM::for_table('tbl_customers')->find_one($id);
|
||||
if($d){
|
||||
@ -157,7 +159,7 @@ switch ($action) {
|
||||
if(Validator::UnsignedNumber($phonenumber) == false){
|
||||
$msg .= 'Phone Number must be a number'. '<br>';
|
||||
}
|
||||
|
||||
|
||||
$id = _post('id');
|
||||
$d = ORM::for_table('tbl_customers')->find_one($id);
|
||||
if($d){
|
||||
@ -170,14 +172,14 @@ switch ($action) {
|
||||
$d->address = $address;
|
||||
$d->phonenumber = $phonenumber;
|
||||
$d->save();
|
||||
|
||||
|
||||
_log('['.$user['username'].']: '.$_L['User_Updated_Successfully'],'User',$user['id']);
|
||||
r2(U . 'accounts/profile', 's', $_L['User_Updated_Successfully']);
|
||||
}else{
|
||||
r2(U . 'accounts/profile', 'e', $msg);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
echo 'action not defined';
|
||||
}
|
Reference in New Issue
Block a user