mirror of
https://github.com/e107inc/e107.git
synced 2025-08-11 00:54:49 +02:00
Introduce e107::setErrorPage() for delivering an error page to the browser.
This commit is contained in:
84
error.php
84
error.php
@@ -21,15 +21,6 @@ $_E107 = array(
|
||||
|
||||
require_once("class2.php");
|
||||
|
||||
// Start session if required.
|
||||
if(!session_id())
|
||||
{
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Include language file.
|
||||
e107::coreLan('error');
|
||||
|
||||
|
||||
/**
|
||||
* Class error_front.
|
||||
@@ -63,92 +54,29 @@ class error_front
|
||||
switch($this->errorNumber)
|
||||
{
|
||||
case 400:
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
|
||||
$subtitle = LAN_ERROR_35; // Error 400 - Bad Request
|
||||
$caption = LAN_ERROR_45;
|
||||
$content = LAN_ERROR_36 . '<br/>' . LAN_ERROR_3;
|
||||
e107::setErrorPage(400);
|
||||
break;
|
||||
|
||||
case 401:
|
||||
header('HTTP/1.1 401 Unauthorized');
|
||||
|
||||
$subtitle = LAN_ERROR_1; // Error 401 - Authentication Failed
|
||||
$caption = LAN_ERROR_45;
|
||||
$content = LAN_ERROR_2 . '<br/>' . LAN_ERROR_3;
|
||||
e107::setErrorPage(401);
|
||||
break;
|
||||
|
||||
case 403:
|
||||
header('HTTP/1.1 403 Forbidden');
|
||||
|
||||
$subtitle = LAN_ERROR_4; // Error 403 - Access forbidden
|
||||
$caption = LAN_ERROR_45;
|
||||
$content = LAN_ERROR_5 . '<br/>' . LAN_ERROR_6 . '<br/><br/>' . LAN_ERROR_2;
|
||||
e107::setErrorPage(403);
|
||||
break;
|
||||
|
||||
case 404:
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
|
||||
$subtitle = LAN_ERROR_7; // Error 404 - Document Not Found
|
||||
$caption = LAN_ERROR_45;
|
||||
$content = LAN_ERROR_21 . '<br/>' . LAN_ERROR_9;
|
||||
|
||||
$errFrom = isset($_SESSION['e107_http_referer']) ? $_SESSION['e107_http_referer'] : $_SERVER['HTTP_REFERER'];
|
||||
|
||||
if(strlen($errFrom))
|
||||
{
|
||||
$content .= '<br/>';
|
||||
$content .= '<br/>';
|
||||
$content .= LAN_ERROR_23 . ' <a href="' . $errFrom . '" rel="external">' . $errFrom . '</a> ';
|
||||
$content .= LAN_ERROR_24;
|
||||
}
|
||||
|
||||
e107::setErrorPage(404);
|
||||
break;
|
||||
|
||||
case 500:
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
|
||||
$subtitle = LAN_ERROR_10; // Error 500 - Internal server error
|
||||
$caption = LAN_ERROR_14;
|
||||
$content = LAN_ERROR_11 . '<br/>' . LAN_ERROR_12;
|
||||
break;
|
||||
|
||||
case 999:
|
||||
if(!defset('E107_DEBUG_LEVEL', false))
|
||||
{
|
||||
e107::redirect();
|
||||
}
|
||||
|
||||
$this->errorNumber = 'DEFAULT'; // Use default template.
|
||||
|
||||
$subtitle = LAN_ERROR_33;
|
||||
$caption = LAN_ERROR_14;
|
||||
$content = '<pre>' . print_r($_SERVER) . print_r($_REQUEST) . '</pre>';
|
||||
e107::setErrorPage(500);
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->errorNumber = 'DEFAULT'; // Use default template.
|
||||
$errorQuery = htmlentities($_SERVER['QUERY_STRING']);
|
||||
|
||||
$subtitle = LAN_ERROR_13 . ' (' . $errorQuery . ')'; // Error - Unknown
|
||||
$caption = LAN_ERROR_14;
|
||||
$content = LAN_ERROR_15;
|
||||
e107::setErrorPage('unknown');
|
||||
break;
|
||||
}
|
||||
|
||||
$tp = e107::getParser();
|
||||
$tpl = e107::getCoreTemplate('error', $this->errorNumber);
|
||||
$sc = e107::getScBatch('error');
|
||||
|
||||
$sc->setVars(array(
|
||||
'title' => LAN_ERROR_TITLE,
|
||||
'subtitle' => $subtitle,
|
||||
'caption' => $caption,
|
||||
'content' => $content,
|
||||
));
|
||||
|
||||
$body = $tp->parseTemplate($tpl, true, $sc);
|
||||
e107::getRender()->tablerender('', $body);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user