diff --git a/system/autoload/Hookers.php b/system/autoload/Hookers.php index 94d033f6..86ab2975 100644 --- a/system/autoload/Hookers.php +++ b/system/autoload/Hookers.php @@ -16,8 +16,10 @@ $menu_registered = array(); * Admin/Sales menu: AFTER_DASHBOARD, CUSTOMERS, PREPAID, SERVICES, REPORTS, VOUCHER, AFTER_ORDER, NETWORK, SETTINGS, AFTER_PAYMENTGATEWAY * | Customer menu: AFTER_DASHBOARD, ORDER, HISTORY, ACCOUNTS * @param string icon from ion icon, ion-person, only for AFTER_ + * @param string label for showing label or number of notification or update + * @param string color Label color */ -function register_menu($name, $admin, $function, $position, $icon = '', $label = '', $color = '') +function register_menu($name, $admin, $function, $position, $icon = '', $label = '', $color = 'success') { global $menu_registered; $menu_registered[] = [ diff --git a/system/boot.php b/system/boot.php index d0312bac..51193ade 100644 --- a/system/boot.php +++ b/system/boot.php @@ -108,6 +108,21 @@ try { ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'), 'radius'); ORM::configure('return_result_sets', true, 'radius'); } +} catch (Throwable $e) { + $ui = new Smarty(); + $ui->setTemplateDir(['custom' => File::pathFixer('ui/ui_custom/'), 'default' => File::pathFixer('ui/ui/')]); + $ui->assign('_url', APP_URL . '/index.php?_route='); + $ui->setCompileDir(File::pathFixer('ui/compiled/')); + $ui->setConfigDir(File::pathFixer('ui/conf/')); + $ui->setCacheDir(File::pathFixer('ui/cache/')); + $ui->assign("error_title", "PHPNuxBill Crash"); + if (isset($_SESSION['uid'])) { + $ui->assign("error_message", $e->getMessage() . '
'); + } else { + $ui->assign("error_message", $e->getMessage() . '
' . $e->getTraceAsString() . '
'); + } + $ui->display('router-error.tpl'); + die(); } catch (Exception $e) { $ui = new Smarty(); $ui->setTemplateDir(['custom' => File::pathFixer('ui/ui_custom/'), 'default' => File::pathFixer('ui/ui/')]); @@ -317,7 +332,6 @@ if ($handler == '') { $handler = 'default'; } try { - $sys_render = File::pathFixer('system/controllers/' . $handler . '.php'); if (file_exists($sys_render)) { $menus = array(); @@ -327,30 +341,28 @@ try { // "function" => $function $ui->assign('_system_menu', $routes[0]); foreach ($menu_registered as $menu) { - if ($menu['admin'] && _admin(false)) { - $menus[$menu['position']] .= ''; - if (!empty($menu['icon'])) { - $menus[$menu['position']] .= ''; - } - if (!empty($menu['label'])) { - $menus[$menu['position']] .= ' - ' . $menu['label'] . ' - '; - } - $menus[$menu['position']] .= '' . $menu['name'] . ''; - } else if (!$menu['admin'] && _auth(false)) { - $menus[$menu['position']] .= ''; - if (!empty($menu['icon'])) { - $menus[$menu['position']] .= ''; - } - if (!empty($menu['label'])) { - $menus[$menu['position']] .= ' - ' . $menu['label'] . ' - '; - } - $menus[$menu['position']] .= '' . $menu['name'] . ''; - } - } + if ($menu['admin'] && _admin(false)) { + $menus[$menu['position']] .= ''; + if (!empty($menu['icon'])) { + $menus[$menu['position']] .= ''; + } + if (!empty($menu['label'])) { + $menus[$menu['position']] .= ''; + $menus[$menu['position']] .= '' . $menu['label'] . ''; + } + $menus[$menu['position']] .= '' . $menu['name'] . ''; + } else if (!$menu['admin'] && _auth(false)) { + $menus[$menu['position']] .= ''; + if (!empty($menu['icon'])) { + $menus[$menu['position']] .= ''; + } + if (!empty($menu['label'])) { + $menus[$menu['position']] .= ''; + $menus[$menu['position']] .= '' . $menu['label'] . ''; + } + $menus[$menu['position']] .= '' . $menu['name'] . ''; + } + } foreach ($menus as $k => $v) { $ui->assign('_MENU_' . $k, $v); } @@ -359,6 +371,14 @@ try { } else { r2(U . 'dashboard', 'e', 'not found'); } +} catch (Throwable $e) { + if (!isset($_SESSION['aid']) || empty($_SESSION['aid'])) { + r2(U . 'home', 'e', $e->getMessage()); + } + $ui->assign("error_message", $e->getMessage() . '
' . $e->getTraceAsString() . '
'); + $ui->assign("error_title", "PHPNuxBill Crash"); + $ui->display('router-error.tpl'); + die(); } catch (Exception $e) { if (!isset($_SESSION['aid']) || empty($_SESSION['aid'])) { r2(U . 'home', 'e', $e->getMessage()); diff --git a/ui/ui/router-error.tpl b/ui/ui/router-error.tpl index 8d42d9a0..14bfc547 100644 --- a/ui/ui/router-error.tpl +++ b/ui/ui/router-error.tpl @@ -14,7 +14,7 @@ - +