diff --git a/public_html/css/default/base.css b/public_html/css/default/base.css index 466293df..c4b97470 100644 --- a/public_html/css/default/base.css +++ b/public_html/css/default/base.css @@ -333,3 +333,45 @@ input[type='submit'].LSview_search { margin-bottom: 0; margin-left: 1.2em; } + +/* + ********************* + * Fatal error + ********************* + */ +#fatal_error { + margin: auto; + max-width: 80%; + text-align: center; +} + +#fatal_error h1 { + border: none; +} + +#fatal_error pre { + color: #111; + text-align: left; + background-color: #eee; + width: 80%; + margin: auto; + margin-top: 3em; + padding: 0.5em; + border-radius: 1em; + border: 1px solid #ccc; +} + +#fatal_error pre em { + border-radius: 6px; + background-color: #60B7D4; + font-family: sans-serif; + font-size: 1em; + font-style: normal; + padding: 5px; + margin: 0.2em; + margin-top: -1.5em; + display: block; + max-width: 50%; + border-radius: 1em; + font-weight: bold; +} diff --git a/public_html/includes/class/class.LSlog.php b/public_html/includes/class/class.LSlog.php index 21ebb3ec..631182a9 100644 --- a/public_html/includes/class/class.LSlog.php +++ b/public_html/includes/class/class.LSlog.php @@ -159,6 +159,15 @@ class LSlog { // Logging on this handler call_user_func(array($handler, 'logging'), $level, $message); } + + if ($level == 'FATAL') { + if (php_sapi_name() == "cli") + die($message); + elseif (class_exists('LStemplate')) + LStemplate :: fatal_error($message); + else + die($message); + } } /** diff --git a/public_html/includes/class/class.LStemplate.php b/public_html/includes/class/class.LStemplate.php index 7f28cb41..d7775349 100644 --- a/public_html/includes/class/class.LStemplate.php +++ b/public_html/includes/class/class.LStemplate.php @@ -320,6 +320,19 @@ class LStemplate { return self :: $_smarty -> fetch("ls:$template"); } + /** + * Handle fatal error + * + * @param[in] $error string|null Error message (optional) + * + * @retval void + **/ + public static function fatal_error($error=null) { + self :: $_smarty -> assign('fatal_error', $error); + self :: $_smarty -> display("ls:fatal_error.tpl"); + exit(); + } + /** * Register a template function * diff --git a/public_html/templates/default/fatal_error.tpl b/public_html/templates/default/fatal_error.tpl new file mode 100644 index 00000000..afaf6414 --- /dev/null +++ b/public_html/templates/default/fatal_error.tpl @@ -0,0 +1,29 @@ + + + + + LdapSaisie{if $pagetitle != ''} - {$pagetitle|escape:"htmlall"}{/if} + + + + {$LSsession_css} + + + +{include file='ls:LSdefault.tpl'} + +{$LSsession_js} + +
+

{tr msg="A fatal error occured. If problem persist, please contact support."}

+ +{if $fatal_error} +
+{tr msg="Details"} :
+{$fatal_error}

+{/if} +
+ + +