url using getUrl

This commit is contained in:
iBNu Maksum 2025-01-31 16:22:58 +07:00
parent 9bf80467a1
commit 1e43ac210a
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
37 changed files with 415 additions and 390 deletions

View File

@ -42,7 +42,7 @@ spl_autoload_register('_autoloader');
if (!file_exists($root_path . 'config.php')) { if (!file_exists($root_path . 'config.php')) {
$root_path .= '..' . DIRECTORY_SEPARATOR; $root_path .= '..' . DIRECTORY_SEPARATOR;
if (!file_exists($root_path . 'config.php')) { if (!file_exists($root_path . 'config.php')) {
r2('install'); r2(getUrl('install'));
} }
} }
@ -196,7 +196,7 @@ function _auth($login = true)
return true; return true;
} else { } else {
if ($login) { if ($login) {
r2(U . 'login'); r2(getUrl('login'));
} else { } else {
return false; return false;
} }
@ -209,7 +209,7 @@ function _admin($login = true)
return true; return true;
} else { } else {
if ($login) { if ($login) {
r2(U . 'login'); r2(getUrl('login'));
} else { } else {
return false; return false;
} }
@ -261,6 +261,13 @@ function showResult($success, $message = '', $result = [], $meta = [])
die(); die();
} }
/**
* make url canonical or standar
*/
function getUrl($url)
{
Text::url($url);
}
function generateUniqueNumericVouchers($totalVouchers, $length = 8) function generateUniqueNumericVouchers($totalVouchers, $length = 8)
{ {
@ -333,10 +340,10 @@ function _alert($text, $type = 'success', $url = "home", $time = 3)
if (!isset($ui)) return; if (!isset($ui)) return;
if (strlen($url) > 4) { if (strlen($url) > 4) {
if (substr($url, 0, 4) != "http") { if (substr($url, 0, 4) != "http") {
$url = U . $url; $url = getUrl($url);
} }
} else { } else {
$url = U . $url; $url = getUrl($url);
} }
$ui->assign('text', $text); $ui->assign('text', $text);
$ui->assign('type', $type); $ui->assign('type', $type);

View File

@ -74,10 +74,10 @@ class Package
if (!$p['enabled']) { if (!$p['enabled']) {
if (!isset($admin) || !isset($admin['id']) || empty($admin['id'])) { if (!isset($admin) || !isset($admin['id']) || empty($admin['id'])) {
r2(U . 'home', 'e', Lang::T('Plan Not found')); r2(getUrl('home'), 'e', Lang::T('Plan Not found'));
} }
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . 'dashboard', 'e', Lang::T('You do not have permission to access this page')); r2(getUrl('dashboard'), 'e', Lang::T('You do not have permission to access this page'));
} }
} }

View File

@ -14,7 +14,7 @@ class Paginator
$adjacents = "2"; $adjacents = "2";
$page = _get('p', 1); $page = _get('p', 1);
$page = (empty($page) ? 1 : $page); $page = (empty($page) ? 1 : $page);
$url = U . implode('/', $routes); $url = getUrl(implode('/', $routes));
if (count($search) > 0) { if (count($search) > 0) {
$url .= '&' . http_build_query($search); $url .= '&' . http_build_query($search);
} }
@ -83,7 +83,7 @@ class Paginator
{ {
global $routes; global $routes;
global $_L; global $_L;
$url = U . implode('/', $routes); $url = getUrl(implode('/', $routes));
$query = urlencode($query); $query = urlencode($query);
$adjacents = "2"; $adjacents = "2";
$page = (int)(empty(_get('p')) ? 1 : _get('p')); $page = (int)(empty(_get('p')) ? 1 : _get('p'));
@ -169,7 +169,7 @@ class Paginator
{ {
global $routes; global $routes;
global $_L; global $_L;
$url = U . $routes['0'] . '/' . $routes['1'] . '/'; $url = getUrl($routes['0'] . '/' . $routes['1'] . '/');
$adjacents = "2"; $adjacents = "2";
$page = (int)(!isset($routes['2']) ? 1 : $routes['2']); $page = (int)(!isset($routes['2']) ? 1 : $routes['2']);
$pagination = ""; $pagination = "";
@ -277,7 +277,7 @@ class Paginator
{ {
global $routes; global $routes;
global $_L; global $_L;
$url = U . $routes['0'] . '/' . $routes['1'] . '/'; $url = getUrl($routes['0'] . '/' . $routes['1'] . '/');
$adjacents = "2"; $adjacents = "2";
$page = (int)(!isset($routes['2']) ? 1 : $routes['2']); $page = (int)(!isset($routes['2']) ? 1 : $routes['2']);
$pagination = ""; $pagination = "";

View File

@ -109,4 +109,20 @@ class Text
} }
return $result; return $result;
} }
public static function url(...$data){
global $config;
$url = implode("", $data);
if ($config['url_canonical'] != 'Yes') {
$u = str_replace('?_route=', '', U);
$pos = strpos($url, '&');
if ($pos === false) {
return $u . $url;
} else {
return $u . substr($url, 0, $pos) . '?' . substr($url, $pos + 1);
}
} else {
return U . $url;
}
}
} }

View File

