From 1e43ac210a9aef50f0f4408bc48d78ebf2bd3ef7 Mon Sep 17 00:00:00 2001 From: iBNu Maksum Date: Fri, 31 Jan 2025 16:22:58 +0700 Subject: [PATCH] url using getUrl --- init.php | 17 +++-- system/autoload/Package.php | 4 +- system/autoload/Paginator.php | 8 +-- system/autoload/Text.php | 16 +++++ system/autoload/User.php | 4 +- system/boot.php | 10 ++- system/controllers/accounts.php | 74 +++++++++---------- system/controllers/admin.php | 2 +- system/controllers/autoload_user.php | 8 +-- system/controllers/bandwidth.php | 14 ++-- system/controllers/coupons.php | 18 ++--- system/controllers/customers.php | 50 ++++++------- system/controllers/customfield.php | 4 +- system/controllers/dashboard.php | 2 +- system/controllers/default.php | 6 +- system/controllers/forgot.php | 6 +- system/controllers/home.php | 54 +++++++------- system/controllers/login.php | 46 ++++++------ system/controllers/logs.php | 6 +- system/controllers/mail.php | 6 +- system/controllers/map.php | 2 +- system/controllers/message.php | 10 +-- system/controllers/order.php | 72 +++++++++---------- system/controllers/pages.php | 6 +- system/controllers/paymentgateway.php | 6 +- system/controllers/plan.php | 68 +++++++++--------- system/controllers/plugin.php | 2 +- system/controllers/pluginmanager.php | 44 ++++++------ system/controllers/pool.php | 40 +++++------ system/controllers/radius.php | 16 ++--- system/controllers/register.php | 8 +-- system/controllers/reports.php | 2 +- system/controllers/routers.php | 12 ++-- system/controllers/search_user.php | 2 +- system/controllers/services.php | 52 +++++++------- system/controllers/settings.php | 100 +++++++++++++------------- system/controllers/voucher.php | 8 +-- 37 files changed, 415 insertions(+), 390 deletions(-) diff --git a/init.php b/init.php index 97c03cd0..b6530a46 100644 --- a/init.php +++ b/init.php @@ -42,7 +42,7 @@ spl_autoload_register('_autoloader'); if (!file_exists($root_path . 'config.php')) { $root_path .= '..' . DIRECTORY_SEPARATOR; if (!file_exists($root_path . 'config.php')) { - r2('install'); + r2(getUrl('install')); } } @@ -196,7 +196,7 @@ function _auth($login = true) return true; } else { if ($login) { - r2(U . 'login'); + r2(getUrl('login')); } else { return false; } @@ -209,7 +209,7 @@ function _admin($login = true) return true; } else { if ($login) { - r2(U . 'login'); + r2(getUrl('login')); } else { return false; } @@ -261,6 +261,13 @@ function showResult($success, $message = '', $result = [], $meta = []) die(); } +/** + * make url canonical or standar + */ +function getUrl($url) +{ + Text::url($url); +} function generateUniqueNumericVouchers($totalVouchers, $length = 8) { @@ -333,10 +340,10 @@ function _alert($text, $type = 'success', $url = "home", $time = 3) if (!isset($ui)) return; if (strlen($url) > 4) { if (substr($url, 0, 4) != "http") { - $url = U . $url; + $url = getUrl($url); } } else { - $url = U . $url; + $url = getUrl($url); } $ui->assign('text', $text); $ui->assign('type', $type); diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 2d30465d..cc8d464b 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -74,10 +74,10 @@ class Package if (!$p['enabled']) { 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'])) { - 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')); } } diff --git a/system/autoload/Paginator.php b/system/autoload/Paginator.php index 3d8b9014..4b6dbc43 100644 --- a/system/autoload/Paginator.php +++ b/system/autoload/Paginator.php @@ -14,7 +14,7 @@ class Paginator $adjacents = "2"; $page = _get('p', 1); $page = (empty($page) ? 1 : $page); - $url = U . implode('/', $routes); + $url = getUrl(implode('/', $routes)); if (count($search) > 0) { $url .= '&' . http_build_query($search); } @@ -83,7 +83,7 @@ class Paginator { global $routes; global $_L; - $url = U . implode('/', $routes); + $url = getUrl(implode('/', $routes)); $query = urlencode($query); $adjacents = "2"; $page = (int)(empty(_get('p')) ? 1 : _get('p')); @@ -169,7 +169,7 @@ class Paginator { global $routes; global $_L; - $url = U . $routes['0'] . '/' . $routes['1'] . '/'; + $url = getUrl($routes['0'] . '/' . $routes['1'] . '/'); $adjacents = "2"; $page = (int)(!isset($routes['2']) ? 1 : $routes['2']); $pagination = ""; @@ -277,7 +277,7 @@ class Paginator { global $routes; global $_L; - $url = U . $routes['0'] . '/' . $routes['1'] . '/'; + $url = getUrl($routes['0'] . '/' . $routes['1'] . '/'); $adjacents = "2"; $page = (int)(!isset($routes['2']) ? 1 : $routes['2']); $pagination = ""; diff --git a/system/autoload/Text.php b/system/autoload/Text.php index 821e7aad..573690b7 100644 --- a/system/autoload/Text.php +++ b/system/autoload/Text.php @@ -109,4 +109,20 @@ class Text } 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; + } + } } diff --git a/system/autoload/User.php b/system/autoload/User.php index 3db62a66..2a3e3cfe 100644 --- a/system/autoload/User.php +++ b/system/autoload/User.php @@ -206,7 +206,7 @@ class User global $config; if ($config['maintenance_mode'] == true) { if ($config['maintenance_mode_logout'] == true) { - r2(U . 'logout', 'd', ''); + r2(getUrl('logout'), 'd', ''); } else { displayMaintenanceMessage(); } @@ -226,7 +226,7 @@ class User global $config; if ($config['maintenance_mode'] == true) { if ($config['maintenance_mode_logout'] == true) { - r2(U . 'logout', 'd', ''); + r2(getUrl('logout'), 'd', ''); } else { displayMaintenanceMessage(); } diff --git a/system/boot.php b/system/boot.php index 43ac9166..c887288e 100644 --- a/system/boot.php +++ b/system/boot.php @@ -96,7 +96,7 @@ try { foreach ($menu_registered as $menu) { if ($menu['admin'] && _admin(false)) { if (count($menu['auth']) == 0 || in_array($admin['user_type'], $menu['auth'])) { - $menus[$menu['position']] .= ''; + $menus[$menu['position']] .= ''; if (!empty($menu['icon'])) { $menus[$menu['position']] .= ''; } @@ -107,7 +107,7 @@ try { $menus[$menu['position']] .= '' . $menu['name'] . ''; } } else if (!$menu['admin'] && _auth(false)) { - $menus[$menu['position']] .= ''; + $menus[$menu['position']] .= ''; if (!empty($menu['icon'])) { $menus[$menu['position']] .= ''; } @@ -124,7 +124,11 @@ try { unset($menus, $menu_registered); include($sys_render); } 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) { Message::sendTelegram( diff --git a/system/controllers/accounts.php b/system/controllers/accounts.php index d21934d5..e75e2a21 100644 --- a/system/controllers/accounts.php +++ b/system/controllers/accounts.php @@ -27,7 +27,7 @@ switch ($action) { $password = _post('password'); $csrf_token = _post('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 if ($password != '') { @@ -36,10 +36,10 @@ switch ($action) { $cnpass = _post('cnpass'); if ($password == $d_pass) { 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) { - 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; $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']); _alert(Lang::T('Password changed successfully, Please login again'), 'success', "login"); } else { - r2(U . 'accounts/change-password', 'e', Lang::T('Incorrect Current Password')); + r2(getUrl('accounts/change-password'), 'e', Lang::T('Incorrect Current Password')); } } else { - r2(U . 'accounts/change-password', 'e', Lang::T('Incorrect Current Password')); + r2(getUrl('accounts/change-password'), 'e', Lang::T('Incorrect Current Password')); } break; @@ -81,7 +81,7 @@ switch ($action) { case 'edit-profile-post': $csrf_token = _post('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'); $address = _post('address'); @@ -142,7 +142,7 @@ switch ($action) { } if (file_exists($_FILES['photo']['tmp_name'])) unlink($_FILES['photo']['tmp_name']); } 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(); _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{ - r2(U . 'accounts/profile', 'e', $msg); + r2(getUrl('accounts/profile'), 'e', $msg); } break; @@ -177,7 +177,7 @@ switch ($action) { case 'phone-update-otp': $csrf_token = _post('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')); $username = $user['username']; @@ -185,16 +185,16 @@ switch ($action) { $_SESSION['new_phone'] = $phone; // Validate the phone number format 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'])) { - 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(); 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)) { mkdir($otpPath); @@ -205,7 +205,7 @@ switch ($action) { // expired 10 minutes 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 { $otp = rand(100000, 999999); file_put_contents($otpFile, $otp); @@ -220,7 +220,7 @@ switch ($action) { Message::sendWhatsapp($phone, $config['CompanyName'] . "\n\n" . Lang::T("Verification code") . "\n$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; @@ -228,7 +228,7 @@ switch ($action) { case 'phone-update-post': $csrf_token = _post('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')); $otp_code = _post('otp'); @@ -237,11 +237,11 @@ switch ($action) { // Validate the phone number format 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'])) { - 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"; @@ -249,7 +249,7 @@ switch ($action) { // Check if OTP file exists 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(); } @@ -257,21 +257,21 @@ switch ($action) { if (time() - filemtime($otpFile) > 1200) { unlink($otpFile); 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(); } else { $code = file_get_contents($otpFile); // Check if OTP code matches 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(); } // Check if the phone number matches the one that requested the OTP $savedPhone = file_get_contents($phoneFile); 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(); } @@ -284,7 +284,7 @@ switch ($action) { $user->phonenumber = Lang::phoneFormat($phone); $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; case 'email-update': @@ -296,7 +296,7 @@ switch ($action) { case 'email-update-otp': $csrf_token = _post('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')); $username = $user['username']; @@ -304,16 +304,16 @@ switch ($action) { $_SESSION['new_email'] = $email; // Validate the phone number format 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'])) { - 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(); 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)) { mkdir($otpPath); @@ -324,7 +324,7 @@ switch ($action) { // expired 10 minutes 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 { $otp = rand(100000, 999999); 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"; Message::sendEmail($email, Lang::T('Change Email Verification Code'), $body); //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; @@ -341,7 +341,7 @@ switch ($action) { case 'email-update-post': $csrf_token = _post('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')); $otp_code = _post('otp'); @@ -349,12 +349,12 @@ switch ($action) { $otpPath = $CACHE_PATH . '/email/'; // Validate the phone number format 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(); } 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"; @@ -362,7 +362,7 @@ switch ($action) { // Check if OTP file exists 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(); } @@ -370,21 +370,21 @@ switch ($action) { if (time() - filemtime($otpFile) > 1200) { unlink($otpFile); 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(); } else { $code = file_get_contents($otpFile); // Check if OTP code matches 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(); } // Check if the phone number matches the one that requested the OTP $savedEmail = file_get_contents($emailFile); 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(); } @@ -396,7 +396,7 @@ switch ($action) { $user->email = $email; $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; case 'language-update-post': diff --git a/system/controllers/admin.php b/system/controllers/admin.php index 03aa16c6..2d8ea84e 100644 --- a/system/controllers/admin.php +++ b/system/controllers/admin.php @@ -10,7 +10,7 @@ header("Expires: Tue, 01 Jan 2000 00:00:00 GMT"); header("Pragma: no-cache"); 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'])) { diff --git a/system/controllers/autoload_user.php b/system/controllers/autoload_user.php index 3da9b5e2..0b18eacf 100644 --- a/system/controllers/autoload_user.php +++ b/system/controllers/autoload_user.php @@ -25,10 +25,10 @@ switch ($action) { if (file_exists($dvc)) { require_once $dvc; if ((new $p['device'])->online_customer($user, $bill['routers'])) { - die('' . Lang::T('You are Online, Logout?') . ''); + die('' . Lang::T('You are Online, Logout?') . ''); } else { if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) { - die('' . Lang::T('Not Online, Login now?') . ''); + die('' . Lang::T('Not Online, Login now?') . ''); } else { die(Lang::T('-')); } @@ -58,7 +58,7 @@ switch ($action) { 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(); foreach ($inboxs as $inbox) { - echo '
  • ' . $inbox['subject'] . '
    ' . Lang::dateTimeFormat($inbox['date_created']) . '
  • '; + echo '
  • ' . $inbox['subject'] . '
    ' . Lang::dateTimeFormat($inbox['date_created']) . '
  • '; } die(); case 'language': @@ -69,7 +69,7 @@ switch ($action) { if (is_file('system/lan/' . $file) && !in_array($file, ['index.html', 'country.json', '.DS_Store'])) { $file = str_replace(".json", "", $file); if(!empty($file)){ - echo '
  • '; + echo '
  • '; if($select == $file){ echo ' '; } diff --git a/system/controllers/bandwidth.php b/system/controllers/bandwidth.php index ca7fe0ef..a482550c 100644 --- a/system/controllers/bandwidth.php +++ b/system/controllers/bandwidth.php @@ -13,7 +13,7 @@ $action = $routes['1']; $ui->assign('_admin', $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) { @@ -53,7 +53,7 @@ switch ($action) { $ui->assign('d', $d); $ui->display('bandwidth-edit.tpl'); } else { - r2(U . 'bandwidth/list', 'e', Lang::T('Account Not Found')); + r2(getUrl('bandwidth/list'), 'e', Lang::T('Account Not Found')); } break; @@ -66,7 +66,7 @@ switch ($action) { $d = ORM::for_table('tbl_bandwidth')->find_one($id); if ($d) { $d->delete(); - r2(U . 'bandwidth/list', 's', Lang::T('Data Deleted Successfully')); + r2(getUrl('bandwidth/list'), 's', Lang::T('Data Deleted Successfully')); } break; @@ -123,9 +123,9 @@ switch ($action) { $d->burst = $burst; $d->save(); - r2(U . 'bandwidth/list', 's', Lang::T('Data Created Successfully')); + r2(getUrl('bandwidth/list'), 's', Lang::T('Data Created Successfully')); } else { - r2(U . 'bandwidth/add', 'e', $msg); + r2(getUrl('bandwidth/add'), 'e', $msg); } break; @@ -179,9 +179,9 @@ switch ($action) { $d->burst = $burst; $d->save(); - r2(U . 'bandwidth/list', 's', Lang::T('Data Updated Successfully')); + r2(getUrl('bandwidth/list'), 's', Lang::T('Data Updated Successfully')); } else { - r2(U . 'bandwidth/edit/' . $id, 'e', $msg); + r2(getUrl('bandwidth/edit/') . $id, 'e', $msg); } break; diff --git a/system/controllers/coupons.php b/system/controllers/coupons.php index 78550832..f019f22f 100644 --- a/system/controllers/coupons.php +++ b/system/controllers/coupons.php @@ -79,14 +79,14 @@ switch ($action) { } if (!empty($error)) { - r2(U . 'coupons/add', 'e', implode('
    ', $error)); + r2(getUrl('coupons/add'), 'e', implode('
    ', $error)); exit; } //check if coupon code already exists $coupon = ORM::for_table('tbl_coupons')->where('code', $code)->find_one(); 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; } @@ -104,10 +104,10 @@ switch ($action) { $coupon->created_at = date('Y-m-d H:i:s'); try { $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) { _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; @@ -120,12 +120,12 @@ switch ($action) { $coupon_id = intval($routes['2']); if (empty($coupon_id)) { - r2(U . 'coupons', 'e', Lang::T('Invalid Coupon ID')); + r2(getUrl('coupons'), 'e', Lang::T('Invalid Coupon ID')); exit; } $coupon = ORM::for_table('tbl_coupons')->find_one($coupon_id); if (!$coupon) { - r2(U . 'coupons', 'e', Lang::T('Coupon Not Found')); + r2(getUrl('coupons'), 'e', Lang::T('Coupon Not Found')); exit; } $ui->assign('coupon', $coupon); @@ -189,7 +189,7 @@ switch ($action) { $error[] = Lang::T('Coupon end date is required'); } if (!empty($error)) { - r2(U . 'coupons/edit/' . $coupon_id, 'e', implode('
    ', $error)); + r2(getUrl('coupons/edit/') . $coupon_id, 'e', implode('
    ', $error)); exit; } $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'); try { $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) { _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; diff --git a/system/controllers/customers.php b/system/controllers/customers.php index 5f5c8fb0..a5fa8f53 100644 --- a/system/controllers/customers.php +++ b/system/controllers/customers.php @@ -27,7 +27,7 @@ switch ($action) { } $csrf_token = _req('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') @@ -168,7 +168,7 @@ switch ($action) { $plan_id = $routes['3']; $csrf_token = _req('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(); if ($b) { @@ -192,13 +192,13 @@ switch ($action) { list($bills, $add_cost) = User::getBills($id_customer); if ($using == 'balance' && $config['enable_balance'] == 'yes') { if (!$cust) { - r2(U . 'plan/recharge', 'e', Lang::T('Customer not found')); + r2(getUrl('plan/recharge'), 'e', Lang::T('Customer not found')); } 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)) { - r2(U . 'plan/recharge', 'e', Lang::T('insufficient balance')); + r2(getUrl('plan/recharge'), 'e', Lang::T('insufficient balance')); } $gateway = 'Recharge Balance'; } @@ -227,7 +227,7 @@ switch ($action) { $ui->assign('csrf_token', Csrf::generateAndStoreToken()); $ui->display('recharge-confirm.tpl'); } else { - r2(U . 'customers/view/' . $id_customer, 'e', 'Cannot find active plan'); + r2(getUrl('customers/view/') . $id_customer, 'e', 'Cannot find active plan'); } break; case 'deactivate': @@ -238,7 +238,7 @@ switch ($action) { $plan_id = $routes['3']; $csrf_token = _req('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(); if ($b) { @@ -261,16 +261,16 @@ switch ($action) { $b->save(); _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']); - 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; case 'sync': $id_customer = $routes['2']; $csrf_token = _req('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(); 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; case 'login': if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { @@ -306,7 +306,7 @@ switch ($action) { $id = $routes['2']; $csrf_token = _req('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); if ($customer) { @@ -366,7 +366,7 @@ switch ($action) { $ui->assign('csrf_token', Csrf::generateAndStoreToken()); $ui->display('customers-view.tpl'); } else { - r2(U . 'customers/list', 'e', Lang::T('Account Not Found')); + r2(getUrl('customers/list'), 'e', Lang::T('Account Not Found')); } break; case 'edit': @@ -405,7 +405,7 @@ switch ($action) { $ui->assign('csrf_token', Csrf::generateAndStoreToken()); $ui->display('customers-edit.tpl'); } else { - r2(U . 'customers/list', 'e', Lang::T('Account Not Found')); + r2(getUrl('customers/list'), 'e', Lang::T('Account Not Found')); } break; @@ -416,7 +416,7 @@ switch ($action) { $id = $routes['2']; $csrf_token = _req('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 $c = ORM::for_table('tbl_customers')->find_one($id); @@ -448,7 +448,7 @@ switch ($action) { $c->delete(); } catch (Exception $e) { } - r2(U . 'customers/list', 's', Lang::T('User deleted Successfully')); + r2(getUrl('customers/list'), 's', Lang::T('User deleted Successfully')); } break; @@ -456,7 +456,7 @@ switch ($action) { $csrf_token = _post('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'), ":+_.@-"); $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 { - r2(U . 'customers/add', 'e', $msg); + r2(getUrl('customers/add'), 'e', $msg); } break; @@ -585,7 +585,7 @@ switch ($action) { $id = _post('id'); $csrf_token = _post('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'), ":+_.@-"); $fullname = _post('fullname'); @@ -708,7 +708,7 @@ switch ($action) { } if (file_exists($_FILES['photo']['tmp_name'])) unlink($_FILES['photo']['tmp_name']); } else { - r2(U . 'settings/app', 'e', 'PHP GD is not installed'); + r2(getUrl('settings/app'), 'e', 'PHP GD is not installed'); } } if ($userDiff) { @@ -815,9 +815,9 @@ switch ($action) { $tur->save(); } } - r2(U . 'customers/view/' . $id, 's', 'User Updated Successfully'); + r2(getUrl('customers/view/') . $id, 's', 'User Updated Successfully'); } else { - r2(U . 'customers/edit/' . $id, 'e', $msg); + r2(getUrl('customers/edit/') . $id, 'e', $msg); } break; @@ -856,7 +856,7 @@ switch ($action) { if (_post('export', '') == 'csv') { $csrf_token = _post('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(); $h = false; diff --git a/system/controllers/customfield.php b/system/controllers/customfield.php index def4480f..d0463283 100644 --- a/system/controllers/customfield.php +++ b/system/controllers/customfield.php @@ -38,9 +38,9 @@ switch ($action) { }); } 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{ - r2(U . 'customfield', 'e', 'Failed to save custom fields!'); + r2(getUrl('customfield'), 'e', 'Failed to save custom fields!'); } default: $fields = []; diff --git a/system/controllers/dashboard.php b/system/controllers/dashboard.php index 9f1185b0..fb5a7ffc 100644 --- a/system/controllers/dashboard.php +++ b/system/controllers/dashboard.php @@ -17,7 +17,7 @@ if (isset($_GET['refresh'])) { unlink($CACHE_PATH . DIRECTORY_SEPARATOR . $file); } } - r2(U . 'dashboard', 's', 'Data Refreshed'); + r2(getUrl('dashboard'), 's', 'Data Refreshed'); } $reset_day = $config['reset_day']; diff --git a/system/controllers/default.php b/system/controllers/default.php index d32f8ce4..84c83049 100644 --- a/system/controllers/default.php +++ b/system/controllers/default.php @@ -5,9 +5,9 @@ **/ if(Admin::getID()){ - r2(U.'dashboard'); + r2(getUrl('dashboard')); }if(User::getID()){ - r2(U.'home'); + r2(getUrl('home')); }else{ - r2(U.'login'); + r2(getUrl('login')); } diff --git a/system/controllers/forgot.php b/system/controllers/forgot.php index 23d028c2..dd726165 100644 --- a/system/controllers/forgot.php +++ b/system/controllers/forgot.php @@ -82,16 +82,16 @@ if ($step == 1) { } setcookie('forgot_username', '', time() - 3600, '/'); } 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 (file_exists($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 { - 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) { $find = _post('find'); diff --git a/system/controllers/home.php b/system/controllers/home.php index 33825a13..65518415 100644 --- a/system/controllers/home.php +++ b/system/controllers/home.php @@ -23,18 +23,18 @@ if (_post('send') == 'balance') { } $target = ORM::for_table('tbl_customers')->where('username', _post('username'))->find_one(); if (!$target) { - r2(U . 'home', 'd', Lang::T('Username not found')); + r2(getUrl('home'), 'd', Lang::T('Username not found')); } $username = _post('username'); $balance = _post('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'])) { - 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']) { - 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)) { //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($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)); - r2(U . 'home', 's', Lang::T('Sending balance success')); + r2(getUrl('home'), 's', Lang::T('Sending balance success')); } } 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') { if ($user['status'] != 'Active') { @@ -90,10 +90,10 @@ if (_post('send') == 'balance') { foreach ($actives as $active) { $router = ORM::for_table('tbl_routers')->where('name', $active['routers'])->find_one(); 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(); $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'])) { @@ -136,7 +136,7 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) { _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); } if (!empty(App::getTokenValue(_get('stoken')))) { - r2(U . "voucher/invoice/"); + r2(getUrl('voucher/invoice/')); die(); } $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(); $router = $routers['id']; } - r2(U. "order/gateway/$router/$bill[plan_id]"); + r2(getUrl('order/gateway/$router/$bill[plan_id]')); } } else if (!empty(_get('extend'))) { if ($user['status'] != 'Active') { _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); } if (!$config['extend_expired']) { - r2(U . 'home', 'e', "cannot extend"); + r2(getUrl('home'), 'e', "cannot extend"); } if (!empty(App::getTokenValue(_get('stoken')))) { - r2(U . 'home', 'e', "You already extend"); + r2(getUrl('home'), 'e', "You already extend"); } $id = _get('extend'); $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 $last = file_get_contents($path); 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') { @@ -202,12 +202,12 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) { "\nLocation: " . $p['routers'] . "\nCustomer: " . $user['fullname'] . "\nNew Expired: " . Lang::dateAndTimeFormat($expiration, $tur['time'])); - r2(U . 'home', 's', "Extend until $expiration"); + r2(getUrl('home'), 's', "Extend until $expiration"); } else { - r2(U . 'home', 'e', "Plan is not expired"); + r2(getUrl('home'), 'e', "Plan is not expired"); } } 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'])) { $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(); _log('User ' . $bill['username'] . ' Deactivate ' . $bill['namebp'], 'Customer', $bill['customer_id']); 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 { - 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; if ($_GET['mikrotik'] == 'login') { (new $p['device'])->connect_customer($user, $_SESSION['nux-ip'], $_SESSION['nux-mac'], $bill['routers']); - r2(U . 'home', 's', Lang::T('Login Request successfully')); + r2(getUrl('home'), 's', Lang::T('Login Request successfully')); } else if ($_GET['mikrotik'] == 'logout') { (new $p['device'])->disconnect_customer($user, $bill['routers']); - r2(U . 'home', 's', Lang::T('Logout Request successfully')); + r2(getUrl('home'), 's', Lang::T('Logout Request successfully')); } } else { 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']); if ($_app_stage != 'demo') { 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']; ///get auth notification from mikrotik if ($getmsg == 'Connected') { $msg .= Lang::T($getmsg); - r2(U . 'home&logged=1', 's', $msg); + r2(getUrl('home&logged=1'), 's', $msg); } else if ($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']); if ($_app_stage != 'demo') { 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']; ///get auth notification from mikrotik if ($getmsg == 'Connected') { $msg .= Lang::T($getmsg); - r2(U . 'home&logged=1', 's', $msg); + r2(getUrl('home&logged=1'), 's', $msg); } else if ($getmsg) { $msg .= Lang::T($getmsg); - r2(U . 'home', 's', $msg); + r2(getUrl('home'), 's', $msg); } } } diff --git a/system/controllers/login.php b/system/controllers/login.php index 736e5b2a..ec6c9013 100644 --- a/system/controllers/login.php +++ b/system/controllers/login.php @@ -11,7 +11,7 @@ if ($maintenance_mode == true) { } if (User::getID()) { - r2(U . 'home'); + r2(getUrl('home')); } if (isset($routes['1'])) { @@ -27,7 +27,7 @@ switch ($do) { $csrf_token = _post('csrf_token'); if (!Csrf::check($csrf_token)) { _msglog('e', Lang::T('Invalid or Expired CSRF Token')); - r2(U . 'login'); + r2(getUrl('login')); } run_hook('customer_login'); #HOOK if ($username != '' and $password != '') { @@ -54,15 +54,15 @@ switch ($do) { } else { _msglog('e', Lang::T('Invalid Username or Password')); _log($username . ' ' . Lang::T('Failed Login'), 'User'); - r2(U . 'login'); + r2(getUrl('login')); } } else { _msglog('e', Lang::T('Invalid Username or Password')); - r2(U . 'login'); + r2(getUrl('login')); } } else { _msglog('e', Lang::T('Invalid Username or Password')); - r2(U . 'login'); + r2(getUrl('login')); } break; @@ -72,7 +72,7 @@ switch ($do) { $csrf_token = _post('csrf_token'); if (!Csrf::check($csrf_token)) { _msglog('e', Lang::T('Invalid or Expired CSRF Token')); - r2(U . 'login'); + r2(getUrl('login')); } $voucher = Text::alphanumeric(_post('voucher_only'), "-_.,"); $tur = ORM::for_table('tbl_user_recharges') @@ -103,7 +103,7 @@ switch ($do) { if (!empty($config['voucher_redirect'])) { r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login")); } else { - r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); + r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login")); } } else { new Exception(Lang::T("Devices Not Found")); @@ -112,7 +112,7 @@ switch ($do) { if (!empty($config['voucher_redirect'])) { _alert(Lang::T("Voucher activation success, now you can login"), 'danger', $config['voucher_redirect']); } 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 { _alert(Lang::T('Internet Plan Expired'), 'danger', "login"); @@ -148,7 +148,7 @@ switch ($do) { if (!empty($config['voucher_redirect'])) { r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login")); } else { - r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); + r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login")); } } else { new Exception(Lang::T("Devices Not Found")); @@ -157,7 +157,7 @@ switch ($do) { if (!empty($config['voucher_redirect'])) { _alert(Lang::T("Voucher activation success, now you can login"), 'danger', $config['voucher_redirect']); } 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 { _alert(Lang::T('Internet Plan Expired'), 'danger', "login"); @@ -190,11 +190,11 @@ switch ($do) { if ($d->save()) { $user = ORM::for_table('tbl_customers')->where('username', $username)->find_one($d->id()); if (!$user) { - r2(U . 'login', 'e', Lang::T('Voucher activation failed')); + r2(getUrl('login'), 'e', Lang::T('Voucher activation failed')); } } else { _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) { @@ -222,7 +222,7 @@ switch ($do) { if (!empty($config['voucher_redirect'])) { r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login")); } else { - r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); + r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login")); } } else { new Exception(Lang::T("Devices Not Found")); @@ -231,26 +231,26 @@ switch ($do) { if (!empty($config['voucher_redirect'])) { r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, you are connected to internet")); } 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) { if (!empty($config['voucher_redirect'])) { r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login")); } else { - r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); + r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login")); } } } if (!empty($config['voucher_redirect'])) { r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login")); } else { - r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); + r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login")); } } else { // if failed to recharge, restore old password $user->password = $oldPass; $user->save(); - r2(U . 'login', 'e', Lang::T("Failed to activate voucher")); + r2(getUrl('login'), 'e', Lang::T("Failed to activate voucher")); } } else { // used voucher @@ -269,7 +269,7 @@ switch ($do) { if (!empty($config['voucher_redirect'])) { r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login")); } else { - r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); + r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login")); } } else { new Exception(Lang::T("Devices Not Found")); @@ -278,30 +278,30 @@ switch ($do) { if (!empty($config['voucher_redirect'])) { r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, you are connected to internet")); } 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) { if (!empty($config['voucher_redirect'])) { r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login")); } else { - r2(U . "login", 's', Lang::T("Voucher activation success, now you can login")); + r2(getUrl('login'), 's', Lang::T("Voucher activation success, now you can login")); } } } else { if (!empty($config['voucher_redirect'])) { r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, you are connected to internet")); } 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 { // voucher used by other customer - r2(U . 'login', 'e', Lang::T('Voucher Not Valid')); + r2(getUrl('login'), 'e', Lang::T('Voucher Not Valid')); } } } else { _msglog('e', Lang::T('Invalid Username or Password')); - r2(U . 'login'); + r2(getUrl('login')); } } default: diff --git a/system/controllers/logs.php b/system/controllers/logs.php index 93b4c849..7a6a752c 100644 --- a/system/controllers/logs.php +++ b/system/controllers/logs.php @@ -85,7 +85,7 @@ switch ($action) { $keep = _post('keep'); if (!empty($keep)) { 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 != '') { $query = ORM::for_table('tbl_logs')->where_like('description', '%' . $q . '%')->order_by_desc('id'); @@ -104,7 +104,7 @@ switch ($action) { $keep = _post('keep'); if (!empty($keep)) { 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 != '') { $query = ORM::for_table('radpostauth', 'radius')->where_like('username', '%' . $q . '%')->order_by_desc('id'); @@ -121,5 +121,5 @@ switch ($action) { default: - r2(U . 'logs/list/', 's', ''); + r2(getUrl('logs/list/'), 's', ''); } diff --git a/system/controllers/mail.php b/system/controllers/mail.php index 32c41bbc..08a4a527 100644 --- a/system/controllers/mail.php +++ b/system/controllers/mail.php @@ -14,7 +14,7 @@ switch ($action) { case 'view': $mail = ORM::for_table('tbl_customers_inbox')->where('customer_id', $user['id'])->find_one($routes['2']); 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){ $mail->date_read = date('Y-m-d H:i:s'); @@ -34,9 +34,9 @@ switch ($action) { case 'delete': if($routes['2']){ 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{ - r2(U. 'home', 'e', Lang::T('Failed to Delete Message')); + r2(getUrl('home'), 'e', Lang::T('Failed to Delete Message')); } break; } diff --git a/system/controllers/map.php b/system/controllers/map.php index 9ef08270..28e24dc8 100644 --- a/system/controllers/map.php +++ b/system/controllers/map.php @@ -49,6 +49,6 @@ switch ($action) { break; default: - r2(U . 'map/customer', 'e', 'action not defined'); + r2(getUrl('map/customer'), 'e', 'action not defined'); break; } diff --git a/system/controllers/message.php b/system/controllers/message.php index c9c9f691..6733db2d 100644 --- a/system/controllers/message.php +++ b/system/controllers/message.php @@ -62,7 +62,7 @@ EOT; // Check if fields are empty 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 { // Get customer details from the database $c = ORM::for_table('tbl_customers')->find_one($id_customer); @@ -84,9 +84,9 @@ EOT; } 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 { - r2(U . 'message/send', 'e', Lang::T('Failed to send message')); + r2(getUrl('message/send'), 'e', Lang::T('Failed to send message')); } } break; @@ -114,7 +114,7 @@ EOT; if (_req('send') == 'now') { // Check if fields are empty 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 { // Get customer details from the database based on the selected group if ($group == 'all') { @@ -234,5 +234,5 @@ EOT; break; default: - r2(U . 'message/send_sms', 'e', 'action not defined'); + r2(getUrl('message/send_sms'), 'e', 'action not defined'); } diff --git a/system/controllers/order.php b/system/controllers/order.php index 68e95a10..702f56a4 100644 --- a/system/controllers/order.php +++ b/system/controllers/order.php @@ -34,7 +34,7 @@ switch ($action) { break; case 'balance': 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('_system_menu', 'balance'); @@ -44,7 +44,7 @@ switch ($action) { break; case 'package': 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('_system_menu', 'package'); @@ -144,12 +144,12 @@ switch ($action) { r_find_unpaid'); #HOOK if ($d) { 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 { - 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 { - 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; case 'view': @@ -160,15 +160,15 @@ switch ($action) { run_hook('customer_view_payment'); #HOOK // jika tidak ditemukan, berarti punya orang lain 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 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 (!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 include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $trx['gateway'] . '.php'; @@ -185,7 +185,7 @@ switch ($action) { ->find_one($trxid); } 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(); @@ -202,10 +202,10 @@ switch ($action) { break; case 'pay': 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']))) { - r2(U . "voucher/invoice/"); + r2(getUrl('voucher/invoice/')); die(); } if ($user['status'] != 'Active') { @@ -213,7 +213,7 @@ switch ($action) { } $plan = ORM::for_table('tbl_plans')->find_one($routes[3]); 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') { $router_name = 'radius'; @@ -247,21 +247,21 @@ switch ($action) { // if success, then get the balance Balance::min($user['id'], $total_cost); 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 { - 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'] . "\nRouter: " . $router_name . "\nPrice: " . $total_cost); } } 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; case 'send': 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') { _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); @@ -270,10 +270,10 @@ switch ($action) { $ui->assign('_system_menu', 'package'); $plan = ORM::for_table('tbl_plans')->find_one($routes['3']); 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']) { - r2(U . "home", 'e', 'Plan is not exists'); + r2(getUrl('home'), 'e', 'Plan is not exists'); } if ($plan['is_radius'] == '1') { $routes['2'] = 0; @@ -312,13 +312,13 @@ switch ($action) { } 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']) { - r2(U . 'home', 'd', Lang::T('insufficient balance')); + r2(getUrl('home'), 'd', Lang::T('insufficient balance')); } 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') ->where('username', _post('username')) @@ -326,7 +326,7 @@ switch ($action) { ->find_one(); if ($active && $active['plan_id'] != $plan['id']) { - r2(U . "order/package", 'e', Lang::T("Target has active plan, different with current plant.") . " [ $active[namebp] ]"); + r2(getUrl('order/package'), 'e', Lang::T("Target has active plan, different with current plant.") . " [ $active[namebp] ]"); } $result = Package::rechargeUser($target['id'], $router_name, $plan['id'], $user['username'], 'Balance'); if (!empty($result)) { @@ -371,7 +371,7 @@ switch ($action) { $d->trx_invoice = $result; $d->status = 2; $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 { $errorMessage = "Send Package with Balance Failed\n\n#u$user[username] #send \n" . $plan['name_plan'] . "\nRouter: " . $router_name . @@ -381,7 +381,7 @@ switch ($action) { $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); } } @@ -395,7 +395,7 @@ switch ($action) { $ui->assign('_title', Lang::T('Select Payment Gateway')); $ui->assign('_system_menu', 'package'); 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_rate_setting = isset($config['tax_rate']) ? $config['tax_rate'] : null; @@ -503,7 +503,7 @@ switch ($action) { if (count($pgs) == 0) { sendTelegram("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) { $ui->assign('pgs', $pgs); @@ -516,7 +516,7 @@ switch ($action) { $ui->assign('custom', '1'); $ui->assign('amount', _post('amount')); } 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 { sendTelegram("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': $gateway = _post('gateway'); $discount = _post('discount') ?: 0; if ($gateway == 'balance') { 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'])) { $gateway = $_SESSION['gateway']; @@ -548,7 +548,7 @@ switch ($action) { _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); } 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 include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $gateway . '.php'; @@ -560,7 +560,7 @@ switch ($action) { $amount = (float) $amount; 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') @@ -569,7 +569,7 @@ switch ($action) { ->find_one(); if ($d) { 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 { if ($gateway == $d['gateway']) { $id = $d['id']; @@ -606,7 +606,7 @@ switch ($action) { $router['name'] = 'balance'; } 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') ->where('username', $user['username']) @@ -614,7 +614,7 @@ switch ($action) { ->find_one(); if ($d) { 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 { if ($gateway == $d['gateway']) { $id = $d['id']; @@ -693,11 +693,11 @@ switch ($action) { break; } 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 { call_user_func($gateway . '_create_transaction', $d, $user); } break; default: - r2(U . "order/package/", 's', ''); + r2(getUrl('order/package/'), 's', ''); } diff --git a/system/controllers/pages.php b/system/controllers/pages.php index 0260238d..bf80ab79 100644 --- a/system/controllers/pages.php +++ b/system/controllers/pages.php @@ -26,7 +26,7 @@ if (strpos($action, "-reset") !== false) { } else { 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) { if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { _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); } } - r2(U . 'pages/' . $action, 's', Lang::T("Saving page success")); + r2(getUrl('pages/') . $action, 's', Lang::T("Saving page success")); } else { - r2(U . 'pages/' . $action, 'e', Lang::T("Failed to save page, make sure i can write to folder pages, chmod 664 pages/*.html")); + r2(getUrl('pages/') . $action, 'e', Lang::T("Failed to save page, make sure i can write to folder pages, chmod 664 pages/*.html")); } } else $ui->display('a404.tpl'); diff --git a/system/controllers/paymentgateway.php b/system/controllers/paymentgateway.php index 7183551f..a6ea1ff1 100644 --- a/system/controllers/paymentgateway.php +++ b/system/controllers/paymentgateway.php @@ -16,7 +16,7 @@ switch ($action) { if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $pg . '.php')) { 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': $pg = alphanumeric($routes[2]); @@ -61,7 +61,7 @@ switch ($action) { $d->value = $pgs; $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')) { @@ -81,7 +81,7 @@ switch ($action) { } } else { if (!empty($action)) { - r2(U . 'paymentgateway', 'w', Lang::T('Payment Gateway Not Found')); + r2(getUrl('paymentgateway'), 'w', Lang::T('Payment Gateway Not Found')); } else { $files = scandir($PAYMENTGATEWAY_PATH); foreach ($files as $file) { diff --git a/system/controllers/plan.php b/system/controllers/plan.php index 59112501..fbfaae81 100644 --- a/system/controllers/plan.php +++ b/system/controllers/plan.php @@ -66,7 +66,7 @@ switch ($action) { $log .= "PLAN NOT FOUND : $tur[username], $tur[namebp], $tur[type], $tur[routers]
    "; } } - r2(U . 'plan/list', 's', $log); + r2(getUrl('plan/list'), 's', $log); case 'recharge': if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Agent', 'Sales'])) { _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 (!$cust) { - r2(U . 'plan/recharge', 'e', Lang::T('Customer not found')); + r2(getUrl('plan/recharge'), 'e', Lang::T('Customer not found')); } 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) { - r2(U . 'plan/recharge', 'e', Lang::T('insufficient balance')); + r2(getUrl('plan/recharge'), 'e', Lang::T('insufficient balance')); } $gateway = 'Recharge Balance'; } @@ -160,7 +160,7 @@ switch ($action) { $ui->assign('plan', $plan); $ui->display('recharge-confirm.tpl'); } else { - r2(U . 'plan/recharge', 'e', $msg); + r2(getUrl('plan/recharge'), 'e', $msg); } break; @@ -217,13 +217,13 @@ switch ($action) { if ($using == 'balance' && $config['enable_balance'] == 'yes') { //$plan = ORM::for_table('tbl_plans')->find_one($planId); if (!$cust) { - r2(U . 'plan/recharge', 'e', Lang::T('Customer not found')); + r2(getUrl('plan/recharge'), 'e', Lang::T('Customer not found')); } 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) { - r2(U . 'plan/recharge', 'e', Lang::T('insufficient balance')); + r2(getUrl('plan/recharge'), 'e', Lang::T('insufficient balance')); } $gateway = 'Recharge Balance'; } @@ -242,10 +242,10 @@ switch ($action) { $ui->display('invoice.tpl'); _log('[' . $admin['username'] . ']: ' . 'Recharge ' . $cust['username'] . ' [' . $in['plan_name'] . '][' . Lang::moneyFormat($in['price']) . ']', $admin['user_type'], $admin['id']); } else { - r2(U . 'plan/recharge', 'e', "Failed to recharge account"); + r2(getUrl('plan/recharge'), 'e', "Failed to recharge account"); } } else { - r2(U . 'plan/recharge', 'e', $msg); + r2(getUrl('plan/recharge'), 'e', $msg); } break; @@ -257,9 +257,9 @@ switch ($action) { $c = ORM::for_table('tbl_customers')->where('username', $in['username'])->find_one(); if ($c) { 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); $ui->assign('_title', 'View Invoice'); @@ -314,7 +314,7 @@ switch ($action) { $ui->assign('_title', 'Edit Plan'); $ui->display('plan-edit.tpl'); } else { - r2(U . 'plan/list', 'e', Lang::T('Account Not Found')); + r2(getUrl('plan/list'), 'e', Lang::T('Account Not Found')); } break; @@ -339,7 +339,7 @@ switch ($action) { } $d->delete(); _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; @@ -405,9 +405,9 @@ switch ($action) { } $d->save(); _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 { - r2(U . 'plan/edit/' . $id, 'e', $msg); + r2(getUrl('plan/edit/') . $id, 'e', $msg); } break; @@ -544,7 +544,7 @@ switch ($action) { $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': $from_id = _post('from_id'); @@ -795,12 +795,12 @@ switch ($action) { } 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 { - r2(U . 'plan/add-voucher/' . $id, 'e', $msg); + r2(getUrl('plan/add-voucher/') . $id, 'e', $msg); } break; @@ -855,11 +855,11 @@ switch ($action) { $voucher = ORM::for_table('tbl_voucher') ->find_one($id); 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) { - 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']); if ($voucher && $plan) { @@ -893,7 +893,7 @@ switch ($action) { $ui->assign('whatsapp', urlencode("```$content```")); $ui->display('voucher-view.tpl'); } else { - r2(U . 'plan/voucher/', 'e', Lang::T('Voucher Not Found')); + r2(getUrl('plan/voucher/'), 'e', Lang::T('Voucher Not Found')); } break; case 'voucher-delete': @@ -905,7 +905,7 @@ switch ($action) { $d = ORM::for_table('tbl_voucher')->find_one($id); if ($d) { $d->delete(); - r2(U . 'plan/voucher', 's', Lang::T('Data Deleted Successfully')); + r2(getUrl('plan/voucher'), 's', Lang::T('Data Deleted Successfully')); } break; @@ -938,10 +938,10 @@ switch ($action) { Package::createInvoice($in); $ui->display('invoice.tpl'); } else { - r2(U . 'plan/refill', 'e', "Failed to refill account"); + r2(getUrl('plan/refill'), 'e', "Failed to refill account"); } } else { - r2(U . 'plan/refill', 'e', Lang::T('Voucher Not Valid')); + r2(getUrl('plan/refill'), 'e', Lang::T('Voucher Not Valid')); } break; case 'deposit': @@ -989,7 +989,7 @@ switch ($action) { } $ui->display('invoice.tpl'); } 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)) { $p = ORM::for_table('tbl_plans')->find_one($plan); @@ -1002,10 +1002,10 @@ switch ($action) { } $ui->display('invoice.tpl'); } else { - r2(U . 'plan/refill', 'e', "Failed to refill account"); + r2(getUrl('plan/refill'), 'e', "Failed to refill account"); } } else { - r2(U . 'plan/refill', 'e', "All field is required"); + r2(getUrl('plan/refill'), 'e', "All field is required"); } break; case 'extend': @@ -1013,7 +1013,7 @@ switch ($action) { $days = $routes[3]; $svoucher = $_GET['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); $status = $tur['status']; @@ -1045,19 +1045,19 @@ switch ($action) { $tur->status = "on"; $tur->save(); } else { - r2(U . 'plan', 's', "Plan not found"); + r2(getUrl('plan'), 's', "Plan not found"); } } 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'] . "\nLocation: " . $p['routers'] . "\nCustomer: " . $c['fullname'] . "\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']); - r2(U . 'plan', 's', "Extend until $expiration"); + r2(getUrl('plan'), 's', "Extend until $expiration"); } else { - r2(U . 'plan', 's', "Customer is not expired yet"); + r2(getUrl('plan'), 's', "Customer is not expired yet"); } break; default: diff --git a/system/controllers/plugin.php b/system/controllers/plugin.php index 900ab4a2..7ecd7521 100644 --- a/system/controllers/plugin.php +++ b/system/controllers/plugin.php @@ -7,5 +7,5 @@ if(function_exists($routes[1])){ call_user_func($routes[1]); }else{ - r2(U.'dashboard', 'e', 'Function not found'); + r2(getUrl('dashboard'), 'e', 'Function not found'); } \ No newline at end of file diff --git a/system/controllers/pluginmanager.php b/system/controllers/pluginmanager.php index b8634df9..94dd524e 100644 --- a/system/controllers/pluginmanager.php +++ b/system/controllers/pluginmanager.php @@ -25,7 +25,7 @@ if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) { $json = json_decode($txt, true); if (empty($json['plugins']) && empty($json['payment_gateway'])) { unlink($cache); - r2(U . 'pluginmanager'); + r2(getUrl('pluginmanager')); } } else { $data = Http::getData($plugin_repository); @@ -35,23 +35,23 @@ if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) { switch ($action) { case 'refresh': if (file_exists($cache)) unlink($cache); - r2(U . "pluginmanager", 's', 'Refresh success'); + r2(getUrl('pluginmanager'), 's', 'Refresh success'); break; case 'dlinstall': 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)) { - r2(U . "pluginmanager", 'e', 'Folder cache/ is not writable'); + r2(getUrl('pluginmanager'), 'e', 'Folder cache/ is not writable'); } 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)) { - 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')) { - 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; if (!file_exists($cache)) { @@ -97,7 +97,7 @@ switch ($action) { } //Cleaning File::deleteFolder($cache); - r2(U . "pluginmanager", 's', 'Installation success'); + r2(getUrl('pluginmanager'), 's', 'Installation success'); } else if (_post('gh_url', '') != '') { $ghUrl = _post('gh_url', ''); if (!empty($config['github_token']) && !empty($config['github_username'])) { @@ -155,17 +155,17 @@ switch ($action) { } } File::deleteFolder($cache); - r2(U . "pluginmanager", 's', 'Installation success'); + r2(getUrl('pluginmanager'), 's', 'Installation success'); } else { - r2(U . 'pluginmanager', 'e', 'Nothing Installed'); + r2(getUrl('pluginmanager'), 'e', 'Nothing Installed'); } break; case 'delete': 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)) { - r2(U . "pluginmanager", 'e', 'Folder plugin/ is not writable'); + r2(getUrl('pluginmanager'), 'e', 'Folder plugin/ is not writable'); } set_time_limit(-1); $tipe = $routes['2']; @@ -199,12 +199,12 @@ switch ($action) { $folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/'); } 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); File::deleteFolder($folder); unlink($file); - r2(U . "pluginmanager", 's', 'Plugin ' . $plugin . ' has been deleted'); + r2(getUrl('pluginmanager'), 's', 'Plugin ' . $plugin . ' has been deleted'); break; } } @@ -213,10 +213,10 @@ switch ($action) { break; case 'install': 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)) { - r2(U . "pluginmanager", 'e', 'Folder plugin/ is not writable'); + r2(getUrl('pluginmanager'), 'e', 'Folder plugin/ is not writable'); } set_time_limit(-1); $tipe = $routes['2']; @@ -250,12 +250,12 @@ switch ($action) { $folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/'); } 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::deleteFolder($folder); unlink($file); - r2(U . "pluginmanager", 's', 'Plugin ' . $plugin . ' has been installed'); + r2(getUrl('pluginmanager'), 's', 'Plugin ' . $plugin . ' has been installed'); break; } } @@ -287,12 +287,12 @@ switch ($action) { $folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/'); } 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::deleteFolder($folder); unlink($file); - r2(U . "paymentgateway", 's', 'Payment Gateway ' . $plugin . ' has been installed'); + r2(getUrl('paymentgateway'), 's', 'Payment Gateway ' . $plugin . ' has been installed'); break; } } @@ -324,12 +324,12 @@ switch ($action) { $folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/'); } 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::deleteFolder($folder); unlink($file); - r2(U . "settings/devices", 's', 'Device ' . $plugin . ' has been installed'); + r2(getUrl('settings/devices'), 's', 'Device ' . $plugin . ' has been installed'); break; } } diff --git a/system/controllers/pool.php b/system/controllers/pool.php index ba599f22..aec8c1bc 100644 --- a/system/controllers/pool.php +++ b/system/controllers/pool.php @@ -51,7 +51,7 @@ switch ($action) { run_hook('view_edit_pool'); #HOOK $ui->display('pool-edit.tpl'); } else { - r2(U . 'pool/list', 'e', Lang::T('Account Not Found')); + r2(getUrl('pool/list'), 'e', Lang::T('Account Not Found')); } break; @@ -65,7 +65,7 @@ switch ($action) { } $d->delete(); - r2(U . 'pool/list', 's', Lang::T('Data Deleted Successfully')); + r2(getUrl('pool/list'), 's', Lang::T('Data Deleted Successfully')); } break; @@ -78,7 +78,7 @@ switch ($action) { $log .= 'DONE: ' . $pool['pool_name'] . ': ' . $pool['range_ip'] . '
    '; } } - r2(U . 'pool/list', 's', $log); + r2(getUrl('pool/list'), 's', $log); break; case 'add-post': $name = _post('name'); @@ -108,9 +108,9 @@ switch ($action) { (new MikrotikPppoe())->add_pool($b); } $b->save(); - r2(U . 'pool/list', 's', Lang::T('Data Created Successfully')); + r2(getUrl('pool/list'), 's', Lang::T('Data Created Successfully')); } else { - r2(U . 'pool/add', 'e', $msg); + r2(getUrl('pool/add'), 'e', $msg); } break; @@ -143,11 +143,11 @@ switch ($action) { (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 { - r2(U . 'pool/edit/' . $id, 'e', $msg); + r2(getUrl('pool/edit/') . $id, 'e', $msg); } - + case 'port': $ui->assign('xfooter', ''); @@ -180,7 +180,7 @@ switch ($action) { run_hook('view_edit_port'); #HOOK $ui->display('port-edit.tpl'); } else { - r2(U . 'pool/port', 'e', Lang::T('Account Not Found')); + r2(getUrl('pool/port'), 'e', Lang::T('Account Not Found')); } break; @@ -191,7 +191,7 @@ switch ($action) { if ($d) { $d->delete(); - r2(U . 'pool/port', 's', Lang::T('Data Deleted Successfully')); + r2(getUrl('pool/port'), 's', Lang::T('Data Deleted Successfully')); } break; @@ -204,7 +204,7 @@ switch ($action) { $log .= 'DONE: ' . $pool['port_name'] . ': ' . $pool['range_port'] . '
    '; } } - r2(U . 'pool/list', 's', $log); + r2(getUrl('pool/list'), 's', $log); break; case 'add-port-post': $name = _post('name'); @@ -231,21 +231,21 @@ switch ($action) { $b->range_port = $port_range; $b->routers = $routers; $b->save(); - r2(U . 'pool/port', 's', Lang::T('Data Created Successfully')); + r2(getUrl('pool/port'), 's', Lang::T('Data Created Successfully')); } else { - r2(U . 'pool/add-port', 'e', $msg); + r2(getUrl('pool/add-port'), 'e', $msg); } break; case 'edit-port-post': - $name = _post('name'); + $name = _post('name'); $public_ip = _post('public_ip'); $range_port = _post('range_port'); $routers = _post('routers'); run_hook('edit_port'); #HOOK $msg = ''; - $msg = ''; + $msg = ''; if (Validator::Length($name, 30, 2) == false) { $msg .= 'Name should be between 3 to 30 characters' . '
    '; } @@ -261,20 +261,18 @@ switch ($action) { } if ($msg == '') { - $d->port_name = $name; + $d->port_name = $name; $d->public_ip = $public_ip; $d->range_port = $range_port; $d->routers = $routers; $d->save(); - - - r2(U . 'pool/port', 's', Lang::T('Data Updated Successfully')); + r2(getUrl('pool/port'), 's', Lang::T('Data Updated Successfully')); } else { - r2(U . 'pool/edit-port/' . $id, 'e', $msg); + r2(getUrl('pool/edit-port/') . $id, 'e', $msg); } break; default: - r2(U . 'pool/list/', 's', ''); + r2(getUrl('pool/list/'), 's', ''); } diff --git a/system/controllers/radius.php b/system/controllers/radius.php index 72b1e155..ca90e916 100644 --- a/system/controllers/radius.php +++ b/system/controllers/radius.php @@ -58,12 +58,12 @@ switch ($action) { if ($msg == '') { require_once $DEVICE_PATH . DIRECTORY_SEPARATOR . "Radius.php"; 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 { - r2(U . 'radius/nas-add/', 'e', "NAS Added Failed"); + r2(getUrl('radius/nas-add/'), 'e', "NAS Added Failed"); } } else { - r2(U . 'radius/nas-add', 'e', $msg); + r2(getUrl('radius/nas-add'), 'e', $msg); } break; case 'nas-edit': @@ -80,7 +80,7 @@ switch ($action) { $ui->assign('d', $d); $ui->display('radius-nas-edit.tpl'); } else { - r2(U . 'radius/list', 'e', Lang::T('Account Not Found')); + r2(getUrl('radius/list'), 'e', Lang::T('Account Not Found')); } break; @@ -115,12 +115,12 @@ switch ($action) { if ($msg == '') { require_once $DEVICE_PATH . DIRECTORY_SEPARATOR . "Radius.php"; 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 { - r2(U . 'radius/nas-add', 'e', 'NAS NOT Exists'); + r2(getUrl('radius/nas-add'), 'e', 'NAS NOT Exists'); } } else { - r2(U . 'radius/nas-add', 'e', $msg); + r2(getUrl('radius/nas-add'), 'e', $msg); } break; case 'nas-delete': @@ -129,7 +129,7 @@ switch ($action) { if ($d) { $d->delete(); } else { - r2(U . 'radius/nas-list', 'e', 'NAS Not found'); + r2(getUrl('radius/nas-list'), 'e', 'NAS Not found'); } default: $ui->assign('_system_menu', 'radius'); diff --git a/system/controllers/register.php b/system/controllers/register.php index ea699570..848d8d0d 100644 --- a/system/controllers/register.php +++ b/system/controllers/register.php @@ -57,7 +57,7 @@ switch ($do) { // Expire after 10 minutes if (file_exists($otpPath) && time() - filemtime($otpPath) > 1200) { unlink($otpPath); - r2(U . 'register', 's', 'Verification code expired'); + r2(getUrl('register'), 's', 'Verification code expired'); } else if (file_exists($otpPath)) { $code = file_get_contents($otpPath); if ($code != $otp_code) { @@ -75,7 +75,7 @@ switch ($do) { unlink($otpPath); } } 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') { 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 { $ui->assign('username', $username); $ui->assign('fullname', $fullname); @@ -159,7 +159,7 @@ switch ($do) { if (!empty($phone_number)) { $d = ORM::for_table('tbl_customers')->where('username', $phone_number)->find_one(); if ($d) { - r2(U . 'register', 's', Lang::T('Account already exists')); + r2(getUrl('register'), 's', Lang::T('Account already exists')); } if (!file_exists($otpPath)) { mkdir($otpPath); diff --git a/system/controllers/reports.php b/system/controllers/reports.php index a1c4e3ca..9f15bdcf 100644 --- a/system/controllers/reports.php +++ b/system/controllers/reports.php @@ -257,7 +257,7 @@ switch ($action) { $keep = _post('keep'); if (!empty($keep)) { 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 != '') { $query = ORM::for_table('tbl_transactions')->where_like('invoice', '%' . $q . '%')->order_by_desc('id'); diff --git a/system/controllers/routers.php b/system/controllers/routers.php index 23bbbfb7..4d121c52 100644 --- a/system/controllers/routers.php +++ b/system/controllers/routers.php @@ -55,7 +55,7 @@ switch ($action) { run_hook('view_router_edit'); #HOOK $ui->display('routers-edit.tpl'); } else { - r2(U . 'routers/list', 'e', Lang::T('Account Not Found')); + r2(getUrl('routers/list'), 'e', Lang::T('Account Not Found')); } break; @@ -65,7 +65,7 @@ switch ($action) { $d = ORM::for_table('tbl_routers')->find_one($id); if ($d) { $d->delete(); - r2(U . 'routers/list', 's', Lang::T('Data Deleted Successfully')); + r2(getUrl('routers/list'), 's', Lang::T('Data Deleted Successfully')); } break; @@ -109,9 +109,9 @@ switch ($action) { $d->enabled = $enabled; $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 { - r2(U . 'routers/add', 'e', $msg); + r2(getUrl('routers/add'), 'e', $msg); } break; @@ -197,9 +197,9 @@ switch ($action) { $p->set('routers', $name); $p->save(); } - r2(U . 'routers/list', 's', Lang::T('Data Updated Successfully')); + r2(getUrl('routers/list'), 's', Lang::T('Data Updated Successfully')); } else { - r2(U . 'routers/edit/' . $id, 'e', $msg); + r2(getUrl('routers/edit/') . $id, 'e', $msg); } break; diff --git a/system/controllers/search_user.php b/system/controllers/search_user.php index b3a04062..fcf229f5 100644 --- a/system/controllers/search_user.php +++ b/system/controllers/search_user.php @@ -2,7 +2,7 @@ $query = isset($_GET['query']) ? trim($_GET['query']) : ''; -if (!empty($query)) { +if (!empty($query)) { $results = ORM::for_table('tbl_customers') ->where_like('username', "%$query%") ->find_many(); diff --git a/system/controllers/services.php b/system/controllers/services.php index 40e546c8..8f054457 100644 --- a/system/controllers/services.php +++ b/system/controllers/services.php @@ -33,7 +33,7 @@ switch ($action) { } } } - r2(U . 'services/hotspot', 's', $log); + r2(getUrl('services/hotspot'), 's', $log); } else if ($routes['2'] == 'pppoe') { $plans = ORM::for_table('tbl_plans')->where('type', 'PPPOE')->find_many(); $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': $ui->assign('xfooter', ''); $name = _req('name'); @@ -193,7 +193,7 @@ switch ($action) { run_hook('view_edit_plan'); #HOOK $ui->display('hotspot-edit.tpl'); } else { - r2(U . 'services/hotspot', 'e', Lang::T('Account Not Found')); + r2(getUrl('services/hotspot'), 'e', Lang::T('Account Not Found')); } break; @@ -214,7 +214,7 @@ switch ($action) { } $d->delete(); - r2(U . 'services/hotspot', 's', Lang::T('Data Deleted Successfully')); + r2(getUrl('services/hotspot'), 's', Lang::T('Data Deleted Successfully')); } break; @@ -307,9 +307,9 @@ switch ($action) { 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 { - r2(U . 'services/add', 'e', $msg); + r2(getUrl('services/add'), 'e', $msg); } break; @@ -420,9 +420,9 @@ switch ($action) { 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 { - r2(U . 'services/edit/' . $id, 'e', $msg); + r2(getUrl('services/edit/') . $id, 'e', $msg); } break; @@ -580,7 +580,7 @@ switch ($action) { run_hook('view_edit_ppoe'); #HOOK $ui->display('pppoe-edit.tpl'); } else { - r2(U . 'services/pppoe', 'e', Lang::T('Account Not Found')); + r2(getUrl('services/pppoe'), 'e', Lang::T('Account Not Found')); } break; @@ -602,7 +602,7 @@ switch ($action) { } $d->delete(); - r2(U . 'services/pppoe', 's', Lang::T('Data Deleted Successfully')); + r2(getUrl('services/pppoe'), 's', Lang::T('Data Deleted Successfully')); } break; @@ -700,9 +700,9 @@ switch ($action) { 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 { - r2(U . 'services/pppoe-add', 'e', $msg); + r2(getUrl('services/pppoe-add'), 'e', $msg); } break; @@ -801,9 +801,9 @@ switch ($action) { 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 { - r2(U . 'services/pppoe-edit/' . $id, 'e', $msg); + r2(getUrl('services/pppoe-edit/') . $id, 'e', $msg); } break; case 'balance': @@ -841,7 +841,7 @@ switch ($action) { if ($d) { run_hook('delete_balance'); #HOOK $d->delete(); - r2(U . 'services/balance', 's', Lang::T('Data Deleted Successfully')); + r2(getUrl('services/balance'), 's', Lang::T('Data Deleted Successfully')); } break; case 'balance-edit-post': @@ -877,9 +877,9 @@ switch ($action) { $d->prepaid = 'yes'; $d->save(); - r2(U . 'services/balance', 's', Lang::T('Data Updated Successfully')); + r2(getUrl('services/balance'), 's', Lang::T('Data Updated Successfully')); } else { - r2(U . 'services/balance-edit/' . $id, 'e', $msg); + r2(getUrl('services/balance-edit/') . $id, 'e', $msg); } break; case 'balance-add-post': @@ -914,9 +914,9 @@ switch ($action) { $d->prepaid = 'yes'; $d->save(); - r2(U . 'services/balance', 's', Lang::T('Data Created Successfully')); + r2(getUrl('services/balance'), 's', Lang::T('Data Created Successfully')); } else { - r2(U . 'services/balance-add', 'e', $msg); + r2(getUrl('services/balance-add'), 'e', $msg); } break; case 'vpn': @@ -1073,7 +1073,7 @@ switch ($action) { run_hook('view_edit_vpn'); #HOOK $ui->display('vpn-edit.tpl'); } else { - r2(U . 'services/vpn', 'e', Lang::T('Account Not Found')); + r2(getUrl('services/vpn'), 'e', Lang::T('Account Not Found')); } break; @@ -1095,7 +1095,7 @@ switch ($action) { } $d->delete(); - r2(U . 'services/vpn', 's', Lang::T('Data Deleted Successfully')); + r2(getUrl('services/vpn'), 's', Lang::T('Data Deleted Successfully')); } break; @@ -1193,9 +1193,9 @@ switch ($action) { 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 { - r2(U . 'services/vpn-add', 'e', $msg); + r2(getUrl('services/vpn-add'), 'e', $msg); } break; @@ -1294,9 +1294,9 @@ switch ($action) { 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 { - r2(U . 'services/vpn-edit/' . $id, 'e', $msg); + r2(getUrl('services/vpn-edit/') . $id, 'e', $msg); } break; default: diff --git a/system/controllers/settings.php b/system/controllers/settings.php index 7aac403c..57725b40 100644 --- a/system/controllers/settings.php +++ b/system/controllers/settings.php @@ -59,19 +59,19 @@ switch ($action) { if (!empty(_get('testWa'))) { $result = Message::sendWhatsapp(_get('testWa'), 'PHPNuxBill Test Whatsapp'); - r2(U . "settings/app", 's', 'Test Whatsapp has been send
    Result: ' . $result); + r2(getUrl('settings/app'), 's', 'Test Whatsapp has been send
    Result: ' . $result); } if (!empty(_get('testSms'))) { $result = Message::sendSMS(_get('testSms'), 'PHPNuxBill Test SMS'); - r2(U . "settings/app", 's', 'Test SMS has been send
    Result: ' . $result); + r2(getUrl('settings/app'), 's', 'Test SMS has been send
    Result: ' . $result); } if (!empty(_get('testEmail'))) { 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'))) { $result = Message::sendTelegram('PHPNuxBill Test Telegram'); - r2(U . "settings/app", 's', 'Test Telegram has been send
    Result: ' . $result); + r2(getUrl('settings/app'), 's', 'Test Telegram has been send
    Result: ' . $result); } $UPLOAD_URL_PATH = str_replace($root_path, '', $UPLOAD_PATH); @@ -105,7 +105,7 @@ switch ($action) { } else { $favicon = $UPLOAD_URL_PATH . DIRECTORY_SEPARATOR . 'favicon.default.png'; } - + $ui->assign('login_logo', $login_logo); $ui->assign('wallpaper', $wallpaper); $ui->assign('favicon', $favicon); @@ -174,12 +174,12 @@ switch ($action) { } $csrf_token = _post('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'); $custom_tax_rate = filter_var(_post('custom_tax_rate'), FILTER_SANITIZE_SPECIAL_CHARS); 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(); } 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); if (file_exists($_FILES['logo']['tmp_name'])) unlink($_FILES['logo']['tmp_name']); } 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 == '') { - r2(U . 'settings/app', 'e', Lang::T('All field is required')); + r2(getUrl('settings/app'), 'e', Lang::T('All field is required')); } else { if ($radius_enable) { try { @@ -229,7 +229,7 @@ switch ($action) { } _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; @@ -242,20 +242,20 @@ switch ($action) { $csrf_token = _post('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))) { - r2(U . 'settings/app', 'e', 'Please fill all required fields'); + r2(getUrl('settings/app'), 'e', 'Please fill all required fields'); return; } 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; } 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; } @@ -278,7 +278,7 @@ switch ($action) { $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']); } 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 if (file_exists($_FILES['login_page_wallpaper']['tmp_name'])) unlink($_FILES['login_page_wallpaper']['tmp_name']); } 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 if (file_exists($_FILES['login_page_logo']['tmp_name'])) unlink($_FILES['login_page_logo']['tmp_name']); } 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']); - 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; case 'localisation': @@ -360,7 +360,7 @@ switch ($action) { } $csrf_token = _post('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'); $date_format = _post('date_format'); @@ -368,7 +368,7 @@ switch ($action) { $lan = _post('lan'); run_hook('save_localisation'); #HOOK 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 { $d = ORM::for_table('tbl_appconfig')->where('setting', 'timezone')->find_one(); $d->value = $tzone; @@ -453,7 +453,7 @@ switch ($action) { $d->value = $lan; $d->save(); _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; @@ -568,7 +568,7 @@ switch ($action) { $ui->assign('csrf_token', $csrf_token); $ui->display('admin-view.tpl'); } else { - r2(U . 'settings/users', 'e', Lang::T('Account Not Found')); + r2(getUrl('settings/users'), 'e', Lang::T('Account Not Found')); } break; case 'users-edit': @@ -624,7 +624,7 @@ switch ($action) { $ui->assign('csrf_token', $csrf_token); $ui->display('admin-edit.tpl'); } else { - r2(U . 'settings/users', 'e', Lang::T('Account Not Found')); + r2(getUrl('settings/users'), 'e', Lang::T('Account Not Found')); } break; @@ -635,15 +635,15 @@ switch ($action) { $id = $routes['2']; 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); if ($d) { run_hook('delete_admin'); #HOOK $d->delete(); - r2(U . 'settings/users', 's', Lang::T('User deleted Successfully')); + r2(getUrl('settings/users'), 's', Lang::T('User deleted Successfully')); } else { - r2(U . 'settings/users', 'e', Lang::T('Account Not Found')); + r2(getUrl('settings/users'), 'e', Lang::T('Account Not Found')); } break; @@ -653,7 +653,7 @@ switch ($action) { } $csrf_token = _post('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'); $fullname = _post('fullname'); @@ -712,16 +712,16 @@ switch ($action) { } _log('[' . $admin['username'] . ']: ' . "Created $user_type $username", $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 { - r2(U . 'settings/users-add', 'e', $msg); + r2(getUrl('settings/users-add'), 'e', $msg); } break; case 'users-edit-post': $csrf_token = _post('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'); $fullname = _post('fullname'); @@ -824,7 +824,7 @@ switch ($action) { } if (file_exists($_FILES['photo']['tmp_name'])) unlink($_FILES['photo']['tmp_name']); } 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(); _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 { - r2(U . 'settings/users-edit/' . $id, 'e', $msg); + r2(getUrl('settings/users-edit/') . $id, 'e', $msg); } break; @@ -875,7 +875,7 @@ switch ($action) { $password = _post('password'); $csrf_token = _post('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 != '') { $d = ORM::for_table('tbl_users')->where('username', $admin['username'])->find_one(); @@ -886,10 +886,10 @@ switch ($action) { $npass = _post('npass'); $cnpass = _post('cnpass'); 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) { - 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); @@ -899,15 +899,15 @@ switch ($action) { _msglog('s', Lang::T('Password changed successfully, Please login again')); _log('[' . $admin['username'] . ']: Password changed successfully', $admin['user_type'], $admin['id']); - r2(U . 'admin'); + r2(getUrl('admin')); } else { - r2(U . 'settings/change-password', 'e', Lang::T('Incorrect Current Password')); + r2(getUrl('settings/change-password'), 'e', Lang::T('Incorrect Current Password')); } } else { - r2(U . 'settings/change-password', 'e', Lang::T('Incorrect Current Password')); + r2(getUrl('settings/change-password'), 'e', Lang::T('Incorrect Current Password')); } } else { - r2(U . 'settings/change-password', 'e', Lang::T('Incorrect Current Password')); + r2(getUrl('settings/change-password'), 'e', Lang::T('Incorrect Current Password')); } break; @@ -933,10 +933,10 @@ switch ($action) { } $csrf_token = _post('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)); - r2(U . 'settings/notifications', 's', Lang::T('Settings Saved Successfully')); + r2(getUrl('settings/notifications'), 's', Lang::T('Settings Saved Successfully')); break; case 'dbstatus': if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { @@ -1025,9 +1025,9 @@ switch ($action) { } catch (Exception $e) { } 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 { - r2(U . "settings/dbstatus", 'e', 'Upload failed'); + r2(getUrl('settings/dbstatus'), 'e', 'Upload failed'); } break; case 'language': @@ -1048,10 +1048,10 @@ switch ($action) { case 'lang-post': $csrf_token = _post('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)); - r2(U . 'settings/language', 's', Lang::T('Translation saved Successfully')); + r2(getUrl('settings/language'), 's', Lang::T('Translation saved Successfully')); break; case 'maintenance': @@ -1063,7 +1063,7 @@ switch ($action) { if (_post('save') == 'save') { $csrf_token = _post('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 $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(); $ui->assign('csrf_token', $csrf_token); @@ -1105,7 +1105,7 @@ switch ($action) { if (_post('save') == 'save') { $csrf_token = _post('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) { $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(); $ui->assign('csrf_token', $csrf_token); diff --git a/system/controllers/voucher.php b/system/controllers/voucher.php index 1c7e0f4b..1bae3d16 100644 --- a/system/controllers/voucher.php +++ b/system/controllers/voucher.php @@ -30,12 +30,12 @@ switch ($action) { $v1->used_date = date('Y-m-d H:i:s'); $v1->user = $user['username']; $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 { - r2(U . 'voucher/activation', 'e', "Failed to refill account"); + r2(getUrl('voucher/activation'), 'e', "Failed to refill account"); } } else { - r2(U . 'voucher/activation', 'e', Lang::T('Voucher Not Valid')); + r2(getUrl('voucher/activation'), 'e', Lang::T('Voucher Not Valid')); } break; @@ -66,7 +66,7 @@ switch ($action) { Package::createInvoice($in); $ui->display('customer/invoice-customer.tpl'); } else { - r2(U . 'voucher/list-activated', 'e', Lang::T('Not Found')); + r2(getUrl('voucher/list-activated'), 'e', Lang::T('Not Found')); } break; default: