$_c ke $config

This commit is contained in:
Ibnu Maksum 2022-09-21 14:15:00 +07:00
parent e7e32475cc
commit d7d9d9efa1
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
12 changed files with 148 additions and 64 deletions

View File

@ -0,0 +1,48 @@
<?php
$menu_registered = array();
/**
* Register for global menu
* @param string name Name of the menu
* @param bool admin true if for admin and false for customer
* @param string function function to run after menu clicks
* @param string position position of menu, use AFTER_ for root menu |
* Admin/Sales menu: AFTER_DASHBOARD, CUSTOMERS, PREPAID, SERVICES, REPORTS, VOUCHER, AFTER_ORDER, NETWORK, SETTINGS, AFTER_PAYMENTGATEWAY
* | Customer menu: AFTER_DASHBOARD, ORDER, HISTORY, ACCOUNTS
* @param string icon from ion icon, ion-person, only for AFTER_
*/
function register_menu($name, $admin, $function, $position, $icon = '')
{
global $menu_registered;
$menu_registered[] = [
"name" => $name,
"admin" => $admin,
"position" => $position,
"icon" => $icon,
"function" => $function
];
}
$hook_registered = array();
function register_hook($action, $function){
$hook_registered[] = [
'action' => $action,
'function' => $function
];
}
function run_hook($action){
global $hook_registered;
foreach($hook_registered as $hook){
if($hook['action'] == $action){
if(function_exists($hook['function'])){
call_user_func($hook['function']);
}
}
}
}

View File