@ -206,7 +206,7 @@ class User
global $config; global $config;
if ($config['maintenance_mode'] == true) { if ($config['maintenance_mode'] == true) {
if ($config['maintenance_mode_logout'] == true) { if ($config['maintenance_mode_logout'] == true) {
r2(U . 'logout', 'd', ''); r2(getUrl('logout'), 'd', '');
} else { } else {
displayMaintenanceMessage(); displayMaintenanceMessage();
} }
@ -226,7 +226,7 @@ class User
global $config; global $config;
if ($config['maintenance_mode'] == true) { if ($config['maintenance_mode'] == true) {
if ($config['maintenance_mode_logout'] == true) { if ($config['maintenance_mode_logout'] == true) {
r2(U . 'logout', 'd', ''); r2(getUrl('logout'), 'd', '');
} else { } else {
displayMaintenanceMessage(); displayMaintenanceMessage();
} }

View File

@ -96,7 +96,7 @@ try {
foreach ($menu_registered as $menu) { foreach ($menu_registered as $menu) {
if ($menu['admin'] && _admin(false)) { if ($menu['admin'] && _admin(false)) {
if (count($menu['auth']) == 0 || in_array($admin['user_type'], $menu['auth'])) { if (count($menu['auth']) == 0 || in_array($admin['user_type'], $menu['auth'])) {
$menus[$menu['position']] .= '<li' . (($routes[1] == $menu['function']) ? ' class="active"' : '') . '><a href="' . U . 'plugin/' . $menu['function'] . '">'; $menus[$menu['position']] .= '<li' . (($routes[1] == $menu['function']) ? ' class="active"' : '') . '><a href="' . getUrl('plugin/' . $menu['function']) . '">';
if (!empty($menu['icon'])) { if (!empty($menu['icon'])) {
$menus[$menu['position']] .= '<i class="' . $menu['icon'] . '"></i>'; $menus[$menu['position']] .= '<i class="' . $menu['icon'] . '"></i>';
} }
@ -107,7 +107,7 @@ try {
$menus[$menu['position']] .= '<span class="text">' . $menu['name'] . '</span></a></li>'; $menus[$menu['position']] .= '<span class="text">' . $menu['name'] . '</span></a></li>';
} }
} else if (!$menu['admin'] && _auth(false)) { } else if (!$menu['admin'] && _auth(false)) {
$menus[$menu['position']] .= '<li' . (($routes[1] == $menu['function']) ? ' class="active"' : '') . '><a href="' . U . 'plugin/' . $menu['function'] . '">'; $menus[$menu['position']] .= '<li' . (($routes[1] == $menu['function']) ? ' class="active"' : '') . '><a href="' . getUrl('plugin/' . $menu['function']) . '">';
if (!empty($menu['icon'])) { if (!empty($menu['icon'])) {
$menus[$menu['position']] .= '<i class="' . $menu['icon'] . '"></i>'; $menus[$menu['position']] .= '<i class="' . $menu['icon'] . '"></i>';
} }
@ -124,7 +124,11 @@ try {
unset($menus, $menu_registered); unset($menus, $menu_registered);
include($sys_render); include($sys_render);
} else { } else {
r2(U . 'dashboard', 'e', 'not found'); // header 404
header("HTTP/1.0 404 Not Found");
header("Content-Type: text/html; charset=utf-8");
echo "404 Not Found";
die();
} }
} catch (Throwable $e) { } catch (Throwable $e) {
Message::sendTelegram( Message::sendTelegram(

View File

@ -27,7 +27,7 @@ switch ($action) {
$password = _post('password'); $password = _post('password');
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'accounts/change-password', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('accounts/change-password'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
run_hook('customer_change_password'); #HOOK run_hook('customer_change_password'); #HOOK
if ($password != '') { if ($password != '') {
@ -36,10 +36,10 @@ switch ($action) {
$cnpass = _post('cnpass'); $cnpass = _post('cnpass');
if ($password == $d_pass) { if ($password == $d_pass) {
if (!Validator::Length($password, 36, 2)) { if (!Validator::Length($password, 36, 2)) {
r2(U . 'accounts/change-password', 'e', 'New Password must be 2 to 35 character'); r2(getUrl('accounts/change-password'), 'e', 'New Password must be 2 to 35 character');
} }
if ($npass != $cnpass) { if ($npass != $cnpass) {
r2(U . 'accounts/change-password', 'e', 'Both Password should be same'); r2(getUrl('accounts/change-password'), 'e', 'Both Password should be same');
} }
$user->password = $npass; $user->password = $npass;
$turs = ORM::for_table('tbl_user_recharges')->where('customer_id', $user['id'])->find_many(); $turs = ORM::for_table('tbl_user_recharges')->where('customer_id', $user['id'])->find_many();
@ -64,10 +64,10 @@ switch ($action) {
_log('[' . $user['username'] . ']: Password changed successfully', 'User', $user['id']); _log('[' . $user['username'] . ']: Password changed successfully', 'User', $user['id']);
_alert(Lang::T('Password changed successfully, Please login again'), 'success', "login"); _alert(Lang::T('Password changed successfully, Please login again'), 'success', "login");
} else { } else {
r2(U . 'accounts/change-password', 'e', Lang::T('Incorrect Current Password')); r2(getUrl('accounts/change-password'), 'e', Lang::T('Incorrect Current Password'));
} }
} else { } else {
r2(U . 'accounts/change-password', 'e', Lang::T('Incorrect Current Password')); r2(getUrl('accounts/change-password'), 'e', Lang::T('Incorrect Current Password'));
} }
break; break;
@ -81,7 +81,7 @@ switch ($action) {
case 'edit-profile-post': case 'edit-profile-post':
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'accounts/profile', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('accounts/profile'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$fullname = _post('fullname'); $fullname = _post('fullname');
$address = _post('address'); $address = _post('address');
@ -142,7 +142,7 @@ switch ($action) {
} }
if (file_exists($_FILES['photo']['tmp_name'])) unlink($_FILES['photo']['tmp_name']); if (file_exists($_FILES['photo']['tmp_name'])) unlink($_FILES['photo']['tmp_name']);
} else { } else {
r2(U . 'settings/app', 'e', 'PHP GD is not installed'); r2(getUrl('settings/app'), 'e', 'PHP GD is not installed');
} }
} }
@ -160,9 +160,9 @@ switch ($action) {
$user->save(); $user->save();
_log('[' . $user['username'] . ']: ' . Lang::T('User Updated Successfully'), 'User', $user['id']); _log('[' . $user['username'] . ']: ' . Lang::T('User Updated Successfully'), 'User', $user['id']);
r2(U . 'accounts/profile', 's', Lang::T('User Updated Successfully')); r2(getUrl('accounts/profile'), 's', Lang::T('User Updated Successfully'));
}else{ }else{
r2(U . 'accounts/profile', 'e', $msg); r2(getUrl('accounts/profile'), 'e', $msg);
} }
break; break;
@ -177,7 +177,7 @@ switch ($action) {
case 'phone-update-otp': case 'phone-update-otp':
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('accounts/phone-update'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$phone = Lang::phoneFormat(_post('phone')); $phone = Lang::phoneFormat(_post('phone'));
$username = $user['username']; $username = $user['username'];
@ -185,16 +185,16 @@ switch ($action) {
$_SESSION['new_phone'] = $phone; $_SESSION['new_phone'] = $phone;
// Validate the phone number format // Validate the phone number format
if (!preg_match('/^[0-9]{10,}$/', $phone) || empty($phone)) { if (!preg_match('/^[0-9]{10,}$/', $phone) || empty($phone)) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Invalid phone number format')); r2(getUrl('accounts/phone-update'), 'e', Lang::T('Invalid phone number format'));
} }
if (empty($config['sms_url'])) { if (empty($config['sms_url'])) {
r2(U . 'accounts/phone-update', 'e', Lang::T('SMS server not Available, Please try again later')); r2(getUrl('accounts/phone-update'), 'e', Lang::T('SMS server not Available, Please try again later'));
} }
$d = ORM::for_table('tbl_customers')->whereNotEqual('username', $username)->where('phonenumber', $phone)->find_one(); $d = ORM::for_table('tbl_customers')->whereNotEqual('username', $username)->where('phonenumber', $phone)->find_one();
if ($d) { if ($d) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Phone number already registered by another customer')); r2(getUrl('accounts/phone-update'), 'e', Lang::T('Phone number already registered by another customer'));
} }
if (!file_exists($otpPath)) { if (!file_exists($otpPath)) {
mkdir($otpPath); mkdir($otpPath);
@ -205,7 +205,7 @@ switch ($action) {
// expired 10 minutes // expired 10 minutes
if (file_exists($otpFile) && time() - filemtime($otpFile) < 600) { if (file_exists($otpFile) && time() - filemtime($otpFile) < 600) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Please wait ') . (600 - (time() - filemtime($otpFile))) . Lang::T(' seconds before sending another SMS')); r2(getUrl('accounts/phone-update'), 'e', Lang::T('Please wait ') . (600 - (time() - filemtime($otpFile))) . Lang::T(' seconds before sending another SMS'));
} else { } else {
$otp = rand(100000, 999999); $otp = rand(100000, 999999);
file_put_contents($otpFile, $otp); file_put_contents($otpFile, $otp);
@ -220,7 +220,7 @@ switch ($action) {
Message::sendWhatsapp($phone, $config['CompanyName'] . "\n\n" . Lang::T("Verification code") . "\n$otp"); Message::sendWhatsapp($phone, $config['CompanyName'] . "\n\n" . Lang::T("Verification code") . "\n$otp");
} }
//redirect after sending OTP //redirect after sending OTP
r2(U . 'accounts/phone-update', 'e', Lang::T('Verification code has been sent to your phone')); r2(getUrl('accounts/phone-update'), 'e', Lang::T('Verification code has been sent to your phone'));
} }
break; break;
@ -228,7 +228,7 @@ switch ($action) {
case 'phone-update-post': case 'phone-update-post':
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('accounts/phone-update'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$phone = Lang::phoneFormat(_post('phone')); $phone = Lang::phoneFormat(_post('phone'));
$otp_code = _post('otp'); $otp_code = _post('otp');
@ -237,11 +237,11 @@ switch ($action) {
// Validate the phone number format // Validate the phone number format
if (!preg_match('/^[0-9]{10,}$/', $phone)) { if (!preg_match('/^[0-9]{10,}$/', $phone)) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Invalid phone number format')); r2(getUrl('accounts/phone-update'), 'e', Lang::T('Invalid phone number format'));
} }
if (empty($config['sms_url'])) { if (empty($config['sms_url'])) {
r2(U . 'accounts/phone-update', 'e', Lang::T('SMS server not Available, Please try again later')); r2(getUrl('accounts/phone-update'), 'e', Lang::T('SMS server not Available, Please try again later'));
} }
$otpFile = $otpPath . sha1($username . $db_pass) . ".txt"; $otpFile = $otpPath . sha1($username . $db_pass) . ".txt";
@ -249,7 +249,7 @@ switch ($action) {
// Check if OTP file exists // Check if OTP file exists
if (!file_exists($otpFile)) { if (!file_exists($otpFile)) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Please request OTP first')); r2(getUrl('accounts/phone-update'), 'e', Lang::T('Please request OTP first'));
exit(); exit();
} }
@ -257,21 +257,21 @@ switch ($action) {
if (time() - filemtime($otpFile) > 1200) { if (time() - filemtime($otpFile) > 1200) {
unlink($otpFile); unlink($otpFile);
unlink($phoneFile); unlink($phoneFile);
r2(U . 'accounts/phone-update', 'e', Lang::T('Verification code expired')); r2(getUrl('accounts/phone-update'), 'e', Lang::T('Verification code expired'));
exit(); exit();
} else { } else {
$code = file_get_contents($otpFile); $code = file_get_contents($otpFile);
// Check if OTP code matches // Check if OTP code matches
if ($code != $otp_code) { if ($code != $otp_code) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Wrong Verification code')); r2(getUrl('accounts/phone-update'), 'e', Lang::T('Wrong Verification code'));
exit(); exit();
} }
// Check if the phone number matches the one that requested the OTP // Check if the phone number matches the one that requested the OTP
$savedPhone = file_get_contents($phoneFile); $savedPhone = file_get_contents($phoneFile);
if ($savedPhone !== $phone) { if ($savedPhone !== $phone) {
r2(U . 'accounts/phone-update', 'e', Lang::T('The phone number does not match the one that requested the OTP')); r2(getUrl('accounts/phone-update'), 'e', Lang::T('The phone number does not match the one that requested the OTP'));
exit(); exit();
} }
@ -284,7 +284,7 @@ switch ($action) {
$user->phonenumber = Lang::phoneFormat($phone); $user->phonenumber = Lang::phoneFormat($phone);
$user->save(); $user->save();
r2(U . 'accounts/profile', 's', Lang::T('Phone number updated successfully')); r2(getUrl('accounts/profile'), 's', Lang::T('Phone number updated successfully'));
break; break;
case 'email-update': case 'email-update':
@ -296,7 +296,7 @@ switch ($action) {
case 'email-update-otp': case 'email-update-otp':
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'accounts/email-update', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('accounts/email-update'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$email = trim(_post('email')); $email = trim(_post('email'));
$username = $user['username']; $username = $user['username'];
@ -304,16 +304,16 @@ switch ($action) {
$_SESSION['new_email'] = $email; $_SESSION['new_email'] = $email;
// Validate the phone number format // Validate the phone number format
if (!Validator::Email($email)) { if (!Validator::Email($email)) {
r2(U . 'accounts/email-update', 'e', Lang::T('Invalid Email address format')); r2(getUrl('accounts/email-update'), 'e', Lang::T('Invalid Email address format'));
} }
if (empty($config['smtp_host'])) { if (empty($config['smtp_host'])) {
r2(U . 'accounts/email-update', 'e', Lang::T('Email server not Available, Please ask admin to configure it')); r2(getUrl('accounts/email-update'), 'e', Lang::T('Email server not Available, Please ask admin to configure it'));
} }
$d = ORM::for_table('tbl_customers')->whereNotEqual('username', $username)->where('email', $email)->find_one(); $d = ORM::for_table('tbl_customers')->whereNotEqual('username', $username)->where('email', $email)->find_one();
if ($d) { if ($d) {
r2(U . 'accounts/email-update', 'e', Lang::T('Email already used by another Customer')); r2(getUrl('accounts/email-update'), 'e', Lang::T('Email already used by another Customer'));
} }
if (!file_exists($otpPath)) { if (!file_exists($otpPath)) {
mkdir($otpPath); mkdir($otpPath);
@ -324,7 +324,7 @@ switch ($action) {
// expired 10 minutes // expired 10 minutes
if (file_exists($otpFile) && time() - filemtime($otpFile) < 600) { if (file_exists($otpFile) && time() - filemtime($otpFile) < 600) {
r2(U . 'accounts/email-update', 'e', Lang::T('Please wait ') . (600 - (time() - filemtime($otpFile))) . Lang::T(' seconds before sending another Email')); r2(getUrl('accounts/email-update'), 'e', Lang::T('Please wait ') . (600 - (time() - filemtime($otpFile))) . Lang::T(' seconds before sending another Email'));
} else { } else {
$otp = rand(100000, 999999); $otp = rand(100000, 999999);
file_put_contents($otpFile, $otp); file_put_contents($otpFile, $otp);
@ -333,7 +333,7 @@ switch ($action) {
$body = Lang::T("Hello") . ' ' . $user['fullname'] . ",\n\n" . Lang::T("Your Email Verification Code is:") . " $otp"; $body = Lang::T("Hello") . ' ' . $user['fullname'] . ",\n\n" . Lang::T("Your Email Verification Code is:") . " $otp";
Message::sendEmail($email, Lang::T('Change Email Verification Code'), $body); Message::sendEmail($email, Lang::T('Change Email Verification Code'), $body);
//redirect after sending OTP //redirect after sending OTP
r2(U . 'accounts/email-update', 'e', Lang::T('Verification code has been sent to your email. Check Spam folder if not found.')); r2(getUrl('accounts/email-update'), 'e', Lang::T('Verification code has been sent to your email. Check Spam folder if not found.'));
} }
break; break;
@ -341,7 +341,7 @@ switch ($action) {
case 'email-update-post': case 'email-update-post':
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'accounts/email-update', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('accounts/email-update'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$email = trim(_post('email')); $email = trim(_post('email'));
$otp_code = _post('otp'); $otp_code = _post('otp');
@ -349,12 +349,12 @@ switch ($action) {
$otpPath = $CACHE_PATH . '/email/'; $otpPath = $CACHE_PATH . '/email/';
// Validate the phone number format // Validate the phone number format
if (!Validator::Email($email)) { if (!Validator::Email($email)) {
r2(U . 'accounts/email-update', 'e', Lang::T('Invalid Email address format')); r2(getUrl('accounts/email-update'), 'e', Lang::T('Invalid Email address format'));
exit(); exit();
} }
if (empty($config['smtp_host'])) { if (empty($config['smtp_host'])) {
r2(U . 'accounts/email-update', 'e', Lang::T('Email server not Available, Please ask admin to configure it')); r2(getUrl('accounts/email-update'), 'e', Lang::T('Email server not Available, Please ask admin to configure it'));
} }
$otpFile = $otpPath . sha1($username . $db_pass) . ".txt"; $otpFile = $otpPath . sha1($username . $db_pass) . ".txt";
@ -362,7 +362,7 @@ switch ($action) {
// Check if OTP file exists // Check if OTP file exists
if (!file_exists($otpFile)) { if (!file_exists($otpFile)) {
r2(U . 'accounts/email-update', 'e', Lang::T('Please request OTP first')); r2(getUrl('accounts/email-update'), 'e', Lang::T('Please request OTP first'));
exit(); exit();
} }
@ -370,21 +370,21 @@ switch ($action) {
if (time() - filemtime($otpFile) > 1200) { if (time() - filemtime($otpFile) > 1200) {
unlink($otpFile); unlink($otpFile);
unlink($emailFile); unlink($emailFile);
r2(U . 'accounts/email-update', 'e', Lang::T('Verification code expired')); r2(getUrl('accounts/email-update'), 'e', Lang::T('Verification code expired'));
exit(); exit();
} else { } else {
$code = file_get_contents($otpFile); $code = file_get_contents($otpFile);
// Check if OTP code matches // Check if OTP code matches
if ($code != $otp_code) { if ($code != $otp_code) {
r2(U . 'accounts/email-update', 'e', Lang::T('Wrong Verification code')); r2(getUrl('accounts/email-update'), 'e', Lang::T('Wrong Verification code'));
exit(); exit();
} }
// Check if the phone number matches the one that requested the OTP // Check if the phone number matches the one that requested the OTP
$savedEmail = file_get_contents($emailFile); $savedEmail = file_get_contents($emailFile);
if ($savedEmail !== $email) { if ($savedEmail !== $email) {
r2(U . 'accounts/email-update', 'e', Lang::T('The Email Address does not match the one that requested the OTP')); r2(getUrl('accounts/email-update'), 'e', Lang::T('The Email Address does not match the one that requested the OTP'));
exit(); exit();
} }
@ -396,7 +396,7 @@ switch ($action) {
$user->email = $email; $user->email = $email;
$user->save(); $user->save();
r2(U . 'accounts/profile', 's', Lang::T('Email Address updated successfully')); r2(getUrl('accounts/profile'), 's', Lang::T('Email Address updated successfully'));
break; break;
case 'language-update-post': case 'language-update-post':

View File

@ -10,7 +10,7 @@ header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Pragma: no-cache"); header("Pragma: no-cache");
if (Admin::getID()) { if (Admin::getID()) {
r2(U . 'dashboard', "s", Lang::T("You are already logged in")); r2(getUrl('dashboard'), "s", Lang::T("You are already logged in"));
} }
if (isset($routes['1'])) { if (isset($routes['1'])) {

View File

@ -25,10 +25,10 @@ switch ($action) {
if (file_exists($dvc)) { if (file_exists($dvc)) {
require_once $dvc; require_once $dvc;
if ((new $p['device'])->online_customer($user, $bill['routers'])) { 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>'); die('<a href="' . getUrl('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 { } else {
if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) { 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>'); die('<a href="' . getUrl('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 { } else {
die(Lang::T('-')); die(Lang::T('-'));
} }
@ -58,7 +58,7 @@ switch ($action) {
case 'inbox': 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(); $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) { 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>'; echo '<li><a href="' . getUrl('mail/view/' . $inbox['id']) . '">' . $inbox['subject'] . '<br><sub class="text-muted">' . Lang::dateTimeFormat($inbox['date_created']) . '</sub></a></li>';
} }
die(); die();
case 'language': case 'language':
@ -69,7 +69,7 @@ switch ($action) {
if (is_file('system/lan/' . $file) && !in_array($file, ['index.html', 'country.json', '.DS_Store'])) { if (is_file('system/lan/' . $file) && !in_array($file, ['index.html', 'country.json', '.DS_Store'])) {
$file = str_replace(".json", "", $file); $file = str_replace(".json", "", $file);
if(!empty($file)){ if(!empty($file)){
echo '<li><a href="' . U . 'accounts/language-update-post&lang=' . $file. '">'; echo '<li><a href="' . getUrl('accounts/language-update-post&lang=' . $file) . '">';
if($select == $file){ if($select == $file){
echo '<span class="glyphicon glyphicon-ok"></span> '; echo '<span class="glyphicon glyphicon-ok"></span> ';
} }

View File

@ -13,7 +13,7 @@ $action = $routes['1'];
$ui->assign('_admin', $admin); $ui->assign('_admin', $admin);
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', Lang::T('You do not have permission to access this page')); r2(getUrl('dashboard'), 'e', Lang::T('You do not have permission to access this page'));
} }
switch ($action) { switch ($action) {
@ -53,7 +53,7 @@ switch ($action) {
$ui->assign('d', $d); $ui->assign('d', $d);
$ui->display('bandwidth-edit.tpl'); $ui->display('bandwidth-edit.tpl');
} else { } else {
r2(U . 'bandwidth/list', 'e', Lang::T('Account Not Found')); r2(getUrl('bandwidth/list'), 'e', Lang::T('Account Not Found'));
} }
break; break;
@ -66,7 +66,7 @@ switch ($action) {
$d = ORM::for_table('tbl_bandwidth')->find_one($id); $d = ORM::for_table('tbl_bandwidth')->find_one($id);
if ($d) { if ($d) {
$d->delete(); $d->delete();
r2(U . 'bandwidth/list', 's', Lang::T('Data Deleted Successfully')); r2(getUrl('bandwidth/list'), 's', Lang::T('Data Deleted Successfully'));
} }
break; break;
@ -123,9 +123,9 @@ switch ($action) {
$d->burst = $burst; $d->burst = $burst;
$d->save(); $d->save();
r2(U . 'bandwidth/list', 's', Lang::T('Data Created Successfully')); r2(getUrl('bandwidth/list'), 's', Lang::T('Data Created Successfully'));
} else { } else {
r2(U . 'bandwidth/add', 'e', $msg); r2(getUrl('bandwidth/add'), 'e', $msg);
} }
break; break;
@ -179,9 +179,9 @@ switch ($action) {
$d->burst = $burst; $d->burst = $burst;
$d->save(); $d->save();
r2(U . 'bandwidth/list', 's', Lang::T('Data Updated Successfully')); r2(getUrl('bandwidth/list'), 's', Lang::T('Data Updated Successfully'));
} else { } else {
r2(U . 'bandwidth/edit/' . $id, 'e', $msg); r2(getUrl('bandwidth/edit/') . $id, 'e', $msg);
} }
break; break;

View File

@ -79,14 +79,14 @@ switch ($action) {
} }
if (!empty($error)) { if (!empty($error)) {
r2(U . 'coupons/add', 'e', implode('<br>', $error)); r2(getUrl('coupons/add'), 'e', implode('<br>', $error));
exit; exit;
} }
//check if coupon code already exists //check if coupon code already exists
$coupon = ORM::for_table('tbl_coupons')->where('code', $code)->find_one(); $coupon = ORM::for_table('tbl_coupons')->where('code', $code)->find_one();
if ($coupon) { if ($coupon) {
r2(U . 'coupons/add', 'e', Lang::T('Coupon Code already exists')); r2(getUrl('coupons/add'), 'e', Lang::T('Coupon Code already exists'));
exit; exit;
} }
@ -104,10 +104,10 @@ switch ($action) {
$coupon->created_at = date('Y-m-d H:i:s'); $coupon->created_at = date('Y-m-d H:i:s');
try { try {
$coupon->save(); $coupon->save();
r2(U . 'coupons', 's', Lang::T('Coupon has been added successfully')); r2(getUrl('coupons'), 's', Lang::T('Coupon has been added successfully'));
} catch (Exception $e) { } catch (Exception $e) {
_log(Lang::T('Error adding coupon: ' . $e->getMessage())); _log(Lang::T('Error adding coupon: ' . $e->getMessage()));
r2(U . 'coupons/add', 'e', Lang::T('Error adding coupon: ' . $e->getMessage())); r2(getUrl('coupons/add'), 'e', Lang::T('Error adding coupon: ' . $e->getMessage()));
} }
break; break;
@ -120,12 +120,12 @@ switch ($action) {
$coupon_id = intval($routes['2']); $coupon_id = intval($routes['2']);
if (empty($coupon_id)) { if (empty($coupon_id)) {
r2(U . 'coupons', 'e', Lang::T('Invalid Coupon ID')); r2(getUrl('coupons'), 'e', Lang::T('Invalid Coupon ID'));
exit; exit;
} }
$coupon = ORM::for_table('tbl_coupons')->find_one($coupon_id); $coupon = ORM::for_table('tbl_coupons')->find_one($coupon_id);
if (!$coupon) { if (!$coupon) {
r2(U . 'coupons', 'e', Lang::T('Coupon Not Found')); r2(getUrl('coupons'), 'e', Lang::T('Coupon Not Found'));
exit; exit;
} }
$ui->assign('coupon', $coupon); $ui->assign('coupon', $coupon);
@ -189,7 +189,7 @@ switch ($action) {
$error[] = Lang::T('Coupon end date is required'); $error[] = Lang::T('Coupon end date is required');
} }
if (!empty($error)) { if (!empty($error)) {
r2(U . 'coupons/edit/' . $coupon_id, 'e', implode('<br>', $error)); r2(getUrl('coupons/edit/') . $coupon_id, 'e', implode('<br>', $error));
exit; exit;
} }
$coupon = ORM::for_table('tbl_coupons')->find_one($coupon_id); $coupon = ORM::for_table('tbl_coupons')->find_one($coupon_id);
@ -206,10 +206,10 @@ switch ($action) {
$coupon->updated_at = date('Y-m-d H:i:s'); $coupon->updated_at = date('Y-m-d H:i:s');
try { try {
$coupon->save(); $coupon->save();
r2(U . 'coupons', 's', Lang::T('Coupon has been updated successfully')); r2(getUrl('coupons'), 's', Lang::T('Coupon has been updated successfully'));
} catch (Exception $e) { } catch (Exception $e) {
_log(Lang::T('Error updating coupon: ') . $e->getMessage()); _log(Lang::T('Error updating coupon: ') . $e->getMessage());
r2(U . 'coupons/edit/' . $coupon_id, 'e', Lang::T('Error updating coupon: ') . $e->getMessage()); r2(getUrl('coupons/edit/') . $coupon_id, 'e', Lang::T('Error updating coupon: ') . $e->getMessage());
} }
break; break;

View File

@ -27,7 +27,7 @@ switch ($action) {
} }
$csrf_token = _req('token'); $csrf_token = _req('token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'customers', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('customers'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$cs = ORM::for_table('tbl_customers') $cs = ORM::for_table('tbl_customers')
@ -168,7 +168,7 @@ switch ($action) {
$plan_id = $routes['3']; $plan_id = $routes['3'];
$csrf_token = _req('token'); $csrf_token = _req('token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'customers/view/' . $id_customer, 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('customers/view/') . $id_customer, 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->where('plan_id', $plan_id)->find_one(); $b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->where('plan_id', $plan_id)->find_one();
if ($b) { if ($b) {
@ -192,13 +192,13 @@ switch ($action) {
list($bills, $add_cost) = User::getBills($id_customer); list($bills, $add_cost) = User::getBills($id_customer);
if ($using == 'balance' && $config['enable_balance'] == 'yes') { if ($using == 'balance' && $config['enable_balance'] == 'yes') {
if (!$cust) { if (!$cust) {
r2(U . 'plan/recharge', 'e', Lang::T('Customer not found')); r2(getUrl('plan/recharge'), 'e', Lang::T('Customer not found'));
} }
if (!$plan) { if (!$plan) {
r2(U . 'plan/recharge', 'e', Lang::T('Plan not found')); r2(getUrl('plan/recharge'), 'e', Lang::T('Plan not found'));
} }
if ($cust['balance'] < ($plan['price'] + $add_cost + $tax)) { if ($cust['balance'] < ($plan['price'] + $add_cost + $tax)) {
r2(U . 'plan/recharge', 'e', Lang::T('insufficient balance')); r2(getUrl('plan/recharge'), 'e', Lang::T('insufficient balance'));
} }
$gateway = 'Recharge Balance'; $gateway = 'Recharge Balance';
} }
@ -227,7 +227,7 @@ switch ($action) {
$ui->assign('csrf_token', Csrf::generateAndStoreToken()); $ui->assign('csrf_token', Csrf::generateAndStoreToken());
$ui->display('recharge-confirm.tpl'); $ui->display('recharge-confirm.tpl');
} else { } else {
r2(U . 'customers/view/' . $id_customer, 'e', 'Cannot find active plan'); r2(getUrl('customers/view/') . $id_customer, 'e', 'Cannot find active plan');
} }
break; break;
case 'deactivate': case 'deactivate':
@ -238,7 +238,7 @@ switch ($action) {
$plan_id = $routes['3']; $plan_id = $routes['3'];
$csrf_token = _req('token'); $csrf_token = _req('token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'customers/view/' . $id_customer, 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('customers/view/') . $id_customer, 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->where('plan_id', $plan_id)->find_one(); $b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->where('plan_id', $plan_id)->find_one();
if ($b) { if ($b) {
@ -261,16 +261,16 @@ switch ($action) {
$b->save(); $b->save();
_log('Admin ' . $admin['username'] . ' Deactivate ' . $b['namebp'] . ' for ' . $b['username'], 'User', $b['customer_id']); _log('Admin ' . $admin['username'] . ' Deactivate ' . $b['namebp'] . ' for ' . $b['username'], 'User', $b['customer_id']);
Message::sendTelegram('Admin ' . $admin['username'] . ' Deactivate ' . $b['namebp'] . ' for u' . $b['username']); Message::sendTelegram('Admin ' . $admin['username'] . ' Deactivate ' . $b['namebp'] . ' for u' . $b['username']);
r2(U . 'customers/view/' . $id_customer, 's', 'Success deactivate customer to Mikrotik'); r2(getUrl('customers/view/') . $id_customer, 's', 'Success deactivate customer to Mikrotik');
} }
} }
r2(U . 'customers/view/' . $id_customer, 'e', 'Cannot find active plan'); r2(getUrl('customers/view/') . $id_customer, 'e', 'Cannot find active plan');
break; break;
case 'sync': case 'sync':
$id_customer = $routes['2']; $id_customer = $routes['2'];
$csrf_token = _req('token'); $csrf_token = _req('token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'customers/view/' . $id_customer, 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('customers/view/') . $id_customer, 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$bs = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->where('status', 'on')->findMany(); $bs = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->where('status', 'on')->findMany();
if ($bs) { if ($bs) {
@ -295,9 +295,9 @@ switch ($action) {
} }
} }
} }
r2(U . 'customers/view/' . $id_customer, 's', 'Sync success to ' . implode(", ", $routers)); r2(getUrl('customers/view/') . $id_customer, 's', 'Sync success to ' . implode(", ", $routers));
} }
r2(U . 'customers/view/' . $id_customer, 'e', 'Cannot find active plan'); r2(getUrl('customers/view/') . $id_customer, 'e', 'Cannot find active plan');
break; break;
case 'login': case 'login':
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
@ -306,7 +306,7 @@ switch ($action) {
$id = $routes['2']; $id = $routes['2'];
$csrf_token = _req('token'); $csrf_token = _req('token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'customers/view/' . $id, 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('customers/view/') . $id, 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$customer = ORM::for_table('tbl_customers')->find_one($id); $customer = ORM::for_table('tbl_customers')->find_one($id);
if ($customer) { if ($customer) {
@ -366,7 +366,7 @@ switch ($action) {
$ui->assign('csrf_token', Csrf::generateAndStoreToken()); $ui->assign('csrf_token', Csrf::generateAndStoreToken());
$ui->display('customers-view.tpl'); $ui->display('customers-view.tpl');
} else { } else {
r2(U . 'customers/list', 'e', Lang::T('Account Not Found')); r2(getUrl('customers/list'), 'e', Lang::T('Account Not Found'));
} }
break; break;
case 'edit': case 'edit':
@ -405,7 +405,7 @@ switch ($action) {
$ui->assign('csrf_token', Csrf::generateAndStoreToken()); $ui->assign('csrf_token', Csrf::generateAndStoreToken());
$ui->display('customers-edit.tpl'); $ui->display('customers-edit.tpl');
} else { } else {
r2(U . 'customers/list', 'e', Lang::T('Account Not Found')); r2(getUrl('customers/list'), 'e', Lang::T('Account Not Found'));
} }
break; break;
@ -416,7 +416,7 @@ switch ($action) {
$id = $routes['2']; $id = $routes['2'];
$csrf_token = _req('token'); $csrf_token = _req('token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'customers/view/' . $id, 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('customers/view/') . $id, 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
run_hook('delete_customer'); #HOOK run_hook('delete_customer'); #HOOK
$c = ORM::for_table('tbl_customers')->find_one($id); $c = ORM::for_table('tbl_customers')->find_one($id);
@ -448,7 +448,7 @@ switch ($action) {
$c->delete(); $c->delete();
} catch (Exception $e) { } catch (Exception $e) {
} }
r2(U . 'customers/list', 's', Lang::T('User deleted Successfully')); r2(getUrl('customers/list'), 's', Lang::T('User deleted Successfully'));
} }
break; break;
@ -456,7 +456,7 @@ switch ($action) {
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'customers/add', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('customers/add'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$username = alphanumeric(_post('username'), ":+_.@-"); $username = alphanumeric(_post('username'), ":+_.@-");
$fullname = _post('fullname'); $fullname = _post('fullname');
@ -575,9 +575,9 @@ switch ($action) {
} }
} }
} }
r2(U . 'customers/list', 's', Lang::T('Account Created Successfully')); r2(getUrl('customers/list'), 's', Lang::T('Account Created Successfully'));
} else { } else {
r2(U . 'customers/add', 'e', $msg); r2(getUrl('customers/add'), 'e', $msg);
} }
break; break;
@ -585,7 +585,7 @@ switch ($action) {
$id = _post('id'); $id = _post('id');
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'customers/edit/' . $id, 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('customers/edit/') . $id, 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$username = alphanumeric(_post('username'), ":+_.@-"); $username = alphanumeric(_post('username'), ":+_.@-");
$fullname = _post('fullname'); $fullname = _post('fullname');
@ -708,7 +708,7 @@ switch ($action) {
} }
if (file_exists($_FILES['photo']['tmp_name'])) unlink($_FILES['photo']['tmp_name']); if (file_exists($_FILES['photo']['tmp_name'])) unlink($_FILES['photo']['tmp_name']);
} else { } else {
r2(U . 'settings/app', 'e', 'PHP GD is not installed'); r2(getUrl('settings/app'), 'e', 'PHP GD is not installed');
} }
} }
if ($userDiff) { if ($userDiff) {
@ -815,9 +815,9 @@ switch ($action) {
$tur->save(); $tur->save();
} }
} }
r2(U . 'customers/view/' . $id, 's', 'User Updated Successfully'); r2(getUrl('customers/view/') . $id, 's', 'User Updated Successfully');
} else { } else {
r2(U . 'customers/edit/' . $id, 'e', $msg); r2(getUrl('customers/edit/') . $id, 'e', $msg);
} }
break; break;
@ -856,7 +856,7 @@ switch ($action) {
if (_post('export', '') == 'csv') { if (_post('export', '') == 'csv') {
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'customers', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('customers'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$d = $query->findMany(); $d = $query->findMany();
$h = false; $h = false;

View File

@ -38,9 +38,9 @@ switch ($action) {
}); });
} }
if(file_put_contents($fieldPath, json_encode($datas))){ if(file_put_contents($fieldPath, json_encode($datas))){
r2(U . 'customfield', 's', 'Successfully saved custom fields!'); r2(getUrl('customfield'), 's', 'Successfully saved custom fields!');
}else{ }else{
r2(U . 'customfield', 'e', 'Failed to save custom fields!'); r2(getUrl('customfield'), 'e', 'Failed to save custom fields!');
} }
default: default:
$fields = []; $fields = [];

View File

@ -17,7 +17,7 @@ if (isset($_GET['refresh'])) {
unlink($CACHE_PATH . DIRECTORY_SEPARATOR . $file); unlink($CACHE_PATH . DIRECTORY_SEPARATOR . $file);
} }
} }
r2(U . 'dashboard', 's', 'Data Refreshed'); r2(getUrl('dashboard'), 's', 'Data Refreshed');
} }
$reset_day = $config['reset_day']; $reset_day = $config['reset_day'];

View File

@ -5,9 +5,9 @@
**/ **/
if(Admin::getID()){ if(Admin::getID()){
r2(U.'dashboard'); r2(getUrl('dashboard'));
}if(User::getID()){ }if(User::getID()){
r2(U.'home'); r2(getUrl('home'));
}else{ }else{
r2(U.'login'); r2(getUrl('login'));
} }

View File

@ -82,16 +82,16 @@ if ($step == 1) {
} }
setcookie('forgot_username', '', time() - 3600, '/'); setcookie('forgot_username', '', time() - 3600, '/');
} else { } else {
r2(U . 'forgot&step=1', 'e', Lang::T('Invalid Username or Verification Code')); r2(getUrl('forgot&step=1'), 'e', Lang::T('Invalid Username or Verification Code'));
} }
} else { } else {
if (file_exists($otpPath)) { if (file_exists($otpPath)) {
unlink($otpPath); unlink($otpPath);
} }
r2(U . 'forgot&step=1', 'e', Lang::T('Invalid Username or Verification Code')); r2(getUrl('forgot&step=1'), 'e', Lang::T('Invalid Username or Verification Code'));
} }
} else { } else {
r2(U . 'forgot&step=1', 'e', Lang::T('Invalid Username or Verification Code')); r2(getUrl('forgot&step=1'), 'e', Lang::T('Invalid Username or Verification Code'));
} }
} else if ($step == 7) { } else if ($step == 7) {
$find = _post('find'); $find = _post('find');

View File

@ -23,18 +23,18 @@ if (_post('send') == 'balance') {
} }
$target = ORM::for_table('tbl_customers')->where('username', _post('username'))->find_one(); $target = ORM::for_table('tbl_customers')->where('username', _post('username'))->find_one();
if (!$target) { if (!$target) {
r2(U . 'home', 'd', Lang::T('Username not found')); r2(getUrl('home'), 'd', Lang::T('Username not found'));
} }
$username = _post('username'); $username = _post('username');
$balance = _post('balance'); $balance = _post('balance');
if ($user['balance'] < $balance) { if ($user['balance'] < $balance) {
r2(U . 'home', 'd', Lang::T('insufficient balance')); r2(getUrl('home'), 'd', Lang::T('insufficient balance'));
} }
if (!empty($config['minimum_transfer']) && intval($balance) < intval($config['minimum_transfer'])) { if (!empty($config['minimum_transfer']) && intval($balance) < intval($config['minimum_transfer'])) {
r2(U . 'home', 'd', Lang::T('Minimum Transfer') . ' ' . Lang::moneyFormat($config['minimum_transfer'])); r2(getUrl('home'), 'd', Lang::T('Minimum Transfer') . ' ' . Lang::moneyFormat($config['minimum_transfer']));
} }
if ($user['username'] == $target['username']) { if ($user['username'] == $target['username']) {
r2(U . 'home', 'd', Lang::T('Cannot send to yourself')); r2(getUrl('home'), 'd', Lang::T('Cannot send to yourself'));
} }
if (Balance::transfer($user['id'], $username, $balance)) { if (Balance::transfer($user['id'], $username, $balance)) {
//sender //sender
@ -75,10 +75,10 @@ if (_post('send') == 'balance') {
Message::sendBalanceNotification($user, $target, $balance, ($user['balance'] - $balance), Lang::getNotifText('balance_send'), $config['user_notification_payment']); Message::sendBalanceNotification($user, $target, $balance, ($user['balance'] - $balance), Lang::getNotifText('balance_send'), $config['user_notification_payment']);
Message::sendBalanceNotification($target, $user, $balance, ($target['balance'] + $balance), Lang::getNotifText('balance_received'), $config['user_notification_payment']); Message::sendBalanceNotification($target, $user, $balance, ($target['balance'] + $balance), Lang::getNotifText('balance_received'), $config['user_notification_payment']);
Message::sendTelegram("#u$user[username] send balance to #u$target[username] \n" . Lang::moneyFormat($balance)); Message::sendTelegram("#u$user[username] send balance to #u$target[username] \n" . Lang::moneyFormat($balance));
r2(U . 'home', 's', Lang::T('Sending balance success')); r2(getUrl('home'), 's', Lang::T('Sending balance success'));
} }
} else { } else {
r2(U . 'home', 'd', Lang::T('Failed, balance is not available')); r2(getUrl('home'), 'd', Lang::T('Failed, balance is not available'));
} }
} else if (_post('send') == 'plan') { } else if (_post('send') == 'plan') {
if ($user['status'] != 'Active') { if ($user['status'] != 'Active') {
@ -90,10 +90,10 @@ if (_post('send') == 'balance') {
foreach ($actives as $active) { foreach ($actives as $active) {
$router = ORM::for_table('tbl_routers')->where('name', $active['routers'])->find_one(); $router = ORM::for_table('tbl_routers')->where('name', $active['routers'])->find_one();
if ($router) { if ($router) {
r2(U . "order/send/$router[id]/$active[plan_id]&u=" . trim(_post('username')), 's', Lang::T('Review package before recharge')); r2(getUrl('order/send/$router[id]/$active[plan_id]&u=') . trim(_post('username')), 's', Lang::T('Review package before recharge'));
} }
} }
r2(U . 'home', 'w', Lang::T('Your friend do not have active package')); r2(getUrl('home'), 'w', Lang::T('Your friend do not have active package'));
} }
$_bill = User::_billing(); $_bill = User::_billing();
$ui->assign('_bills', $_bill); $ui->assign('_bills', $_bill);
@ -128,7 +128,7 @@ if (isset($_GET['sync']) && !empty($_GET['sync'])) {
} }
} }
} }
r2(U . 'home', 's', $log); r2(getUrl('home'), 's', $log);
} }
if (isset($_GET['recharge']) && !empty($_GET['recharge'])) { if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
@ -136,7 +136,7 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
_alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', "");
} }
if (!empty(App::getTokenValue(_get('stoken')))) { if (!empty(App::getTokenValue(_get('stoken')))) {
r2(U . "voucher/invoice/"); r2(getUrl('voucher/invoice/'));
die(); die();
} }
$bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['recharge'])->where('username', $user['username'])->findOne(); $bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['recharge'])->where('username', $user['username'])->findOne();
@ -147,17 +147,17 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
$routers = ORM::for_table('tbl_routers')->where('name', $bill['routers'])->find_one(); $routers = ORM::for_table('tbl_routers')->where('name', $bill['routers'])->find_one();
$router = $routers['id']; $router = $routers['id'];
} }
r2(U. "order/gateway/$router/$bill[plan_id]"); r2(getUrl('order/gateway/$router/$bill[plan_id]'));
} }
} else if (!empty(_get('extend'))) { } else if (!empty(_get('extend'))) {
if ($user['status'] != 'Active') { if ($user['status'] != 'Active') {
_alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', "");
} }
if (!$config['extend_expired']) { if (!$config['extend_expired']) {
r2(U . 'home', 'e', "cannot extend"); r2(getUrl('home'), 'e', "cannot extend");
} }
if (!empty(App::getTokenValue(_get('stoken')))) { if (!empty(App::getTokenValue(_get('stoken')))) {
r2(U . 'home', 'e', "You already extend"); r2(getUrl('home'), 'e', "You already extend");
} }
$id = _get('extend'); $id = _get('extend');
$tur = ORM::for_table('tbl_user_recharges')->where('customer_id', $user['id'])->where('id', $id)->find_one(); $tur = ORM::for_table('tbl_user_recharges')->where('customer_id', $user['id'])->where('id', $id)->find_one();
@ -172,7 +172,7 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
// is already extend // is already extend
$last = file_get_contents($path); $last = file_get_contents($path);
if ($last == $m) { if ($last == $m) {
r2(U . 'home', 'e', "You already extend for this month"); r2(getUrl('home'), 'e', "You already extend for this month");
} }
} }
if ($tur['status'] != 'on') { if ($tur['status'] != 'on') {
@ -202,12 +202,12 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
"\nLocation: " . $p['routers'] . "\nLocation: " . $p['routers'] .
"\nCustomer: " . $user['fullname'] . "\nCustomer: " . $user['fullname'] .
"\nNew Expired: " . Lang::dateAndTimeFormat($expiration, $tur['time'])); "\nNew Expired: " . Lang::dateAndTimeFormat($expiration, $tur['time']));
r2(U . 'home', 's', "Extend until $expiration"); r2(getUrl('home'), 's', "Extend until $expiration");
} else { } else {
r2(U . 'home', 'e', "Plan is not expired"); r2(getUrl('home'), 'e', "Plan is not expired");
} }
} else { } else {
r2(U . 'home', 'e', "Plan Not Found or Not Active"); r2(getUrl('home'), 'e', "Plan Not Found or Not Active");
} }
} else if (isset($_GET['deactivate']) && !empty($_GET['deactivate'])) { } else if (isset($_GET['deactivate']) && !empty($_GET['deactivate'])) {
$bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['deactivate'])->where('username', $user['username'])->findOne(); $bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['deactivate'])->where('username', $user['username'])->findOne();
@ -228,9 +228,9 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
$bill->save(); $bill->save();
_log('User ' . $bill['username'] . ' Deactivate ' . $bill['namebp'], 'Customer', $bill['customer_id']); _log('User ' . $bill['username'] . ' Deactivate ' . $bill['namebp'], 'Customer', $bill['customer_id']);
Message::sendTelegram('User u' . $bill['username'] . ' Deactivate ' . $bill['namebp']); Message::sendTelegram('User u' . $bill['username'] . ' Deactivate ' . $bill['namebp']);
r2(U . 'home', 's', 'Success deactivate ' . $bill['namebp']); r2(getUrl('home'), 's', 'Success deactivate ' . $bill['namebp']);
} else { } else {
r2(U . 'home', 'e', 'No Active Plan'); r2(getUrl('home'), 'e', 'No Active Plan');
} }
} }
@ -245,10 +245,10 @@ if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'] && $_c['hs_auth_m
require_once $dvc; require_once $dvc;
if ($_GET['mikrotik'] == 'login') { if ($_GET['mikrotik'] == 'login') {
(new $p['device'])->connect_customer($user, $_SESSION['nux-ip'], $_SESSION['nux-mac'], $bill['routers']); (new $p['device'])->connect_customer($user, $_SESSION['nux-ip'], $_SESSION['nux-mac'], $bill['routers']);
r2(U . 'home', 's', Lang::T('Login Request successfully')); r2(getUrl('home'), 's', Lang::T('Login Request successfully'));
} else if ($_GET['mikrotik'] == 'logout') { } else if ($_GET['mikrotik'] == 'logout') {
(new $p['device'])->disconnect_customer($user, $bill['routers']); (new $p['device'])->disconnect_customer($user, $bill['routers']);
r2(U . 'home', 's', Lang::T('Logout Request successfully')); r2(getUrl('home'), 's', Lang::T('Logout Request successfully'));
} }
} else { } else {
new Exception(Lang::T("Devices Not Found")); new Exception(Lang::T("Devices Not Found"));
@ -269,16 +269,16 @@ if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'] && !empty($_SESSI
$ui->assign('logged', $_GET['logged']); $ui->assign('logged', $_GET['logged']);
if ($_app_stage != 'demo') { if ($_app_stage != 'demo') {
if ($_GET['mikrotik'] == 'login') { if ($_GET['mikrotik'] == 'login') {
r2(U . 'home&hchap=true', 's', Lang::T('Login Request successfully')); r2(getUrl('home&hchap=true'), 's', Lang::T('Login Request successfully'));
} }
$getmsg = $_GET['msg']; $getmsg = $_GET['msg'];
///get auth notification from mikrotik ///get auth notification from mikrotik
if ($getmsg == 'Connected') { if ($getmsg == 'Connected') {
$msg .= Lang::T($getmsg); $msg .= Lang::T($getmsg);
r2(U . 'home&logged=1', 's', $msg); r2(getUrl('home&logged=1'), 's', $msg);
} else if ($getmsg) { } else if ($getmsg) {
$msg .= Lang::T($getmsg); $msg .= Lang::T($getmsg);
r2(U . 'home', 's', $msg); r2(getUrl('home'), 's', $msg);
} }
} }
} }
@ -296,16 +296,16 @@ if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'] && !empty($_SESSI
$ui->assign('logged', $_GET['logged']); $ui->assign('logged', $_GET['logged']);
if ($_app_stage != 'demo') { if ($_app_stage != 'demo') {
if ($_GET['mikrotik'] == 'login') { if ($_GET['mikrotik'] == 'login') {
r2(U . 'home&hchap=true', 's', Lang::T('Login Request successfully')); r2(getUrl('home&hchap=true'), 's', Lang::T('Login Request successfully'));
} }
$getmsg = $_GET['msg']; $getmsg = $_GET['msg'];
///get auth notification from mikrotik ///get auth notification from mikrotik
if ($getmsg == 'Connected') { if ($getmsg == 'Connected') {
$msg .= Lang::T($getmsg); $msg .= Lang::T($getmsg);
r2(U . 'home&logged=1', 's', $msg); r2(getUrl('home&logged=1'), 's', $msg);
} else if ($getmsg) { } else if ($getmsg) {
$msg .= Lang::T($getmsg); $msg .= Lang::T($getmsg);
r2(U . 'home', 's', $msg); r2(getUrl('home'), 's', $msg);
} }
} }
} }

