Path Configuration

This commit is contained in:
Ibnu Maksum 2024-02-26 14:38:04 +07:00
parent 617e628b04
commit d2fa9be8d1
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
18 changed files with 270 additions and 242 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
config.php config.php
.DS_Store .DS_Store
.vscode/ .vscode/
ui/ui/compiled
ui/compiled/*.php ui/compiled/*.php
ui/cache/*.php ui/cache/*.php
test.php test.php

View File

@ -45,18 +45,20 @@ if (!file_exists($root_path . 'config.php')) {
} }
} }
if (!file_exists($root_path . File::pathFixer('system/orm.php'))) { if (!file_exists($root_path . File::pathFixer('system/orm.php'))) {
die($root_path . "orm.php file not found"); die($root_path . "orm.php file not found");
} }
if (!file_exists($root_path . File::pathFixer('system/uploads/notifications.default.json'))) {
die($root_path . File::pathFixer("system/uploads/notifications.default.json file not found"));
}
$UPLOAD_PATH = $root_path . File::pathFixer('system/uploads'); $UPLOAD_PATH = $root_path . File::pathFixer('system/uploads');
$CACHE_PATH = $root_path . File::pathFixer('system/cache'); $CACHE_PATH = $root_path . File::pathFixer('system/cache');
$PAGES_PATH = $root_path . File::pathFixer('pages'); $PAGES_PATH = $root_path . File::pathFixer('pages');
$PLUGIN_PATH = $root_path . File::pathFixer('system/plugin');
$PAYMENTGATEWAY_PATH = $root_path . File::pathFixer('system/paymentgateway');
$UI_PATH = 'ui';
if (!file_exists($UPLOAD_PATH . File::pathFixer('/notifications.default.json'))) {
die($UPLOAD_PATH . File::pathFixer("/notifications.default.json file not found"));
}
require_once $root_path . 'config.php'; require_once $root_path . 'config.php';
require_once $root_path . File::pathFixer('system/orm.php'); require_once $root_path . File::pathFixer('system/orm.php');
@ -74,13 +76,13 @@ if ($_app_stage != 'Live') {
define('U', APP_URL . '/index.php?_route='); define('U', APP_URL . '/index.php?_route=');
// notification message // notification message
if (file_exists($root_path . File::pathFixer("system/uploads/notifications.json"))) { if (file_exists($root_path . $UPLOAD_PATH . DIRECTORY_SEPARATOR . "notifications.json")) {
$_notifmsg = json_decode(file_get_contents($root_path . File::pathFixer('system/uploads/notifications.json')), true); $_notifmsg = json_decode(file_get_contents($root_path . $UPLOAD_PATH . DIRECTORY_SEPARATOR . 'notifications.json'), true);
} }
$_notifmsg_default = json_decode(file_get_contents($root_path . File::pathFixer('system/uploads/notifications.default.json')), true); $_notifmsg_default = json_decode(file_get_contents($root_path . $UPLOAD_PATH . DIRECTORY_SEPARATOR . 'notifications.default.json'), true);
//register all plugin //register all plugin
foreach (glob(File::pathFixer($root_path . File::pathFixer("system/plugin/*.php"))) as $filename) { foreach (glob(File::pathFixer($PLUGIN_PATH . DIRECTORY_SEPARATOR . '*.php')) as $filename) {
try { try {
include $filename; include $filename;
} catch (Throwable $e) { } catch (Throwable $e) {

View File

@ -1,21 +1,24 @@
<?php <?php
/** /**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/) * PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux * by https://t.me/ibnux
**/ **/
Class Admin{ class Admin
{
public static function getID(){ public static function getID()
{
global $db_password; global $db_password;
if (isset($_SESSION['aid'])) { if (isset($_SESSION['aid'])) {
return $_SESSION['aid']; return $_SESSION['aid'];
} else if (isset($_COOKIE['aid'])) { } else if (isset($_COOKIE['aid'])) {
// id.time.sha1 // id.time.sha1
$tmp = explode('.', $_COOKIE['aid']); $tmp = explode('.', $_COOKIE['aid']);
if(sha1($tmp[0].$tmp[1].$db_password)==$tmp[2]){ if (sha1($tmp[0] . '.' . $tmp[1] . '.' . $db_password) == $tmp[2]) {
if($tmp[1] < 86400*7){ if (time() - $tmp[1] < 86400 * 7) {
$_SESSION['aid'] = $tmp[0]; $_SESSION['aid'] = $tmp[0];
return $tmp[0]; return $tmp[0];
} }
@ -24,7 +27,8 @@ Class Admin{
return 0; return 0;
} }
public static function setCookie($aid){ public static function setCookie($aid)
{
global $db_password; global $db_password;
if (isset($aid)) { if (isset($aid)) {
$time = time(); $time = time();
@ -32,13 +36,15 @@ Class Admin{
} }
} }
public static function removeCookie(){ public static function removeCookie()
{
if (isset($_COOKIE['aid'])) { if (isset($_COOKIE['aid'])) {
setcookie('aid', '', time() - 86400); setcookie('aid', '', time() - 86400);
} }
} }
public static function _info($id = 0){ public static function _info($id = 0)
{
if (empty($id) && $id == 0) { if (empty($id) && $id == 0) {
$id = Admin::getID(); $id = Admin::getID();
} }

View File

@ -10,13 +10,13 @@ class User
{ {
public static function getID(){ public static function getID(){
global $db_password; global $db_password;
if(isset($_SESSION['uid'])){ if(isset($_SESSION['uid']) && !empty($_SESSION['uid'])){
return $_SESSION['uid']; return $_SESSION['uid'];
}else if(isset($_COOKIE['uid'])){ }else if(isset($_COOKIE['uid'])){
// id.time.sha1 // id.time.sha1
$tmp = explode('.',$_COOKIE['uid']); $tmp = explode('.',$_COOKIE['uid']);
if(sha1($tmp[0].$tmp[1].$db_password)==$tmp[2]){ if(sha1($tmp[0].'.'.$tmp[1].'.'.$db_password)==$tmp[2]){
if($tmp[1] < 86400*30){ if(time()-$tmp[1] < 86400*30){
$_SESSION['uid'] = $tmp[0]; $_SESSION['uid'] = $tmp[0];
return $tmp[0]; return $tmp[0];
} }

View File

@ -9,11 +9,14 @@ try {
require_once 'init.php'; require_once 'init.php';
} catch (Throwable $e) { } catch (Throwable $e) {
$ui = new Smarty(); $ui = new Smarty();
$ui->setTemplateDir(['custom' => File::pathFixer('ui/ui_custom/'), 'default' => File::pathFixer('ui/ui/')]); $ui->setTemplateDir([
'custom' => File::pathFixer($UI_PATH . '/ui_custom/'),
'default' => File::pathFixer($UI_PATH . '/ui/')
]);
$ui->assign('_url', APP_URL . '/index.php?_route='); $ui->assign('_url', APP_URL . '/index.php?_route=');
$ui->setCompileDir(File::pathFixer('ui/compiled/')); $ui->setCompileDir(File::pathFixer($UI_PATH . '/compiled/'));
$ui->setConfigDir(File::pathFixer('ui/conf/')); $ui->setConfigDir(File::pathFixer($UI_PATH . '/conf/'));
$ui->setCacheDir(File::pathFixer('ui/cache/')); $ui->setCacheDir(File::pathFixer($UI_PATH . '/cache/'));
$ui->assign("error_title", "PHPNuxBill Crash"); $ui->assign("error_title", "PHPNuxBill Crash");
if (_auth()) { if (_auth()) {
$ui->assign("error_message", $e->getMessage() . '<br>'); $ui->assign("error_message", $e->getMessage() . '<br>');
@ -24,11 +27,14 @@ try {
die(); die();
} catch (Exception $e) { } catch (Exception $e) {
$ui = new Smarty(); $ui = new Smarty();
$ui->setTemplateDir(['custom' => File::pathFixer('ui/ui_custom/'), 'default' => File::pathFixer('ui/ui/')]); $ui->setTemplateDir([
'custom' => File::pathFixer($UI_PATH . '/ui_custom/'),
'default' => File::pathFixer($UI_PATH . '/ui/')
]);
$ui->assign('_url', APP_URL . '/index.php?_route='); $ui->assign('_url', APP_URL . '/index.php?_route=');
$ui->setCompileDir(File::pathFixer('ui/compiled/')); $ui->setCompileDir(File::pathFixer($UI_PATH . '/compiled/'));
$ui->setConfigDir(File::pathFixer('ui/conf/')); $ui->setConfigDir(File::pathFixer($UI_PATH . '/conf/'));
$ui->setCacheDir(File::pathFixer('ui/cache/')); $ui->setCacheDir(File::pathFixer($UI_PATH . '/cache/'));
$ui->assign("error_title", "PHPNuxBill Crash"); $ui->assign("error_title", "PHPNuxBill Crash");
if (_auth()) { if (_auth()) {
$ui->assign("error_message", $e->getMessage() . '<br>'); $ui->assign("error_message", $e->getMessage() . '<br>');
@ -48,24 +54,33 @@ function _notify($msg, $type = 'e')
$ui = new Smarty(); $ui = new Smarty();
$ui->assign('_kolaps', $_COOKIE['kolaps']); $ui->assign('_kolaps', $_COOKIE['kolaps']);
if (!empty($config['theme']) && $config['theme'] != 'default') { if (!empty($config['theme']) && $config['theme'] != 'default') {
$_theme = APP_URL . '/ui/themes/' . $config['theme']; $_theme = APP_URL . '/' . $UI_PATH . '/themes/' . $config['theme'];
$ui->setTemplateDir(['custom' => File::pathFixer('ui/ui_custom/'), 'theme' => File::pathFixer('ui/themes/' . $config['theme']), 'default' => File::pathFixer('ui/ui/')]); $ui->setTemplateDir([
'custom' => File::pathFixer($UI_PATH . '/ui_custom/'),
'theme' => File::pathFixer($UI_PATH . '/themes/' . $config['theme']),
'default' => File::pathFixer($UI_PATH . '/ui/')
]);
} else { } else {
$_theme = APP_URL . '/ui/ui'; $_theme = APP_URL . '/' . $UI_PATH . '/ui';
$ui->setTemplateDir(['custom' => File::pathFixer('ui/ui_custom/'), 'default' => File::pathFixer('ui/ui/')]); $ui->setTemplateDir([
'custom' => File::pathFixer($UI_PATH . '/ui_custom/'),
'default' => File::pathFixer($UI_PATH . '/ui/')
]);
} }
$ui->assign('_theme', $_theme); $ui->assign('_theme', $_theme);
$ui->addTemplateDir(File::pathFixer('system/paymentgateway/ui/'), 'pg'); $ui->addTemplateDir($PAYMENTGATEWAY_PATH . File::pathFixer('/ui/'), 'pg');
$ui->addTemplateDir(File::pathFixer('system/plugin/ui/'), 'plugin'); $ui->addTemplateDir($PLUGIN_PATH . File::pathFixer('/ui/'), 'plugin');
$ui->setCompileDir(File::pathFixer('ui/compiled/')); $ui->setCompileDir(File::pathFixer($UI_PATH . '/compiled/'));
$ui->setConfigDir(File::pathFixer('ui/conf/')); $ui->setConfigDir(File::pathFixer($UI_PATH . '/conf/'));
$ui->setCacheDir(File::pathFixer('ui/cache/')); $ui->setCacheDir(File::pathFixer($UI_PATH . '/cache/'));
$ui->assign('app_url', APP_URL); $ui->assign('app_url', APP_URL);
$ui->assign('_domain', str_replace('www.', '', parse_url(APP_URL, PHP_URL_HOST))); $ui->assign('_domain', str_replace('www.', '', parse_url(APP_URL, PHP_URL_HOST)));
$ui->assign('_url', APP_URL . '/index.php?_route='); $ui->assign('_url', APP_URL . '/index.php?_route=');
$ui->assign('_path', __DIR__); $ui->assign('_path', __DIR__);
$ui->assign('_c', $config); $ui->assign('_c', $config);
$ui->assign('_L', $_L); $ui->assign('UPLOAD_PATH', $UPLOAD_PATH);
$ui->assign('CACHE_PATH', $CACHE_PATH);
$ui->assign('PAGES_PATH', $PAGES_PATH);
$ui->assign('_system_menu', 'dashboard'); $ui->assign('_system_menu', 'dashboard');
function _msglog($type, $msg) function _msglog($type, $msg)

View File

@ -138,7 +138,7 @@ switch ($action) {
case 'phone-update-otp': case 'phone-update-otp':
$phone = _post('phone'); $phone = _post('phone');
$username = $user['username']; $username = $user['username'];
$otpPath = 'system/cache/sms/'; $otpPath = $CACHE_PATH . '/sms/';
// Validate the phone number format // Validate the phone number format
if (!preg_match('/^[0-9]{10,}$/', $phone)) { if (!preg_match('/^[0-9]{10,}$/', $phone)) {
@ -190,7 +190,7 @@ switch ($action) {
$phone = _post('phone'); $phone = _post('phone');
$otp_code = _post('otp'); $otp_code = _post('otp');
$username = $user['username']; $username = $user['username'];
$otpPath = 'system/cache/sms/'; $otpPath = $CACHE_PATH . '/sms/';
// Validate the phone number format // Validate the phone number format
if (!preg_match('/^[0-9]{10,}$/', $phone)) { if (!preg_match('/^[0-9]{10,}$/', $phone)) {

View File

@ -9,8 +9,8 @@
$action = $routes['1']; $action = $routes['1'];
if(file_exists('system/paymentgateway/'.$action.'.php')){ if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php')) {
include 'system/paymentgateway/'.$action.'.php'; include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php';
if (function_exists($action . '_payment_notification')) { if (function_exists($action . '_payment_notification')) {
run_hook('callback_payment_notification'); #HOOK run_hook('callback_payment_notification'); #HOOK
call_user_func($action . '_payment_notification'); call_user_func($action . '_payment_notification');

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/) * PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux * by https://t.me/ibnux
@ -12,7 +13,7 @@ $plugin_repository = 'https://hotspotbilling.github.io/Plugin-Repository/reposit
$action = $routes['1']; $action = $routes['1'];
$ui->assign('_admin', $admin); $ui->assign('_admin', $admin);
$cache = File::pathFixer('system/cache/codecanyon.json'); $cache = File::pathFixer($CACHE_PATH . '/codecanyon.json');
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard"); _alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
@ -24,14 +25,14 @@ if (empty($config['envato_token'])) {
switch ($action) { switch ($action) {
case 'install': case 'install':
if (!is_writeable(File::pathFixer('system/cache/'))) { if (!is_writeable(File::pathFixer($CACHE_PATH . '/'))) {
r2(U . "codecanyon", 'e', 'Folder system/cache/ is not writable'); r2(U . "codecanyon", 'e', 'Folder system/cache/ is not writable');
} }
if (!is_writeable(File::pathFixer('system/plugin/'))) { if (!is_writeable($PLUGIN_PATH)) {
r2(U . "codecanyon", 'e', 'Folder system/plugin/ is not writable'); r2(U . "codecanyon", 'e', 'Folder plugin/ is not writable');
} }
if (!is_writeable(File::pathFixer('system/paymentgateway/'))) { if (!is_writeable($PAYMENTGATEWAY_PATH)) {
r2(U . "codecanyon", 'e', 'Folder system/paymentgateway/ is not writable'); r2(U . "codecanyon", 'e', 'Folder paymentgateway/ is not writable');
} }
set_time_limit(-1); set_time_limit(-1);
$item_id = $routes['2']; $item_id = $routes['2'];
@ -41,7 +42,7 @@ switch ($action) {
if (!isset($json['download_url'])) { if (!isset($json['download_url'])) {
r2(U . 'codecanyon', 'e', 'Failed to get download url. ' . $json['description']); r2(U . 'codecanyon', 'e', 'Failed to get download url. ' . $json['description']);
} }
$file = File::pathFixer('system/cache/codecanyon/'); $file = File::pathFixer($CACHE_PATH . '/codecanyon/');
if (!file_exists($file)) { if (!file_exists($file)) {
mkdir($file); mkdir($file);
} }
@ -61,16 +62,16 @@ switch ($action) {
curl_close($ch); curl_close($ch);
fclose($fp); fclose($fp);
//extract //extract
$target = File::pathFixer('system/cache/codecanyon/' . $item_id . '/'); $target = File::pathFixer($CACHE_PATH . '/codecanyon/' . $item_id . '/');
$zip = new ZipArchive(); $zip = new ZipArchive();
$zip->open($file); $zip->open($file);
$zip->extractTo($target); $zip->extractTo($target);
$zip->close(); $zip->close();
//moving //moving
if (file_exists($target . 'plugin')) { if (file_exists($target . 'plugin')) {
File::copyFolder($target . 'plugin', File::pathFixer('system/plugin/')); File::copyFolder($target . 'plugin', $PLUGIN_PATH . DIRECTORY_SEPARATOR);
} else if (file_exists($target . 'paymentgateway')) { } else if (file_exists($target . 'paymentgateway')) {
File::copyFolder($target . 'paymentgateway', File::pathFixer('system/paymentgateway/')); File::copyFolder($target . 'paymentgateway', $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR);
} else if (file_exists($target . 'theme')) { } else if (file_exists($target . 'theme')) {
File::copyFolder($target . 'theme', File::pathFixer('ui/themes/')); File::copyFolder($target . 'theme', File::pathFixer('ui/themes/'));
} }

View File

@ -78,8 +78,8 @@ $ui->assign('log', $log);
if ($config['hide_vs'] != 'yes') { if ($config['hide_vs'] != 'yes') {
$cacheStocksfile = File::pathFixer('system/cache/VoucherStocks.temp'); $cacheStocksfile = $CACHE_PATH . File::pathFixer('/VoucherStocks.temp');
$cachePlanfile = File::pathFixer('system/cache/VoucherPlans.temp'); $cachePlanfile = $CACHE_PATH . File::pathFixer('/VoucherPlans.temp');
//Cache for 5 minutes //Cache for 5 minutes
if (file_exists($cacheStocksfile) && time() - filemtime($cacheStocksfile) < 600) { if (file_exists($cacheStocksfile) && time() - filemtime($cacheStocksfile) < 600) {
$stocks = json_decode(file_get_contents($cacheStocksfile), true); $stocks = json_decode(file_get_contents($cacheStocksfile), true);
@ -111,7 +111,7 @@ if($config['hide_vs'] != 'yes'){
} }
} }
$cacheMRfile = File::pathFixer('system/cache/monthlyRegistered.temp'); $cacheMRfile = File::pathFixer('/monthlyRegistered.temp');
//Cache for 1 hour //Cache for 1 hour
if (file_exists($cacheMRfile) && time() - filemtime($cacheMRfile) < 3600) { if (file_exists($cacheMRfile) && time() - filemtime($cacheMRfile) < 3600) {
$monthlyRegistered = json_decode(file_get_contents($cacheMRfile), true); $monthlyRegistered = json_decode(file_get_contents($cacheMRfile), true);
@ -134,7 +134,7 @@ if(file_exists($cacheMRfile) && time()- filemtime($cacheMRfile) < 3600){
file_put_contents($cacheMRfile, json_encode($monthlyRegistered)); file_put_contents($cacheMRfile, json_encode($monthlyRegistered));
} }
$cacheMSfile = File::pathFixer('system/cache/monthlySales.temp'); $cacheMSfile = $CACHE_PATH . File::pathFixer('/monthlySales.temp');
//Cache for 12 hours //Cache for 12 hours
if (file_exists($cacheMSfile) && time() - filemtime($cacheMSfile) < 43200) { if (file_exists($cacheMSfile) && time() - filemtime($cacheMSfile) < 43200) {
$monthlySales = json_decode(file_get_contents($cacheMSfile), true); $monthlySales = json_decode(file_get_contents($cacheMSfile), true);

View File

@ -62,10 +62,10 @@ switch ($action) {
$title = ' Reports [' . $mdate . ']'; $title = ' Reports [' . $mdate . ']';
$title = str_replace('-', ' ', $title); $title = str_replace('-', ' ', $title);
if(file_exists('system/uploads/logo.png')){ if (file_exists($UPLOAD_PATH . '/logo.png')) {
$logo = 'system/uploads/logo.png'; $logo = $UPLOAD_PATH . '/logo.png';
} else { } else {
$logo = 'system/uploads/logo.default.png'; $logo = $UPLOAD_PATH . '/logo.default.png';
} }
if ($x) { if ($x) {
@ -234,10 +234,10 @@ EOF;
$title = ' Reports [' . $mdate . ']'; $title = ' Reports [' . $mdate . ']';
$title = str_replace('-', ' ', $title); $title = str_replace('-', ' ', $title);
if(file_exists('system/uploads/logo.png')){ if (file_exists($UPLOAD_PATH . '/logo.png')) {
$logo = 'system/uploads/logo.png'; $logo = $UPLOAD_PATH . '/logo.png';
} else { } else {
$logo = 'system/uploads/logo.default.png'; $logo = $UPLOAD_PATH . '/logo.default.png';
} }
if ($x) { if ($x) {

View File

@ -108,11 +108,11 @@ switch ($action) {
r2(U . "order/buy/" . (($trx['routers_id'] == 0) ? $trx['routers'] : $trx['routers_id']) . '/' . $trx['plan_id'], 'w', Lang::T("Checking payment")); r2(U . "order/buy/" . (($trx['routers_id'] == 0) ? $trx['routers'] : $trx['routers_id']) . '/' . $trx['plan_id'], 'w', Lang::T("Checking payment"));
} }
if ($routes['3'] == 'check') { if ($routes['3'] == 'check') {
if (!file_exists('system/paymentgateway/' . $trx['gateway'] . '.php')) { if (!file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $trx['gateway'] . '.php')) {
r2(U . 'order/view/' . $trxid, 'e', Lang::T("No Payment Gateway Available")); r2(U . 'order/view/' . $trxid, 'e', Lang::T("No Payment Gateway Available"));
} }
run_hook('customer_check_payment_status'); #HOOK run_hook('customer_check_payment_status'); #HOOK
include 'system/paymentgateway/' . $trx['gateway'] . '.php'; include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $trx['gateway'] . '.php';
call_user_func($trx['gateway'] . '_validate_config'); call_user_func($trx['gateway'] . '_validate_config');
call_user_func($config['payment_gateway'] . '_get_status', $trx, $user); call_user_func($config['payment_gateway'] . '_get_status', $trx, $user);
} else if ($routes['3'] == 'cancel') { } else if ($routes['3'] == 'cancel') {
@ -273,11 +273,11 @@ switch ($action) {
if ($config['payment_gateway'] == 'none') { if ($config['payment_gateway'] == 'none') {
r2(U . 'home', 'e', Lang::T("No Payment Gateway Available")); r2(U . 'home', 'e', Lang::T("No Payment Gateway Available"));
} }
if (!file_exists('system/paymentgateway/' . $config['payment_gateway'] . '.php')) { if (!file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $config['payment_gateway'] . '.php')) {
r2(U . 'home', 'e', Lang::T("No Payment Gateway Available")); r2(U . 'home', 'e', Lang::T("No Payment Gateway Available"));
} }
run_hook('customer_buy_plan'); #HOOK run_hook('customer_buy_plan'); #HOOK
include 'system/paymentgateway/' . $config['payment_gateway'] . '.php'; include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $config['payment_gateway'] . '.php';
call_user_func($config['payment_gateway'] . '_validate_config'); call_user_func($config['payment_gateway'] . '_validate_config');
if ($routes['2'] == 'radius') { if ($routes['2'] == 'radius') {

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/) * PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux * by https://t.me/ibnux
@ -10,8 +11,8 @@ $ui->assign('_system_menu', 'paymentgateway');
$action = alphanumeric($routes['1']); $action = alphanumeric($routes['1']);
$ui->assign('_admin', $admin); $ui->assign('_admin', $admin);
if(file_exists('system/paymentgateway/'.$action.'.php')){ if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php')) {
include 'system/paymentgateway/'.$action.'.php'; include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (function_exists($action . '_save_config')) { if (function_exists($action . '_save_config')) {
call_user_func($action . '_save_config'); call_user_func($action . '_save_config');
@ -29,7 +30,7 @@ if(file_exists('system/paymentgateway/'.$action.'.php')){
if (!empty($action)) { if (!empty($action)) {
r2(U . 'paymentgateway', 'w', Lang::T('Payment Gateway Not Found')); r2(U . 'paymentgateway', 'w', Lang::T('Payment Gateway Not Found'));
} else { } else {
$files = scandir('system/paymentgateway/'); $files = scandir($PAYMENTGATEWAY_PATH);
foreach ($files as $file) { foreach ($files as $file) {
if (pathinfo($file, PATHINFO_EXTENSION) == 'php') { if (pathinfo($file, PATHINFO_EXTENSION) == 'php') {
$pgs[] = str_replace('.php', '', $file); $pgs[] = str_replace('.php', '', $file);

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/) * PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux * by https://t.me/ibnux
@ -18,7 +19,7 @@ if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard"); _alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
} }
$cache = File::pathFixer('system/cache/plugin_repository.json'); $cache = $CACHE_PATH . File::pathFixer('/plugin_repository.json');
if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) { if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) {
$txt = file_get_contents($cache); $txt = file_get_contents($cache);
$json = json_decode($txt, true); $json = json_decode($txt, true);
@ -35,16 +36,16 @@ if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) {
switch ($action) { switch ($action) {
case 'install': case 'install':
if(!is_writeable(File::pathFixer('system/cache/'))){ if (!is_writeable($CACHE_PATH)) {
r2(U . "pluginmanager", 'e', 'Folder system/cache/ is not writable'); r2(U . "pluginmanager", 'e', 'Folder cache/ is not writable');
} }
if(!is_writeable(File::pathFixer('system/plugin/'))){ if (!is_writeable($PLUGIN_PATH)) {
r2(U . "pluginmanager", 'e', 'Folder system/plugin/ is not writable'); r2(U . "pluginmanager", 'e', 'Folder plugin/ is not writable');
} }
set_time_limit(-1); set_time_limit(-1);
$tipe = $routes['2']; $tipe = $routes['2'];
$plugin = $routes['3']; $plugin = $routes['3'];
$file = File::pathFixer('system/cache/') . $plugin . '.zip'; $file = $CACHE_PATH . File::pathFixer('/') . $plugin . '.zip';
if (file_exists($file)) unlink($file); if (file_exists($file)) unlink($file);
if ($tipe == 'plugin') { if ($tipe == 'plugin') {
foreach ($json['plugins'] as $plg) { foreach ($json['plugins'] as $plg) {
@ -63,16 +64,16 @@ switch ($action) {
$zip = new ZipArchive(); $zip = new ZipArchive();
$zip->open($file); $zip->open($file);
$zip->extractTo(File::pathFixer('system/cache/')); $zip->extractTo($CACHE_PATH);
$zip->close(); $zip->close();
$folder = File::pathFixer('system/cache/' . $plugin.'-main/'); $folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-main/');
if (!file_exists($folder)) { if (!file_exists($folder)) {
$folder = File::pathFixer('system/cache/' . $plugin.'-master/'); $folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/');
} }
if (!file_exists($folder)) { if (!file_exists($folder)) {
r2(U . "pluginmanager", 'e', 'Extracted Folder is unknown'); r2(U . "pluginmanager", 'e', 'Extracted Folder is unknown');
} }
File::copyFolder($folder, File::pathFixer('system/plugin/'), ['README.md','LICENSE']); File::copyFolder($folder, $PLUGIN_PATH . DIRECTORY_SEPARATOR, ['README.md', 'LICENSE']);
File::deleteFolder($folder); File::deleteFolder($folder);
unlink($file); unlink($file);
r2(U . "pluginmanager", 's', 'Plugin ' . $plugin . ' has been installed'); r2(U . "pluginmanager", 's', 'Plugin ' . $plugin . ' has been installed');
@ -97,16 +98,16 @@ switch ($action) {
$zip = new ZipArchive(); $zip = new ZipArchive();
$zip->open($file); $zip->open($file);
$zip->extractTo(File::pathFixer('system/cache/')); $zip->extractTo($CACHE_PATH);
$zip->close(); $zip->close();
$folder = File::pathFixer('system/cache/' . $plugin.'-main/'); $folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-main/');
if (!file_exists($folder)) { if (!file_exists($folder)) {
$folder = File::pathFixer('system/cache/' . $plugin.'-master/'); $folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/');
} }
if (!file_exists($folder)) { if (!file_exists($folder)) {
r2(U . "pluginmanager", 'e', 'Extracted Folder is unknown'); r2(U . "pluginmanager", 'e', 'Extracted Folder is unknown');
} }
File::copyFolder($folder, File::pathFixer('system/paymentgateway/'), ['README.md','LICENSE']); File::copyFolder($folder, $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR, ['README.md', 'LICENSE']);
File::deleteFolder($folder); File::deleteFolder($folder);
unlink($file); unlink($file);
r2(U . "paymentgateway", 's', 'Payment Gateway ' . $plugin . ' has been installed'); r2(U . "paymentgateway", 's', 'Payment Gateway ' . $plugin . ' has been installed');

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/) * PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux * by https://t.me/ibnux
@ -10,7 +11,7 @@ if (isset($routes['1'])) {
$do = 'register-display'; $do = 'register-display';
} }
$otpPath = 'system/cache/sms/'; $otpPath = $CACHE_PATH . File::pathFixer('/sms/');
switch ($do) { switch ($do) {
case 'post': case 'post':

View File

@ -30,10 +30,10 @@ switch ($action) {
r2(U . "settings/app", 's', 'Test Telegram has been send<br>Result: ' . $result); r2(U . "settings/app", 's', 'Test Telegram has been send<br>Result: ' . $result);
} }
if (file_exists('system/uploads/logo.png')) { if (file_exists($UPLOAD_PATH . DIRECTORY_SEPARATOR . 'logo.png')) {
$logo = 'system/uploads/logo.png?' . time(); $logo = $UPLOAD_PATH . DIRECTORY_SEPARATOR . 'logo.png?' . time();
} else { } else {
$logo = 'system/uploads/logo.default.png'; $logo = $UPLOAD_PATH . DIRECTORY_SEPARATOR . 'logo.default.png';
} }
$ui->assign('logo', $logo); $ui->assign('logo', $logo);
if ($_c['radius_enable'] && empty($_c['radius_client'])) { if ($_c['radius_enable'] && empty($_c['radius_client'])) {
@ -92,8 +92,8 @@ switch ($action) {
if (!empty($_FILES['logo']['name'])) { if (!empty($_FILES['logo']['name'])) {
if (function_exists('imagecreatetruecolor')) { if (function_exists('imagecreatetruecolor')) {
if (file_exists('system/uploads/logo.png')) unlink('system/uploads/logo.png'); if (file_exists($UPLOAD_PATH . DIRECTORY_SEPARATOR . 'logo.png')) unlink($UPLOAD_PATH . DIRECTORY_SEPARATOR . 'logo.png');
File::resizeCropImage($_FILES['logo']['tmp_name'], 'system/uploads/logo.png', 1078, 200, 100); File::resizeCropImage($_FILES['logo']['tmp_name'], $UPLOAD_PATH . DIRECTORY_SEPARATOR . 'logo.png', 1078, 200, 100);
if (file_exists($_FILES['logo']['tmp_name'])) unlink($_FILES['logo']['tmp_name']); if (file_exists($_FILES['logo']['tmp_name'])) unlink($_FILES['logo']['tmp_name']);
} else { } else {
r2(U . 'settings/app', 'e', 'PHP GD is not installed'); r2(U . 'settings/app', 'e', 'PHP GD is not installed');
@ -668,19 +668,19 @@ switch ($action) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard"); _alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
} }
run_hook('view_notifications'); #HOOK run_hook('view_notifications'); #HOOK
if (file_exists("system/uploads/notifications.json")) { if (file_exists($UPLOAD_PATH . DIRECTORY_SEPARATOR . "notifications.json")) {
$ui->assign('_json', json_decode(file_get_contents('system/uploads/notifications.json'), true)); $ui->assign('_json', json_decode(file_get_contents($UPLOAD_PATH . DIRECTORY_SEPARATOR . 'notifications.json'), true));
} else { } else {
$ui->assign('_json', json_decode(file_get_contents('system/uploads/notifications.default.json'), true)); $ui->assign('_json', json_decode(file_get_contents($UPLOAD_PATH . DIRECTORY_SEPARATOR . 'notifications.default.json'), true));
} }
$ui->assign('_default', json_decode(file_get_contents('system/uploads/notifications.default.json'), true)); $ui->assign('_default', json_decode(file_get_contents($UPLOAD_PATH . DIRECTORY_SEPARATOR . 'notifications.default.json'), true));
$ui->display('app-notifications.tpl'); $ui->display('app-notifications.tpl');
break; break;
case 'notifications-post': case 'notifications-post':
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard"); _alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
} }
file_put_contents("system/uploads/notifications.json", json_encode($_POST)); file_put_contents($UPLOAD_PATH . "/notifications.json", json_encode($_POST));
r2(U . 'settings/notifications', 's', Lang::T('Settings Saved Successfully')); r2(U . 'settings/notifications', 's', Lang::T('Settings Saved Successfully'));
break; break;
case 'dbstatus': case 'dbstatus':

View File

@ -6,7 +6,7 @@
<div class="box-body box-profile"> <div class="box-body box-profile">
<img class="profile-user-img img-responsive img-circle" <img class="profile-user-img img-responsive img-circle"
src="https://robohash.org/{$d['id']}?set=set3&size=100x100&bgset=bg1" src="https://robohash.org/{$d['id']}?set=set3&size=100x100&bgset=bg1"
onerror="this.src='system/uploads/user.default.jpg'" alt="avatar"> onerror="this.src='{$UPLOAD_PATH}/user.default.jpg'" alt="avatar">
<h3 class="profile-username text-center">{$d['fullname']}</h3> <h3 class="profile-username text-center">{$d['fullname']}</h3>

View File

@ -81,14 +81,14 @@
<li class="dropdown user user-menu"> <li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="https://robohash.org/{$_admin['id']}?set=set3&size=100x100&bgset=bg1" <img src="https://robohash.org/{$_admin['id']}?set=set3&size=100x100&bgset=bg1"
onerror="this.src='system/uploads/admin.default.png'" class="user-image" onerror="this.src='{$UPLOAD_PATH}/admin.default.png'" class="user-image"
alt="Avatar"> alt="Avatar">
<span class="hidden-xs">{$_admin['fullname']}</span> <span class="hidden-xs">{$_admin['fullname']}</span>
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li class="user-header"> <li class="user-header">
<img src="https://robohash.org/{$_admin['id']}?set=set3&size=100x100&bgset=bg1" <img src="https://robohash.org/{$_admin['id']}?set=set3&size=100x100&bgset=bg1"
onerror="this.src='system/uploads/admin.default.png'" class="img-circle" onerror="this.src='{$UPLOAD_PATH}/admin.default.png'" class="img-circle"
alt="Avatar"> alt="Avatar">
<p> <p>
{$_admin['fullname']} {$_admin['fullname']}

View File

@ -66,13 +66,13 @@
<span>{$_user['fullname']}</span> <span>{$_user['fullname']}</span>
{/if} {/if}
<img src="https://robohash.org/{$_user['id']}?set=set3&size=100x100&bgset=bg1" <img src="https://robohash.org/{$_user['id']}?set=set3&size=100x100&bgset=bg1"
onerror="this.src='system/uploads/user.default.jpg'" class="user-image" onerror="this.src='{$UPLOAD_PATH}/user.default.jpg'" class="user-image"
alt="User Image"> alt="User Image">
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li class="user-header"> <li class="user-header">
<img src="https://robohash.org/{$_user['id']}?set=set3&size=100x100&bgset=bg1" <img src="https://robohash.org/{$_user['id']}?set=set3&size=100x100&bgset=bg1"
onerror="this.src='system/uploads/user.default.jpg'" class="img-circle" onerror="this.src='{$UPLOAD_PATH}/user.default.jpg'" class="img-circle"
alt="User Image"> alt="User Image">
<p> <p>