phpnuxbill/system/controllers/autoload.php

91 lines
3.2 KiB
PHP
Raw Normal View History

2017-03-11 03:51:06 +08:00
<?php
2023-10-12 16:55:42 +08:00
/**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux
**/
2023-08-23 13:11:07 +08:00
2017-03-11 03:51:06 +08:00
/**
2023-08-23 13:11:07 +08:00
* used for ajax
**/
2022-09-18 01:00:40 +08:00
2017-03-11 03:51:06 +08:00
_admin();
2024-02-13 14:54:01 +08:00
$ui->assign('_title', Lang::T('Network'));
2017-03-11 03:51:06 +08:00
$ui->assign('_system_menu', 'network');
$action = $routes['1'];
$ui->assign('_admin', $admin);
switch ($action) {
case 'pool':
2023-08-23 13:11:07 +08:00
$routers = _get('routers');
2023-10-04 12:25:58 +08:00
if(empty($routers)){
$d = ORM::for_table('tbl_pool')->find_many();
}else{
$d = ORM::for_table('tbl_pool')->where('routers', $routers)->find_many();
}
$ui->assign('routers', $routers);
2023-08-23 13:11:07 +08:00
$ui->assign('d', $d);
2017-03-11 03:51:06 +08:00
$ui->display('autoload-pool.tpl');
break;
2022-09-01 15:52:32 +08:00
2017-03-11 03:51:06 +08:00
case 'server':
2023-08-23 13:11:07 +08:00
$d = ORM::for_table('tbl_routers')->where('enabled', '1')->find_many();
$ui->assign('d', $d);
2022-09-01 15:52:32 +08:00
2017-03-11 03:51:06 +08:00
$ui->display('autoload-server.tpl');
break;
2022-09-01 15:52:32 +08:00
2017-03-11 03:51:06 +08:00
case 'plan':
2023-08-23 13:11:07 +08:00
$server = _post('server');
$jenis = _post('jenis');
2024-03-12 14:58:42 +08:00
if(in_array($admin['user_type'], array('SuperAdmin', 'Admin'))){
if($server=='radius'){
$d = ORM::for_table('tbl_plans')->where('is_radius', 1)->where('type', $jenis)->find_many();
}else{
$d = ORM::for_table('tbl_plans')->where('routers', $server)->where('type', $jenis)->find_many();
}
2023-10-04 16:51:51 +08:00
}else{
2024-03-12 14:58:42 +08:00
if($server=='radius'){
$d = ORM::for_table('tbl_plans')->where('is_radius', 1)->where('type', $jenis)->where('enabled', '1')->find_many();
}else{
$d = ORM::for_table('tbl_plans')->where('routers', $server)->where('type', $jenis)->where('enabled', '1')->find_many();
}
2023-10-04 16:51:51 +08:00
}
2023-08-23 13:11:07 +08:00
$ui->assign('d', $d);
2022-09-01 15:52:32 +08:00
2017-03-11 03:51:06 +08:00
$ui->display('autoload.tpl');
break;
2023-09-07 11:54:20 +08:00
case 'customer_is_active':
$d = ORM::for_table('tbl_user_recharges')->where('customer_id', $routes['2'])->findOne();
if ($d) {
if ($d['status'] == 'on') {
die('<span class="label label-success" title="Expired ' . Lang::dateAndTimeFormat($d['expiration'], $d['time']) . '">'.$d['namebp'].'</span>');
2023-09-07 11:54:20 +08:00
} else {
die('<span class="label label-danger" title="Expired ' . Lang::dateAndTimeFormat($d['expiration'], $d['time']) . '">'.$d['namebp'].'</span>');
2023-09-07 11:54:20 +08:00
}
} else {
die('<span class="label label-danger">&bull;</span>');
2023-09-07 11:54:20 +08:00
}
break;
2023-08-23 13:11:07 +08:00
case 'customer_select2':
$s = addslashes(_get('s'));
if (empty($s)) {
$c = ORM::for_table('tbl_customers')->limit(30)->find_many();
} else {
2023-12-19 10:55:55 +08:00
$c = ORM::for_table('tbl_customers')->where_raw("(`username` LIKE '%$s%' OR `fullname` LIKE '%$s%' OR `phonenumber` LIKE '%$s%' OR `email` LIKE '%$s%')")->limit(30)->find_many();
2023-08-23 13:11:07 +08:00
}
header('Content-Type: application/json');
2023-08-23 16:00:34 +08:00
foreach ($c as $cust) {
2023-08-23 13:11:07 +08:00
$json[] = [
'id' => $cust['id'],
2023-08-23 16:00:34 +08:00
'text' => $cust['username'] . ' - ' . $cust['fullname'] . ' - ' . $cust['email']
2023-08-23 13:11:07 +08:00
];
}
2023-08-23 16:00:34 +08:00
echo json_encode(['results' => $json]);
2023-08-23 13:11:07 +08:00
die();
break;
2017-03-11 03:51:06 +08:00
default:
2023-09-27 16:01:48 +08:00
$ui->display('a404.tpl');
2023-08-23 13:11:07 +08:00
}