View File

@ -11,7 +11,7 @@ if ($maintenance_mode == true) {
} }
if (User::getID()) { if (User::getID()) {
r2(U . 'home'); r2(getUrl('home'));
} }
if (isset($routes['1'])) { if (isset($routes['1'])) {
@ -27,7 +27,7 @@ switch ($do) {
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
_msglog('e', Lang::T('Invalid or Expired CSRF Token')); _msglog('e', Lang::T('Invalid or Expired CSRF Token'));
r2(U . 'login'); r2(getUrl('login'));
} }
run_hook('customer_login'); #HOOK run_hook('customer_login'); #HOOK
if ($username != '' and $password != '') { if ($username != '' and $password != '') {
@ -54,15 +54,15 @@ switch ($do) {
} else { } else {
_msglog('e', Lang::T('Invalid Username or Password')); _msglog('e', Lang::T('Invalid Username or Password'));
_log($username . ' ' . Lang::T('Failed Login'), 'User'); _log($username . ' ' . Lang::T('Failed Login'), 'User');
r2(U . 'login'); r2(getUrl('login'));
} }
} else { } else {
_msglog('e', Lang::T('Invalid Username or Password')); _msglog('e', Lang::T('Invalid Username or Password'));
r2(U . 'login'); r2(getUrl('login'));
} }
} else { } else {
_msglog('e', Lang::T('Invalid Username or Password')); _msglog('e', Lang::T('Invalid Username or Password'));
r2(U . 'login'); r2(getUrl('login'));
} }
break; break;
@ -72,7 +72,7 @@ switch ($do) {
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
_msglog('e', Lang::T('Invalid or Expired CSRF Token')); _msglog('e', Lang::T('Invalid or Expired CSRF Token'));
r2(U . 'login'); r2(getUrl('login'));
} }
$voucher = Text::alphanumeric(_post('voucher_only'), "-_.,"); $voucher = Text::alphanumeric(_post('voucher_only'), "-_.,");
$tur = ORM::for_table('tbl_user_recharges') $tur = ORM::for_table('tbl_user_recharges')
@ -103,7 +103,7 @@ switch ($do) {
if (!empty($config['voucher_redirect'])) { if (!empty($config['voucher_redirect'])) {
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login")); r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login"));
} else { } else {
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login"));
} }
} else { } else {
new Exception(Lang::T("Devices Not Found")); new Exception(Lang::T("Devices Not Found"));
@ -112,7 +112,7 @@ switch ($do) {
if (!empty($config['voucher_redirect'])) { if (!empty($config['voucher_redirect'])) {
_alert(Lang::T("Voucher activation success, now you can login"), 'danger', $config['voucher_redirect']); _alert(Lang::T("Voucher activation success, now you can login"), 'danger', $config['voucher_redirect']);
} else { } else {
r2(U . "login", 's', Lang::T("Voucher activation success, you are connected to internet")); r2(getUrl('login'), 's', Lang::T("Voucher activation success, you are connected to internet"));
} }
} else { } else {
_alert(Lang::T('Internet Plan Expired'), 'danger', "login"); _alert(Lang::T('Internet Plan Expired'), 'danger', "login");
@ -148,7 +148,7 @@ switch ($do) {
if (!empty($config['voucher_redirect'])) { if (!empty($config['voucher_redirect'])) {
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login")); r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login"));
} else { } else {
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login"));
} }
} else { } else {
new Exception(Lang::T("Devices Not Found")); new Exception(Lang::T("Devices Not Found"));
@ -157,7 +157,7 @@ switch ($do) {
if (!empty($config['voucher_redirect'])) { if (!empty($config['voucher_redirect'])) {
_alert(Lang::T("Voucher activation success, now you can login"), 'danger', $config['voucher_redirect']); _alert(Lang::T("Voucher activation success, now you can login"), 'danger', $config['voucher_redirect']);
} else { } else {
r2(U . "login", 's', Lang::T("Voucher activation success, you are connected to internet")); r2(getUrl('login'), 's', Lang::T("Voucher activation success, you are connected to internet"));
} }
} else { } else {
_alert(Lang::T('Internet Plan Expired'), 'danger', "login"); _alert(Lang::T('Internet Plan Expired'), 'danger', "login");
@ -190,11 +190,11 @@ switch ($do) {
if ($d->save()) { if ($d->save()) {
$user = ORM::for_table('tbl_customers')->where('username', $username)->find_one($d->id()); $user = ORM::for_table('tbl_customers')->where('username', $username)->find_one($d->id());
if (!$user) { if (!$user) {
r2(U . 'login', 'e', Lang::T('Voucher activation failed')); r2(getUrl('login'), 'e', Lang::T('Voucher activation failed'));
} }
} else { } else {
_alert(Lang::T('Login Successful'), 'success', "dashboard"); _alert(Lang::T('Login Successful'), 'success', "dashboard");
r2(U . 'login', 'e', Lang::T('Voucher activation failed') . '.'); r2(getUrl('login'), 'e', Lang::T('Voucher activation failed') . '.');
} }
} }
if ($v1['status'] == 0) { if ($v1['status'] == 0) {
@ -222,7 +222,7 @@ switch ($do) {
if (!empty($config['voucher_redirect'])) { if (!empty($config['voucher_redirect'])) {
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login")); r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login"));
} else { } else {
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login"));
} }
} else { } else {
new Exception(Lang::T("Devices Not Found")); new Exception(Lang::T("Devices Not Found"));
@ -231,26 +231,26 @@ switch ($do) {
if (!empty($config['voucher_redirect'])) { if (!empty($config['voucher_redirect'])) {
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, you are connected to internet")); r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, you are connected to internet"));
} else { } else {
r2(U . "login", 's', Lang::T("Voucher activation success, you are connected to internet")); r2(getUrl('login'), 's', Lang::T("Voucher activation success, you are connected to internet"));
} }
} catch (Exception $e) { } catch (Exception $e) {
if (!empty($config['voucher_redirect'])) { if (!empty($config['voucher_redirect'])) {
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login")); r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login"));
} else { } else {
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login"));
} }
} }
} }
if (!empty($config['voucher_redirect'])) { if (!empty($config['voucher_redirect'])) {
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login")); r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login"));
} else { } else {
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login"));
} }
} else { } else {
// if failed to recharge, restore old password // if failed to recharge, restore old password
$user->password = $oldPass; $user->password = $oldPass;
$user->save(); $user->save();
r2(U . 'login', 'e', Lang::T("Failed to activate voucher")); r2(getUrl('login'), 'e', Lang::T("Failed to activate voucher"));
} }
} else { } else {
// used voucher // used voucher
@ -269,7 +269,7 @@ switch ($do) {
if (!empty($config['voucher_redirect'])) { if (!empty($config['voucher_redirect'])) {
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login")); r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login"));
} else { } else {
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login"));
} }
} else { } else {
new Exception(Lang::T("Devices Not Found")); new Exception(Lang::T("Devices Not Found"));
@ -278,30 +278,30 @@ switch ($do) {
if (!empty($config['voucher_redirect'])) { if (!empty($config['voucher_redirect'])) {
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, you are connected to internet")); r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, you are connected to internet"));
} else { } else {
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login"));
} }
} catch (Exception $e) { } catch (Exception $e) {
if (!empty($config['voucher_redirect'])) { if (!empty($config['voucher_redirect'])) {
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login")); r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login"));
} else { } else {
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login"));
} }
} }
} else { } else {
if (!empty($config['voucher_redirect'])) { if (!empty($config['voucher_redirect'])) {
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, you are connected to internet")); r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, you are connected to internet"));
} else { } else {
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login"));
} }
} }
} else { } else {
// voucher used by other customer // voucher used by other customer
r2(U . 'login', 'e', Lang::T('Voucher Not Valid')); r2(getUrl('login'), 'e', Lang::T('Voucher Not Valid'));
} }
} }
} else { } else {
_msglog('e', Lang::T('Invalid Username or Password')); _msglog('e', Lang::T('Invalid Username or Password'));
r2(U . 'login'); r2(getUrl('login'));
} }
} }
default: default:

