diff --git a/system/autoload/Mikrotik.php b/system/autoload/Mikrotik.php index 99ffc0cf..76e90823 100644 --- a/system/autoload/Mikrotik.php +++ b/system/autoload/Mikrotik.php @@ -72,7 +72,7 @@ class Mikrotik public static function setHotspotPlan($client, $name, $sharedusers, $rate) { $printRequest = new RouterOS\Request( - '/ip hotspot user profile print .proplist=name', + '/ip hotspot user profile print .proplist=.id', RouterOS\Query::where('name', $name) ); $profileID = $client->sendSync($printRequest)->getProperty('.id'); @@ -92,7 +92,7 @@ class Mikrotik public static function setHotspotExpiredPlan($client, $name, $pool) { $printRequest = new RouterOS\Request( - '/ip hotspot user profile print .proplist=name', + '/ip hotspot user profile print .proplist=.id', RouterOS\Query::where('name', $name) ); $profileID = $client->sendSync($printRequest)->getProperty('.id'); @@ -120,7 +120,7 @@ class Mikrotik public static function removeHotspotPlan($client, $name) { $printRequest = new RouterOS\Request( - '/ip hotspot user profile print .proplist=name', + '/ip hotspot user profile print .proplist=.id', RouterOS\Query::where('name', $name) ); $profileID = $client->sendSync($printRequest)->getProperty('.id'); @@ -135,7 +135,7 @@ class Mikrotik public static function removeHotspotUser($client, $username) { $printRequest = new RouterOS\Request( - '/ip hotspot user print .proplist=name', + '/ip hotspot user print .proplist=.id', RouterOS\Query::where('name', $username) ); $userID = $client->sendSync($printRequest)->getProperty('.id'); @@ -322,7 +322,7 @@ class Mikrotik public static function removePool($client, $name) { $printRequest = new RouterOS\Request( - '/ip pool print .proplist=name', + '/ip pool print .proplist=.id', RouterOS\Query::where('name', $name) ); $poolID = $client->sendSync($printRequest)->getProperty('.id'); @@ -347,7 +347,7 @@ class Mikrotik public static function setPool($client, $name, $ip_address) { $printRequest = new RouterOS\Request( - '/ip pool print .proplist=name', + '/ip pool print .proplist=.id', RouterOS\Query::where('name', $name) ); $poolID = $client->sendSync($printRequest)->getProperty('id'); @@ -380,7 +380,7 @@ class Mikrotik public static function setPpoePlan($client, $name, $pool, $rate) { $printRequest = new RouterOS\Request( - '/ppp profile print .proplist=name', + '/ppp profile print .proplist=.id', RouterOS\Query::where('name', $name) ); $profileID = $client->sendSync($printRequest)->getProperty('.id'); @@ -401,7 +401,7 @@ class Mikrotik public static function removePpoePlan($client, $name) { $printRequest = new RouterOS\Request( - '/ppp profile print .proplist=name', + '/ppp profile print .proplist=.id', RouterOS\Query::where('name', $name) ); $profileID = $client->sendSync($printRequest)->getProperty('.id'); diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 638680b9..4b3a491e 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -106,8 +106,10 @@ class Package // if it same internet plan, expired will extend if ($p['validity_unit'] == 'Months') { $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); + $time = $b['time']; } else if ($p['validity_unit'] == 'Days') { $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days')); + $time = $b['time']; } else if ($p['validity_unit'] == 'Hrs') { $datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' hours'))); $date_exp = $datetime[0]; @@ -150,6 +152,7 @@ class Package } else { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addHotspotUser($client, $p, $c); } diff --git a/system/boot.php b/system/boot.php index dcfe4f11..b2437547 100644 --- a/system/boot.php +++ b/system/boot.php @@ -4,6 +4,33 @@ * PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/) **/ + + +// on some server, it getting error because of slash is backwards +function _autoloader($class) +{ + if (strpos($class, '_') !== false) { + $class = str_replace('_', DIRECTORY_SEPARATOR, $class); + if (file_exists('autoload' . DIRECTORY_SEPARATOR . $class . '.php')) { + include 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; + } else { + $class = str_replace("\\", DIRECTORY_SEPARATOR, $class); + if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) + include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; + } + } else { + if (file_exists('autoload' . DIRECTORY_SEPARATOR . $class . '.php')) { + include 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; + } else { + $class = str_replace("\\", DIRECTORY_SEPARATOR, $class); + if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) + include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; + } + } +} + +spl_autoload_register('_autoloader'); + function r2($to, $ntype = 'e', $msg = '') { if ($msg == '') { @@ -47,8 +74,7 @@ function _get($param, $defvalue = '') } } - -require('system/orm.php'); +require_once File::pathFixer('system/orm.php'); ORM::configure("mysql:host=$db_host;dbname=$db_name"); ORM::configure('username', $db_user); @@ -81,15 +107,15 @@ function _notify($msg, $type = 'e') $_SESSION['notify'] = $msg; } -$lan_file = 'system/lan/' . $config['language'] . '/common.lan.php'; +$lan_file = File::pathFixer('system/lan/' . $config['language'] . '/common.lan.php'); require($lan_file); $ui = new Smarty(); -$ui->setTemplateDir(['custom' => 'ui/ui_custom/', 'default' => 'ui/ui/']); -$ui->addTemplateDir('system/paymentgateway/ui/', 'pg'); -$ui->addTemplateDir('system/plugin/ui/', 'plugin'); -$ui->setCompileDir('ui/compiled/'); -$ui->setConfigDir('ui/conf/'); -$ui->setCacheDir('ui/cache/'); +$ui->setTemplateDir(['custom' => File::pathFixer('ui/ui_custom/'), 'default' => File::pathFixer('ui/ui/')]); +$ui->addTemplateDir(File::pathFixer('system/paymentgateway/ui/'), 'pg'); +$ui->addTemplateDir(File::pathFixer('system/plugin/ui/'), 'plugin'); +$ui->setCompileDir(File::pathFixer('ui/compiled/')); +$ui->setConfigDir(File::pathFixer('ui/conf/')); +$ui->setCacheDir(File::pathFixer('ui/cache/')); $ui->assign('app_url', APP_URL); $ui->assign('_domain', str_replace('www.', '', parse_url(APP_URL, PHP_URL_HOST))); define('U', APP_URL . '/index.php?_route='); @@ -129,40 +155,16 @@ if (isset($_SESSION['notify'])) { include "autoload/Hookers.php"; // notification message -if(file_exists("system/uploads/notifications.json")){ - $_notifmsg =json_decode(file_get_contents('system/uploads/notifications.json'), true); +if (file_exists(File::pathFixer("system/uploads/notifications.json"))) { + $_notifmsg = json_decode(file_get_contents(File::pathFixer('system/uploads/notifications.json')), true); } -$_notifmsg_default = json_decode(file_get_contents('system/uploads/notifications.default.json'), true); +$_notifmsg_default = json_decode(file_get_contents(File::pathFixer('system/uploads/notifications.default.json')), true); //register all plugin -foreach (glob("system/plugin/*.php") as $filename) { +foreach (glob(File::pathFixer("system/plugin/*.php")) as $filename) { include $filename; } -// on some server, it getting error because of slash is backwards -function _autoloader($class) -{ - if (strpos($class, '_') !== false) { - $class = str_replace('_', DIRECTORY_SEPARATOR, $class); - if (file_exists('autoload' . DIRECTORY_SEPARATOR . $class . '.php')) { - include 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; - } else { - $class = str_replace("\\", DIRECTORY_SEPARATOR, $class); - if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) - include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; - } - } else { - if (file_exists('autoload' . DIRECTORY_SEPARATOR . $class . '.php')) { - include 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; - } else { - $class = str_replace("\\", DIRECTORY_SEPARATOR, $class); - if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) - include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; - } - } -} - -spl_autoload_register('_autoloader'); function _auth($login = true) { @@ -281,7 +283,7 @@ $handler = $routes[0]; if ($handler == '') { $handler = 'default'; } -$sys_render = 'system/controllers/' . $handler . '.php'; +$sys_render = File::pathFixer('system/controllers/' . $handler . '.php'); if (file_exists($sys_render)) { $menus = array(); // "name" => $name, diff --git a/system/cron.php b/system/cron.php index d573c7e5..5cc5c6ed 100644 --- a/system/cron.php +++ b/system/cron.php @@ -4,10 +4,34 @@ * PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/) **/ -require('../config.php'); -require('orm.php'); +// on some server, it getting error because of slash is backwards +function _autoloader($class) +{ + if (strpos($class, '_') !== false) { + $class = str_replace('_', DIRECTORY_SEPARATOR, $class); + if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) { + include __DIR__.DIRECTORY_SEPARATOR.'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; + } else { + $class = str_replace("\\", DIRECTORY_SEPARATOR, $class); + if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) + include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; + } + } else { + if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) { + include __DIR__.DIRECTORY_SEPARATOR.'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; + } else { + $class = str_replace("\\", DIRECTORY_SEPARATOR, $class); + if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) + include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; + } + } +} +spl_autoload_register('_autoloader'); -require_once 'autoload/PEAR2/Autoload.php'; +require_once __DIR__.File::pathFixer('/../config.php'); +require_once 'orm.php'; +require_once __DIR__.File::pathFixer('/autoload/PEAR2/Autoload.php'); +include __DIR__.File::pathFixer("/autoload/Hookers.php"); ORM::configure("mysql:host=$db_host;dbname=$db_name"); ORM::configure('username', $db_user); @@ -16,44 +40,17 @@ ORM::configure('return_result_sets', true); ORM::configure('logging', true); -include "autoload/Hookers.php"; - // notification message -if (file_exists("uploads/notifications.json")) { - $_notifmsg = json_decode(file_get_contents('uploads/notifications.json'), true); +if (file_exists(__DIR__.File::pathFixer("uploads/notifications.json"))) { + $_notifmsg = json_decode(file_get_contents(__DIR__.File::pathFixer('uploads/notifications.json')), true); } -$_notifmsg_default = json_decode(file_get_contents('uploads/notifications.default.json'), true); +$_notifmsg_default = json_decode(file_get_contents(__DIR__.File::pathFixer('uploads/notifications.default.json')), true); //register all plugin -foreach (glob("plugin/*.php") as $filename) { +foreach (glob(File::pathFixer("plugin/*.php")) as $filename) { include $filename; } -// on some server, it getting error because of slash is backwards -function _autoloader($class) -{ - if (strpos($class, '_') !== false) { - $class = str_replace('_', DIRECTORY_SEPARATOR, $class); - if (file_exists('autoload' . DIRECTORY_SEPARATOR . $class . '.php')) { - include 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; - } else { - $class = str_replace("\\", DIRECTORY_SEPARATOR, $class); - if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) - include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; - } - } else { - if (file_exists('autoload' . DIRECTORY_SEPARATOR . $class . '.php')) { - include 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; - } else { - $class = str_replace("\\", DIRECTORY_SEPARATOR, $class); - if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) - include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; - } - } -} - -spl_autoload_register('_autoloader'); - $result = ORM::for_table('tbl_appconfig')->find_many(); foreach ($result as $value) { $config[$value['setting']] = $value['value']; @@ -83,10 +80,10 @@ foreach ($d as $ds) { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); + Mikrotik::removeHotspotActiveUser($client, $c['username']); if(!empty($p['pool_expired'])){ Mikrotik::setHotspotUserPackage($client, $c['username'], 'EXPIRED NUXBILL '.$p['pool_expired']); }else{ - Mikrotik::removeHotspotActiveUser($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']); } Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], $textExpired, $config['user_notification_expired']); @@ -130,10 +127,10 @@ foreach ($d as $ds) { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); + Mikrotik::removePpoeActive($client, $c['username']); if(!empty($p['pool_expired'])){ Mikrotik::setPpoeUserPlan($client, $c['username'], 'EXPIRED NUXBILL '.$p['pool_expired']); }else{ - Mikrotik::removePpoeActive($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']); } Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], $textExpired, $config['user_notification_expired']); diff --git a/system/cron_reminder.php b/system/cron_reminder.php index 22474f84..7813dcca 100644 --- a/system/cron_reminder.php +++ b/system/cron_reminder.php @@ -7,30 +7,6 @@ * 0 7 * * * /usr/bin/php /var/www/system/cron_reminder.php **/ -require('../config.php'); -require('orm.php'); - -require_once 'autoload/PEAR2/Autoload.php'; - -ORM::configure("mysql:host=$db_host;dbname=$db_name"); -ORM::configure('username', $db_user); -ORM::configure('password', $db_password); -ORM::configure('return_result_sets', true); -ORM::configure('logging', true); - - -include "autoload/Hookers.php"; - -// notification message -if(file_exists("uploads/notifications.json")){ - $_notifmsg =json_decode(file_get_contents('uploads/notifications.json'), true); -} -$_notifmsg_default = json_decode(file_get_contents('uploads/notifications.default.json'), true); - -//register all plugin -foreach (glob("plugin/*.php") as $filename) { - include $filename; -} // on some server, it getting error because of slash is backwards function _autoloader($class) @@ -38,7 +14,7 @@ function _autoloader($class) if (strpos($class, '_') !== false) { $class = str_replace('_', DIRECTORY_SEPARATOR, $class); if (file_exists('autoload' . DIRECTORY_SEPARATOR . $class . '.php')) { - include 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; + include __DIR__.DIRECTORY_SEPARATOR.'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; } else { $class = str_replace("\\", DIRECTORY_SEPARATOR, $class); if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) @@ -46,7 +22,7 @@ function _autoloader($class) } } else { if (file_exists('autoload' . DIRECTORY_SEPARATOR . $class . '.php')) { - include 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; + include __DIR__.DIRECTORY_SEPARATOR.'autoload' . DIRECTORY_SEPARATOR . $class . '.php'; } else { $class = str_replace("\\", DIRECTORY_SEPARATOR, $class); if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) @@ -57,6 +33,30 @@ function _autoloader($class) spl_autoload_register('_autoloader'); + require_once __DIR__.File::pathFixer('/../config.php'); + require_once __DIR__.File::pathFixer('orm.php'); + require_once __DIR__.File::pathFixer('/autoload/PEAR2/Autoload.php'); + include __DIR__.File::pathFixer("/autoload/Hookers.php"); + +ORM::configure("mysql:host=$db_host;dbname=$db_name"); +ORM::configure('username', $db_user); +ORM::configure('password', $db_password); +ORM::configure('return_result_sets', true); +ORM::configure('logging', true); + + +// notification message +if (file_exists(__DIR__.File::pathFixer("uploads/notifications.json"))) { + $_notifmsg = json_decode(file_get_contents(__DIR__.File::pathFixer('uploads/notifications.json')), true); +} +$_notifmsg_default = json_decode(file_get_contents(__DIR__.File::pathFixer('uploads/notifications.default.json')), true); + + +//register all plugin +foreach (glob(File::pathFixer("plugin/*.php")) as $filename) { + include $filename; +} + $result = ORM::for_table('tbl_appconfig')->find_many(); foreach ($result as $value) { $config[$value['setting']] = $value['value']; diff --git a/system/lan/indonesia/common.lan.php b/system/lan/indonesia/common.lan.php index 05f63cc9..f789d5b7 100644 --- a/system/lan/indonesia/common.lan.php +++ b/system/lan/indonesia/common.lan.php @@ -341,3 +341,8 @@ $_L['Allow_balance_transfer_between_customers'] = 'Bolehkan transfer saldo antar $_L['Refill_Balance'] = 'Refill Balance'; $_L['Balance_Plans'] = 'Balance Plans'; $_L['Expired_IP_Pool'] = 'Expired IP Pool'; +$_L['Company_Logo'] = 'Company Logo'; +$_L['Disable_Voucher'] = 'Disable Voucher'; +$_L['Minimum_Balance_Transfer'] = 'Minimum Balance Transfer'; +$_L['Reminder_Notification'] = 'Reminder Notification'; +$_L['Invoice_Footer'] = 'Invoice Footer'; diff --git a/system/radius.php b/system/radius.php index 174a862a..13073efc 100644 --- a/system/radius.php +++ b/system/radius.php @@ -7,11 +7,12 @@ if(php_sapi_name() !== 'cli'){ die("RUN ON COMMAND LINE ONLY BY RADIUS ENGINE"); } -require(__DIR__.'/../config.php'); -require(__DIR__.'/orm.php'); +require_once __DIR__.File::pathFixer('/../config.php'); +require_once __DIR__.File::pathFixer('orm.php'); +require_once __DIR__.File::pathFixer('/autoload/PEAR2/Autoload.php'); +include __DIR__.File::pathFixer("/autoload/Hookers.php"); use PEAR2\Net\RouterOS; -require_once 'autoload/PEAR2/Autoload.php'; ORM::configure("mysql:host=$db_host;dbname=$db_name"); ORM::configure('username', $db_user);