check if demo or not

This commit is contained in:
Ibnu Maksum 2024-06-12 15:39:43 +07:00
parent 987e21b3ce
commit 6a4ac274d1
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
13 changed files with 28 additions and 152 deletions

View File

@ -20,7 +20,7 @@ class Package
*/
public static function rechargeUser($id_customer, $router_name, $plan_id, $gateway, $channel, $note = '')
{
global $config, $admin, $c, $p, $b, $t, $d, $zero, $trx, $DEVICE_PATH;
global $config, $admin, $c, $p, $b, $t, $d, $zero, $trx, $_app_stage;
$date_now = date("Y-m-d H:i:s");
$date_only = date("Y-m-d");
$time_only = date("H:i:s");
@ -222,7 +222,7 @@ class Package
if ($isChangePlan || $b['status'] == 'off') {
$dvc = Package::getDevice($p);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {
@ -305,7 +305,7 @@ class Package
} else {
// active plan not exists
$dvc = Package::getDevice($p);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {
@ -407,13 +407,13 @@ class Package
public static function changeTo($username, $plan_id, $from_id)
{
global $DEVICE_PATH;
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)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->change_customer($b, $c, $p);
} else {

View File

@ -44,7 +44,7 @@ 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)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_customer($c, $p);
} else {

View File

@ -18,7 +18,7 @@ switch ($action) {
$bill = ORM::for_table('tbl_user_recharges')->where('id', $routes['2'])->where('username', $user['username'])->findOne();
if ($bill['type'] == 'Hotspot' && $bill['status'] == 'on') {
$dvc = Package::getDevice($d);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
if ((new $d['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>');

View File

@ -214,7 +214,7 @@ 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)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->change_customer($c, $p);
} else {
@ -242,7 +242,7 @@ switch ($action) {
if ($p) {
$routers[] = $b['routers'];
$dvc = Package::getDevice($p);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {
@ -330,7 +330,7 @@ switch ($action) {
$p = ORM::for_table('tbl_plans')->find_one($c['plan_id']);
if($p){
$dvc = Package::getDevice($p);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_customer($d, $p);
} else {
@ -569,7 +569,7 @@ switch ($action) {
$c->save();
$p = ORM::for_table('tbl_plans')->find_one($c['plan_id']);
$dvc = Package::getDevice($p);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_customer($d, $p);
(new $p['device'])->add_customer($d, $p);

View File

@ -156,7 +156,7 @@ 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)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_customer($user, $p);
} else {
@ -188,7 +188,7 @@ 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)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_customer($user, $p);
} else {
@ -212,7 +212,7 @@ 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)) {
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']);

View File

@ -97,7 +97,7 @@ switch ($do) {
try {
$p = ORM::for_table('tbl_plans')->where('id', $v1['id_plan'])->find_one();
$dvc = Package::getDevice($p);
if (file_exists($dvc)) {
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 {
@ -141,7 +141,7 @@ switch ($do) {
try {
$p = ORM::for_table('tbl_plans')->where('id', $v1['id_plan'])->find_one();
$dvc = Package::getDevice($p);
if (file_exists($dvc)) {
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 {

View File

@ -44,7 +44,7 @@ switch ($action) {
$p = ORM::for_table('tbl_plans')->findOne($plan['plan_id']);
$c = ORM::for_table('tbl_customers')->findOne($plan['customer_id']);
$dvc = Package::getDevice($plan);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {
@ -258,7 +258,7 @@ 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)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_customer($c, $p);
} else {
@ -774,7 +774,7 @@ 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)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_customer($c, $p);
} else {

View File

@ -24,7 +24,7 @@ switch ($action) {
$router = '';
foreach ($plans as $plan) {
$dvc = Package::getDevice($plan);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_plan($plan);
} else {
@ -38,7 +38,7 @@ switch ($action) {
$router = '';
foreach ($plans as $plan) {
$dvc = Package::getDevice($plan);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_plan($plan);
} else {
@ -128,7 +128,7 @@ switch ($action) {
if ($d) {
run_hook('delete_plan'); #HOOK
$dvc = Package::getDevice($d);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_plan($d);
} else {
@ -212,7 +212,7 @@ switch ($action) {
$d->save();
$dvc = Package::getDevice($d);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_plan($d);
} else {
@ -304,7 +304,7 @@ switch ($action) {
$d->save();
$dvc = Package::getDevice($d);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $d['device'])->update_plan($old, $d);
} else {
@ -408,7 +408,7 @@ switch ($action) {
run_hook('delete_ppoe'); #HOOK
$dvc = Package::getDevice($d);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_plan($d);
} else {
@ -497,7 +497,7 @@ switch ($action) {
$d->save();
$dvc = Package::getDevice($d);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->add_plan($d);
} else {
@ -578,7 +578,7 @@ switch ($action) {
$d->save();
$dvc = Package::getDevice($d);
if (file_exists($dvc)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $d['device'])->update_plan($old, $d);
} else {

View File

@ -33,7 +33,7 @@ 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)) {
if (file_exists($dvc) && $_app_stage != 'demo') {
require_once $dvc;
(new $p['device'])->remove_customer($c, $p);
} else {

View File

@ -15,10 +15,6 @@ class MikrotikHotspot
function add_customer($customer, $plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($plan['routers']);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$this->removeHotspotUser($client, $customer['username']);
@ -28,10 +24,6 @@ class MikrotikHotspot
function remove_customer($customer, $plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($plan['routers']);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
if (!empty($plan['plan_expired'])) {
@ -45,10 +37,6 @@ class MikrotikHotspot
function change_customer($customer, $plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($plan['routers']);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$this->removeHotspotUser($client, $customer['username']);
@ -58,10 +46,6 @@ class MikrotikHotspot
function add_plan($plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($plan['routers']);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$bw = ORM::for_table("tbl_bandwidth")->find_one($plan['id_bw']);
@ -90,10 +74,6 @@ class MikrotikHotspot
function online_customer($customer, $router_name)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($router_name);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$printRequest = new RouterOS\Request(
@ -105,10 +85,6 @@ class MikrotikHotspot
function connect_customer($customer, $ip, $mac_address, $router_name)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($router_name);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$addRequest = new RouterOS\Request('/ip/hotspot/active/login');
@ -123,10 +99,6 @@ class MikrotikHotspot
function disconnect_customer($customer, $router_name)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($router_name);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$printRequest = new RouterOS\Request(
@ -144,10 +116,6 @@ class MikrotikHotspot
function update_plan($old_plan, $new_plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($new_plan['routers']);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
@ -187,10 +155,6 @@ class MikrotikHotspot
function remove_plan($plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($plan['routers']);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$printRequest = new RouterOS\Request(

View File

@ -15,10 +15,6 @@ class MikrotikPppoe
function add_customer($customer, $plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($plan['routers']);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$this->removePpoeUser($client, $customer['username']);
@ -28,10 +24,6 @@ class MikrotikPppoe
function remove_customer($customer, $plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($plan['routers']);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
if (!empty($plan['plan_expired'])) {
@ -45,10 +37,6 @@ class MikrotikPppoe
function change_customer($customer, $plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($plan['routers']);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$this->removePpoeUser($client, $customer['username']);
@ -59,10 +47,6 @@ class MikrotikPppoe
function add_plan($plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($plan['routers']);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
@ -96,10 +80,6 @@ class MikrotikPppoe
function update_plan($old_name, $new_plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($new_plan['routers']);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
@ -140,10 +120,6 @@ class MikrotikPppoe
function remove_plan($plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($plan['routers']);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$printRequest = new RouterOS\Request(
@ -221,10 +197,6 @@ class MikrotikPppoe
function online_customer($customer, $router_name)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
$mikrotik = $this->info($router_name);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$printRequest = new RouterOS\Request(
@ -237,18 +209,10 @@ class MikrotikPppoe
function connect_customer($customer, $ip, $mac_address, $router_name)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
}
function disconnect_customer($customer, $router_name)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
}
function info($name)

View File

@ -19,10 +19,6 @@ class Radius {
function remove_customer($customer, $plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
if (empty($plan['plan_expired'])) {
$p = ORM::for_table("tbl_plans")->find_one($plan['plan_expired']);
$this->customerDeactivate($customer['username']);
@ -89,26 +85,14 @@ class Radius {
function online_customer($customer, $router_name)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
}
function connect_customer($customer, $ip, $mac_address, $router_name)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
}
function disconnect_customer($customer, $router_name)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
}
public function getTableNas()

View File

@ -9,74 +9,38 @@ class FileName {
function add_customer($customer, $plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
}
function remove_customer($customer, $plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
}
function change_customer($customer, $plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
}
function add_plan($plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
}
function update_plan($old_name, $plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
}
function remove_plan($plan)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
}
function online_customer($customer, $router_name)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
}
function connect_customer($customer, $ip, $mac_address, $router_name)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
}
function disconnect_customer($customer, $router_name)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return;
}
}
}