mirror of
https://github.com/e107inc/e107.git
synced 2025-01-18 05:09:05 +01:00
Merge pull request #2148 from lonalore/error
Error page improvement: template support. And status code support for e107::redirect().
This commit is contained in:
commit
97229f6329
@ -1,9 +1,9 @@
|
||||
# Custom error pages for php scripts only
|
||||
<FilesMatch \.php$>
|
||||
<FilesMatch \.php$>
|
||||
ErrorDocument 400 /error.php?400
|
||||
ErrorDocument 401 /error.php?401
|
||||
ErrorDocument 403 /error.php?403
|
||||
ErrorDocument 404 /error.php?404
|
||||
ErrorDocument 404 /error.php?404
|
||||
ErrorDocument 500 /error.php?500
|
||||
</FilesMatch>
|
||||
|
||||
|
@ -1,102 +1,104 @@
|
||||
<?php
|
||||
/*
|
||||
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2011 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2016 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* System error controller
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
* @file
|
||||
* System error controller.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class core_system_error_controller.
|
||||
*/
|
||||
class core_system_error_controller extends eController
|
||||
{
|
||||
function preAction()
|
||||
|
||||
/**
|
||||
* Pre-action callback, fired only if dispatch status is still true
|
||||
* and action method is found.
|
||||
*/
|
||||
public function preAction()
|
||||
{
|
||||
e107::coreLan('error');
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias
|
||||
*/
|
||||
public function action404()
|
||||
{
|
||||
$this->_forward('notfound');
|
||||
}
|
||||
|
||||
public function actionNotfound()
|
||||
{
|
||||
$this->getResponse()
|
||||
->setRenderMod('error404')
|
||||
->addHeader('HTTP/1.0 404 Not Found');
|
||||
|
||||
$this->addTitle(LAN_ERROR_7);
|
||||
$template = e107::getCoreTemplate('error', 404);
|
||||
|
||||
$vars = new e_vars(array(
|
||||
'SITEURL' => SITEURL,
|
||||
'SEARCHURL' => e107::getUrl()->create('search'),
|
||||
));
|
||||
|
||||
|
||||
$body = e107::getParser()->parseTemplate(
|
||||
$this->updateTemplate($template['start']).
|
||||
$this->updateTemplate($template['body']).
|
||||
$this->updateTemplate($template['end'])
|
||||
, true, null, $vars);
|
||||
|
||||
$this->addBody($body);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update template to v2.x spec. ALL CAPS shortcodes only.
|
||||
* @param $template
|
||||
* @return mixed
|
||||
*/
|
||||
private function updateTemplate($template)
|
||||
{
|
||||
$srch = array('{siteUrl}','{searchUrl}');
|
||||
$repl = array('{SITEURL}','{SEARCHURL}');
|
||||
|
||||
return str_replace($srch,$repl,$template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias
|
||||
* Alias for "Error 403".
|
||||
*/
|
||||
public function action403()
|
||||
{
|
||||
$this->_forward('forbidden');
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for "Error 404".
|
||||
*/
|
||||
public function action404()
|
||||
{
|
||||
$this->_forward('notfound');
|
||||
}
|
||||
|
||||
/**
|
||||
* Error 403.
|
||||
*/
|
||||
public function actionForbidden()
|
||||
{
|
||||
$this->getResponse()
|
||||
->setRenderMod('error403')
|
||||
->addHeader('HTTP/1.0 403 Forbidden');
|
||||
|
||||
$this->addTitle(LAN_ERROR_7);
|
||||
$template = e107::getCoreTemplate('error', 403);
|
||||
|
||||
$vars = new e_vars(array(
|
||||
'SITEURL' => SITEURL,
|
||||
$response = $this->getResponse();
|
||||
$response->setRenderMod('error403');
|
||||
$response->addHeader('HTTP/1.0 403 Forbidden');
|
||||
|
||||
$tp = e107::getParser();
|
||||
$tpl = e107::getCoreTemplate('error', '403');
|
||||
$sc = e107::getScBatch('error');
|
||||
|
||||
$title = LAN_ERROR_TITLE;
|
||||
$subtitle = LAN_ERROR_4;
|
||||
$caption = LAN_ERROR_45;
|
||||
$content = LAN_ERROR_5 . '<br/>' . LAN_ERROR_6 . '<br/><br/>' . LAN_ERROR_2;
|
||||
|
||||
$sc->setVars(array(
|
||||
'title' => $title,
|
||||
'subtitle' => $subtitle,
|
||||
'caption' => $caption,
|
||||
'content' => $content,
|
||||
));
|
||||
|
||||
$body = e107::getParser()->parseTemplate(
|
||||
$this->updateTemplate($template['start']).
|
||||
$this->updateTemplate($template['body']).
|
||||
$this->updateTemplate($template['end'])
|
||||
, true, null, $vars);
|
||||
|
||||
|
||||
$body = $tp->parseTemplate($tpl, true, $sc);
|
||||
$this->addBody($body);
|
||||
}
|
||||
|
||||
function actionHelloWorld()
|
||||
|
||||
/**
|
||||
* Error 404.
|
||||
*/
|
||||
public function actionNotfound()
|
||||
{
|
||||
//$this->addTitle('Hello!');
|
||||
//echo 'Hello World';
|
||||
$response = $this->getResponse();
|
||||
$response->setRenderMod('error404');
|
||||
$response->addHeader('HTTP/1.0 404 Not Found');
|
||||
|
||||
$tp = e107::getParser();
|
||||
$tpl = e107::getCoreTemplate('error', '404');
|
||||
$sc = e107::getScBatch('error');
|
||||
|
||||
$title = LAN_ERROR_TITLE;
|
||||
$subtitle = LAN_ERROR_7;
|
||||
$caption = LAN_ERROR_45;
|
||||
$content = LAN_ERROR_21 . '<br/>' . LAN_ERROR_9;
|
||||
|
||||
$sc->setVars(array(
|
||||
'title' => $title,
|
||||
'subtitle' => $subtitle,
|
||||
'caption' => $caption,
|
||||
'content' => $content,
|
||||
));
|
||||
|
||||
$body = $tp->parseTemplate($tpl, true, $sc);
|
||||
$this->addBody($body);
|
||||
}
|
||||
|
||||
}
|
||||
|
81
e107_core/shortcodes/batch/error_shortcodes.php
Normal file
81
e107_core/shortcodes/batch/error_shortcodes.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2016 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* @file
|
||||
* Error shortcodes.
|
||||
*/
|
||||
|
||||
if(!defined('e107_INIT'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class error_shortcodes.
|
||||
*/
|
||||
class error_shortcodes extends e_shortcode
|
||||
{
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function sc_error_title()
|
||||
{
|
||||
return varset($this->var['title'], '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function sc_error_subtitle()
|
||||
{
|
||||
return varset($this->var['subtitle'], '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function sc_error_caption()
|
||||
{
|
||||
return varset($this->var['caption'], '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function sc_error_content()
|
||||
{
|
||||
return varset($this->var['content'], '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function sc_error_link_home()
|
||||
{
|
||||
$icon = e107::getParser()->toGlyph('fa-home');
|
||||
$url = SITEURL;
|
||||
|
||||
return '<a href="' . $url . '" class="btn btn-primary">' . $icon . ' ' . LAN_ERROR_20 . '</a>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function sc_error_link_search()
|
||||
{
|
||||
$icon = e107::getParser()->toGlyph('fa-search');
|
||||
$url = e107::getUrl()->create('search');
|
||||
|
||||
return '<a href="' . $url . '" class="btn btn-default">' . $icon . ' ' . LAN_ERROR_22 . '</a>';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,47 +1,187 @@
|
||||
<?php
|
||||
/*
|
||||
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2016 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* Error Templates
|
||||
*
|
||||
* $Id: $
|
||||
* @file
|
||||
* Error templates.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package e107
|
||||
* @subpackage e107_templates
|
||||
* @version $Id$;
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
if(!defined('e107_INIT'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
$ERROR_TEMPLATE = array();
|
||||
|
||||
$ERROR_TEMPLATE['404']['start'] = '<div class="error-404 alert-danger">';
|
||||
$ERROR_TEMPLATE['404']['body'] = '
|
||||
<h3><i class="icon-exclamation-sign" title="'.LAN_ERROR_45.'"></i> '.LAN_ERROR_45.'</h3>
|
||||
<p>
|
||||
'.LAN_ERROR_21.'<br />'.LAN_ERROR_9.'
|
||||
</p>
|
||||
<a href="{SITEURL}">'.LAN_ERROR_20.'</a><br />
|
||||
<a href="{SEARCHURL}">'.LAN_ERROR_22.'</a>
|
||||
/**
|
||||
* 400 Bad Request.
|
||||
*/
|
||||
$ERROR_TEMPLATE['400'] = '
|
||||
<h1 class="text-center">
|
||||
<strong>{ERROR_TITLE}</strong>
|
||||
</h1>
|
||||
<h2 class="text-center">
|
||||
{ERROR_SUBTITLE}
|
||||
</h2>
|
||||
<br/>
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{ERROR_CAPTION}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{ERROR_CONTENT}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="error-actions text-center">
|
||||
{ERROR_LINK_HOME}
|
||||
</div>
|
||||
<br/>
|
||||
';
|
||||
$ERROR_TEMPLATE['404']['end'] = '</div>';
|
||||
|
||||
|
||||
$ERROR_TEMPLATE['403']['start'] = '<div class="error-403 alert-danger">';
|
||||
$ERROR_TEMPLATE['403']['body'] = '
|
||||
<h3><i class="icon-exclamation-sign" title="'.LAN_ERROR_4.'"></i> '.LAN_ERROR_4.'</h3>
|
||||
<p>
|
||||
'.LAN_ERROR_5.'<br />'.LAN_ERROR_6.'<br /><br />'.LAN_ERROR_2.'
|
||||
</p>
|
||||
<a href="{SITEURL}">'.LAN_ERROR_20.'</a><br />
|
||||
/**
|
||||
* 401 Unauthorized.
|
||||
*/
|
||||
$ERROR_TEMPLATE['401'] = '
|
||||
<h1 class="text-center">
|
||||
<strong>{ERROR_TITLE}</strong>
|
||||
</h1>
|
||||
<h2 class="text-center">
|
||||
{ERROR_SUBTITLE}
|
||||
</h2>
|
||||
<br/>
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{ERROR_CAPTION}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{ERROR_CONTENT}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="error-actions text-center">
|
||||
{ERROR_LINK_HOME}
|
||||
</div>
|
||||
<br/>
|
||||
';
|
||||
$ERROR_TEMPLATE['403']['end'] = '</div>';
|
||||
|
||||
/**
|
||||
* 403 Forbidden.
|
||||
*/
|
||||
$ERROR_TEMPLATE['403'] = '
|
||||
<h1 class="text-center">
|
||||
<strong>{ERROR_TITLE}</strong>
|
||||
</h1>
|
||||
<h2 class="text-center">
|
||||
{ERROR_SUBTITLE}
|
||||
</h2>
|
||||
<br/>
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{ERROR_CAPTION}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{ERROR_CONTENT}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="error-actions text-center">
|
||||
{ERROR_LINK_HOME}
|
||||
</div>
|
||||
<br/>
|
||||
';
|
||||
|
||||
/**
|
||||
* 404 Not Found.
|
||||
*/
|
||||
$ERROR_TEMPLATE['404'] = '
|
||||
<h1 class="text-center">
|
||||
<strong>{ERROR_TITLE}</strong>
|
||||
</h1>
|
||||
<h2 class="text-center">
|
||||
{ERROR_SUBTITLE}
|
||||
</h2>
|
||||
<br/>
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{ERROR_CAPTION}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{ERROR_CONTENT}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="error-actions text-center">
|
||||
{ERROR_LINK_HOME} {ERROR_LINK_SEARCH}
|
||||
</div>
|
||||
<br/>
|
||||
';
|
||||
|
||||
/**
|
||||
* 500 Internal server error.
|
||||
*/
|
||||
$ERROR_TEMPLATE['500'] = '
|
||||
<h1 class="text-center">
|
||||
<strong>{ERROR_TITLE}</strong>
|
||||
</h1>
|
||||
<h2 class="text-center">
|
||||
{ERROR_SUBTITLE}
|
||||
</h2>
|
||||
<br/>
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{ERROR_CAPTION}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{ERROR_CONTENT}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="error-actions text-center">
|
||||
{ERROR_LINK_HOME}
|
||||
</div>
|
||||
<br/>
|
||||
';
|
||||
|
||||
/**
|
||||
* Default error page.
|
||||
*/
|
||||
$ERROR_TEMPLATE['DEFAULT'] = '
|
||||
<h1 class="text-center">
|
||||
<strong>{ERROR_TITLE}</strong>
|
||||
</h1>
|
||||
<h2 class="text-center">
|
||||
{ERROR_SUBTITLE}
|
||||
</h2>
|
||||
<br/>
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{ERROR_CAPTION}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{ERROR_CONTENT}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="error-actions text-center">
|
||||
{ERROR_LINK_HOME}
|
||||
</div>
|
||||
<br/>
|
||||
';
|
||||
|
@ -42,7 +42,7 @@ class core_system_rewrite_url extends eUrlConfig
|
||||
'name' => LAN_EURL_CORE_SYSTEM, // Module name
|
||||
'label' => LAN_EURL_SYSTEM_REWRITE_LABEL, // Current profile name
|
||||
'description' => LAN_EURL_SYSTEM_REWRITE_DESCR, //
|
||||
'examples' => array("{SITEURL}system/error404")
|
||||
'examples' => array("{SITEURL}system/error/404")
|
||||
),
|
||||
'form' => array(), // Under construction - additional configuration options
|
||||
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
|
||||
|
@ -3036,11 +3036,26 @@ class e107
|
||||
|
||||
/**
|
||||
* Simple redirect method for developers.
|
||||
* @param $url string : 'admin' to redirect to admin entry page or leave blank to go to home page (SITEURL)
|
||||
*
|
||||
* @param string $url
|
||||
* 'admin' to redirect to admin entry page or leave blank to go to home page
|
||||
* (SITEURL).
|
||||
* @param int $http_response_code
|
||||
* The HTTP status code to use for the redirection, defaults to 302.
|
||||
* The valid values for 3xx redirection status codes are defined in RFC 2616
|
||||
* and the draft for the new HTTP status codes:
|
||||
* - 301: Moved Permanently (the recommended value for most redirects).
|
||||
* - 302: Found (default in PHP, sometimes used for spamming search engines).
|
||||
* - 303: See Other.
|
||||
* - 304: Not Modified.
|
||||
* - 305: Use Proxy.
|
||||
* - 307: Temporary Redirect.
|
||||
* @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3
|
||||
* @see https://tools.ietf.org/html/draft-reschke-http-status-308-07
|
||||
*/
|
||||
public static function redirect($url='')
|
||||
public static function redirect($url = '', $http_response_code = 302)
|
||||
{
|
||||
self::getRedirect()->go($url);
|
||||
self::getRedirect()->go($url, true, $http_response_code);
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
define("PAGE_NAME", "Error");
|
||||
define("LAN_ERROR_TITLE", "Oops!");
|
||||
|
||||
define("LAN_ERROR_1", "Error 401 - Authentication Failed");
|
||||
define("LAN_ERROR_2", "The URL you've requested requires a correct username and password. Either you entered an incorrect username/password, or your browser doesn't support this feature.");
|
||||
@ -21,7 +22,7 @@ define("LAN_ERROR_6", "Please inform the administrator of the referring page if
|
||||
|
||||
define("LAN_ERROR_7", "Error 404 - Document Not Found");
|
||||
define("LAN_ERROR_9", "Please inform the administrator of the referring page if you think this error message has been shown by mistake.");
|
||||
define("LAN_ERROR_10", "Error 500 - Malformed Header");
|
||||
define("LAN_ERROR_10", "Error 500 - Internal server error");
|
||||
define("LAN_ERROR_11", "The server encountered an internal error or misconfiguration and was unable to complete your request");
|
||||
define("LAN_ERROR_12", "Please inform the administrator of the referring page if you think this error page has been shown by mistake.");
|
||||
define("LAN_ERROR_13", "Error - Unknown");
|
||||
|
248
error.php
248
error.php
@ -1,115 +1,159 @@
|
||||
<?php
|
||||
/*
|
||||
+ ----------------------------------------------------------------------------+
|
||||
| e107 website system
|
||||
|
|
||||
| Copyright (C) 2008-2009 e107 Inc
|
||||
| http://e107.org
|
||||
|
|
||||
|
|
||||
| Released under the terms and conditions of the
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/error.php,v $
|
||||
| $Revision$
|
||||
| $Date$
|
||||
| $Author$
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2016 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* @file
|
||||
* System error pages.
|
||||
*/
|
||||
|
||||
define("ERR_PAGE_ACTIVE", 'error');
|
||||
|
||||
//TODO - template(s)
|
||||
//We need minimal mod.
|
||||
$_E107 = array(
|
||||
'no_forceuserupdate',
|
||||
'no_online',
|
||||
'no_prunetmp',
|
||||
);
|
||||
|
||||
//We need minimal mod
|
||||
$_E107 = array('no_forceuserupdate', 'no_online', 'no_prunetmp');
|
||||
require_once("class2.php");
|
||||
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
|
||||
|
||||
//start session if required
|
||||
if(!session_id()) session_start();
|
||||
|
||||
if (!defined('PAGE_NAME')) define('PAGE_NAME','Error page');
|
||||
$errorHeader = '';
|
||||
$errorText = '';
|
||||
$errorNumber = 999;
|
||||
$errFrom = isset($_SESSION['e107_http_referer']) ? $_SESSION['e107_http_referer'] : $_SERVER['HTTP_REFERER'];
|
||||
$errReturnTo = isset($_SESSION['e107_error_return']) ? $_SESSION['e107_error_return'] : array();
|
||||
unset($_SESSION['e107_http_referer'], $_SESSION['e107_error_return']);
|
||||
|
||||
$errTo = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
||||
$errorQuery = htmlentities($_SERVER['QUERY_STRING']);
|
||||
$base_path = e_HTTP;
|
||||
if (is_numeric(e_QUERY)) $errorNumber = intval(e_QUERY);
|
||||
|
||||
switch($errorNumber)
|
||||
// Start session if required.
|
||||
if(!session_id())
|
||||
{
|
||||
case 400 :
|
||||
$errorHeader = "HTTP/1.1 400 Bad Request";
|
||||
$errorText = "<h1><img src='".e_IMAGE_ABS."generic/warning.png' alt='".LAN_ERROR_37."' /> ".LAN_ERROR_35."</h1><div class='installh'>".LAN_ERROR_36."</div><br /><div class='smalltext'>".LAN_ERROR_3."</div>
|
||||
<br /><div class='installh'>".LAN_ERROR_2."<br /><a href='{$base_path}index.php'>".LAN_ERROR_20."</a></div>";
|
||||
break;
|
||||
case 401:
|
||||
$errorHeader = "HTTP/1.1 401 Unauthorized";
|
||||
$errorText = "<h1><img src='".e_IMAGE_ABS."generic/warning.png' alt='".LAN_ERROR_37."' /> ".LAN_ERROR_1."</h1><div class='installh'>".LAN_ERROR_2."</div><br /><div class='smalltext'>".LAN_ERROR_3."</div>
|
||||
<br /><div class='installh'>".LAN_ERROR_2."<br /><a href='{$base_path}index.php'>".LAN_ERROR_20."</a></div>";
|
||||
break;
|
||||
case 403:
|
||||
$errorHeader = "HTTP/1.1 403 Forbidden";
|
||||
$errorText = "<h1><img src='".e_IMAGE_ABS."generic/warning.png' alt='".LAN_ERROR_37."' /> ".LAN_ERROR_4."</h1><div class='installh'>".LAN_ERROR_5."</div><br /><div class='smalltext'>".LAN_ERROR_6."</div>
|
||||
<br /><div class='installh'>".LAN_ERROR_2."<br /><a href='{$base_path}index.php'>".LAN_ERROR_20."</a></div>";
|
||||
break;
|
||||
case 404:
|
||||
$errorHeader = "HTTP/1.1 404 Not Found";
|
||||
$errorText = "<h1><img src='".e_IMAGE_ABS."generic/warning.png' alt='".LAN_ERROR_37."' /> ".LAN_ERROR_7."</h1>".LAN_ERROR_21.'<br />'.LAN_ERROR_9."<br /><br />";
|
||||
if (strlen($errFrom)) $errorText .= LAN_ERROR_23." <a href='{$errFrom}' rel='external'>{$errFrom}</a> ".LAN_ERROR_24." -- ".LAN_ERROR_19."<br /><br />";
|
||||
//.LAN_ERROR_23."<b>{$errTo}</b>".LAN_ERROR_24."<br /><br />" ???
|
||||
|
||||
$errorText .= "<h3>".LAN_ERROR_45."</h3>";
|
||||
if($errReturnTo)
|
||||
{
|
||||
foreach ($errReturnTo as $url => $label)
|
||||
{
|
||||
$errorText .= "<a href='{$url}'>".$label."</a><br />";
|
||||
}
|
||||
$errorText .= '<br />';
|
||||
}
|
||||
$errorText .= "<a href='{$base_path}index.php'>".LAN_ERROR_20."</a><br />";
|
||||
$errorText .= "<a href='{$base_path}search.php'>".LAN_ERROR_22."</a>";
|
||||
break;
|
||||
case 500:
|
||||
$errorHeader = "HTTP/1.1 500 Internal Server Error";
|
||||
$errorText = "<h1><img src='".e_IMAGE_ABS."generic/warning.png' alt='".LAN_ERROR_37."' /> ".LAN_ERROR_10."</h1><div class='installh'>".LAN_ERROR_11."</div><br /><div class='smalltext'>".LAN_ERROR_12."</div>
|
||||
<br /><div class='installh'>".LAN_ERROR_2."<br /><a href='{$base_path}index.php'>".LAN_ERROR_20."</a></div>";
|
||||
break;
|
||||
case 999:
|
||||
if (E107_DEBUG_LEVEL)
|
||||
{
|
||||
echo LAN_ERROR_33."<br/><pre>\n";
|
||||
print_r($_SERVER);
|
||||
print_r($_REQUEST);
|
||||
echo "\n</pre>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
header("location: ".e_HTTP."index.php");
|
||||
exit;
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
$errorText = "<h1>".LAN_ERROR_13." (".$errorQuery.")</h1><div class='installh'>".LAN_ERROR_14."</div><br /><div class='smalltext'>".LAN_ERROR_15."</div>
|
||||
<br /><div class='installh'><a href='{$base_path}index.php'>".LAN_ERROR_20."</a></div>";
|
||||
|
||||
// default:
|
||||
// $errorText = LAN_ERROR_34." e_QUERY = '".e_QUERY."'<br/><a href='{$base_path}index.php'>".LAN_ERROR_20."</a>";
|
||||
// break;
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Include language file.
|
||||
e107::coreLan('error');
|
||||
|
||||
|
||||
/**
|
||||
* Class error_front.
|
||||
*/
|
||||
class error_front
|
||||
{
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
private $errorNumber;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if(is_numeric(e_QUERY))
|
||||
{
|
||||
$this->errorNumber = intval(e_QUERY);
|
||||
}
|
||||
|
||||
$this->renderErrorPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the error page.
|
||||
*/
|
||||
public function renderErrorPage()
|
||||
{
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
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>';
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($errorHeader) header($errorHeader);
|
||||
|
||||
require_once(HEADERF);
|
||||
|
||||
e107::getRender()->tablerender(PAGE_NAME, $errorText);
|
||||
new error_front();
|
||||
require_once(FOOTERF);
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user