@ -42,7 +42,7 @@ switch ($action) {
if ($c){ if ($c){
$mikrotik = Mikrotik::info($c['routers']); $mikrotik = Mikrotik::info($c['routers']);
if($c['type'] == 'Hotspot'){ if($c['type'] == 'Hotspot'){
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setHotspotUser($client,$c['username'],$npass); Mikrotik::setHotspotUser($client,$c['username'],$npass);
Mikrotik::removeHotspotActiveUser($client,$user['username']); Mikrotik::removeHotspotActiveUser($client,$user['username']);
@ -56,7 +56,7 @@ switch ($action) {
r2(U.'login'); r2(U.'login');
}else{ }else{
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setPpoeUser($client,$c['username'],$npass); Mikrotik::setPpoeUser($client,$c['username'],$npass);
Mikrotik::removePpoeActive($client,$user['username']); Mikrotik::removePpoeActive($client,$user['username']);

View File

@ -64,13 +64,13 @@ switch ($action) {
if ($c) { if ($c) {
$mikrotik = Mikrotik::info($c['routers']); $mikrotik = Mikrotik::info($c['routers']);
if ($c['type'] == 'Hotspot') { if ($c['type'] == 'Hotspot') {
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client,$c['username']); Mikrotik::removeHotspotUser($client,$c['username']);
Mikrotik::removeHotspotActiveUser($client,$user['username']); Mikrotik::removeHotspotActiveUser($client,$user['username']);
} }
} else { } else {
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePpoeUser($client,$c['username']); Mikrotik::removePpoeUser($client,$c['username']);
Mikrotik::removePpoeActive($client,$user['username']); Mikrotik::removePpoeActive($client,$user['username']);
@ -182,7 +182,7 @@ switch ($action) {
if ($c) { if ($c) {
$mikrotik = Mikrotik::info($c['routers']); $mikrotik = Mikrotik::info($c['routers']);
if ($c['type'] == 'Hotspot') { if ($c['type'] == 'Hotspot') {
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setHotspotUser($client,$c['username'],$password); Mikrotik::setHotspotUser($client,$c['username'],$password);
Mikrotik::removeHotspotActiveUser($client,$user['username']); Mikrotik::removeHotspotActiveUser($client,$user['username']);
@ -191,7 +191,7 @@ switch ($action) {
$d->password = $password; $d->password = $password;
$d->save(); $d->save();
} else { } else {
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setPpoeUser($client,$c['username'],$password); Mikrotik::setPpoeUser($client,$c['username'],$password);
Mikrotik::removePpoeActive($client,$user['username']); Mikrotik::removePpoeActive($client,$user['username']);

View File

@ -70,7 +70,7 @@ switch ($action) {
</div> </div>
<div id="logo"><img id="image" src="system/uploads/logo.png" alt="logo" /></div> <div id="logo"><img id="image" src="system/uploads/logo.png" alt="logo" /></div>
</div> </div>
<div id="header">'.$_L['All_Transactions_at_Date'].': '. date($_c['date_format'], strtotime($mdate)).'</div> <div id="header">'.$_L['All_Transactions_at_Date'].': '. date($config['date_format'], strtotime($mdate)).'</div>
<table id="customers"> <table id="customers">
<tr> <tr>
<th>'.$_L['Username'].'</th> <th>'.$_L['Username'].'</th>
@ -88,7 +88,7 @@ switch ($action) {
$username = $value['username']; $username = $value['username'];
$plan_name = $value['plan_name']; $plan_name = $value['plan_name'];
$type = $value['type']; $type = $value['type'];
$price = $_c['currency_code'].' '. number_format($value['price'],0,$_c['dec_point'],$_c['thousands_sep']); $price = $config['currency_code'].' '. number_format($value['price'],0,$config['dec_point'],$config['thousands_sep']);
$recharged_on = date( $config['date_format'], strtotime($value['recharged_on'])); $recharged_on = date( $config['date_format'], strtotime($value['recharged_on']));
$expiration = date( $config['date_format'], strtotime($value['expiration'])); $expiration = date( $config['date_format'], strtotime($value['expiration']));
$time = $value['time']; $time = $value['time'];
@ -108,7 +108,7 @@ switch ($action) {
} }
$html .= '</table> $html .= '</table>
<h4 class="text-uppercase text-bold">'.$_L['Total_Income'].':</h4> <h4 class="text-uppercase text-bold">'.$_L['Total_Income'].':</h4>
<h3 class="sum">'.$_c['currency_code'].' '.number_format($xy,2,$_c['dec_point'],$_c['thousands_sep']).'</h3>'; <h3 class="sum">'.$config['currency_code'].' '.number_format($xy,2,$config['dec_point'],$config['thousands_sep']).'</h3>';
run_hook('print_pdf_by_date'); #HOOK run_hook('print_pdf_by_date'); #HOOK
define('_MPDF_PATH','system/vendors/mpdf/'); define('_MPDF_PATH','system/vendors/mpdf/');
@ -243,7 +243,7 @@ EOF;
</div> </div>
<div id="logo"><img id="image" src="system/uploads/logo.png" alt="logo" /></div> <div id="logo"><img id="image" src="system/uploads/logo.png" alt="logo" /></div>
</div> </div>
<div id="header">'.$_L['All_Transactions_at_Date'].': '.date( $_c['date_format'], strtotime($fdate)).' - ' .date( $_c['date_format'], strtotime($tdate)).'</div> <div id="header">'.$_L['All_Transactions_at_Date'].': '.date( $config['date_format'], strtotime($fdate)).' - ' .date( $config['date_format'], strtotime($tdate)).'</div>
<table id="customers"> <table id="customers">
<tr> <tr>
<th>'.$_L['Username'].'</th> <th>'.$_L['Username'].'</th>
@ -261,7 +261,7 @@ EOF;
$username = $value['username']; $username = $value['username'];
$plan_name = $value['plan_name']; $plan_name = $value['plan_name'];
$type = $value['type']; $type = $value['type'];
$price = $_c['currency_code'].' '. number_format($value['price'],0,$_c['dec_point'],$_c['thousands_sep']); $price = $config['currency_code'].' '. number_format($value['price'],0,$config['dec_point'],$config['thousands_sep']);
$recharged_on = date( $config['date_format'], strtotime($value['recharged_on'])); $recharged_on = date( $config['date_format'], strtotime($value['recharged_on']));
$expiration = date( $config['date_format'], strtotime($value['expiration'])); $expiration = date( $config['date_format'], strtotime($value['expiration']));
$time = $value['time']; $time = $value['time'];
@ -281,7 +281,7 @@ EOF;
} }
$html .= '</table> $html .= '</table>
<h4 class="text-uppercase text-bold">'.$_L['Total_Income'].':</h4> <h4 class="text-uppercase text-bold">'.$_L['Total_Income'].':</h4>
<h3 class="sum">'.$_c['currency_code'].' '.number_format($xy,2,$_c['dec_point'],$_c['thousands_sep']).'</h3>'; <h3 class="sum">'.$config['currency_code'].' '.number_format($xy,2,$config['dec_point'],$config['thousands_sep']).'</h3>';
run_hook('pdf_by_period'); #HOOK run_hook('pdf_by_period'); #HOOK
define('_MPDF_PATH','system/vendors/mpdf/'); define('_MPDF_PATH','system/vendors/mpdf/');

View File

@ -71,7 +71,7 @@ switch ($action) {
run_hook('customer_check_payment_status'); #HOOK run_hook('customer_check_payment_status'); #HOOK
include 'system/paymentgateway/' . $trx['gateway'] . '.php'; include 'system/paymentgateway/' . $trx['gateway'] . '.php';
call_user_func($trx['gateway'] . '_validate_config'); call_user_func($trx['gateway'] . '_validate_config');
call_user_func($_c['payment_gateway'] . '_get_status', $trx, $user); call_user_func($config['payment_gateway'] . '_get_status', $trx, $user);
} else if ($routes['3'] == 'cancel') { } else if ($routes['3'] == 'cancel') {
run_hook('customer_cancel_payment'); #HOOK run_hook('customer_cancel_payment'); #HOOK
@ -100,15 +100,15 @@ switch ($action) {
$ui->display('user-orderView.tpl'); $ui->display('user-orderView.tpl');
break; break;
case 'buy': case 'buy':
if ($_c['payment_gateway'] == 'none') { if ($config['payment_gateway'] == 'none') {
r2(U . 'home', 'e', Lang::T("No Payment Gateway Available")); r2(U . 'home', 'e', Lang::T("No Payment Gateway Available"));
} }
if (!file_exists('system/paymentgateway/' . $_c['payment_gateway'] . '.php')) { if (!file_exists('system/paymentgateway/' . $config['payment_gateway'] . '.php')) {
r2(U . 'home', 'e', Lang::T("No Payment Gateway Available")); r2(U . 'home', 'e', Lang::T("No Payment Gateway Available"));
} }
run_hook('customer_buy_plan'); #HOOK run_hook('customer_buy_plan'); #HOOK
include 'system/paymentgateway/' . $_c['payment_gateway'] . '.php'; include 'system/paymentgateway/' . $config['payment_gateway'] . '.php';
call_user_func($_c['payment_gateway'] . '_validate_config'); call_user_func($config['payment_gateway'] . '_validate_config');
$router = ORM::for_table('tbl_routers')->where('enabled', '1')->find_one($routes['2'] * 1); $router = ORM::for_table('tbl_routers')->where('enabled', '1')->find_one($routes['2'] * 1);
$plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3'] * 1); $plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3'] * 1);
@ -123,7 +123,7 @@ switch ($action) {
if ($d['pg_url_payment']) { if ($d['pg_url_payment']) {
r2(U . "order/view/" . $d['id'], 'w', Lang::T("You already have unpaid transaction, cancel it or pay it.")); r2(U . "order/view/" . $d['id'], 'w', Lang::T("You already have unpaid transaction, cancel it or pay it."));
} else { } else {
if ($_c['payment_gateway'] == $d['gateway']) { if ($config['payment_gateway'] == $d['gateway']) {
$id = $d['id']; $id = $d['id'];
} else { } else {
$d->status = 4; $d->status = 4;
@ -134,7 +134,7 @@ switch ($action) {
if (empty($id)) { if (empty($id)) {
$d = ORM::for_table('tbl_payment_gateway')->create(); $d = ORM::for_table('tbl_payment_gateway')->create();
$d->username = $user['username']; $d->username = $user['username'];
$d->gateway = $_c['payment_gateway']; $d->gateway = $config['payment_gateway'];
$d->plan_id = $plan['id']; $d->plan_id = $plan['id'];
$d->plan_name = $plan['name_plan']; $d->plan_name = $plan['name_plan'];
$d->routers_id = $router['id']; $d->routers_id = $router['id'];
@ -146,7 +146,7 @@ switch ($action) {
$id = $d->id(); $id = $d->id();
} else { } else {
$d->username = $user['username']; $d->username = $user['username'];
$d->gateway = $_c['payment_gateway']; $d->gateway = $config['payment_gateway'];
$d->plan_id = $plan['id']; $d->plan_id = $plan['id'];
$d->plan_name = $plan['name_plan']; $d->plan_name = $plan['name_plan'];
$d->routers_id = $router['id']; $d->routers_id = $router['id'];
@ -159,7 +159,7 @@ switch ($action) {
if (!$id) { if (!$id) {
r2(U . "order/package/" . $d['id'], 'e', Lang::T("Failed to create Transaction..")); r2(U . "order/package/" . $d['id'], 'e', Lang::T("Failed to create Transaction.."));
} else { } else {
call_user_func($_c['payment_gateway'] . '_create_transaction', $d, $user); call_user_func($config['payment_gateway'] . '_create_transaction', $d, $user);
} }
break; break;
default: default:

View File

@ -63,7 +63,7 @@ switch ($action) {
$d = ORM::for_table('tbl_pool')->find_one($id); $d = ORM::for_table('tbl_pool')->find_one($id);
$mikrotik = Mikrotik::info($d['routers']); $mikrotik = Mikrotik::info($d['routers']);
if ($d) { if ($d) {
if (!$_c['radius_mode']) { if (!$config['radius_mode']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePool($client, $d['pool_name']); Mikrotik::removePool($client, $d['pool_name']);
} }
@ -92,7 +92,7 @@ switch ($action) {
} }
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
if ($msg == '') { if ($msg == '') {
if (!$_c['radius_mode']) { if (!$config['radius_mode']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePool($client, $name, $ip_address); Mikrotik::removePool($client, $name, $ip_address);
} }
@ -132,7 +132,7 @@ switch ($action) {
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
if ($msg == '') { if ($msg == '') {
if (!$_c['radius_mode']) { if (!$config['radius_mode']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setPool($client, $name,$poolName, $ip_address); Mikrotik::setPool($client, $name,$poolName, $ip_address);
} }

View File

@ -103,7 +103,7 @@ switch ($action) {
run_hook('recharge_customer'); #HOOK run_hook('recharge_customer'); #HOOK
if ($type == 'Hotspot') { if ($type == 'Hotspot') {
if ($b) { if ($b) {
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client,$c['username']); Mikrotik::removeHotspotUser($client,$c['username']);
Mikrotik::addHotspotUser($client,$p,$c); Mikrotik::addHotspotUser($client,$p,$c);
@ -136,7 +136,7 @@ switch ($action) {
$t->type = "Hotspot"; $t->type = "Hotspot";
$t->save(); $t->save();
} else { } else {
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addHotspotUser($client,$p,$c); Mikrotik::addHotspotUser($client,$p,$c);
} }
@ -175,7 +175,7 @@ switch ($action) {
} else { } else {
if ($b) { if ($b) {
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePpoeUser($client,$c['username']); Mikrotik::removePpoeUser($client,$c['username']);
Mikrotik::addPpoeUser($client,$p,$c); Mikrotik::addPpoeUser($client,$p,$c);
@ -208,7 +208,7 @@ switch ($action) {
$t->type = "PPPOE"; $t->type = "PPPOE";
$t->save(); $t->save();
} else { } else {
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addPpoeUser($client,$p,$c); Mikrotik::addPpoeUser($client,$p,$c);
} }
@ -249,9 +249,9 @@ switch ($action) {
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one(); $in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
$ui->assign('in', $in); $ui->assign('in', $in);
sendWhatsapp($c['username'], "*$_c[CompanyName]*\n". sendWhatsapp($c['username'], "*$config[CompanyName]*\n".
"$_c[address]\n". "$config[address]\n".
"$_c[phone]\n". "$config[phone]\n".
"\n\n". "\n\n".
"INVOICE: *$in[invoice]*\n". "INVOICE: *$in[invoice]*\n".
"$_L[Date] : $date_now\n". "$_L[Date] : $date_now\n".
@ -259,13 +259,13 @@ switch ($action) {
"\n\n". "\n\n".
"$_L[Type] : *$in[type]*\n". "$_L[Type] : *$in[type]*\n".
"$_L[Plan_Name] : *$in[plan_name]*\n". "$_L[Plan_Name] : *$in[plan_name]*\n".
"$_L[Plan_Price] : *$_c[currency_code] ".number_format($in['price'],2,$_c['dec_point'],$_c['thousands_sep'])."*\n\n". "$_L[Plan_Price] : *$config[currency_code] ".number_format($in['price'],2,$config['dec_point'],$config['thousands_sep'])."*\n\n".
"$_L[Username] : *$in[username]*\n". "$_L[Username] : *$in[username]*\n".
"$_L[Password] : **********\n\n". "$_L[Password] : **********\n\n".
"$_L[Created_On] :\n*".date($_c['date_format'], strtotime($in['recharged_on']))." $in[time]*\n". "$_L[Created_On] :\n*".date($config['date_format'], strtotime($in['recharged_on']))." $in[time]*\n".
"$_L[Expires_On] :\n*".date($_c['date_format'], strtotime($in['expiration']))." $in[time]*\n". "$_L[Expires_On] :\n*".date($config['date_format'], strtotime($in['expiration']))." $in[time]*\n".
"\n\n". "\n\n".
"$_c[note]"); "$config[note]");
$ui->assign('date', $date_now); $ui->assign('date', $date_now);
@ -309,14 +309,14 @@ switch ($action) {
if ($d) { if ($d) {
run_hook('delete_customer_active_plan'); #HOOK run_hook('delete_customer_active_plan'); #HOOK
if ($d['type'] == 'Hotspot') { if ($d['type'] == 'Hotspot') {
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client,$c['username']); Mikrotik::removeHotspotUser($client,$c['username']);
} }
$d->delete(); $d->delete();
} else { } else {
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePpoeUser($client,$c['username']); Mikrotik::removePpoeUser($client,$c['username']);
} }
@ -560,7 +560,7 @@ switch ($action) {
if ($v1) { if ($v1) {
if ($v1['type'] == 'Hotspot') { if ($v1['type'] == 'Hotspot') {
if ($b) { if ($b) {
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client,$c['username']); Mikrotik::removeHotspotUser($client,$c['username']);
Mikrotik::addHotspotUser($client,$p,$c); Mikrotik::addHotspotUser($client,$p,$c);
@ -593,7 +593,7 @@ switch ($action) {
$t->type = "Hotspot"; $t->type = "Hotspot";
$t->save(); $t->save();
} else { } else {
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addHotspotUser($client,$p,$c); Mikrotik::addHotspotUser($client,$p,$c);
} }
@ -637,7 +637,7 @@ switch ($action) {
"\nPrice: ".$p['price']); "\nPrice: ".$p['price']);
} else { } else {
if ($b) { if ($b) {
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePpoeUser($client,$c['username']); Mikrotik::removePpoeUser($client,$c['username']);
Mikrotik::addPpoeUser($client,$p,$c); Mikrotik::addPpoeUser($client,$p,$c);
@ -670,7 +670,7 @@ switch ($action) {
$t->type = "PPPOE"; $t->type = "PPPOE";
$t->save(); $t->save();
} else { } else {
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addPpoeUser($client,$p,$c); Mikrotik::addPpoeUser($client,$p,$c);
} }
@ -718,9 +718,9 @@ switch ($action) {
$ui->assign('in', $in); $ui->assign('in', $in);
sendWhatsapp($c['username'], "*$_c[CompanyName]*\n". sendWhatsapp($c['username'], "*$config[CompanyName]*\n".
"$_c[address]\n". "$config[address]\n".
"$_c[phone]\n". "$config[phone]\n".
"\n\n". "\n\n".
"INVOICE: *$in[invoice]*\n". "INVOICE: *$in[invoice]*\n".
"$_L[Date] : $date_now\n". "$_L[Date] : $date_now\n".
@ -728,13 +728,13 @@ switch ($action) {
"\n\n". "\n\n".
"$_L[Type] : *$in[type]*\n". "$_L[Type] : *$in[type]*\n".
"$_L[Plan_Name] : *$in[plan_name]*\n". "$_L[Plan_Name] : *$in[plan_name]*\n".
"$_L[Plan_Price] : *$_c[currency_code] ".number_format($in['price'],2,$_c['dec_point'],$_c['thousands_sep'])."*\n\n". "$_L[Plan_Price] : *$config[currency_code] ".number_format($in['price'],2,$config['dec_point'],$config['thousands_sep'])."*\n\n".
"$_L[Username] : *$in[username]*\n". "$_L[Username] : *$in[username]*\n".
"$_L[Password] : **********\n\n". "$_L[Password] : **********\n\n".
"$_L[Created_On] :\n*".date($_c['date_format'], strtotime($in['recharged_on']))." $in[time]*\n". "$_L[Created_On] :\n*".date($config['date_format'], strtotime($in['recharged_on']))." $in[time]*\n".
"$_L[Expires_On] :\n*".date($_c['date_format'], strtotime($in['expiration']))." $in[time]*\n". "$_L[Expires_On] :\n*".date($config['date_format'], strtotime($in['expiration']))." $in[time]*\n".
"\n\n". "\n\n".
"$_c[note]"); "$config[note]");
$ui->assign('date', $date_now); $ui->assign('date', $date_now);
$ui->display('invoice.tpl'); $ui->display('invoice.tpl');

View File

@ -39,7 +39,7 @@ switch ($do) {
$msg .= $_L['PasswordsNotMatch'] . '<br>'; $msg .= $_L['PasswordsNotMatch'] . '<br>';
} }
if(!empty($_c['sms_url'])){ if(!empty($config['sms_url'])){
$otpPath .= sha1($username.$db_password).".txt"; $otpPath .= sha1($username.$db_password).".txt";
run_hook('validate_otp'); #HOOK run_hook('validate_otp'); #HOOK
if(file_exists($otpPath) && time()-filemtime($otpPath)>300){ if(file_exists($otpPath) && time()-filemtime($otpPath)>300){
@ -109,7 +109,7 @@ switch ($do) {
break; break;
default: default:
if(!empty($_c['sms_url'])){ if(!empty($config['sms_url'])){
$username = _post('username'); $username = _post('username');
if(!empty($username)){ if(!empty($username)){
$d = ORM::for_table('tbl_customers')->where('username', $username)->find_one(); $d = ORM::for_table('tbl_customers')->where('username', $username)->find_one();
@ -132,7 +132,7 @@ switch ($do) {
}else{ }else{
$otp = rand(100000,999999); $otp = rand(100000,999999);
file_put_contents($otpPath, $otp); file_put_contents($otpPath, $otp);
sendSMS($username,$_c['CompanyName']."\nYour Verification code are: $otp"); sendSMS($username,$config['CompanyName']."\nYour Verification code are: $otp");
$ui->assign('username', $username); $ui->assign('username', $username);
$ui->assign('notify', '<div class="alert alert-success"> $ui->assign('notify', '<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert"> <button type="button" class="close" data-dismiss="alert">

View File

@ -85,7 +85,7 @@ switch ($action) {
$msg .= $_L['Router_already_exist']. '<br>'; $msg .= $_L['Router_already_exist']. '<br>';
} }
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
Mikrotik::getClient($ip_address,$username,$password); Mikrotik::getClient($ip_address,$username,$password);
} }
@ -146,7 +146,7 @@ switch ($action) {
} }
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
Mikrotik::getClient($ip_address,$username,$password); Mikrotik::getClient($ip_address,$username,$password);
} }

View File

@ -70,7 +70,7 @@ switch ($action) {
$d = ORM::for_table('tbl_plans')->find_one($id); $d = ORM::for_table('tbl_plans')->find_one($id);
if ($d) { if ($d) {
run_hook('delete_plan'); #HOOK run_hook('delete_plan'); #HOOK
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$mikrotik = Mikrotik::info($d['routers']); $mikrotik = Mikrotik::info($d['routers']);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotPlan($client,$d['name_plan']); Mikrotik::removeHotspotPlan($client,$d['name_plan']);
@ -130,7 +130,7 @@ switch ($action) {
} }
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown; $rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addHotspotPlan($client, $name, $sharedusers, $rate); Mikrotik::addHotspotPlan($client, $name, $sharedusers, $rate);
@ -209,7 +209,7 @@ switch ($action) {
} }
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown; $rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setHotspotPlan($client, $name, $sharedusers, $rate); Mikrotik::setHotspotPlan($client, $name, $sharedusers, $rate);
@ -290,7 +290,7 @@ switch ($action) {
$d = ORM::for_table('tbl_plans')->find_one($id); $d = ORM::for_table('tbl_plans')->find_one($id);
if ($d) { if ($d) {
run_hook('delete_ppoe'); #HOOK run_hook('delete_ppoe'); #HOOK
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$mikrotik = Mikrotik::info($d['routers']); $mikrotik = Mikrotik::info($d['routers']);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePpoePlan($client, $d['name_plan']); Mikrotik::removePpoePlan($client, $d['name_plan']);
@ -341,7 +341,7 @@ switch ($action) {
} }
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown; $rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addPpoePlan($client, $name, $pool, $rate); Mikrotik::addPpoePlan($client, $name, $pool, $rate);
@ -407,7 +407,7 @@ switch ($action) {
} }
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown; $rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
if(!$_c['radius_mode']){ if(!$config['radius_mode']){
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setPpoePlan($client, $name, $pool, $rate); Mikrotik::setPpoePlan($client, $name, $pool, $rate);

View File

@ -53,7 +53,7 @@ switch ($action) {
if ($v1) { if ($v1) {
if ($v1['type'] == 'Hotspot') { if ($v1['type'] == 'Hotspot') {
if ($b) { if ($b) {
if (!$_c['radius_mode']) { if (!$config['radius_mode']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']);
Mikrotik::addHotspotUser($client, $p, $c); Mikrotik::addHotspotUser($client, $p, $c);
@ -85,7 +85,7 @@ switch ($action) {
$t->type = "Hotspot"; $t->type = "Hotspot";
$t->save(); $t->save();
} else { } else {
if (!$_c['radius_mode']) { if (!$config['radius_mode']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addHotspotUser($client, $p, $c); Mikrotik::addHotspotUser($client, $p, $c);
} }
@ -129,7 +129,7 @@ switch ($action) {
"\nPrice: " . $p['price']); "\nPrice: " . $p['price']);
} else { } else {
if ($b) { if ($b) {
if (!$_c['radius_mode']) { if (!$config['radius_mode']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']);
Mikrotik::addPpoeUser($client, $p, $c); Mikrotik::addPpoeUser($client, $p, $c);
@ -162,7 +162,7 @@ switch ($action) {
$t->type = "PPPOE"; $t->type = "PPPOE";
$t->save(); $t->save();
} else { } else {
if (!$_c['radius_mode']) { if (!$config['radius_mode']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addPpoeUser($client, $p, $c); Mikrotik::addPpoeUser($client, $p, $c);
} }

View File

@ -6,7 +6,6 @@
require('../config.php'); require('../config.php');
require('orm.php'); require('orm.php');
use PEAR2\Net\RouterOS;
require_once 'autoload/PEAR2/Autoload.php'; require_once 'autoload/PEAR2/Autoload.php';
ORM::configure("mysql:host=$db_host;dbname=$db_name"); ORM::configure("mysql:host=$db_host;dbname=$db_name");
@ -15,6 +14,41 @@ ORM::configure('password', $db_password);
ORM::configure('return_result_sets', true); ORM::configure('return_result_sets', true);
ORM::configure('logging', true); ORM::configure('logging', true);
include "autoload/Hookers.php";
//register all plugin
foreach (glob("system/plugin/*.php") as $filename)
{
include $filename;
}
// on some server, it getting error because of slash is backwards
function _autoloader($class)
{
if (strpos($class, '_') !== false) {
$class = str_replace('_', DIRECTORY_SEPARATOR, $class);
if (file_exists('autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
include 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
} else {
$class = str_replace("\\", DIRECTORY_SEPARATOR, $class);
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'))
include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
}
} else {
if (file_exists('autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
include 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
} else {
$class = str_replace("\\", DIRECTORY_SEPARATOR, $class);
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'))
include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
}
}
}
spl_autoload_register('_autoloader');
$result = ORM::for_table('tbl_appconfig')->find_many(); $result = ORM::for_table('tbl_appconfig')->find_many();
foreach($result as $value){ foreach($result as $value){
$config[$value['setting']]=$value['value']; $config[$value['setting']]=$value['value'];
@ -23,6 +57,8 @@ date_default_timezone_set($config['timezone']);
$d = ORM::for_table('tbl_user_recharges')->where('status','on')->find_many(); $d = ORM::for_table('tbl_user_recharges')->where('status','on')->find_many();
run_hook('cronjob'); #HOOK
foreach ($d as $ds){ foreach ($d as $ds){
if($ds['type'] == 'Hotspot'){ if($ds['type'] == 'Hotspot'){
$date_now = strtotime(date("Y-m-d H:i:s")); $date_now = strtotime(date("Y-m-d H:i:s"));