forked from kevinowino869/mitrobill
.github
admin
docs
install
pages_template
qrcode
scan
system
autoload
cache
controllers
accounts.php
admin.php
autoload.php
autoload_user.php
bandwidth.php
callback.php
community.php
customers.php
dashboard.php
default.php
export.php
home.php
index.html
login.php
logout.php
logs.php
mail.php
map.php
message.php
order.php
page.php
pages.php
paymentgateway.php
plan.php
plugin.php
pluginmanager.php
pool.php
radius.php
register.php
reports.php
routers.php
services.php
settings.php
voucher.php
devices
lan
paymentgateway
plugin
uploads
vendor
.htaccess
api.php
boot.php
composer.json
composer.lock
cron.php
cron_reminder.php
index.html
orm.php
updates.json
ui
.gitignore
.htaccess_firewall
CHANGELOG.md
Dockerfile
LICENSE
README.md
composer.json
config.sample.php
docker-compose.example.yml
favicon.ico
index.php
init.php
radius.php
update.php
version.json
80 lines
3.3 KiB
PHP
80 lines
3.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
|
* by https://t.me/ibnux
|
|
**/
|
|
|
|
/**
|
|
* used for ajax
|
|
**/
|
|
|
|
_auth();
|
|
|
|
$action = $routes['1'];
|
|
$user = User::_info();
|
|
|
|
switch ($action) {
|
|
case 'isLogin':
|
|
$bill = ORM::for_table('tbl_user_recharges')->where('id', $routes['2'])->where('username', $user['username'])->findOne();
|
|
if ($bill['type'] == 'Hotspot' && $bill['status'] == 'on') {
|
|
$p = ORM::for_table('tbl_plans')->find_one($bill['plan_id']);
|
|
$dvc = Package::getDevice($p);
|
|
if ($_app_stage != 'demo') {
|
|
try {
|
|
if (file_exists($dvc)) {
|
|
require_once $dvc;
|
|
if ((new $p['device'])->online_customer($user, $bill['routers'])) {
|
|
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('-'));
|
|
}
|
|
}
|
|
} else {
|
|
die(Lang::T('-'));
|
|
}
|
|
} catch (Exception $e) {
|
|
die(Lang::T('Failed to connect to device'));
|
|
}
|
|
}
|
|
die(Lang::T('-'));
|
|
} else {
|
|
die('--');
|
|
}
|
|
break;
|
|
case 'inbox_unread':
|
|
$count = ORM::for_table('tbl_customers_inbox')->where('customer_id', $user['id'])->whereRaw('date_read is null')->count('id');
|
|
if ($count > 0) {
|
|
echo $count;
|
|
}
|
|
die();
|
|
case 'inbox':
|
|
$inboxs = ORM::for_table('tbl_customers_inbox')->selects(['id', 'subject', 'date_created'])->where('customer_id', $user['id'])->whereRaw('date_read is null')->order_by_desc('date_created')->limit(10)->find_many();
|
|
foreach ($inboxs as $inbox) {
|
|
echo '<li><a href="' . U . 'mail/view/' . $inbox['id'] . '">' . $inbox['subject'] . '<br><sub class="text-muted">' . Lang::dateTimeFormat($inbox['date_created']) . '</sub></a></li>';
|
|
}
|
|
die();
|
|
case 'language':
|
|
$select = _get('select');
|
|
$folders = [];
|
|
$files = scandir('system/lan/');
|
|
foreach ($files as $file) {
|
|
if (is_file('system/lan/' . $file) && !in_array($file, ['index.html', 'country.json', '.DS_Store'])) {
|
|
$file = str_replace(".json", "", $file);
|
|
if(!empty($file)){
|
|
echo '<li><a href="' . U . 'accounts/language-update-post&lang=' . $file. '">';
|
|
if($select == $file){
|
|
echo '<span class="glyphicon glyphicon-ok"></span> ';
|
|
}
|
|
echo ucwords($file) . '</a></li>';
|
|
}
|
|
}
|
|
}
|
|
die();
|
|
default:
|
|
$ui->display('404.tpl');
|
|
}
|