View File

@ -85,7 +85,7 @@ switch ($action) {
$keep = _post('keep'); $keep = _post('keep');
if (!empty($keep)) { if (!empty($keep)) {
ORM::raw_execute("DELETE FROM tbl_logs WHERE UNIX_TIMESTAMP(date) < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL $keep DAY))"); ORM::raw_execute("DELETE FROM tbl_logs WHERE UNIX_TIMESTAMP(date) < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL $keep DAY))");
r2(U . "logs/list/", 's', "Delete logs older than $keep days"); r2(getUrl('logs/list/'), 's', "Delete logs older than $keep days");
} }
if ($q != '') { if ($q != '') {
$query = ORM::for_table('tbl_logs')->where_like('description', '%' . $q . '%')->order_by_desc('id'); $query = ORM::for_table('tbl_logs')->where_like('description', '%' . $q . '%')->order_by_desc('id');
@ -104,7 +104,7 @@ switch ($action) {
$keep = _post('keep'); $keep = _post('keep');
if (!empty($keep)) { if (!empty($keep)) {
ORM::raw_execute("DELETE FROM radpostauth WHERE UNIX_TIMESTAMP(authdate) < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL $keep DAY))", [], 'radius'); ORM::raw_execute("DELETE FROM radpostauth WHERE UNIX_TIMESTAMP(authdate) < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL $keep DAY))", [], 'radius');
r2(U . "logs/radius/", 's', "Delete logs older than $keep days"); r2(getUrl('logs/radius/'), 's', "Delete logs older than $keep days");
} }
if ($q != '') { if ($q != '') {
$query = ORM::for_table('radpostauth', 'radius')->where_like('username', '%' . $q . '%')->order_by_desc('id'); $query = ORM::for_table('radpostauth', 'radius')->where_like('username', '%' . $q . '%')->order_by_desc('id');
@ -121,5 +121,5 @@ switch ($action) {
default: default:
r2(U . 'logs/list/', 's', ''); r2(getUrl('logs/list/'), 's', '');
} }

View File

@ -14,7 +14,7 @@ switch ($action) {
case 'view': case 'view':
$mail = ORM::for_table('tbl_customers_inbox')->where('customer_id', $user['id'])->find_one($routes['2']); $mail = ORM::for_table('tbl_customers_inbox')->where('customer_id', $user['id'])->find_one($routes['2']);
if(!$mail){ if(!$mail){
r2(U. 'mail', 'e', Lang::T('Message Not Found')); r2(getUrl('mail'), 'e', Lang::T('Message Not Found'));
} }
if($mail['date_read'] == null){ if($mail['date_read'] == null){
$mail->date_read = date('Y-m-d H:i:s'); $mail->date_read = date('Y-m-d H:i:s');
@ -34,9 +34,9 @@ switch ($action) {
case 'delete': case 'delete':
if($routes['2']){ if($routes['2']){
if(ORM::for_table('tbl_customers_inbox')->where('customer_id', $user['id'])->where('id', $routes['2'])->find_one()->delete()){ if(ORM::for_table('tbl_customers_inbox')->where('customer_id', $user['id'])->where('id', $routes['2'])->find_one()->delete()){
r2(U. 'mail', 's', Lang::T('Mail Deleted Successfully')); r2(getUrl('mail'), 's', Lang::T('Mail Deleted Successfully'));
}else{ }else{
r2(U. 'home', 'e', Lang::T('Failed to Delete Message')); r2(getUrl('home'), 'e', Lang::T('Failed to Delete Message'));
} }
break; break;
} }

View File

@ -49,6 +49,6 @@ switch ($action) {
break; break;
default: default:
r2(U . 'map/customer', 'e', 'action not defined'); r2(getUrl('map/customer'), 'e', 'action not defined');
break; break;
} }

View File

@ -62,7 +62,7 @@ EOT;
// Check if fields are empty // Check if fields are empty
if ($id_customer == '' or $message == '' or $via == '') { if ($id_customer == '' or $message == '' or $via == '') {
r2(U . 'message/send', 'e', Lang::T('All field is required')); r2(getUrl('message/send'), 'e', Lang::T('All field is required'));
} else { } else {
// Get customer details from the database // Get customer details from the database
$c = ORM::for_table('tbl_customers')->find_one($id_customer); $c = ORM::for_table('tbl_customers')->find_one($id_customer);
@ -84,9 +84,9 @@ EOT;
} }
if (isset($smsSent) || isset($waSent)) { if (isset($smsSent) || isset($waSent)) {
r2(U . 'message/send', 's', Lang::T('Message Sent Successfully')); r2(getUrl('message/send'), 's', Lang::T('Message Sent Successfully'));
} else { } else {
r2(U . 'message/send', 'e', Lang::T('Failed to send message')); r2(getUrl('message/send'), 'e', Lang::T('Failed to send message'));
} }
} }
break; break;
@ -114,7 +114,7 @@ EOT;
if (_req('send') == 'now') { if (_req('send') == 'now') {
// Check if fields are empty // Check if fields are empty
if ($group == '' || $message == '' || $via == '') { if ($group == '' || $message == '' || $via == '') {
r2(U . 'message/send_bulk', 'e', Lang::T('All fields are required')); r2(getUrl('message/send_bulk'), 'e', Lang::T('All fields are required'));
} else { } else {
// Get customer details from the database based on the selected group // Get customer details from the database based on the selected group
if ($group == 'all') { if ($group == 'all') {
@ -234,5 +234,5 @@ EOT;
break; break;
default: default:
r2(U . 'message/send_sms', 'e', 'action not defined'); r2(getUrl('message/send_sms'), 'e', 'action not defined');
} }

View File

@ -34,7 +34,7 @@ switch ($action) {
break; break;
case 'balance': case 'balance':
if (strpos($user['email'], '@') === false) { if (strpos($user['email'], '@') === false) {
r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address")); r2(getUrl('accounts/profile'), 'e', Lang::T("Please enter your email address"));
} }
$ui->assign('_title', 'Top Up'); $ui->assign('_title', 'Top Up');
$ui->assign('_system_menu', 'balance'); $ui->assign('_system_menu', 'balance');
@ -44,7 +44,7 @@ switch ($action) {
break; break;
case 'package': case 'package':
if (strpos($user['email'], '@') === false) { if (strpos($user['email'], '@') === false) {
r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address")); r2(getUrl('accounts/profile'), 'e', Lang::T("Please enter your email address"));
} }
$ui->assign('_title', 'Order Plan'); $ui->assign('_title', 'Order Plan');
$ui->assign('_system_menu', 'package'); $ui->assign('_system_menu', 'package');
@ -144,12 +144,12 @@ switch ($action) {
r_find_unpaid'); #HOOK r_find_unpaid'); #HOOK
if ($d) { if ($d) {
if (empty($d['pg_url_payment'])) { if (empty($d['pg_url_payment'])) {
r2(U . "order/buy/" . $trx['routers_id'] . '/' . $trx['plan_id'], 'w', Lang::T("Checking payment")); r2(getUrl('order/buy/') . $trx['routers_id'] . '/' . $trx['plan_id'], 'w', Lang::T("Checking payment"));
} else { } else {
r2(U . "order/view/" . $d['id'] . '/check/', 's', Lang::T("You have unpaid transaction")); r2(getUrl('order/view/') . $d['id'] . '/check/', 's', Lang::T("You have unpaid transaction"));
} }
} else { } else {
r2(U . "order/package/", 's', Lang::T("You have no unpaid transaction")); r2(getUrl('order/package/'), 's', Lang::T("You have no unpaid transaction"));
} }
break; break;
case 'view': case 'view':
@ -160,15 +160,15 @@ switch ($action) {
run_hook('customer_view_payment'); #HOOK run_hook('customer_view_payment'); #HOOK
// jika tidak ditemukan, berarti punya orang lain // jika tidak ditemukan, berarti punya orang lain
if (empty($trx)) { if (empty($trx)) {
r2(U . "order/package", 'w', Lang::T("Payment not found")); r2(getUrl('order/package'), 'w', Lang::T("Payment not found"));
} }
// jika url kosong, balikin ke buy, kecuali cancel // jika url kosong, balikin ke buy, kecuali cancel
if ($trx['status'] == 1 && empty($trx['pg_url_payment']) && $routes['3'] != 'cancel') { if ($trx['status'] == 1 && empty($trx['pg_url_payment']) && $routes['3'] != 'cancel') {
r2(U . "order/buy/" . (($trx['routers_id'] == 0) ? $trx['routers'] : $trx['routers_id']) . '/' . $trx['plan_id'], 'w', Lang::T("Checking payment")); r2(getUrl('order/buy/') . (($trx['routers_id'] == 0) ? $trx['routers'] : $trx['routers_id']) . '/' . $trx['plan_id'], 'w', Lang::T("Checking payment"));
} }
if ($routes['3'] == 'check') { if ($routes['3'] == 'check') {
if (!file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $trx['gateway'] . '.php')) { if (!file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $trx['gateway'] . '.php')) {
r2(U . 'order/view/' . $trxid, 'e', Lang::T("No Payment Gateway Available")); r2(getUrl('order/view/') . $trxid, 'e', Lang::T("No Payment Gateway Available"));
} }
run_hook('customer_check_payment_status'); #HOOK run_hook('customer_check_payment_status'); #HOOK
include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $trx['gateway'] . '.php'; include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $trx['gateway'] . '.php';
@ -185,7 +185,7 @@ switch ($action) {
->find_one($trxid); ->find_one($trxid);
} }
if (empty($trx)) { if (empty($trx)) {
r2(U . "order/package", 'e', Lang::T("Transaction Not found")); r2(getUrl('order/package'), 'e', Lang::T("Transaction Not found"));
} }
$router = ORM::for_table('tbl_routers')->where('name', $trx['routers'])->find_one(); $router = ORM::for_table('tbl_routers')->where('name', $trx['routers'])->find_one();
@ -202,10 +202,10 @@ switch ($action) {
break; break;
case 'pay': case 'pay':
if ($config['enable_balance'] != 'yes') { if ($config['enable_balance'] != 'yes') {
r2(U . "order/package", 'e', Lang::T("Balance not enabled")); r2(getUrl('order/package'), 'e', Lang::T("Balance not enabled"));
} }
if (!empty(App::getTokenValue($_GET['stoken']))) { if (!empty(App::getTokenValue($_GET['stoken']))) {
r2(U . "voucher/invoice/"); r2(getUrl('voucher/invoice/'));
die(); die();
} }
if ($user['status'] != 'Active') { if ($user['status'] != 'Active') {
@ -213,7 +213,7 @@ switch ($action) {
} }
$plan = ORM::for_table('tbl_plans')->find_one($routes[3]); $plan = ORM::for_table('tbl_plans')->find_one($routes[3]);
if (!$plan) { if (!$plan) {
r2(U . "order/package", 'e', Lang::T("Plan Not found")); r2(getUrl('order/package'), 'e', Lang::T("Plan Not found"));
} }
if ($plan['is_radius'] == '1') { if ($plan['is_radius'] == '1') {
$router_name = 'radius'; $router_name = 'radius';
@ -247,21 +247,21 @@ switch ($action) {
// if success, then get the balance // if success, then get the balance
Balance::min($user['id'], $total_cost); Balance::min($user['id'], $total_cost);
App::setToken($_GET['stoken'], "success"); App::setToken($_GET['stoken'], "success");
r2(U . "voucher/invoice/", 's', Lang::T("Success to buy package")); r2(getUrl('voucher/invoice/'), 's', Lang::T("Success to buy package"));
} else { } else {
r2(U . "order/package", 'e', Lang::T("Failed to buy package")); r2(getUrl('order/package'), 'e', Lang::T("Failed to buy package"));
Message::sendTelegram("Buy Package with Balance Failed\n\n#u$c[username] #buy \n" . $plan['name_plan'] . Message::sendTelegram("Buy Package with Balance Failed\n\n#u$c[username] #buy \n" . $plan['name_plan'] .
"\nRouter: " . $router_name . "\nRouter: " . $router_name .
"\nPrice: " . $total_cost); "\nPrice: " . $total_cost);
} }
} else { } else {
r2(U . "order/gateway/$routes[2]/$routes[3]", 'e', Lang::T("Insufficient balance")); r2(getUrl('order/gateway/$routes[2]/$routes[3]'), 'e', Lang::T("Insufficient balance"));
} }
break; break;
case 'send': case 'send':
if ($config['enable_balance'] != 'yes') { if ($config['enable_balance'] != 'yes') {
r2(U . "order/package", 'e', Lang::T("Balance not enabled")); r2(getUrl('order/package'), 'e', Lang::T("Balance not enabled"));
} }
if ($user['status'] != 'Active') { if ($user['status'] != 'Active') {
_alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', "");
@ -270,10 +270,10 @@ switch ($action) {
$ui->assign('_system_menu', 'package'); $ui->assign('_system_menu', 'package');
$plan = ORM::for_table('tbl_plans')->find_one($routes['3']); $plan = ORM::for_table('tbl_plans')->find_one($routes['3']);
if (empty($plan)) { if (empty($plan)) {
r2(U . "order/package", 'e', Lang::T("Plan Not found")); r2(getUrl('order/package'), 'e', Lang::T("Plan Not found"));
} }
if (!$plan['enabled']) { if (!$plan['enabled']) {
r2(U . "home", 'e', 'Plan is not exists'); r2(getUrl('home'), 'e', 'Plan is not exists');
} }
if ($plan['is_radius'] == '1') { if ($plan['is_radius'] == '1') {
$routes['2'] = 0; $routes['2'] = 0;
@ -312,13 +312,13 @@ switch ($action) {
} }
if (!$target) { if (!$target) {
r2(U . 'home', 'd', Lang::T('Username not found')); r2(getUrl('home'), 'd', Lang::T('Username not found'));
} }
if ($user['balance'] < $plan['price']) { if ($user['balance'] < $plan['price']) {
r2(U . 'home', 'd', Lang::T('insufficient balance')); r2(getUrl('home'), 'd', Lang::T('insufficient balance'));
} }
if ($user['username'] == $target['username']) { if ($user['username'] == $target['username']) {
r2(U . "order/pay/$routes[2]/$routes[3]", 's', '^_^ v'); r2(getUrl('order/pay/$routes[2]/$routes[3]'), 's', '^_^ v');
} }
$active = ORM::for_table('tbl_user_recharges') $active = ORM::for_table('tbl_user_recharges')
->where('username', _post('username')) ->where('username', _post('username'))
@ -326,7 +326,7 @@ switch ($action) {
->find_one(); ->find_one();
if ($active && $active['plan_id'] != $plan['id']) { if ($active && $active['plan_id'] != $plan['id']) {
r2(U . "order/package", 'e', Lang::T("Target has active plan, different with current plant.") . " [ <b>$active[namebp]</b> ]"); r2(getUrl('order/package'), 'e', Lang::T("Target has active plan, different with current plant.") . " [ <b>$active[namebp]</b> ]");
} }
$result = Package::rechargeUser($target['id'], $router_name, $plan['id'], $user['username'], 'Balance'); $result = Package::rechargeUser($target['id'], $router_name, $plan['id'], $user['username'], 'Balance');
if (!empty($result)) { if (!empty($result)) {
@ -371,7 +371,7 @@ switch ($action) {
$d->trx_invoice = $result; $d->trx_invoice = $result;
$d->status = 2; $d->status = 2;
$d->save(); $d->save();
r2(U . "order/view/$trx_id", 's', Lang::T("Success to send package")); r2(getUrl('order/view/$trx_id'), 's', Lang::T("Success to send package"));
} else { } else {
$errorMessage = "Send Package with Balance Failed\n\n#u$user[username] #send \n" . $plan['name_plan'] . $errorMessage = "Send Package with Balance Failed\n\n#u$user[username] #send \n" . $plan['name_plan'] .
"\nRouter: " . $router_name . "\nRouter: " . $router_name .
@ -381,7 +381,7 @@ switch ($action) {
$errorMessage .= "\nTax: " . $tax; $errorMessage .= "\nTax: " . $tax;
} }
r2(U . "order/package", 'e', Lang::T("Failed to Send package")); r2(getUrl('order/package'), 'e', Lang::T("Failed to Send package"));
Message::sendTelegram($errorMessage); Message::sendTelegram($errorMessage);
} }
} }
@ -395,7 +395,7 @@ switch ($action) {
$ui->assign('_title', Lang::T('Select Payment Gateway')); $ui->assign('_title', Lang::T('Select Payment Gateway'));
$ui->assign('_system_menu', 'package'); $ui->assign('_system_menu', 'package');
if (strpos($user['email'], '@') === false) { if (strpos($user['email'], '@') === false) {
r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address")); r2(getUrl('accounts/profile'), 'e', Lang::T("Please enter your email address"));
} }
$tax_enable = isset($config['enable_tax']) ? $config['enable_tax'] : 'no'; $tax_enable = isset($config['enable_tax']) ? $config['enable_tax'] : 'no';
$tax_rate_setting = isset($config['tax_rate']) ? $config['tax_rate'] : null; $tax_rate_setting = isset($config['tax_rate']) ? $config['tax_rate'] : null;
@ -503,7 +503,7 @@ switch ($action) {
if (count($pgs) == 0) { if (count($pgs) == 0) {
sendTelegram("Payment Gateway not set, please set it in Settings"); sendTelegram("Payment Gateway not set, please set it in Settings");
_log(Lang::T("Payment Gateway not set, please set it in Settings")); _log(Lang::T("Payment Gateway not set, please set it in Settings"));
r2(U . "home", 'e', Lang::T("Failed to create Transaction..")); r2(getUrl('home'), 'e', Lang::T("Failed to create Transaction.."));
} }
if (count($pgs) > 0) { if (count($pgs) > 0) {
$ui->assign('pgs', $pgs); $ui->assign('pgs', $pgs);
@ -516,7 +516,7 @@ switch ($action) {
$ui->assign('custom', '1'); $ui->assign('custom', '1');
$ui->assign('amount', _post('amount')); $ui->assign('amount', _post('amount'));
} else { } else {
r2(U . "order/balance", 'e', Lang::T("Please enter amount")); r2(getUrl('order/balance'), 'e', Lang::T("Please enter amount"));
} }
} }
@ -530,14 +530,14 @@ switch ($action) {
} else { } else {
sendTelegram("Payment Gateway not set, please set it in Settings"); sendTelegram("Payment Gateway not set, please set it in Settings");
_log(Lang::T("Payment Gateway not set, please set it in Settings")); _log(Lang::T("Payment Gateway not set, please set it in Settings"));
r2(U . "home", 'e', Lang::T("Failed to create Transaction..")); r2(getUrl('home'), 'e', Lang::T("Failed to create Transaction.."));
} }
case 'buy': case 'buy':
$gateway = _post('gateway'); $gateway = _post('gateway');
$discount = _post('discount') ?: 0; $discount = _post('discount') ?: 0;
if ($gateway == 'balance') { if ($gateway == 'balance') {
unset($_SESSION['gateway']); unset($_SESSION['gateway']);
r2(U . 'order/pay/' . $routes[2] . '/' . $routes[3]); r2(getUrl('order/pay/') . $routes[2] . '/' . $routes[3]);
} }
if (empty($gateway) && !empty($_SESSION['gateway'])) { if (empty($gateway) && !empty($_SESSION['gateway'])) {
$gateway = $_SESSION['gateway']; $gateway = $_SESSION['gateway'];
@ -548,7 +548,7 @@ switch ($action) {
_alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', "");
} }
if (empty($gateway)) { if (empty($gateway)) {
r2(U . 'order/gateway/' . $routes[2] . '/' . $routes[3], 'w', Lang::T("Please select Payment Gateway")); r2(getUrl('order/gateway/') . $routes[2] . '/' . $routes[3], 'w', Lang::T("Please select Payment Gateway"));
} }
run_hook('customer_buy_plan'); #HOOK run_hook('customer_buy_plan'); #HOOK
include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $gateway . '.php'; include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $gateway . '.php';
@ -560,7 +560,7 @@ switch ($action) {
$amount = (float) $amount; $amount = (float) $amount;
if ($amount <= 0) { if ($amount <= 0) {
r2(U . "order/gateway/" . $routes[2] . '/' . $routes[3], 'w', Lang::T("Please enter amount")); r2(getUrl('order/gateway/') . $routes[2] . '/' . $routes[3], 'w', Lang::T("Please enter amount"));
} }
$d = ORM::for_table('tbl_payment_gateway') $d = ORM::for_table('tbl_payment_gateway')
@ -569,7 +569,7 @@ switch ($action) {
->find_one(); ->find_one();
if ($d) { if ($d) {
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(getUrl('order/view/') . $d['id'], 'w', Lang::T("You already have unpaid transaction, cancel it or pay it."));
} else { } else {
if ($gateway == $d['gateway']) { if ($gateway == $d['gateway']) {
$id = $d['id']; $id = $d['id'];
@ -606,7 +606,7 @@ switch ($action) {
$router['name'] = 'balance'; $router['name'] = 'balance';
} }
if (empty($router) || empty($plan)) { if (empty($router) || empty($plan)) {
r2(U . "order/package", 'e', Lang::T("Plan Not found")); r2(getUrl('order/package'), 'e', Lang::T("Plan Not found"));
} }
$d = ORM::for_table('tbl_payment_gateway') $d = ORM::for_table('tbl_payment_gateway')
->where('username', $user['username']) ->where('username', $user['username'])
@ -614,7 +614,7 @@ switch ($action) {
->find_one(); ->find_one();
if ($d) { if ($d) {
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(getUrl('order/view/') . $d['id'], 'w', Lang::T("You already have unpaid transaction, cancel it or pay it."));
} else { } else {
if ($gateway == $d['gateway']) { if ($gateway == $d['gateway']) {
$id = $d['id']; $id = $d['id'];
@ -693,11 +693,11 @@ switch ($action) {
break; break;
} }
if (!$id) { if (!$id) {
r2(U . "order/package/" . $d['id'], 'e', Lang::T("Failed to create Transaction..")); r2(getUrl('order/package/') . $d['id'], 'e', Lang::T("Failed to create Transaction.."));
} else { } else {
call_user_func($gateway . '_create_transaction', $d, $user); call_user_func($gateway . '_create_transaction', $d, $user);
} }
break; break;
default: default:
r2(U . "order/package/", 's', ''); r2(getUrl('order/package/'), 's', '');
} }

View File

@ -26,7 +26,7 @@ if (strpos($action, "-reset") !== false) {
} else { } else {
file_put_contents($path, Http::getData('https://raw.githubusercontent.com/hotspotbilling/phpnuxbill/master/pages_template/' . $action . '.html')); file_put_contents($path, Http::getData('https://raw.githubusercontent.com/hotspotbilling/phpnuxbill/master/pages_template/' . $action . '.html'));
} }
r2(U . 'pages/' . $action); r2(getUrl('pages/') . $action);
} else if (strpos($action, "-post") === false) { } else if (strpos($action, "-post") === false) {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard"); _alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
@ -78,9 +78,9 @@ if (strpos($action, "-reset") !== false) {
file_put_contents("$PAGES_PATH/vouchers/" . _post('template_name') . '.html', $html); file_put_contents("$PAGES_PATH/vouchers/" . _post('template_name') . '.html', $html);
} }
} }
r2(U . 'pages/' . $action, 's', Lang::T("Saving page success")); r2(getUrl('pages/') . $action, 's', Lang::T("Saving page success"));
} else { } else {
r2(U . 'pages/' . $action, 'e', Lang::T("Failed to save page, make sure i can write to folder pages, <i>chmod 664 pages/*.html<i>")); r2(getUrl('pages/') . $action, 'e', Lang::T("Failed to save page, make sure i can write to folder pages, <i>chmod 664 pages/*.html<i>"));
} }
} else } else
$ui->display('a404.tpl'); $ui->display('a404.tpl');

View File

@ -16,7 +16,7 @@ switch ($action) {
if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $pg . '.php')) { if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $pg . '.php')) {
deleteFile($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR, $pg); deleteFile($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR, $pg);
} }
r2(U . 'paymentgateway', 's', Lang::T('Payment Gateway Deleted')); r2(getUrl('paymentgateway'), 's', Lang::T('Payment Gateway Deleted'));
case 'audit': case 'audit':
$pg = alphanumeric($routes[2]); $pg = alphanumeric($routes[2]);
@ -61,7 +61,7 @@ switch ($action) {
$d->value = $pgs; $d->value = $pgs;
$d->save(); $d->save();
} }
r2(U . 'paymentgateway', 's', Lang::T('Payment Gateway saved successfully')); r2(getUrl('paymentgateway'), 's', Lang::T('Payment Gateway saved successfully'));
} }
if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php')) { if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php')) {
@ -81,7 +81,7 @@ switch ($action) {
} }
} else { } else {
if (!empty($action)) { if (!empty($action)) {
r2(U . 'paymentgateway', 'w', Lang::T('Payment Gateway Not Found')); r2(getUrl('paymentgateway'), 'w', Lang::T('Payment Gateway Not Found'));
} else { } else {
$files = scandir($PAYMENTGATEWAY_PATH); $files = scandir($PAYMENTGATEWAY_PATH);
foreach ($files as $file) { foreach ($files as $file) {

View File

@ -66,7 +66,7 @@ switch ($action) {
$log .= "PLAN NOT FOUND : $tur[username], $tur[namebp], $tur[type], $tur[routers]<br>"; $log .= "PLAN NOT FOUND : $tur[username], $tur[namebp], $tur[type], $tur[routers]<br>";
} }
} }
r2(U . 'plan/list', 's', $log); r2(getUrl('plan/list'), 's', $log);
case 'recharge': case 'recharge':
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Agent', 'Sales'])) { if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Agent', 'Sales'])) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard"); _alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
@ -127,13 +127,13 @@ switch ($action) {
if ($using == 'balance' && $config['enable_balance'] == 'yes') { if ($using == 'balance' && $config['enable_balance'] == 'yes') {
if (!$cust) { if (!$cust) {
r2(U . 'plan/recharge', 'e', Lang::T('Customer not found')); r2(getUrl('plan/recharge'), 'e', Lang::T('Customer not found'));
} }
if (!$plan) { if (!$plan) {
r2(U . 'plan/recharge', 'e', Lang::T('Plan not found')); r2(getUrl('plan/recharge'), 'e', Lang::T('Plan not found'));
} }
if ($cust['balance'] < $total_cost) { if ($cust['balance'] < $total_cost) {
r2(U . 'plan/recharge', 'e', Lang::T('insufficient balance')); r2(getUrl('plan/recharge'), 'e', Lang::T('insufficient balance'));
} }
$gateway = 'Recharge Balance'; $gateway = 'Recharge Balance';
} }
@ -160,7 +160,7 @@ switch ($action) {
$ui->assign('plan', $plan); $ui->assign('plan', $plan);
$ui->display('recharge-confirm.tpl'); $ui->display('recharge-confirm.tpl');
} else { } else {
r2(U . 'plan/recharge', 'e', $msg); r2(getUrl('plan/recharge'), 'e', $msg);
} }
break; break;
@ -217,13 +217,13 @@ switch ($action) {
if ($using == 'balance' && $config['enable_balance'] == 'yes') { if ($using == 'balance' && $config['enable_balance'] == 'yes') {
//$plan = ORM::for_table('tbl_plans')->find_one($planId); //$plan = ORM::for_table('tbl_plans')->find_one($planId);
if (!$cust) { if (!$cust) {
r2(U . 'plan/recharge', 'e', Lang::T('Customer not found')); r2(getUrl('plan/recharge'), 'e', Lang::T('Customer not found'));
} }
if (!$plan) { if (!$plan) {
r2(U . 'plan/recharge', 'e', Lang::T('Plan not found')); r2(getUrl('plan/recharge'), 'e', Lang::T('Plan not found'));
} }
if ($cust['balance'] < $total_cost) { if ($cust['balance'] < $total_cost) {
r2(U . 'plan/recharge', 'e', Lang::T('insufficient balance')); r2(getUrl('plan/recharge'), 'e', Lang::T('insufficient balance'));
} }
$gateway = 'Recharge Balance'; $gateway = 'Recharge Balance';
} }
@ -242,10 +242,10 @@ switch ($action) {
$ui->display('invoice.tpl'); $ui->display('invoice.tpl');
_log('[' . $admin['username'] . ']: ' . 'Recharge ' . $cust['username'] . ' [' . $in['plan_name'] . '][' . Lang::moneyFormat($in['price']) . ']', $admin['user_type'], $admin['id']); _log('[' . $admin['username'] . ']: ' . 'Recharge ' . $cust['username'] . ' [' . $in['plan_name'] . '][' . Lang::moneyFormat($in['price']) . ']', $admin['user_type'], $admin['id']);
} else { } else {
r2(U . 'plan/recharge', 'e', "Failed to recharge account"); r2(getUrl('plan/recharge'), 'e', "Failed to recharge account");
} }
} else { } else {
r2(U . 'plan/recharge', 'e', $msg); r2(getUrl('plan/recharge'), 'e', $msg);
} }
break; break;
@ -257,9 +257,9 @@ switch ($action) {
$c = ORM::for_table('tbl_customers')->where('username', $in['username'])->find_one(); $c = ORM::for_table('tbl_customers')->where('username', $in['username'])->find_one();
if ($c) { if ($c) {
Message::sendInvoice($c, $in); Message::sendInvoice($c, $in);
r2(U . 'plan/view/' . $id, 's', "Success send to customer"); r2(getUrl('plan/view/') . $id, 's', "Success send to customer");
} }
r2(U . 'plan/view/' . $id, 'd', "Customer not found"); r2(getUrl('plan/view/') . $id, 'd', "Customer not found");
} }
Package::createInvoice($in); Package::createInvoice($in);
$ui->assign('_title', 'View Invoice'); $ui->assign('_title', 'View Invoice');
@ -314,7 +314,7 @@ switch ($action) {
$ui->assign('_title', 'Edit Plan'); $ui->assign('_title', 'Edit Plan');
$ui->display('plan-edit.tpl'); $ui->display('plan-edit.tpl');
} else { } else {
r2(U . 'plan/list', 'e', Lang::T('Account Not Found')); r2(getUrl('plan/list'), 'e', Lang::T('Account Not Found'));
} }
break; break;
@ -339,7 +339,7 @@ switch ($action) {
} }
$d->delete(); $d->delete();
_log('[' . $admin['username'] . ']: ' . 'Delete Plan for Customer ' . $c['username'] . ' [' . $in['plan_name'] . '][' . Lang::moneyFormat($in['price']) . ']', $admin['user_type'], $admin['id']); _log('[' . $admin['username'] . ']: ' . 'Delete Plan for Customer ' . $c['username'] . ' [' . $in['plan_name'] . '][' . Lang::moneyFormat($in['price']) . ']', $admin['user_type'], $admin['id']);
r2(U . 'plan/list', 's', Lang::T('Data Deleted Successfully')); r2(getUrl('plan/list'), 's', Lang::T('Data Deleted Successfully'));
} }
break; break;
@ -405,9 +405,9 @@ switch ($action) {
} }
$d->save(); $d->save();
_log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer ' . $d['username'] . ' to [' . $d['namebp'] . '][' . Lang::moneyFormat($p['price']) . ']', $admin['user_type'], $admin['id']); _log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer ' . $d['username'] . ' to [' . $d['namebp'] . '][' . Lang::moneyFormat($p['price']) . ']', $admin['user_type'], $admin['id']);
r2(U . 'plan/list', 's', Lang::T('Data Updated Successfully')); r2(getUrl('plan/list'), 's', Lang::T('Data Updated Successfully'));
} else { } else {
r2(U . 'plan/edit/' . $id, 'e', $msg); r2(getUrl('plan/edit/') . $id, 'e', $msg);
} }
break; break;
@ -544,7 +544,7 @@ switch ($action) {
$jml++; $jml++;
} }
} }
r2(U . 'plan/voucher', 's', "$jml " . Lang::T('Data Deleted Successfully')); r2(getUrl('plan/voucher'), 's', "$jml " . Lang::T('Data Deleted Successfully'));
} }
case 'print-voucher': case 'print-voucher':
$from_id = _post('from_id'); $from_id = _post('from_id');
@ -795,12 +795,12 @@ switch ($action) {
} }
if ($numbervoucher == 1) { if ($numbervoucher == 1) {
r2(U . 'plan/voucher-view/' . $d->id(), 's', Lang::T('Create Vouchers Successfully')); r2(getUrl('plan/voucher-view/') . $d->id(), 's', Lang::T('Create Vouchers Successfully'));
} }
r2(U . 'plan/voucher', 's', Lang::T('Create Vouchers Successfully')); r2(getUrl('plan/voucher'), 's', Lang::T('Create Vouchers Successfully'));
} else { } else {
r2(U . 'plan/add-voucher/' . $id, 'e', $msg); r2(getUrl('plan/add-voucher/') . $id, 'e', $msg);
} }
break; break;
@ -855,11 +855,11 @@ switch ($action) {
$voucher = ORM::for_table('tbl_voucher') $voucher = ORM::for_table('tbl_voucher')
->find_one($id); ->find_one($id);
if (!in_array($voucher['generated_by'], $sales)) { if (!in_array($voucher['generated_by'], $sales)) {
r2(U . 'plan/voucher/', 'e', Lang::T('Voucher Not Found')); r2(getUrl('plan/voucher/'), 'e', Lang::T('Voucher Not Found'));
} }
} }
if (!$voucher) { if (!$voucher) {
r2(U . 'plan/voucher/', 'e', Lang::T('Voucher Not Found')); r2(getUrl('plan/voucher/'), 'e', Lang::T('Voucher Not Found'));
} }
$plan = ORM::for_table('tbl_plans')->find_one($voucher['id_plan']); $plan = ORM::for_table('tbl_plans')->find_one($voucher['id_plan']);
if ($voucher && $plan) { if ($voucher && $plan) {
@ -893,7 +893,7 @@ switch ($action) {
$ui->assign('whatsapp', urlencode("```$content```")); $ui->assign('whatsapp', urlencode("```$content```"));
$ui->display('voucher-view.tpl'); $ui->display('voucher-view.tpl');
} else { } else {
r2(U . 'plan/voucher/', 'e', Lang::T('Voucher Not Found')); r2(getUrl('plan/voucher/'), 'e', Lang::T('Voucher Not Found'));
} }
break; break;
case 'voucher-delete': case 'voucher-delete':
@ -905,7 +905,7 @@ switch ($action) {
$d = ORM::for_table('tbl_voucher')->find_one($id); $d = ORM::for_table('tbl_voucher')->find_one($id);
if ($d) { if ($d) {
$d->delete(); $d->delete();
r2(U . 'plan/voucher', 's', Lang::T('Data Deleted Successfully')); r2(getUrl('plan/voucher'), 's', Lang::T('Data Deleted Successfully'));
} }
break; break;
@ -938,10 +938,10 @@ switch ($action) {
Package::createInvoice($in); Package::createInvoice($in);
$ui->display('invoice.tpl'); $ui->display('invoice.tpl');
} else { } else {
r2(U . 'plan/refill', 'e', "Failed to refill account"); r2(getUrl('plan/refill'), 'e', "Failed to refill account");
} }
} else { } else {
r2(U . 'plan/refill', 'e', Lang::T('Voucher Not Valid')); r2(getUrl('plan/refill'), 'e', Lang::T('Voucher Not Valid'));
} }
break; break;
case 'deposit': case 'deposit':
@ -989,7 +989,7 @@ switch ($action) {
} }
$ui->display('invoice.tpl'); $ui->display('invoice.tpl');
} else { } else {
r2(U . 'plan/refill', 'e', "Failed to refill account"); r2(getUrl('plan/refill'), 'e', "Failed to refill account");
} }
} else if (!empty($user) && !empty($plan)) { } else if (!empty($user) && !empty($plan)) {
$p = ORM::for_table('tbl_plans')->find_one($plan); $p = ORM::for_table('tbl_plans')->find_one($plan);
@ -1002,10 +1002,10 @@ switch ($action) {
} }
$ui->display('invoice.tpl'); $ui->display('invoice.tpl');
} else { } else {
r2(U . 'plan/refill', 'e', "Failed to refill account"); r2(getUrl('plan/refill'), 'e', "Failed to refill account");
} }
} else { } else {
r2(U . 'plan/refill', 'e', "All field is required"); r2(getUrl('plan/refill'), 'e', "All field is required");
} }
break; break;
case 'extend': case 'extend':
@ -1013,7 +1013,7 @@ switch ($action) {
$days = $routes[3]; $days = $routes[3];
$svoucher = $_GET['svoucher']; $svoucher = $_GET['svoucher'];
if (App::getVoucherValue($svoucher)) { if (App::getVoucherValue($svoucher)) {
r2(U . 'plan', 's', "Extend already done"); r2(getUrl('plan'), 's', "Extend already done");
} }
$tur = ORM::for_table('tbl_user_recharges')->find_one($id); $tur = ORM::for_table('tbl_user_recharges')->find_one($id);
$status = $tur['status']; $status = $tur['status'];
@ -1045,19 +1045,19 @@ switch ($action) {
$tur->status = "on"; $tur->status = "on";
$tur->save(); $tur->save();
} else { } else {
r2(U . 'plan', 's', "Plan not found"); r2(getUrl('plan'), 's', "Plan not found");
} }
} else { } else {
r2(U . 'plan', 's', "Customer not found"); r2(getUrl('plan'), 's', "Customer not found");
} }
Message::sendTelegram("#u$tur[username] #extend #" . $p['type'] . " \n" . $p['name_plan'] . Message::sendTelegram("#u$tur[username] #extend #" . $p['type'] . " \n" . $p['name_plan'] .
"\nLocation: " . $p['routers'] . "\nLocation: " . $p['routers'] .
"\nCustomer: " . $c['fullname'] . "\nCustomer: " . $c['fullname'] .
"\nNew Expired: " . Lang::dateAndTimeFormat($expiration, $tur['time'])); "\nNew Expired: " . Lang::dateAndTimeFormat($expiration, $tur['time']));
_log("$admin[fullname] extend Customer $tur[customer_id] $tur[username] for $days days", $admin['user_type'], $admin['id']); _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"); r2(getUrl('plan'), 's', "Extend until $expiration");
} else { } else {
r2(U . 'plan', 's', "Customer is not expired yet"); r2(getUrl('plan'), 's', "Customer is not expired yet");
} }
break; break;
default: default:

View File

@ -7,5 +7,5 @@
if(function_exists($routes[1])){ if(function_exists($routes[1])){
call_user_func($routes[1]); call_user_func($routes[1]);
}else{ }else{
r2(U.'dashboard', 'e', 'Function not found'); r2(getUrl('dashboard'), 'e', 'Function not found');
} }

View File

@ -25,7 +25,7 @@ if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) {
$json = json_decode($txt, true); $json = json_decode($txt, true);
if (empty($json['plugins']) && empty($json['payment_gateway'])) { if (empty($json['plugins']) && empty($json['payment_gateway'])) {
unlink($cache); unlink($cache);
r2(U . 'pluginmanager'); r2(getUrl('pluginmanager'));
} }
} else { } else {
$data = Http::getData($plugin_repository); $data = Http::getData($plugin_repository);
@ -35,23 +35,23 @@ if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) {
switch ($action) { switch ($action) {
case 'refresh': case 'refresh':
if (file_exists($cache)) unlink($cache); if (file_exists($cache)) unlink($cache);
r2(U . "pluginmanager", 's', 'Refresh success'); r2(getUrl('pluginmanager'), 's', 'Refresh success');
break; break;
case 'dlinstall': case 'dlinstall':
if ($_app_stage == 'demo') { if ($_app_stage == 'demo') {
r2(U . "pluginmanager", 'e', 'Demo Mode cannot install as it Security risk'); r2(getUrl('pluginmanager'), 'e', 'Demo Mode cannot install as it Security risk');
} }
if (!is_writeable($CACHE_PATH)) { if (!is_writeable($CACHE_PATH)) {
r2(U . "pluginmanager", 'e', 'Folder cache/ is not writable'); r2(getUrl('pluginmanager'), 'e', 'Folder cache/ is not writable');
} }
if (!is_writeable($PLUGIN_PATH)) { if (!is_writeable($PLUGIN_PATH)) {
r2(U . "pluginmanager", 'e', 'Folder plugin/ is not writable'); r2(getUrl('pluginmanager'), 'e', 'Folder plugin/ is not writable');
} }
if (!is_writeable($DEVICE_PATH)) { if (!is_writeable($DEVICE_PATH)) {
r2(U . "pluginmanager", 'e', 'Folder devices/ is not writable'); r2(getUrl('pluginmanager'), 'e', 'Folder devices/ is not writable');
} }
if (!is_writeable($UI_PATH . DIRECTORY_SEPARATOR . 'themes')) { if (!is_writeable($UI_PATH . DIRECTORY_SEPARATOR . 'themes')) {
r2(U . "pluginmanager", 'e', 'Folder themes/ is not writable'); r2(getUrl('pluginmanager'), 'e', 'Folder themes/ is not writable');
} }
$cache = $CACHE_PATH . DIRECTORY_SEPARATOR . 'installer' . DIRECTORY_SEPARATOR; $cache = $CACHE_PATH . DIRECTORY_SEPARATOR . 'installer' . DIRECTORY_SEPARATOR;
if (!file_exists($cache)) { if (!file_exists($cache)) {
@ -97,7 +97,7 @@ switch ($action) {
} }
//Cleaning //Cleaning
File::deleteFolder($cache); File::deleteFolder($cache);
r2(U . "pluginmanager", 's', 'Installation success'); r2(getUrl('pluginmanager'), 's', 'Installation success');
} else if (_post('gh_url', '') != '') { } else if (_post('gh_url', '') != '') {
$ghUrl = _post('gh_url', ''); $ghUrl = _post('gh_url', '');
if (!empty($config['github_token']) && !empty($config['github_username'])) { if (!empty($config['github_token']) && !empty($config['github_username'])) {
@ -155,17 +155,17 @@ switch ($action) {
} }
} }
File::deleteFolder($cache); File::deleteFolder($cache);
r2(U . "pluginmanager", 's', 'Installation success'); r2(getUrl('pluginmanager'), 's', 'Installation success');
} else { } else {
r2(U . 'pluginmanager', 'e', 'Nothing Installed'); r2(getUrl('pluginmanager'), 'e', 'Nothing Installed');
} }
break; break;
case 'delete': case 'delete':
if (!is_writeable($CACHE_PATH)) { if (!is_writeable($CACHE_PATH)) {
r2(U . "pluginmanager", 'e', 'Folder cache/ is not writable'); r2(getUrl('pluginmanager'), 'e', 'Folder cache/ is not writable');
} }
if (!is_writeable($PLUGIN_PATH)) { if (!is_writeable($PLUGIN_PATH)) {
r2(U . "pluginmanager", 'e', 'Folder plugin/ is not writable'); r2(getUrl('pluginmanager'), 'e', 'Folder plugin/ is not writable');
} }
set_time_limit(-1); set_time_limit(-1);
$tipe = $routes['2']; $tipe = $routes['2'];
@ -199,12 +199,12 @@ switch ($action) {
$folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/'); $folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/');
} }
if (!file_exists($folder)) { if (!file_exists($folder)) {
r2(U . "pluginmanager", 'e', 'Extracted Folder is unknown'); r2(getUrl('pluginmanager'), 'e', 'Extracted Folder is unknown');
} }
scanAndRemovePath($folder, $PLUGIN_PATH . DIRECTORY_SEPARATOR); scanAndRemovePath($folder, $PLUGIN_PATH . DIRECTORY_SEPARATOR);
File::deleteFolder($folder); File::deleteFolder($folder);
unlink($file); unlink($file);
r2(U . "pluginmanager", 's', 'Plugin ' . $plugin . ' has been deleted'); r2(getUrl('pluginmanager'), 's', 'Plugin ' . $plugin . ' has been deleted');
break; break;
} }
} }
@ -213,10 +213,10 @@ switch ($action) {
break; break;
case 'install': case 'install':
if (!is_writeable($CACHE_PATH)) { if (!is_writeable($CACHE_PATH)) {
r2(U . "pluginmanager", 'e', 'Folder cache/ is not writable'); r2(getUrl('pluginmanager'), 'e', 'Folder cache/ is not writable');
} }
if (!is_writeable($PLUGIN_PATH)) { if (!is_writeable($PLUGIN_PATH)) {
r2(U . "pluginmanager", 'e', 'Folder plugin/ is not writable'); r2(getUrl('pluginmanager'), 'e', 'Folder plugin/ is not writable');
} }
set_time_limit(-1); set_time_limit(-1);
$tipe = $routes['2']; $tipe = $routes['2'];
@ -250,12 +250,12 @@ switch ($action) {
$folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/'); $folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/');
} }
if (!file_exists($folder)) { if (!file_exists($folder)) {
r2(U . "pluginmanager", 'e', 'Extracted Folder is unknown'); r2(getUrl('pluginmanager'), 'e', 'Extracted Folder is unknown');
} }
File::copyFolder($folder, $PLUGIN_PATH . DIRECTORY_SEPARATOR, ['README.md', 'LICENSE']); File::copyFolder($folder, $PLUGIN_PATH . DIRECTORY_SEPARATOR, ['README.md', 'LICENSE']);
File::deleteFolder($folder); File::deleteFolder($folder);
unlink($file); unlink($file);
r2(U . "pluginmanager", 's', 'Plugin ' . $plugin . ' has been installed'); r2(getUrl('pluginmanager'), 's', 'Plugin ' . $plugin . ' has been installed');
break; break;
} }
} }
@ -287,12 +287,12 @@ switch ($action) {
$folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/'); $folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/');
} }
if (!file_exists($folder)) { if (!file_exists($folder)) {
r2(U . "pluginmanager", 'e', 'Extracted Folder is unknown'); r2(getUrl('pluginmanager'), 'e', 'Extracted Folder is unknown');
} }
File::copyFolder($folder, $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR, ['README.md', 'LICENSE']); File::copyFolder($folder, $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR, ['README.md', 'LICENSE']);
File::deleteFolder($folder); File::deleteFolder($folder);
unlink($file); unlink($file);
r2(U . "paymentgateway", 's', 'Payment Gateway ' . $plugin . ' has been installed'); r2(getUrl('paymentgateway'), 's', 'Payment Gateway ' . $plugin . ' has been installed');
break; break;
} }
} }
@ -324,12 +324,12 @@ switch ($action) {
$folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/'); $folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/');
} }
if (!file_exists($folder)) { if (!file_exists($folder)) {
r2(U . "pluginmanager", 'e', 'Extracted Folder is unknown'); r2(getUrl('pluginmanager'), 'e', 'Extracted Folder is unknown');
} }
File::copyFolder($folder, $DEVICE_PATH . DIRECTORY_SEPARATOR, ['README.md', 'LICENSE']); File::copyFolder($folder, $DEVICE_PATH . DIRECTORY_SEPARATOR, ['README.md', 'LICENSE']);
File::deleteFolder($folder); File::deleteFolder($folder);
unlink($file); unlink($file);
r2(U . "settings/devices", 's', 'Device ' . $plugin . ' has been installed'); r2(getUrl('settings/devices'), 's', 'Device ' . $plugin . ' has been installed');
break; break;
} }
} }

