mitrobill/system/controllers/autoload_user.php

44 lines
1.6 KiB
PHP
Raw Normal View History

2023-06-15 15:26:38 +07:00
<?php
2023-10-12 15:55:42 +07:00
/**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux
**/
2023-06-15 15:26:38 +07:00
/**
* used for ajax
**/
_auth();
$action = $routes['1'];
$user = User::_info();
switch ($action) {
case 'isLogin':
2023-11-15 11:45:29 +07:00
$bill = ORM::for_table('tbl_user_recharges')->where('id', $routes['2'])->where('username', $user['username'])->findOne();
2023-06-15 15:26:38 +07:00
if ($bill['type'] == 'Hotspot' && $bill['status'] == 'on') {
2024-06-20 11:33:15 +07:00
$p = ORM::for_table('tbl_plans')->find_one($bill['plan_id']);
$dvc = Package::getDevice($p);
2024-06-12 15:39:43 +07:00
if (file_exists($dvc) && $_app_stage != 'demo') {
2024-06-07 17:21:29 +07:00
require_once $dvc;
2024-06-20 11:33:15 +07:00
if ((new $p['device'])->online_customer($user, $bill['routers'])) {
2024-06-07 17:21:29 +07:00
die('<a href="' . U . 'home&mikrotik=logout&id='.$bill['id'].'" 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&id='.$bill['id'].'" 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'));
}
2023-06-15 15:26:38 +07:00
}
2024-06-07 17:21:29 +07:00
} else {
new Exception(Lang::T("Devices Not Found"));
2023-06-15 15:26:38 +07:00
}
} else {
die('--');
}
break;
default:
2023-09-27 15:01:48 +07:00
$ui->display('404.tpl');
2023-06-15 15:26:38 +07:00
}