Fix Demo mode

This commit is contained in:
Ibnu Maksum 2024-06-20 14:16:09 +07:00
parent 29ad9dec73
commit 28ec7883e2
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
10 changed files with 242 additions and 207 deletions

View File

@ -68,7 +68,7 @@ class Package
if ($p['prepaid'] == 'no') {
$day_exp = $p['expired_date'];
}
if(empty($day_exp)){
if (empty($day_exp)) {
$day_exp = 20;
}
@ -214,11 +214,13 @@ class Package
if ($isChangePlan || $b['status'] == 'off') {
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
}
@ -297,11 +299,13 @@ class Package
} else {
// active plan not exists
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
$d = ORM::for_table('tbl_user_recharges')->create();
@ -397,23 +401,6 @@ class Package
return $inv;
}
public static function changeTo($username, $plan_id, $from_id)
{
global $_app_stage;
$c = ORM::for_table('tbl_customers')->where('username', $username)->find_one();
$p = ORM::for_table('tbl_plans')->where('id', $plan_id)->find_one();
$b = ORM::for_table('tbl_user_recharges')->find_one($from_id);
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->change_customer($b, $c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
public static function _raid()
{
return ORM::for_table('tbl_transactions')->max('id') + 1;

View File

@ -44,11 +44,13 @@ switch ($action) {
// if has active plan, change the password to devices
$p = ORM::for_table('tbl_plans')->where('id', $c['plan_id'])->find_one();
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->remove_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
}
$d->password = $npass;

View File

@ -1,4 +1,5 @@
<?php
/**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux
@ -19,20 +20,21 @@ switch ($action) {
if ($bill['type'] == 'Hotspot' && $bill['status'] == 'on') {
$p = ORM::for_table('tbl_plans')->find_one($bill['plan_id']);
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
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('Your account not connected to internet'));
if ($_app_stage != 'demo') {
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('Your account not connected to internet'));
}
}
} else {
new Exception(Lang::T("Devices Not Found"));
}
} else {
new Exception(Lang::T("Devices Not Found"));
}
} else {
die('--');

View File

@ -214,11 +214,13 @@ switch ($action) {
if ($p) {
$p = ORM::for_table('tbl_plans')->where('id', $c['plan_id'])->find_one();
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->change_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->change_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
$b->status = 'off';
$b->expiration = date('Y-m-d');
@ -242,11 +244,13 @@ switch ($action) {
if ($p) {
$routers[] = $b['routers'];
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
}
}
@ -328,13 +332,15 @@ switch ($action) {
$c = ORM::for_table('tbl_user_recharges')->where('username', $d['username'])->find_one();
if ($c) {
$p = ORM::for_table('tbl_plans')->find_one($c['plan_id']);
if($p){
if ($p) {
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_customer($d, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->remove_customer($d, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
}
try {
@ -569,12 +575,14 @@ switch ($action) {
$c->save();
$p = ORM::for_table('tbl_plans')->find_one($c['plan_id']);
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_customer($d, $p);
(new $p['device'])->add_customer($d, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->remove_customer($d, $p);
(new $p['device'])->add_customer($d, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
}
}

View File

@ -156,11 +156,13 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
if ($tur['status'] != 'on') {
$p = ORM::for_table('tbl_plans')->findOne($tur['plan_id']);
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_customer($user, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->add_customer($user, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
// make customer cannot extend again
@ -188,11 +190,13 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
if ($bill) {
$p = ORM::for_table('tbl_plans')->where('id', $bill['plan_id'])->find_one();
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_customer($user, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->remove_customer($user, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
$bill->status = 'off';
$bill->expiration = date('Y-m-d');
@ -212,17 +216,19 @@ if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) {
$bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['id'])->where('username', $user['username'])->findOne();
$p = ORM::for_table('tbl_plans')->where('id', $bill['plan_id'])->find_one();
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
if ($_GET['mikrotik'] == 'login') {
(new $p['device'])->connect_customer($user, $_SESSION['nux-ip'], $_SESSION['nux-mac'], $bill['routers']);
r2(U . 'home', 's', Lang::T('Login Request successfully'));
} else if ($_GET['mikrotik'] == 'logout') {
(new $p['device'])->disconnect_customer($user, $bill['routers']);
r2(U . 'home', 's', Lang::T('Logout Request successfully'));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
if ($_GET['mikrotik'] == 'login') {
(new $p['device'])->connect_customer($user, $_SESSION['nux-ip'], $_SESSION['nux-mac'], $bill['routers']);
r2(U . 'home', 's', Lang::T('Login Request successfully'));
} else if ($_GET['mikrotik'] == 'logout') {
(new $p['device'])->disconnect_customer($user, $bill['routers']);
r2(U . 'home', 's', Lang::T('Logout Request successfully'));
}
} else {
new Exception(Lang::T("Devices Not Found"));
}
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
@ -230,6 +236,6 @@ $ui->assign('unpaid', ORM::for_table('tbl_payment_gateway')
->where('username', $user['username'])
->where('status', 1)
->find_one());
$ui->assign('code', alphanumeric(_get('code'),"-"));
$ui->assign('code', alphanumeric(_get('code'), "-"));
run_hook('view_customer_dashboard'); #HOOK
$ui->display('user-dashboard.tpl');

View File

@ -97,14 +97,17 @@ switch ($do) {
try {
$p = ORM::for_table('tbl_plans')->where('id', $v1['id_plan'])->find_one();
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->connect_customer($user, $_SESSION['nux-ip'], $_SESSION['nux-mac'], $v1['routers']);
} else {
if (!empty($config['voucher_redirect'])) {
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->connect_customer($user, $_SESSION['nux-ip'], $_SESSION['nux-mac'], $v1['routers']);
if (!empty($config['voucher_redirect'])) {
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login"));
} else {
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login"));
}
} else {
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login"));
new Exception(Lang::T("Devices Not Found"));
}
}
if (!empty($config['voucher_redirect'])) {
@ -141,14 +144,17 @@ switch ($do) {
try {
$p = ORM::for_table('tbl_plans')->where('id', $v1['id_plan'])->find_one();
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->connect_customer($user, $_SESSION['nux-ip'], $_SESSION['nux-mac'], $v1['routers']);
} else {
if (!empty($config['voucher_redirect'])) {
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->connect_customer($user, $_SESSION['nux-ip'], $_SESSION['nux-mac'], $v1['routers']);
if (!empty($config['voucher_redirect'])) {
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login"));
} else {
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login"));
}
} else {
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login"));
new Exception(Lang::T("Devices Not Found"));
}
}
if (!empty($config['voucher_redirect'])) {
@ -182,7 +188,7 @@ switch ($do) {
default:
run_hook('customer_view_login'); #HOOK
if ($config['disable_registration'] == 'yes') {
$ui->assign('code', alphanumeric(_get('code'),"-"));
$ui->assign('code', alphanumeric(_get('code'), "-"));
$ui->display('user-login-noreg.tpl');
} else {
$ui->display('user-login.tpl');

View File

@ -42,21 +42,23 @@ switch ($action) {
$router = '';
foreach ($turs as $tur) {
$p = ORM::for_table('tbl_plans')->findOne($tur['plan_id']);
if($p){
if ($p) {
$c = ORM::for_table('tbl_customers')->findOne($tur['customer_id']);
if($c){
if ($c) {
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
$log .= "DONE : $tur[username], $ptur[namebp], $tur[type], $tur[routers]<br>";
}else{
} else {
$log .= "Customer NOT FOUND : $tur[username], $tur[namebp], $tur[type], $tur[routers]<br>";
}
}else{
} else {
$log .= "PLAN NOT FOUND : $tur[username], $tur[namebp], $tur[type], $tur[routers]<br>";
}
}
@ -71,7 +73,7 @@ switch ($action) {
}
$usings = explode(',', $config['payment_usings']);
$usings = array_filter(array_unique($usings));
if(count($usings)==0){
if (count($usings) == 0) {
$usings[] = Lang::T('Cash');
}
$ui->assign('usings', $usings);
@ -117,7 +119,7 @@ switch ($action) {
}
$usings = explode(',', $config['payment_usings']);
$usings = array_filter(array_unique($usings));
if(count($usings)==0){
if (count($usings) == 0) {
$usings[] = Lang::T('Cash');
}
$ui->assign('usings', $usings);
@ -267,11 +269,14 @@ switch ($action) {
if ($d) {
run_hook('delete_customer_active_plan'); #HOOK
$p = ORM::for_table('tbl_plans')->find_one($d['plan_id']);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
$dvc = Package::getDevice($p);
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->remove_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
$d->delete();
_log('[' . $admin['username'] . ']: ' . 'Delete Plan for Customer ' . $c['username'] . ' [' . $in['plan_name'] . '][' . Lang::moneyFormat($in['price']) . ']', $admin['user_type'], $admin['id']);
@ -316,19 +321,23 @@ switch ($action) {
//remove from old plan
$p = ORM::for_table('tbl_plans')->find_one($oldPlanID);
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_customer($customer, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->remove_customer($customer, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
//add new plan
$dvc = Package::getDevice($newPlan);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $newPlan['device'])->add_customer($customer, $newPlan);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $newPlan['device'])->add_customer($customer, $newPlan);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
}
$d->save();
@ -580,13 +589,12 @@ switch ($action) {
}
run_hook('create_voucher'); #HOOK
$vouchers = [];
if($voucher_format == 'numbers'){
if (strlen($lengthcode)<6) {
if ($voucher_format == 'numbers') {
if (strlen($lengthcode) < 6) {
$msg .= 'The Length Code must be a more than 6 for numbers' . '<br>';
}
$vouchers = generateUniqueNumericVouchers($numbervoucher, $lengthcode);
}
else {
} else {
for ($i = 0; $i < $numbervoucher; $i++) {
$code = strtoupper(substr(md5(time() . rand(10000, 99999)), 0, $lengthcode));
if ($voucher_format == 'low') {
@ -595,11 +603,10 @@ switch ($action) {
$code = Lang::randomUpLowCase($code);
}
$vouchers[] = $code;
}
}
foreach($vouchers as $code){
foreach ($vouchers as $code) {
$d = ORM::for_table('tbl_voucher')->create();
$d->type = $type;
$d->routers = $server;
@ -758,7 +765,7 @@ switch ($action) {
$c = ORM::for_table('tbl_customers')->where('id', $user)->find_one();
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
Package::createInvoice($in);
if(!empty($stoken)){
if (!empty($stoken)) {
App::setToken($stoken, $in['id']);
}
$ui->display('invoice.tpl');
@ -793,15 +800,17 @@ switch ($action) {
$c = ORM::for_table('tbl_customers')->findOne($tur['customer_id']);
$p = ORM::for_table('tbl_plans')->find_one($d['plan_id']);
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
_log("$admin[fullname] extend Customer $tur[customer_id] $tur[username] for $days days", $admin['user_type'], $admin['id']);
r2(U . 'plan', 's', "Extend until $expiration");
}else{
} else {
r2(U . 'plan', 's', "Customer is not expired yet");
}
break;
@ -811,8 +820,8 @@ switch ($action) {
$search = _post('search');
if ($search != '') {
$query = ORM::for_table('tbl_user_recharges')
->whereRaw("username LIKE '%$search%' OR namebp LIKE '%$search%' OR method LIKE '%$search%' OR routers LIKE '%$search%' OR type LIKE '%$search%'")
->order_by_desc('id');
->whereRaw("username LIKE '%$search%' OR namebp LIKE '%$search%' OR method LIKE '%$search%' OR routers LIKE '%$search%' OR type LIKE '%$search%'")
->order_by_desc('id');
$d = Paginator::findMany($query, ['search' => $search]);
} else {
$query = ORM::for_table('tbl_user_recharges')->order_by_desc('id');

View File

@ -24,11 +24,13 @@ switch ($action) {
$router = '';
foreach ($plans as $plan) {
$dvc = Package::getDevice($plan);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_plan($plan);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->add_plan($plan);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
}
r2(U . 'services/hotspot', 's', $log);
@ -38,11 +40,13 @@ switch ($action) {
$router = '';
foreach ($plans as $plan) {
$dvc = Package::getDevice($plan);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_plan($plan);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->add_plan($plan);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
}
r2(U . 'services/pppoe', 's', $log);
@ -128,11 +132,13 @@ switch ($action) {
if ($d) {
run_hook('delete_plan'); #HOOK
$dvc = Package::getDevice($d);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_plan($d);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->remove_plan($d);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
$d->delete();
@ -210,24 +216,25 @@ switch ($action) {
$d->enabled = $enabled;
$d->prepaid = $prepaid;
$d->device = $device;
if($prepaid == 'no'){
if($expired_date>28 && $expired_date < 1){
if ($prepaid == 'no') {
if ($expired_date > 28 && $expired_date < 1) {
$expired_date = 20;
}
$d->expired_date = $expired_date;
}else{
} else {
$d->expired_date = 0;
}
$d->save();
$dvc = Package::getDevice($d);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_plan($d);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->add_plan($d);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
r2(U . 'services/edit/' . $d->id(), 's', Lang::T('Data Created Successfully'));
} else {
r2(U . 'services/add', 'e', $msg);
@ -311,24 +318,25 @@ switch ($action) {
$d->enabled = $enabled;
$d->prepaid = $prepaid;
$d->device = $device;
if($prepaid == 'no'){
if($expired_date>28 && $expired_date < 1){
if ($prepaid == 'no') {
if ($expired_date > 28 && $expired_date < 1) {
$expired_date = 20;
}
$d->expired_date = $expired_date;
}else{
} else {
$d->expired_date = 0;
}
$d->save();
$dvc = Package::getDevice($d);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $d['device'])->update_plan($old, $d);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $d['device'])->update_plan($old, $d);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
r2(U . 'services/hotspot', 's', Lang::T('Data Updated Successfully'));
} else {
r2(U . 'services/edit/' . $id, 'e', $msg);
@ -426,11 +434,13 @@ switch ($action) {
run_hook('delete_ppoe'); #HOOK
$dvc = Package::getDevice($d);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_plan($d);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->remove_plan($d);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
$d->delete();
@ -510,12 +520,12 @@ switch ($action) {
$d->is_radius = 0;
$d->routers = $routers;
}
if($prepaid == 'no'){
if($expired_date>28 && $expired_date < 1){
if ($prepaid == 'no') {
if ($expired_date > 28 && $expired_date < 1) {
$expired_date = 20;
}
$d->expired_date = $expired_date;
}else{
} else {
$d->expired_date = 0;
}
$d->enabled = $enabled;
@ -524,13 +534,14 @@ switch ($action) {
$d->save();
$dvc = Package::getDevice($d);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_plan($d);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->add_plan($d);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
r2(U . 'services/pppoe', 's', Lang::T('Data Created Successfully'));
} else {
r2(U . 'services/pppoe-add', 'e', $msg);
@ -603,24 +614,25 @@ switch ($action) {
$d->enabled = $enabled;
$d->prepaid = $prepaid;
$d->device = $device;
if($prepaid == 'no'){
if($expired_date>28 && $expired_date < 1){
if ($prepaid == 'no') {
if ($expired_date > 28 && $expired_date < 1) {
$expired_date = 20;
}
$d->expired_date = $expired_date;
}else{
} else {
$d->expired_date = 0;
}
$d->save();
$dvc = Package::getDevice($d);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $d['device'])->update_plan($old, $d);
} else {
new Exception(Lang::T("Devices Not Found"));
if ($_app_stage != 'demo') {
if (file_exists($dvc)) {
require_once $dvc;
(new $d['device'])->update_plan($old, $d);
} else {
new Exception(Lang::T("Devices Not Found"));
}
}
r2(U . 'services/pppoe', 's', Lang::T('Data Updated Successfully'));
} else {
r2(U . 'services/pppoe-edit/' . $id, 'e', $msg);

View File

@ -33,12 +33,14 @@ foreach ($d as $ds) {
$c = ORM::for_table('tbl_customers')->where('id', $ds['customer_id'])->find_one();
$p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one();
$dvc = Package::getDevice($p);
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_customer($c, $p);
} else {
echo "Cron error Devices $p[device] not found, cannot disconnect $c[username]";
Message::sendTelegram("Cron error Devices $p[device] not found, cannot disconnect $c[username]");
if($_app_stage != 'demo'){
if (file_exists($dvc)) {
require_once $dvc;
(new $p['device'])->remove_customer($c, $p);
} else {
echo "Cron error Devices $p[device] not found, cannot disconnect $c[username]";
Message::sendTelegram("Cron error Devices $p[device] not found, cannot disconnect $c[username]");
}
}
echo Message::sendPackageNotification($c, $u['namebp'], $p['price'], $textExpired, $config['user_notification_expired']) . "\n";
//update database user dengan status off

View File

@ -644,5 +644,6 @@
"Category": "Category",
"later": "later",
"Package_Details": "Package Details",
"Summary": "Summary"
"Summary": "Summary",
"Devices_Not_Found": "Devices Not Found"
}