View File

@ -51,7 +51,7 @@ switch ($action) {
run_hook('view_edit_pool'); #HOOK run_hook('view_edit_pool'); #HOOK
$ui->display('pool-edit.tpl'); $ui->display('pool-edit.tpl');
} else { } else {
r2(U . 'pool/list', 'e', Lang::T('Account Not Found')); r2(getUrl('pool/list'), 'e', Lang::T('Account Not Found'));
} }
break; break;
@ -65,7 +65,7 @@ switch ($action) {
} }
$d->delete(); $d->delete();
r2(U . 'pool/list', 's', Lang::T('Data Deleted Successfully')); r2(getUrl('pool/list'), 's', Lang::T('Data Deleted Successfully'));
} }
break; break;
@ -78,7 +78,7 @@ switch ($action) {
$log .= 'DONE: ' . $pool['pool_name'] . ': ' . $pool['range_ip'] . '<br>'; $log .= 'DONE: ' . $pool['pool_name'] . ': ' . $pool['range_ip'] . '<br>';
} }
} }
r2(U . 'pool/list', 's', $log); r2(getUrl('pool/list'), 's', $log);
break; break;
case 'add-post': case 'add-post':
$name = _post('name'); $name = _post('name');
@ -108,9 +108,9 @@ switch ($action) {
(new MikrotikPppoe())->add_pool($b); (new MikrotikPppoe())->add_pool($b);
} }
$b->save(); $b->save();
r2(U . 'pool/list', 's', Lang::T('Data Created Successfully')); r2(getUrl('pool/list'), 's', Lang::T('Data Created Successfully'));
} else { } else {
r2(U . 'pool/add', 'e', $msg); r2(getUrl('pool/add'), 'e', $msg);
} }
break; break;
@ -143,9 +143,9 @@ switch ($action) {
(new MikrotikPppoe())->update_pool($old, $d); (new MikrotikPppoe())->update_pool($old, $d);
} }
r2(U . 'pool/list', 's', Lang::T('Data Updated Successfully')); r2(getUrl('pool/list'), 's', Lang::T('Data Updated Successfully'));
} else { } else {
r2(U . 'pool/edit/' . $id, 'e', $msg); r2(getUrl('pool/edit/') . $id, 'e', $msg);
} }
case 'port': case 'port':
@ -180,7 +180,7 @@ switch ($action) {
run_hook('view_edit_port'); #HOOK run_hook('view_edit_port'); #HOOK
$ui->display('port-edit.tpl'); $ui->display('port-edit.tpl');
} else { } else {
r2(U . 'pool/port', 'e', Lang::T('Account Not Found')); r2(getUrl('pool/port'), 'e', Lang::T('Account Not Found'));
} }
break; break;
@ -191,7 +191,7 @@ switch ($action) {
if ($d) { if ($d) {
$d->delete(); $d->delete();
r2(U . 'pool/port', 's', Lang::T('Data Deleted Successfully')); r2(getUrl('pool/port'), 's', Lang::T('Data Deleted Successfully'));
} }
break; break;
@ -204,7 +204,7 @@ switch ($action) {
$log .= 'DONE: ' . $pool['port_name'] . ': ' . $pool['range_port'] . '<br>'; $log .= 'DONE: ' . $pool['port_name'] . ': ' . $pool['range_port'] . '<br>';
} }
} }
r2(U . 'pool/list', 's', $log); r2(getUrl('pool/list'), 's', $log);
break; break;
case 'add-port-post': case 'add-port-post':
$name = _post('name'); $name = _post('name');
@ -231,21 +231,21 @@ switch ($action) {
$b->range_port = $port_range; $b->range_port = $port_range;
$b->routers = $routers; $b->routers = $routers;
$b->save(); $b->save();
r2(U . 'pool/port', 's', Lang::T('Data Created Successfully')); r2(getUrl('pool/port'), 's', Lang::T('Data Created Successfully'));
} else { } else {
r2(U . 'pool/add-port', 'e', $msg); r2(getUrl('pool/add-port'), 'e', $msg);
} }
break; break;
case 'edit-port-post': case 'edit-port-post':
$name = _post('name'); $name = _post('name');
$public_ip = _post('public_ip'); $public_ip = _post('public_ip');
$range_port = _post('range_port'); $range_port = _post('range_port');
$routers = _post('routers'); $routers = _post('routers');
run_hook('edit_port'); #HOOK run_hook('edit_port'); #HOOK
$msg = ''; $msg = '';
$msg = ''; $msg = '';
if (Validator::Length($name, 30, 2) == false) { if (Validator::Length($name, 30, 2) == false) {
$msg .= 'Name should be between 3 to 30 characters' . '<br>'; $msg .= 'Name should be between 3 to 30 characters' . '<br>';
} }
@ -261,20 +261,18 @@ switch ($action) {
} }
if ($msg == '') { if ($msg == '') {
$d->port_name = $name; $d->port_name = $name;
$d->public_ip = $public_ip; $d->public_ip = $public_ip;
$d->range_port = $range_port; $d->range_port = $range_port;
$d->routers = $routers; $d->routers = $routers;
$d->save(); $d->save();
r2(getUrl('pool/port'), 's', Lang::T('Data Updated Successfully'));
r2(U . 'pool/port', 's', Lang::T('Data Updated Successfully'));
} else { } else {
r2(U . 'pool/edit-port/' . $id, 'e', $msg); r2(getUrl('pool/edit-port/') . $id, 'e', $msg);
} }
break; break;
default: default:
r2(U . 'pool/list/', 's', ''); r2(getUrl('pool/list/'), 's', '');
} }

