Add login Internet from User account
This commit is contained in:
34
system/controllers/autoload_user.php
Normal file
34
system/controllers/autoload_user.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* used for ajax
|
||||
**/
|
||||
|
||||
_auth();
|
||||
|
||||
$action = $routes['1'];
|
||||
$user = User::_info();
|
||||
$bill = User::_billing();
|
||||
|
||||
switch ($action) {
|
||||
case 'isLogin':
|
||||
if ($bill['type'] == 'Hotspot' && $bill['status'] == 'on') {
|
||||
$m = Mikrotik::info($bill['routers']);
|
||||
$client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
||||
if (Mikrotik::isUserLogin($client, $user['username'])) {
|
||||
die('<a href="' . U . 'home&mikrotik=logout" onclick="return confirm(\''.Lang::T('Disconnect Internet?').'\')" class="btn btn-success btn-xs btn-block">'.Lang::T('You are Online, Logout?').'</a>');
|
||||
} else {
|
||||
if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) {
|
||||
die('<a href="' . U . 'home&mikrotik=login" onclick="return confirm(\''.Lang::T('Connect to Internet?').'\')" class="btn btn-danger btn-xs btn-block">'.Lang::T('Not Online, Login now?').'</a>');
|
||||
}else{
|
||||
die(Lang::T('Your account not connected to internet'));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
die('--');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
echo 'action not defined';
|
||||
}
|
@ -13,6 +13,21 @@ $ui->assign('_user', $user);
|
||||
$bill = User::_billing();
|
||||
$ui->assign('_bill', $bill);
|
||||
|
||||
if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) {
|
||||
$ui->assign('nux_mac', $_SESSION['nux-mac']);
|
||||
$ui->assign('nux_ip', $_SESSION['nux-ip']);
|
||||
if ($_GET['mikrotik'] == 'login') {
|
||||
$m = Mikrotik::info($bill['routers']);
|
||||
$c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
||||
Mikrotik::logMeIn($c, $user['username'], $user['password'], $_SESSION['nux-ip'], $_SESSION['nux-mac']);
|
||||
r2(U . 'home', 's', Lang::T('Login Request successfully'));
|
||||
}else if ($_GET['mikrotik'] == 'logout') {
|
||||
$m = Mikrotik::info($bill['routers']);
|
||||
$c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
||||
Mikrotik::logMeOut($c, $user['username']);
|
||||
r2(U . 'home', 's', Lang::T('Logout Request successfully'));
|
||||
}
|
||||
}
|
||||
|
||||
$ui->assign('unpaid', ORM::for_table('tbl_payment_gateway')
|
||||
->where('username', $user['username'])
|
||||
|
Reference in New Issue
Block a user