check error Database

This commit is contained in:
Ibnu Maksum 2023-09-14 13:53:28 +07:00
parent e64527cee2
commit a85ccf06fa
No known key found for this signature in database
GPG key ID: 7FC82848810579E5
2 changed files with 45 additions and 32 deletions

View file

@ -10,6 +10,7 @@
- Fix Customer counter in dashboard
- Show Customer Balance in header
- Fix Plugin Manager using Http::Get
- Show Some error page when crash
## 2023.9.7
- Fix PPPOE Delete Customer

View file

@ -73,39 +73,52 @@ function _get($param, $defvalue = '')
return safedata($_GET[$param]);
}
}
try {
require_once File::pathFixer('system/orm.php');
require_once File::pathFixer('system/orm.php');
ORM::configure("mysql:host=$db_host;dbname=$db_name");
ORM::configure('username', $db_user);
ORM::configure('password', $db_password);
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
ORM::configure('return_result_sets', true);
if ($_app_stage != 'Live') {
ORM::configure('logging', true);
}
$result = ORM::for_table('tbl_appconfig')->find_many();
foreach ($result as $value) {
$config[$value['setting']] = $value['value'];
}
date_default_timezone_set($config['timezone']);
$_c = $config;
// check if proxy setup in database
if(empty($http_proxy) && !empty($config['http_proxy'])){
$http_proxy = $config['http_proxy'];
if(empty($http_proxyauth) && !empty($config['http_proxyauth'])){
$http_proxyauth = $config['http_proxyauth'];
ORM::configure("mysql:host=$db_host;dbname=$db_name");
ORM::configure('username', $db_user);
ORM::configure('password', $db_password);
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
ORM::configure('return_result_sets', true);
if ($_app_stage != 'Live') {
ORM::configure('logging', true);
}
}
if ($config['radius_mode']) {
ORM::configure("mysql:host=$radius_host;dbname=$radius_name", null, 'radius');
ORM::configure('username', $radius_user, 'radius');
ORM::configure('password', $radius_password, 'radius');
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'), 'radius');
ORM::configure('return_result_sets', true, 'radius');
$result = ORM::for_table('tbl_appconfig')->find_many();
foreach ($result as $value) {
$config[$value['setting']] = $value['value'];
}
date_default_timezone_set($config['timezone']);
$_c = $config;
// check if proxy setup in database
if (empty($http_proxy) && !empty($config['http_proxy'])) {
$http_proxy = $config['http_proxy'];
if (empty($http_proxyauth) && !empty($config['http_proxyauth'])) {
$http_proxyauth = $config['http_proxyauth'];
}
}
if ($config['radius_mode']) {
ORM::configure("mysql:host=$radius_host;dbname=$radius_name", null, 'radius');
ORM::configure('username', $radius_user, 'radius');
ORM::configure('password', $radius_password, 'radius');
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'), 'radius');
ORM::configure('return_result_sets', true, 'radius');
}
} catch (Exception $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");
$ui->assign("error_message", $e->getMessage());
$ui->display('router-error.tpl');
die();
}
function _notify($msg, $type = 'e')
@ -323,10 +336,9 @@ try {
} else {
r2(U . 'dashboard', 'e', 'not found');
}
} catch (Exception $e) {
$ui->assign("error_title", "PHPNuxBill Crash");
$ui->assign("error_message", $e->getMessage());
$ui->display('router-error.tpl');
die();
}
}