View File

@ -58,12 +58,12 @@ switch ($action) {
if ($msg == '') { if ($msg == '') {
require_once $DEVICE_PATH . DIRECTORY_SEPARATOR . "Radius.php"; require_once $DEVICE_PATH . DIRECTORY_SEPARATOR . "Radius.php";
if ((new Radius())->nasAdd($shortname, $nasname, $ports, $secret, $routers, $description, $type, $server, $community) > 0) { if ((new Radius())->nasAdd($shortname, $nasname, $ports, $secret, $routers, $description, $type, $server, $community) > 0) {
r2(U . 'radius/nas-list/', 's', "NAS Added"); r2(getUrl('radius/nas-list/'), 's', "NAS Added");
} else { } else {
r2(U . 'radius/nas-add/', 'e', "NAS Added Failed"); r2(getUrl('radius/nas-add/'), 'e', "NAS Added Failed");
} }
} else { } else {
r2(U . 'radius/nas-add', 'e', $msg); r2(getUrl('radius/nas-add'), 'e', $msg);
} }
break; break;
case 'nas-edit': case 'nas-edit':
@ -80,7 +80,7 @@ switch ($action) {
$ui->assign('d', $d); $ui->assign('d', $d);
$ui->display('radius-nas-edit.tpl'); $ui->display('radius-nas-edit.tpl');
} else { } else {
r2(U . 'radius/list', 'e', Lang::T('Account Not Found')); r2(getUrl('radius/list'), 'e', Lang::T('Account Not Found'));
} }
break; break;
@ -115,12 +115,12 @@ switch ($action) {
if ($msg == '') { if ($msg == '') {
require_once $DEVICE_PATH . DIRECTORY_SEPARATOR . "Radius.php"; require_once $DEVICE_PATH . DIRECTORY_SEPARATOR . "Radius.php";
if ((new Radius())->nasUpdate($id, $shortname, $nasname, $ports, $secret, $routers, $description, $type, $server, $community)) { if ((new Radius())->nasUpdate($id, $shortname, $nasname, $ports, $secret, $routers, $description, $type, $server, $community)) {
r2(U . 'radius/list/', 's', "NAS Saved"); r2(getUrl('radius/list/'), 's', "NAS Saved");
} else { } else {
r2(U . 'radius/nas-add', 'e', 'NAS NOT Exists'); r2(getUrl('radius/nas-add'), 'e', 'NAS NOT Exists');
} }
} else { } else {
r2(U . 'radius/nas-add', 'e', $msg); r2(getUrl('radius/nas-add'), 'e', $msg);
} }
break; break;
case 'nas-delete': case 'nas-delete':
@ -129,7 +129,7 @@ switch ($action) {
if ($d) { if ($d) {
$d->delete(); $d->delete();
} else { } else {
r2(U . 'radius/nas-list', 'e', 'NAS Not found'); r2(getUrl('radius/nas-list'), 'e', 'NAS Not found');
} }
default: default:
$ui->assign('_system_menu', 'radius'); $ui->assign('_system_menu', 'radius');

View File

@ -57,7 +57,7 @@ switch ($do) {
// Expire after 10 minutes // Expire after 10 minutes
if (file_exists($otpPath) && time() - filemtime($otpPath) > 1200) { if (file_exists($otpPath) && time() - filemtime($otpPath) > 1200) {
unlink($otpPath); unlink($otpPath);
r2(U . 'register', 's', 'Verification code expired'); r2(getUrl('register'), 's', 'Verification code expired');
} else if (file_exists($otpPath)) { } else if (file_exists($otpPath)) {
$code = file_get_contents($otpPath); $code = file_get_contents($otpPath);
if ($code != $otp_code) { if ($code != $otp_code) {
@ -75,7 +75,7 @@ switch ($do) {
unlink($otpPath); unlink($otpPath);
} }
} else { } else {
r2(U . 'register', 's', 'No Verification code'); r2(getUrl('register'), 's', 'No Verification code');
} }
} }
@ -120,7 +120,7 @@ switch ($do) {
if ($config['reg_nofify_admin'] == 'yes') { if ($config['reg_nofify_admin'] == 'yes') {
sendTelegram($config['CompanyName'] . ' - ' . Lang::T('New User Registration') . "\n\nFull Name: " . $fullname . "\nUsername: " . $username . "\nEmail: " . $email . "\nPhone Number: " . $phone_number . "\nAddress: " . $address); sendTelegram($config['CompanyName'] . ' - ' . Lang::T('New User Registration') . "\n\nFull Name: " . $fullname . "\nUsername: " . $username . "\nEmail: " . $email . "\nPhone Number: " . $phone_number . "\nAddress: " . $address);
} }
r2(U . 'login', 's', Lang::T('Register Success! You can login now')); r2(getUrl('login'), 's', Lang::T('Register Success! You can login now'));
} else { } else {
$ui->assign('username', $username); $ui->assign('username', $username);
$ui->assign('fullname', $fullname); $ui->assign('fullname', $fullname);
@ -159,7 +159,7 @@ switch ($do) {
if (!empty($phone_number)) { if (!empty($phone_number)) {
$d = ORM::for_table('tbl_customers')->where('username', $phone_number)->find_one(); $d = ORM::for_table('tbl_customers')->where('username', $phone_number)->find_one();
if ($d) { if ($d) {
r2(U . 'register', 's', Lang::T('Account already exists')); r2(getUrl('register'), 's', Lang::T('Account already exists'));
} }
if (!file_exists($otpPath)) { if (!file_exists($otpPath)) {
mkdir($otpPath); mkdir($otpPath);

View File

@ -257,7 +257,7 @@ switch ($action) {
$keep = _post('keep'); $keep = _post('keep');
if (!empty($keep)) { if (!empty($keep)) {
ORM::raw_execute("DELETE FROM tbl_transactions WHERE date < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL $keep DAY))"); ORM::raw_execute("DELETE FROM tbl_transactions WHERE date < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL $keep DAY))");
r2(U . "logs/list/", 's', "Delete logs older than $keep days"); r2(getUrl('logs/list/'), 's', "Delete logs older than $keep days");
} }
if ($q != '') { if ($q != '') {
$query = ORM::for_table('tbl_transactions')->where_like('invoice', '%' . $q . '%')->order_by_desc('id'); $query = ORM::for_table('tbl_transactions')->where_like('invoice', '%' . $q . '%')->order_by_desc('id');

View File

@ -55,7 +55,7 @@ switch ($action) {
run_hook('view_router_edit'); #HOOK run_hook('view_router_edit'); #HOOK
$ui->display('routers-edit.tpl'); $ui->display('routers-edit.tpl');
} else { } else {
r2(U . 'routers/list', 'e', Lang::T('Account Not Found')); r2(getUrl('routers/list'), 'e', Lang::T('Account Not Found'));
} }
break; break;
@ -65,7 +65,7 @@ switch ($action) {
$d = ORM::for_table('tbl_routers')->find_one($id); $d = ORM::for_table('tbl_routers')->find_one($id);
if ($d) { if ($d) {
$d->delete(); $d->delete();
r2(U . 'routers/list', 's', Lang::T('Data Deleted Successfully')); r2(getUrl('routers/list'), 's', Lang::T('Data Deleted Successfully'));
} }
break; break;
@ -109,9 +109,9 @@ switch ($action) {
$d->enabled = $enabled; $d->enabled = $enabled;
$d->save(); $d->save();
r2(U . 'routers/edit/' . $d->id(), 's', Lang::T('Data Created Successfully')); r2(getUrl('routers/edit/') . $d->id(), 's', Lang::T('Data Created Successfully'));
} else { } else {
r2(U . 'routers/add', 'e', $msg); r2(getUrl('routers/add'), 'e', $msg);
} }
break; break;
@ -197,9 +197,9 @@ switch ($action) {
$p->set('routers', $name); $p->set('routers', $name);
$p->save(); $p->save();
} }
r2(U . 'routers/list', 's', Lang::T('Data Updated Successfully')); r2(getUrl('routers/list'), 's', Lang::T('Data Updated Successfully'));
} else { } else {
r2(U . 'routers/edit/' . $id, 'e', $msg); r2(getUrl('routers/edit/') . $id, 'e', $msg);
} }
break; break;

View File

@ -33,7 +33,7 @@ switch ($action) {
} }
} }
} }
r2(U . 'services/hotspot', 's', $log); r2(getUrl('services/hotspot'), 's', $log);
} else if ($routes['2'] == 'pppoe') { } else if ($routes['2'] == 'pppoe') {
$plans = ORM::for_table('tbl_plans')->where('type', 'PPPOE')->find_many(); $plans = ORM::for_table('tbl_plans')->where('type', 'PPPOE')->find_many();
$log = ''; $log = '';
@ -49,9 +49,9 @@ switch ($action) {
} }
} }
} }
r2(U . 'services/pppoe', 's', $log); r2(getUrl('services/pppoe'), 's', $log);
} }
r2(U . 'services/hotspot', 'w', 'Unknown command'); r2(getUrl('services/hotspot'), 'w', 'Unknown command');
case 'hotspot': case 'hotspot':
$ui->assign('xfooter', '<script type="text/javascript" src="ui/lib/c/hotspot.js"></script>'); $ui->assign('xfooter', '<script type="text/javascript" src="ui/lib/c/hotspot.js"></script>');
$name = _req('name'); $name = _req('name');
@ -193,7 +193,7 @@ switch ($action) {
run_hook('view_edit_plan'); #HOOK run_hook('view_edit_plan'); #HOOK
$ui->display('hotspot-edit.tpl'); $ui->display('hotspot-edit.tpl');
} else { } else {
r2(U . 'services/hotspot', 'e', Lang::T('Account Not Found')); r2(getUrl('services/hotspot'), 'e', Lang::T('Account Not Found'));
} }
break; break;
@ -214,7 +214,7 @@ switch ($action) {
} }
$d->delete(); $d->delete();
r2(U . 'services/hotspot', 's', Lang::T('Data Deleted Successfully')); r2(getUrl('services/hotspot'), 's', Lang::T('Data Deleted Successfully'));
} }
break; break;
@ -307,9 +307,9 @@ switch ($action) {
new Exception(Lang::T("Devices Not Found")); new Exception(Lang::T("Devices Not Found"));
} }
} }
r2(U . 'services/edit/' . $d->id(), 's', Lang::T('Data Created Successfully')); r2(getUrl('services/edit/') . $d->id(), 's', Lang::T('Data Created Successfully'));
} else { } else {
r2(U . 'services/add', 'e', $msg); r2(getUrl('services/add'), 'e', $msg);
} }
break; break;
@ -420,9 +420,9 @@ switch ($action) {
new Exception(Lang::T("Devices Not Found")); new Exception(Lang::T("Devices Not Found"));
} }
} }
r2(U . 'services/hotspot', 's', Lang::T('Data Updated Successfully')); r2(getUrl('services/hotspot'), 's', Lang::T('Data Updated Successfully'));
} else { } else {
r2(U . 'services/edit/' . $id, 'e', $msg); r2(getUrl('services/edit/') . $id, 'e', $msg);
} }
break; break;
@ -580,7 +580,7 @@ switch ($action) {
run_hook('view_edit_ppoe'); #HOOK run_hook('view_edit_ppoe'); #HOOK
$ui->display('pppoe-edit.tpl'); $ui->display('pppoe-edit.tpl');
} else { } else {
r2(U . 'services/pppoe', 'e', Lang::T('Account Not Found')); r2(getUrl('services/pppoe'), 'e', Lang::T('Account Not Found'));
} }
break; break;
@ -602,7 +602,7 @@ switch ($action) {
} }
$d->delete(); $d->delete();
r2(U . 'services/pppoe', 's', Lang::T('Data Deleted Successfully')); r2(getUrl('services/pppoe'), 's', Lang::T('Data Deleted Successfully'));
} }
break; break;
@ -700,9 +700,9 @@ switch ($action) {
new Exception(Lang::T("Devices Not Found")); new Exception(Lang::T("Devices Not Found"));
} }
} }
r2(U . 'services/pppoe', 's', Lang::T('Data Created Successfully')); r2(getUrl('services/pppoe'), 's', Lang::T('Data Created Successfully'));
} else { } else {
r2(U . 'services/pppoe-add', 'e', $msg); r2(getUrl('services/pppoe-add'), 'e', $msg);
} }
break; break;
@ -801,9 +801,9 @@ switch ($action) {
new Exception(Lang::T("Devices Not Found")); new Exception(Lang::T("Devices Not Found"));
} }
} }
r2(U . 'services/pppoe', 's', Lang::T('Data Updated Successfully')); r2(getUrl('services/pppoe'), 's', Lang::T('Data Updated Successfully'));
} else { } else {
r2(U . 'services/pppoe-edit/' . $id, 'e', $msg); r2(getUrl('services/pppoe-edit/') . $id, 'e', $msg);
} }
break; break;
case 'balance': case 'balance':
@ -841,7 +841,7 @@ switch ($action) {
if ($d) { if ($d) {
run_hook('delete_balance'); #HOOK run_hook('delete_balance'); #HOOK
$d->delete(); $d->delete();
r2(U . 'services/balance', 's', Lang::T('Data Deleted Successfully')); r2(getUrl('services/balance'), 's', Lang::T('Data Deleted Successfully'));
} }
break; break;
case 'balance-edit-post': case 'balance-edit-post':
@ -877,9 +877,9 @@ switch ($action) {
$d->prepaid = 'yes'; $d->prepaid = 'yes';
$d->save(); $d->save();
r2(U . 'services/balance', 's', Lang::T('Data Updated Successfully')); r2(getUrl('services/balance'), 's', Lang::T('Data Updated Successfully'));
} else { } else {
r2(U . 'services/balance-edit/' . $id, 'e', $msg); r2(getUrl('services/balance-edit/') . $id, 'e', $msg);
} }
break; break;
case 'balance-add-post': case 'balance-add-post':
@ -914,9 +914,9 @@ switch ($action) {
$d->prepaid = 'yes'; $d->prepaid = 'yes';
$d->save(); $d->save();
r2(U . 'services/balance', 's', Lang::T('Data Created Successfully')); r2(getUrl('services/balance'), 's', Lang::T('Data Created Successfully'));
} else { } else {
r2(U . 'services/balance-add', 'e', $msg); r2(getUrl('services/balance-add'), 'e', $msg);
} }
break; break;
case 'vpn': case 'vpn':
@ -1073,7 +1073,7 @@ switch ($action) {
run_hook('view_edit_vpn'); #HOOK run_hook('view_edit_vpn'); #HOOK
$ui->display('vpn-edit.tpl'); $ui->display('vpn-edit.tpl');
} else { } else {
r2(U . 'services/vpn', 'e', Lang::T('Account Not Found')); r2(getUrl('services/vpn'), 'e', Lang::T('Account Not Found'));
} }
break; break;
@ -1095,7 +1095,7 @@ switch ($action) {
} }
$d->delete(); $d->delete();
r2(U . 'services/vpn', 's', Lang::T('Data Deleted Successfully')); r2(getUrl('services/vpn'), 's', Lang::T('Data Deleted Successfully'));
} }
break; break;
@ -1193,9 +1193,9 @@ switch ($action) {
new Exception(Lang::T("Devices Not Found")); new Exception(Lang::T("Devices Not Found"));
} }
} }
r2(U . 'services/vpn', 's', Lang::T('Data Created Successfully')); r2(getUrl('services/vpn'), 's', Lang::T('Data Created Successfully'));
} else { } else {
r2(U . 'services/vpn-add', 'e', $msg); r2(getUrl('services/vpn-add'), 'e', $msg);
} }
break; break;
@ -1294,9 +1294,9 @@ switch ($action) {
new Exception(Lang::T("Devices Not Found")); new Exception(Lang::T("Devices Not Found"));
} }
} }
r2(U . 'services/vpn', 's', Lang::T('Data Updated Successfully')); r2(getUrl('services/vpn'), 's', Lang::T('Data Updated Successfully'));
} else { } else {
r2(U . 'services/vpn-edit/' . $id, 'e', $msg); r2(getUrl('services/vpn-edit/') . $id, 'e', $msg);
} }
break; break;
default: default:

View File

