Fix redirect and check user in database
This commit is contained in:
parent
a9d10d330f
commit
12e06a51e4
@ -10,6 +10,10 @@ class User
|
|||||||
{
|
{
|
||||||
$id = $_SESSION['uid'];
|
$id = $_SESSION['uid'];
|
||||||
$d = ORM::for_table('tbl_customers')->find_one($id);
|
$d = ORM::for_table('tbl_customers')->find_one($id);
|
||||||
|
|
||||||
|
if(empty($d['username'])){
|
||||||
|
r2(U . 'logout', 'd', '');
|
||||||
|
}
|
||||||
return $d;
|
return $d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||||
**/
|
**/
|
||||||
_auth();
|
_auth();
|
||||||
$ui->assign('_title', $_L['My_Account']);
|
$ui->assign('_title', $_L['My_Account']);
|
||||||
$ui->assign('_system_menu', 'accounts');
|
$ui->assign('_system_menu', 'accounts');
|
||||||
@ -11,6 +12,7 @@ $user = User::_info();
|
|||||||
$ui->assign('_user', $user);
|
$ui->assign('_user', $user);
|
||||||
|
|
||||||
use PEAR2\Net\RouterOS;
|
use PEAR2\Net\RouterOS;
|
||||||
|
|
||||||
require_once 'system/autoload/PEAR2/Autoload.php';
|
require_once 'system/autoload/PEAR2/Autoload.php';
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
@ -23,83 +25,79 @@ switch ($action) {
|
|||||||
case 'change-password-post':
|
case 'change-password-post':
|
||||||
$password = _post('password');
|
$password = _post('password');
|
||||||
run_hook('customer_change_password'); #HOOK
|
run_hook('customer_change_password'); #HOOK
|
||||||
if($password != ''){
|
if ($password != '') {
|
||||||
$d = ORM::for_table('tbl_customers')->where('username',$user['username'])->find_one();
|
$d = ORM::for_table('tbl_customers')->where('username', $user['username'])->find_one();
|
||||||
if($d){
|
if ($d) {
|
||||||
$d_pass = $d['password'];
|
$d_pass = $d['password'];
|
||||||
$npass = _post('npass');
|
$npass = _post('npass');
|
||||||
$cnpass = _post('cnpass');
|
$cnpass = _post('cnpass');
|
||||||
|
|
||||||
if(Password::_uverify($password,$d_pass) == true){
|
if (Password::_uverify($password, $d_pass) == true) {
|
||||||
if(!Validator::Length($npass,15,2)){
|
if (!Validator::Length($npass, 15, 2)) {
|
||||||
r2(U.'accounts/change-password','e','New Password must be 3 to 14 character');
|
r2(U . 'accounts/change-password', 'e', 'New Password must be 3 to 14 character');
|
||||||
}
|
}
|
||||||
if($npass != $cnpass){
|
if ($npass != $cnpass) {
|
||||||
r2(U.'accounts/change-password','e','Both Password should be same');
|
r2(U . 'accounts/change-password', 'e', 'Both Password should be same');
|
||||||
}
|
}
|
||||||
|
|
||||||
$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) {
|
||||||
$mikrotik = Mikrotik::info($c['routers']);
|
$mikrotik = Mikrotik::info($c['routers']);
|
||||||
if($c['type'] == 'Hotspot'){
|
if ($c['type'] == 'Hotspot') {
|
||||||
if(!$config['radius_mode']){
|
if (!$config['radius_mode']) {
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
Mikrotik::setHotspotUser($client,$c['username'],$npass);
|
Mikrotik::setHotspotUser($client, $c['username'], $npass);
|
||||||
Mikrotik::removeHotspotActiveUser($client,$user['username']);
|
Mikrotik::removeHotspotActiveUser($client, $user['username']);
|
||||||
}
|
}
|
||||||
$d->password = $npass;
|
$d->password = $npass;
|
||||||
$d->save();
|
$d->save();
|
||||||
|
|
||||||
_msglog('s',$_L['Password_Changed_Successfully']);
|
_msglog('s', $_L['Password_Changed_Successfully']);
|
||||||
_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 {
|
||||||
}else{
|
if (!$config['radius_mode']) {
|
||||||
if(!$config['radius_mode']){
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
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();
|
||||||
|
|
||||||
_msglog('s',$_L['Password_Changed_Successfully']);
|
_msglog('s', $_L['Password_Changed_Successfully']);
|
||||||
_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{
|
} else {
|
||||||
$d->password = $npass;
|
$d->password = $npass;
|
||||||
$d->save();
|
$d->save();
|
||||||
|
|
||||||
_msglog('s',$_L['Password_Changed_Successfully']);
|
_msglog('s', $_L['Password_Changed_Successfully']);
|
||||||
_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 {
|
||||||
}else{
|
r2(U . 'accounts/change-password', 'e', $_L['Incorrect_Current_Password']);
|
||||||
r2(U.'accounts/change-password','e',$_L['Incorrect_Current_Password']);
|
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
r2(U.'accounts/change-password','e',$_L['Incorrect_Current_Password']);
|
r2(U . 'accounts/change-password', 'e', $_L['Incorrect_Current_Password']);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
r2(U.'accounts/change-password','e',$_L['Incorrect_Current_Password']);
|
r2(U . 'accounts/change-password', 'e', $_L['Incorrect_Current_Password']);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'profile':
|
case 'profile':
|
||||||
|
$d = ORM::for_table('tbl_customers')->find_one($user['id']);
|
||||||
$id = $_SESSION['uid'];
|
if ($d) {
|
||||||
$d = ORM::for_table('tbl_customers')->find_one($id);
|
|
||||||
if($d){
|
|
||||||
run_hook('customer_view_edit_profile'); #HOOK
|
run_hook('customer_view_edit_profile'); #HOOK
|
||||||
$ui->assign('d',$d);
|
$ui->assign('d', $d);
|
||||||
$ui->display('user-profile.tpl');
|
$ui->display('user-profile.tpl');
|
||||||
}else{
|
} else {
|
||||||
r2(U . 'accounts/users', 'e', $_L['Account_Not_Found']);
|
r2(U . 'home', 'e', $_L['Account_Not_Found']);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -110,34 +108,33 @@ switch ($action) {
|
|||||||
$phonenumber = _post('phonenumber');
|
$phonenumber = _post('phonenumber');
|
||||||
run_hook('customer_edit_profile'); #HOOK
|
run_hook('customer_edit_profile'); #HOOK
|
||||||
$msg = '';
|
$msg = '';
|
||||||
if(Validator::Length($fullname,31,2) == false){
|
if (Validator::Length($fullname, 31, 2) == false) {
|
||||||
$msg .= 'Full Name should be between 3 to 30 characters'. '<br>';
|
$msg .= 'Full Name should be between 3 to 30 characters' . '<br>';
|
||||||
}
|
}
|
||||||
if(Validator::UnsignedNumber($phonenumber) == false){
|
if (Validator::UnsignedNumber($phonenumber) == false) {
|
||||||
$msg .= 'Phone Number must be a number'. '<br>';
|
$msg .= 'Phone Number must be a number' . '<br>';
|
||||||
}
|
|
||||||
|
|
||||||
$id = _post('id');
|
|
||||||
$d = ORM::for_table('tbl_customers')->find_one($id);
|
|
||||||
if($d){
|
|
||||||
}else{
|
|
||||||
$msg .= $_L['Data_Not_Found']. '<br>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($msg == ''){
|
$d = ORM::for_table('tbl_customers')->find_one($user['id']);
|
||||||
|
if ($d) {
|
||||||
|
} else {
|
||||||
|
$msg .= $_L['Data_Not_Found'] . '<br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($msg == '') {
|
||||||
$d->fullname = $fullname;
|
$d->fullname = $fullname;
|
||||||
$d->address = $address;
|
$d->address = $address;
|
||||||
$d->email = $email;
|
$d->email = $email;
|
||||||
$d->phonenumber = $phonenumber;
|
$d->phonenumber = $phonenumber;
|
||||||
$d->save();
|
$d->save();
|
||||||
|
|
||||||
_log('['.$user['username'].']: '.$_L['User_Updated_Successfully'],'User',$user['id']);
|
_log('[' . $user['username'] . ']: ' . $_L['User_Updated_Successfully'], 'User', $user['id']);
|
||||||
r2(U . 'accounts/profile', 's', $_L['User_Updated_Successfully']);
|
r2(U . 'accounts/profile', 's', $_L['User_Updated_Successfully']);
|
||||||
}else{
|
} else {
|
||||||
r2(U . 'accounts/profile', 'e', $msg);
|
r2(U . 'accounts/profile', 'e', $msg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
echo 'action not defined';
|
echo 'action not defined';
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ $ui->assign('_title', $_L['Dashboard']);
|
|||||||
$user = User::_info();
|
$user = User::_info();
|
||||||
$ui->assign('_user', $user);
|
$ui->assign('_user', $user);
|
||||||
|
|
||||||
|
|
||||||
//Client Page
|
//Client Page
|
||||||
$bill = User::_billing();
|
$bill = User::_billing();
|
||||||
$ui->assign('_bill', $bill);
|
$ui->assign('_bill', $bill);
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
</div>
|
</div>
|
||||||
{if isset($notify)}
|
{if isset($notify)}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6 col-md-offset-3">
|
<div class="col-sm-6 col-sm-offset-3">
|
||||||
{$notify}
|
{$notify}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4 col-md-offset-2">
|
<div class="col-sm-6 col-sm-offset-1">
|
||||||
<div class="panel panel-info">
|
<div class="panel panel-info">
|
||||||
<div class="panel-heading">{$_L['Announcement']}</div>
|
<div class="panel-heading">{$_L['Announcement']}</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@ -36,7 +36,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-sm-4">
|
||||||
<div class="panel panel-primary">
|
<div class="panel panel-primary">
|
||||||
<div class="panel-heading">{$_L['Sign_In_Member']}</div>
|
<div class="panel-heading">{$_L['Sign_In_Member']}</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user