Show some error page when crash

This commit is contained in:
Ibnu Maksum 2023-09-14 13:45:35 +07:00
parent fc5aa083a1
commit e64527cee2
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
5 changed files with 72 additions and 44 deletions

View File

@ -17,7 +17,8 @@ class Mikrotik
$iport = explode(":", $ip);
return new RouterOS\Client($iport[0], $user, $pass, ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
$ui->assign("error_meesage", "Unable to connect to the router.<br>" . $e->getMessage());
$ui->assign("error_title", "Mikrotik Connection Error");
$ui->assign("error_message", "Unable to connect to the router.<br>" . $e->getMessage());
$ui->display('router-error.tpl');
die();
}

View File

@ -290,8 +290,10 @@ $handler = $routes[0];
if ($handler == '') {
$handler = 'default';
}
$sys_render = File::pathFixer('system/controllers/' . $handler . '.php');
if (file_exists($sys_render)) {
try {
$sys_render = File::pathFixer('system/controllers/' . $handler . '.php');
if (file_exists($sys_render)) {
$menus = array();
// "name" => $name,
// "admin" => $admin,
@ -318,6 +320,13 @@ if (file_exists($sys_render)) {
}
unset($menus, $menu_registered);
include($sys_render);
} else {
} 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();
}

View File

@ -130,7 +130,7 @@
</div>
</div>
</div>
<div class="col-sm-6">
<div class="col-sm-6" id="update">
<div class="box box-primary box-hovered mb20 activities">
<div class="box-header">
<h3 class="box-title">PHPNUXBILL</h3>

BIN
ui/ui/images/error.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 KiB

View File

@ -4,7 +4,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Router Error - PHPNuxBill</title>
<title>Error - PHPNuxBill</title>
<link rel="shortcut icon" href="ui/ui/images/logo.png" type="image/x-icon" />
<link rel="stylesheet" href="ui/ui/styles/bootstrap.min.css">
@ -32,27 +32,45 @@
<body class="hold-transition skin-blue">
<div class="container">
<section class="content-header">
<h1 class="text-center">
Router Error
</h1>
</section>
<section class="content">
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<div class="alert alert-danger text-center">
{$error_meesage}
<div class="col-md-3">
<img src="./ui/ui/images/error.png" class="img-responsive hidden-sm hidden-xs">
</div>
<a href="javascript::history.back()" onclick="history.back()" class="btn btn-warning btn-block">back</a>
<div class="col-md-6">
<div class="box box-danger box-solid text-center">
<section class="content-header">
<h1 class="text-center">
{$error_title}
</h1>
</section>
<div class="box-title" style="font-size:xx-large; color:red">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
</div>
<div class="box-body" style="font-size: larger;">
<br><br>
{$error_message}
<br><br><br>
</div>
<div class="box-footer">
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<a href="./update.php?step=4" class="btn btn-info btn-sm btn-block">Update Database</a>
<a href="{$_url}community#update" class="btn btn-primary btn-sm btn-block">Update
PHPNuxBill</a>
</div>
<br><br>
<a href="javascript::history.back()" onclick="history.back()"
class="btn btn-warning btn-block">back</a>
</div>
</div>
</div>
<div class="col-md-4">
<img src="./ui/ui/images/error.png" class="img-responsive hidden-md hidden-lg">
</div>
</div>
</section>
<footer class="footer text-center">
PHPNuxBill by <a href="https://github.com/hotspotbilling/phpnuxbill" rel="nofollow noreferrer noopener"
target="_blank">iBNuX</a>
</footer>
</div>
</body>