@ -59,19 +59,19 @@ switch ($action) {
if (!empty(_get('testWa'))) { if (!empty(_get('testWa'))) {
$result = Message::sendWhatsapp(_get('testWa'), 'PHPNuxBill Test Whatsapp'); $result = Message::sendWhatsapp(_get('testWa'), 'PHPNuxBill Test Whatsapp');
r2(U . "settings/app", 's', 'Test Whatsapp has been send<br>Result: ' . $result); r2(getUrl('settings/app'), 's', 'Test Whatsapp has been send<br>Result: ' . $result);
} }
if (!empty(_get('testSms'))) { if (!empty(_get('testSms'))) {
$result = Message::sendSMS(_get('testSms'), 'PHPNuxBill Test SMS'); $result = Message::sendSMS(_get('testSms'), 'PHPNuxBill Test SMS');
r2(U . "settings/app", 's', 'Test SMS has been send<br>Result: ' . $result); r2(getUrl('settings/app'), 's', 'Test SMS has been send<br>Result: ' . $result);
} }
if (!empty(_get('testEmail'))) { if (!empty(_get('testEmail'))) {
Message::sendEmail(_get('testEmail'), 'PHPNuxBill Test Email', 'PHPNuxBill Test Email Body'); Message::sendEmail(_get('testEmail'), 'PHPNuxBill Test Email', 'PHPNuxBill Test Email Body');
r2(U . "settings/app", 's', 'Test Email has been send'); r2(getUrl('settings/app'), 's', 'Test Email has been send');
} }
if (!empty(_get('testTg'))) { if (!empty(_get('testTg'))) {
$result = Message::sendTelegram('PHPNuxBill Test Telegram'); $result = Message::sendTelegram('PHPNuxBill Test Telegram');
r2(U . "settings/app", 's', 'Test Telegram has been send<br>Result: ' . $result); r2(getUrl('settings/app'), 's', 'Test Telegram has been send<br>Result: ' . $result);
} }
$UPLOAD_URL_PATH = str_replace($root_path, '', $UPLOAD_PATH); $UPLOAD_URL_PATH = str_replace($root_path, '', $UPLOAD_PATH);
@ -174,12 +174,12 @@ switch ($action) {
} }
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'settings/app', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('settings/app'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$company = _post('CompanyName'); $company = _post('CompanyName');
$custom_tax_rate = filter_var(_post('custom_tax_rate'), FILTER_SANITIZE_SPECIAL_CHARS); $custom_tax_rate = filter_var(_post('custom_tax_rate'), FILTER_SANITIZE_SPECIAL_CHARS);
if (preg_match('/[^0-9.]/', $custom_tax_rate)) { if (preg_match('/[^0-9.]/', $custom_tax_rate)) {
r2(U . 'settings/app', 'e', 'Special characters are not allowed in tax rate'); r2(getUrl('settings/app'), 'e', 'Special characters are not allowed in tax rate');
die(); die();
} }
run_hook('save_settings'); #HOOK run_hook('save_settings'); #HOOK
@ -189,11 +189,11 @@ switch ($action) {
File::resizeCropImage($_FILES['logo']['tmp_name'], $UPLOAD_PATH . DIRECTORY_SEPARATOR . 'logo.png', 1078, 200, 100); File::resizeCropImage($_FILES['logo']['tmp_name'], $UPLOAD_PATH . DIRECTORY_SEPARATOR . 'logo.png', 1078, 200, 100);
if (file_exists($_FILES['logo']['tmp_name'])) unlink($_FILES['logo']['tmp_name']); if (file_exists($_FILES['logo']['tmp_name'])) unlink($_FILES['logo']['tmp_name']);
} else { } else {
r2(U . 'settings/app', 'e', 'PHP GD is not installed'); r2(getUrl('settings/app'), 'e', 'PHP GD is not installed');
} }
} }
if ($_POST['general'] && $company == '') { if ($_POST['general'] && $company == '') {
r2(U . 'settings/app', 'e', Lang::T('All field is required')); r2(getUrl('settings/app'), 'e', Lang::T('All field is required'));
} else { } else {
if ($radius_enable) { if ($radius_enable) {
try { try {
@ -229,7 +229,7 @@ switch ($action) {
} }
_log('[' . $admin['username'] . ']: ' . Lang::T('Settings Saved Successfully'), $admin['user_type'], $admin['id']); _log('[' . $admin['username'] . ']: ' . Lang::T('Settings Saved Successfully'), $admin['user_type'], $admin['id']);
r2(U . 'settings/app', 's', Lang::T('Settings Saved Successfully')); r2(getUrl('settings/app'), 's', Lang::T('Settings Saved Successfully'));
} }
break; break;
@ -242,20 +242,20 @@ switch ($action) {
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'settings/app', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('settings/app'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
if ($login_page_type == 'custom' && (empty($login_Page_template) || empty($login_page_title) || empty($login_page_description))) { if ($login_page_type == 'custom' && (empty($login_Page_template) || empty($login_page_title) || empty($login_page_description))) {
r2(U . 'settings/app', 'e', 'Please fill all required fields'); r2(getUrl('settings/app'), 'e', 'Please fill all required fields');
return; return;
} }
if (strlen($login_page_title) > 25) { if (strlen($login_page_title) > 25) {
r2(U . 'settings/app', 'e', 'Login page title must not exceed 25 characters'); r2(getUrl('settings/app'), 'e', 'Login page title must not exceed 25 characters');
return; return;
} }
if (strlen($login_page_description) > 100) { if (strlen($login_page_description) > 100) {
r2(U . 'settings/app', 'e', 'Login page description must not exceed 50 characters'); r2(getUrl('settings/app'), 'e', 'Login page description must not exceed 50 characters');
return; return;
} }
@ -278,7 +278,7 @@ switch ($action) {
$settings['login_page_favicon'] = basename($favicon_path); // Save dynamic file name $settings['login_page_favicon'] = basename($favicon_path); // Save dynamic file name
if (file_exists($_FILES['login_page_favicon']['tmp_name'])) unlink($_FILES['login_page_favicon']['tmp_name']); if (file_exists($_FILES['login_page_favicon']['tmp_name'])) unlink($_FILES['login_page_favicon']['tmp_name']);
} else { } else {
r2(U . 'settings/app', 'e', 'Favicon must be a JPG, JPEG, or PNG image.'); r2(getUrl('settings/app'), 'e', 'Favicon must be a JPG, JPEG, or PNG image.');
} }
} }
@ -291,7 +291,7 @@ switch ($action) {
$settings['login_page_wallpaper'] = basename($wallpaper_path); // Save dynamic file name $settings['login_page_wallpaper'] = basename($wallpaper_path); // Save dynamic file name
if (file_exists($_FILES['login_page_wallpaper']['tmp_name'])) unlink($_FILES['login_page_wallpaper']['tmp_name']); if (file_exists($_FILES['login_page_wallpaper']['tmp_name'])) unlink($_FILES['login_page_wallpaper']['tmp_name']);
} else { } else {
r2(U . 'settings/app', 'e', 'Wallpaper must be a JPG, JPEG, or PNG image.'); r2(getUrl('settings/app'), 'e', 'Wallpaper must be a JPG, JPEG, or PNG image.');
} }
} }
@ -304,7 +304,7 @@ switch ($action) {
$settings['login_page_logo'] = basename($logo_path); // Save dynamic file name $settings['login_page_logo'] = basename($logo_path); // Save dynamic file name
if (file_exists($_FILES['login_page_logo']['tmp_name'])) unlink($_FILES['login_page_logo']['tmp_name']); if (file_exists($_FILES['login_page_logo']['tmp_name'])) unlink($_FILES['login_page_logo']['tmp_name']);
} else { } else {
r2(U . 'settings/app', 'e', 'Logo must be a JPG, JPEG, or PNG image.'); r2(getUrl('settings/app'), 'e', 'Logo must be a JPG, JPEG, or PNG image.');
} }
} }
@ -322,7 +322,7 @@ switch ($action) {
} }
_log('[' . $admin['username'] . ']: ' . Lang::T('Login Page Settings Saved Successfully'), $admin['user_type'], $admin['id']); _log('[' . $admin['username'] . ']: ' . Lang::T('Login Page Settings Saved Successfully'), $admin['user_type'], $admin['id']);
r2(U . 'settings/app', 's', Lang::T('Login Page Settings Saved Successfully')); r2(getUrl('settings/app'), 's', Lang::T('Login Page Settings Saved Successfully'));
break; break;
case 'localisation': case 'localisation':
@ -360,7 +360,7 @@ switch ($action) {
} }
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'settings/app', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('settings/app'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$tzone = _post('tzone'); $tzone = _post('tzone');
$date_format = _post('date_format'); $date_format = _post('date_format');
@ -368,7 +368,7 @@ switch ($action) {
$lan = _post('lan'); $lan = _post('lan');
run_hook('save_localisation'); #HOOK run_hook('save_localisation'); #HOOK
if ($tzone == '' or $date_format == '' or $lan == '') { if ($tzone == '' or $date_format == '' or $lan == '') {
r2(U . 'settings/app', 'e', Lang::T('All field is required')); r2(getUrl('settings/app'), 'e', Lang::T('All field is required'));
} else { } else {
$d = ORM::for_table('tbl_appconfig')->where('setting', 'timezone')->find_one(); $d = ORM::for_table('tbl_appconfig')->where('setting', 'timezone')->find_one();
$d->value = $tzone; $d->value = $tzone;
@ -453,7 +453,7 @@ switch ($action) {
$d->value = $lan; $d->value = $lan;
$d->save(); $d->save();
_log('[' . $admin['username'] . ']: ' . 'Settings Saved Successfully', $admin['user_type'], $admin['id']); _log('[' . $admin['username'] . ']: ' . 'Settings Saved Successfully', $admin['user_type'], $admin['id']);
r2(U . 'settings/localisation', 's', 'Settings Saved Successfully'); r2(getUrl('settings/localisation'), 's', 'Settings Saved Successfully');
} }
break; break;
@ -568,7 +568,7 @@ switch ($action) {
$ui->assign('csrf_token', $csrf_token); $ui->assign('csrf_token', $csrf_token);
$ui->display('admin-view.tpl'); $ui->display('admin-view.tpl');
} else { } else {
r2(U . 'settings/users', 'e', Lang::T('Account Not Found')); r2(getUrl('settings/users'), 'e', Lang::T('Account Not Found'));
} }
break; break;
case 'users-edit': case 'users-edit':
@ -624,7 +624,7 @@ switch ($action) {
$ui->assign('csrf_token', $csrf_token); $ui->assign('csrf_token', $csrf_token);
$ui->display('admin-edit.tpl'); $ui->display('admin-edit.tpl');
} else { } else {
r2(U . 'settings/users', 'e', Lang::T('Account Not Found')); r2(getUrl('settings/users'), 'e', Lang::T('Account Not Found'));
} }
break; break;
@ -635,15 +635,15 @@ switch ($action) {
$id = $routes['2']; $id = $routes['2'];
if (($admin['id']) == $id) { if (($admin['id']) == $id) {
r2(U . 'settings/users', 'e', 'Sorry You can\'t delete yourself'); r2(getUrl('settings/users'), 'e', 'Sorry You can\'t delete yourself');
} }
$d = ORM::for_table('tbl_users')->find_one($id); $d = ORM::for_table('tbl_users')->find_one($id);
if ($d) { if ($d) {
run_hook('delete_admin'); #HOOK run_hook('delete_admin'); #HOOK
$d->delete(); $d->delete();
r2(U . 'settings/users', 's', Lang::T('User deleted Successfully')); r2(getUrl('settings/users'), 's', Lang::T('User deleted Successfully'));
} else { } else {
r2(U . 'settings/users', 'e', Lang::T('Account Not Found')); r2(getUrl('settings/users'), 'e', Lang::T('Account Not Found'));
} }
break; break;
@ -653,7 +653,7 @@ switch ($action) {
} }
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'settings/users-add', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('settings/users-add'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$username = _post('username'); $username = _post('username');
$fullname = _post('fullname'); $fullname = _post('fullname');
@ -712,16 +712,16 @@ switch ($action) {
} }
_log('[' . $admin['username'] . ']: ' . "Created $user_type <b>$username</b>", $admin['user_type'], $admin['id']); _log('[' . $admin['username'] . ']: ' . "Created $user_type <b>$username</b>", $admin['user_type'], $admin['id']);
r2(U . 'settings/users', 's', Lang::T('Account Created Successfully')); r2(getUrl('settings/users'), 's', Lang::T('Account Created Successfully'));
} else { } else {
r2(U . 'settings/users-add', 'e', $msg); r2(getUrl('settings/users-add'), 'e', $msg);
} }
break; break;
case 'users-edit-post': case 'users-edit-post':
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'settings/users-edit/', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('settings/users-edit/'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$username = _post('username'); $username = _post('username');
$fullname = _post('fullname'); $fullname = _post('fullname');
@ -824,7 +824,7 @@ switch ($action) {
} }
if (file_exists($_FILES['photo']['tmp_name'])) unlink($_FILES['photo']['tmp_name']); if (file_exists($_FILES['photo']['tmp_name'])) unlink($_FILES['photo']['tmp_name']);
} else { } else {
r2(U . 'settings/app', 'e', 'PHP GD is not installed'); r2(getUrl('settings/app'), 'e', 'PHP GD is not installed');
} }
} }
@ -858,9 +858,9 @@ switch ($action) {
$d->save(); $d->save();
_log('[' . $admin['username'] . ']: $username ' . Lang::T('User Updated Successfully'), $admin['user_type'], $admin['id']); _log('[' . $admin['username'] . ']: $username ' . Lang::T('User Updated Successfully'), $admin['user_type'], $admin['id']);
r2(U . 'settings/users-view/' . $id, 's', 'User Updated Successfully'); r2(getUrl('settings/users-view/') . $id, 's', 'User Updated Successfully');
} else { } else {
r2(U . 'settings/users-edit/' . $id, 'e', $msg); r2(getUrl('settings/users-edit/') . $id, 'e', $msg);
} }
break; break;
@ -875,7 +875,7 @@ switch ($action) {
$password = _post('password'); $password = _post('password');
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'settings/change-password', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('settings/change-password'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
if ($password != '') { if ($password != '') {
$d = ORM::for_table('tbl_users')->where('username', $admin['username'])->find_one(); $d = ORM::for_table('tbl_users')->where('username', $admin['username'])->find_one();
@ -886,10 +886,10 @@ switch ($action) {
$npass = _post('npass'); $npass = _post('npass');
$cnpass = _post('cnpass'); $cnpass = _post('cnpass');
if (!Validator::Length($npass, 15, 5)) { if (!Validator::Length($npass, 15, 5)) {
r2(U . 'settings/change-password', 'e', 'New Password must be 6 to 14 character'); r2(getUrl('settings/change-password'), 'e', 'New Password must be 6 to 14 character');
} }
if ($npass != $cnpass) { if ($npass != $cnpass) {
r2(U . 'settings/change-password', 'e', 'Both Password should be same'); r2(getUrl('settings/change-password'), 'e', 'Both Password should be same');
} }
$npass = Password::_crypt($npass); $npass = Password::_crypt($npass);
@ -899,15 +899,15 @@ switch ($action) {
_msglog('s', Lang::T('Password changed successfully, Please login again')); _msglog('s', Lang::T('Password changed successfully, Please login again'));
_log('[' . $admin['username'] . ']: Password changed successfully', $admin['user_type'], $admin['id']); _log('[' . $admin['username'] . ']: Password changed successfully', $admin['user_type'], $admin['id']);
r2(U . 'admin'); r2(getUrl('admin'));
} else { } else {
r2(U . 'settings/change-password', 'e', Lang::T('Incorrect Current Password')); r2(getUrl('settings/change-password'), 'e', Lang::T('Incorrect Current Password'));
} }
} else { } else {
r2(U . 'settings/change-password', 'e', Lang::T('Incorrect Current Password')); r2(getUrl('settings/change-password'), 'e', Lang::T('Incorrect Current Password'));
} }
} else { } else {
r2(U . 'settings/change-password', 'e', Lang::T('Incorrect Current Password')); r2(getUrl('settings/change-password'), 'e', Lang::T('Incorrect Current Password'));
} }
break; break;
@ -933,10 +933,10 @@ switch ($action) {
} }
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'settings/notifications', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('settings/notifications'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
file_put_contents($UPLOAD_PATH . "/notifications.json", json_encode($_POST)); file_put_contents($UPLOAD_PATH . "/notifications.json", json_encode($_POST));
r2(U . 'settings/notifications', 's', Lang::T('Settings Saved Successfully')); r2(getUrl('settings/notifications'), 's', Lang::T('Settings Saved Successfully'));
break; break;
case 'dbstatus': case 'dbstatus':
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
@ -1025,9 +1025,9 @@ switch ($action) {
} catch (Exception $e) { } catch (Exception $e) {
} }
if (file_exists($_FILES['json']['tmp_name'])) unlink($_FILES['json']['tmp_name']); if (file_exists($_FILES['json']['tmp_name'])) unlink($_FILES['json']['tmp_name']);
r2(U . "settings/dbstatus", 's', "Restored $suc success $fal failed"); r2(getUrl('settings/dbstatus'), 's', "Restored $suc success $fal failed");
} else { } else {
r2(U . "settings/dbstatus", 'e', 'Upload failed'); r2(getUrl('settings/dbstatus'), 'e', 'Upload failed');
} }
break; break;
case 'language': case 'language':
@ -1048,10 +1048,10 @@ switch ($action) {
case 'lang-post': case 'lang-post':
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'settings/language', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('settings/language'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
file_put_contents($lan_file, json_encode($_POST, JSON_PRETTY_PRINT)); file_put_contents($lan_file, json_encode($_POST, JSON_PRETTY_PRINT));
r2(U . 'settings/language', 's', Lang::T('Translation saved Successfully')); r2(getUrl('settings/language'), 's', Lang::T('Translation saved Successfully'));
break; break;
case 'maintenance': case 'maintenance':
@ -1063,7 +1063,7 @@ switch ($action) {
if (_post('save') == 'save') { if (_post('save') == 'save') {
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'settings/maintenance', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('settings/maintenance'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
$status = isset($_POST['maintenance_mode']) ? 1 : 0; // Checkbox returns 1 if checked, otherwise 0 $status = isset($_POST['maintenance_mode']) ? 1 : 0; // Checkbox returns 1 if checked, otherwise 0
$force_logout = isset($_POST['maintenance_mode_logout']) ? 1 : 0; // Checkbox returns 1 if checked, otherwise 0 $force_logout = isset($_POST['maintenance_mode_logout']) ? 1 : 0; // Checkbox returns 1 if checked, otherwise 0
@ -1088,7 +1088,7 @@ switch ($action) {
} }
} }
r2(U . "settings/maintenance", 's', Lang::T('Settings Saved Successfully')); r2(getUrl('settings/maintenance'), 's', Lang::T('Settings Saved Successfully'));
} }
$csrf_token = Csrf::generateAndStoreToken(); $csrf_token = Csrf::generateAndStoreToken();
$ui->assign('csrf_token', $csrf_token); $ui->assign('csrf_token', $csrf_token);
@ -1105,7 +1105,7 @@ switch ($action) {
if (_post('save') == 'save') { if (_post('save') == 'save') {
$csrf_token = _post('csrf_token'); $csrf_token = _post('csrf_token');
if (!Csrf::check($csrf_token)) { if (!Csrf::check($csrf_token)) {
r2(U . 'settings/miscellaneous', 'e', Lang::T('Invalid or Expired CSRF Token') . "."); r2(getUrl('settings/miscellaneous'), 'e', Lang::T('Invalid or Expired CSRF Token') . ".");
} }
foreach ($_POST as $key => $value) { foreach ($_POST as $key => $value) {
$d = ORM::for_table('tbl_appconfig')->where('setting', $key)->find_one(); $d = ORM::for_table('tbl_appconfig')->where('setting', $key)->find_one();
@ -1120,7 +1120,7 @@ switch ($action) {
} }
} }
r2(U . "settings/miscellaneous", 's', Lang::T('Settings Saved Successfully')); r2(getUrl('settings/miscellaneous'), 's', Lang::T('Settings Saved Successfully'));
} }
$csrf_token = Csrf::generateAndStoreToken(); $csrf_token = Csrf::generateAndStoreToken();
$ui->assign('csrf_token', $csrf_token); $ui->assign('csrf_token', $csrf_token);

View File

@ -30,12 +30,12 @@ switch ($action) {
$v1->used_date = date('Y-m-d H:i:s'); $v1->used_date = date('Y-m-d H:i:s');
$v1->user = $user['username']; $v1->user = $user['username'];
$v1->save(); $v1->save();
r2(U . "voucher/list-activated", 's', Lang::T('Activation Vouchers Successfully')); r2(getUrl('voucher/list-activated'), 's', Lang::T('Activation Vouchers Successfully'));
} else { } else {
r2(U . 'voucher/activation', 'e', "Failed to refill account"); r2(getUrl('voucher/activation'), 'e', "Failed to refill account");
} }
} else { } else {
r2(U . 'voucher/activation', 'e', Lang::T('Voucher Not Valid')); r2(getUrl('voucher/activation'), 'e', Lang::T('Voucher Not Valid'));
} }
break; break;
@ -66,7 +66,7 @@ switch ($action) {
Package::createInvoice($in); Package::createInvoice($in);
$ui->display('customer/invoice-customer.tpl'); $ui->display('customer/invoice-customer.tpl');
} else { } else {
r2(U . 'voucher/list-activated', 'e', Lang::T('Not Found')); r2(getUrl('voucher/list-activated'), 'e', Lang::T('Not Found'));
} }
break; break;
default: default: