mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 21:27:25 +02:00
Error page improvement: template support.
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
# Custom error pages for php scripts only
|
# Custom error pages for php scripts only
|
||||||
<FilesMatch \.php$>
|
<FilesMatch \.php$>
|
||||||
ErrorDocument 400 /error.php?400
|
ErrorDocument 400 /error.php?400
|
||||||
ErrorDocument 401 /error.php?401
|
ErrorDocument 401 /error.php?401
|
||||||
ErrorDocument 403 /error.php?403
|
ErrorDocument 403 /error.php?403
|
||||||
ErrorDocument 404 /error.php?404
|
|
||||||
ErrorDocument 500 /error.php?500
|
ErrorDocument 500 /error.php?500
|
||||||
</FilesMatch>
|
</FilesMatch>
|
||||||
|
|
||||||
|
@@ -1,102 +1,104 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
|
/**
|
||||||
* e107 website system
|
* 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
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
* System error controller
|
* @file
|
||||||
*
|
* System error controller.
|
||||||
* $URL$
|
*/
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
/**
|
||||||
|
* Class core_system_error_controller.
|
||||||
|
*/
|
||||||
class core_system_error_controller extends eController
|
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');
|
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.
|
* Alias for "Error 403".
|
||||||
* @param $template
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
private function updateTemplate($template)
|
|
||||||
{
|
|
||||||
$srch = array('{siteUrl}','{searchUrl}');
|
|
||||||
$repl = array('{SITEURL}','{SEARCHURL}');
|
|
||||||
|
|
||||||
return str_replace($srch,$repl,$template);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Alias
|
|
||||||
*/
|
*/
|
||||||
public function action403()
|
public function action403()
|
||||||
{
|
{
|
||||||
$this->_forward('forbidden');
|
$this->_forward('forbidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for "Error 404".
|
||||||
|
*/
|
||||||
|
public function action404()
|
||||||
|
{
|
||||||
|
$this->_forward('notfound');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error 403.
|
||||||
|
*/
|
||||||
public function actionForbidden()
|
public function actionForbidden()
|
||||||
{
|
{
|
||||||
$this->getResponse()
|
$response = $this->getResponse();
|
||||||
->setRenderMod('error403')
|
$response->setRenderMod('error403');
|
||||||
->addHeader('HTTP/1.0 403 Forbidden');
|
$response->addHeader('HTTP/1.0 403 Forbidden');
|
||||||
|
|
||||||
$this->addTitle(LAN_ERROR_7);
|
$tp = e107::getParser();
|
||||||
$template = e107::getCoreTemplate('error', 403);
|
$tpl = e107::getCoreTemplate('error', '403');
|
||||||
|
$sc = e107::getScBatch('error');
|
||||||
$vars = new e_vars(array(
|
|
||||||
'SITEURL' => SITEURL,
|
$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(
|
$body = $tp->parseTemplate($tpl, true, $sc);
|
||||||
$this->updateTemplate($template['start']).
|
|
||||||
$this->updateTemplate($template['body']).
|
|
||||||
$this->updateTemplate($template['end'])
|
|
||||||
, true, null, $vars);
|
|
||||||
|
|
||||||
$this->addBody($body);
|
$this->addBody($body);
|
||||||
}
|
}
|
||||||
|
|
||||||
function actionHelloWorld()
|
/**
|
||||||
|
* Error 404.
|
||||||
|
*/
|
||||||
|
public function actionNotfound()
|
||||||
{
|
{
|
||||||
//$this->addTitle('Hello!');
|
$response = $this->getResponse();
|
||||||
//echo 'Hello World';
|
$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
|
<?php
|
||||||
/*
|
|
||||||
|
/**
|
||||||
* e107 website system
|
* 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
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
* Error Templates
|
* @file
|
||||||
*
|
* Error templates.
|
||||||
* $Id: $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
if(!defined('e107_INIT'))
|
||||||
*
|
{
|
||||||
* @package e107
|
exit;
|
||||||
* @subpackage e107_templates
|
}
|
||||||
* @version $Id$;
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
|
||||||
|
|
||||||
$ERROR_TEMPLATE = array();
|
$ERROR_TEMPLATE = array();
|
||||||
|
|
||||||
$ERROR_TEMPLATE['404']['start'] = '<div class="error-404 alert-danger">';
|
/**
|
||||||
$ERROR_TEMPLATE['404']['body'] = '
|
* 400 Bad Request.
|
||||||
<h3><i class="icon-exclamation-sign" title="'.LAN_ERROR_45.'"></i> '.LAN_ERROR_45.'</h3>
|
*/
|
||||||
<p>
|
$ERROR_TEMPLATE['400'] = '
|
||||||
'.LAN_ERROR_21.'<br />'.LAN_ERROR_9.'
|
<h1 class="text-center">
|
||||||
</p>
|
<strong>{ERROR_TITLE}</strong>
|
||||||
<a href="{SITEURL}">'.LAN_ERROR_20.'</a><br />
|
</h1>
|
||||||
<a href="{SEARCHURL}">'.LAN_ERROR_22.'</a>
|
<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">';
|
* 401 Unauthorized.
|
||||||
$ERROR_TEMPLATE['403']['body'] = '
|
*/
|
||||||
<h3><i class="icon-exclamation-sign" title="'.LAN_ERROR_4.'"></i> '.LAN_ERROR_4.'</h3>
|
$ERROR_TEMPLATE['401'] = '
|
||||||
<p>
|
<h1 class="text-center">
|
||||||
'.LAN_ERROR_5.'<br />'.LAN_ERROR_6.'<br /><br />'.LAN_ERROR_2.'
|
<strong>{ERROR_TITLE}</strong>
|
||||||
</p>
|
</h1>
|
||||||
<a href="{SITEURL}">'.LAN_ERROR_20.'</a><br />
|
<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
|
'name' => LAN_EURL_CORE_SYSTEM, // Module name
|
||||||
'label' => LAN_EURL_SYSTEM_REWRITE_LABEL, // Current profile name
|
'label' => LAN_EURL_SYSTEM_REWRITE_LABEL, // Current profile name
|
||||||
'description' => LAN_EURL_SYSTEM_REWRITE_DESCR, //
|
'description' => LAN_EURL_SYSTEM_REWRITE_DESCR, //
|
||||||
'examples' => array("{SITEURL}system/error404")
|
'examples' => array("{SITEURL}system/error/404")
|
||||||
),
|
),
|
||||||
'form' => array(), // Under construction - additional configuration options
|
'form' => array(), // Under construction - additional configuration options
|
||||||
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
|
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
|
||||||
|
@@ -3036,11 +3036,26 @@ class e107
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple redirect method for developers.
|
* 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("PAGE_NAME", "Error");
|
||||||
|
define("LAN_ERROR_TITLE", "Oops!");
|
||||||
|
|
||||||
define("LAN_ERROR_1", "Error 401 - Authentication Failed");
|
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.");
|
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_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_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_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_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");
|
define("LAN_ERROR_13", "Error - Unknown");
|
||||||
|
248
error.php
248
error.php
@@ -1,115 +1,159 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
+ ----------------------------------------------------------------------------+
|
* e107 website system
|
||||||
| e107 website system
|
*
|
||||||
|
|
* Copyright (C) 2008-2016 e107 Inc (e107.org)
|
||||||
| Copyright (C) 2008-2009 e107 Inc
|
* Released under the terms and conditions of the
|
||||||
| http://e107.org
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
|
*
|
||||||
|
|
* @file
|
||||||
| Released under the terms and conditions of the
|
* System error pages.
|
||||||
| GNU General Public License (http://gnu.org).
|
*/
|
||||||
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/error.php,v $
|
|
||||||
| $Revision$
|
|
||||||
| $Date$
|
|
||||||
| $Author$
|
|
||||||
+----------------------------------------------------------------------------+
|
|
||||||
*/
|
|
||||||
|
|
||||||
define("ERR_PAGE_ACTIVE", 'error');
|
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");
|
require_once("class2.php");
|
||||||
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
|
|
||||||
|
|
||||||
//start session if required
|
// Start session if required.
|
||||||
if(!session_id()) session_start();
|
if(!session_id())
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
case 400 :
|
session_start();
|
||||||
$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>";
|
// Include language file.
|
||||||
break;
|
e107::coreLan('error');
|
||||||
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>";
|
* Class error_front.
|
||||||
break;
|
*/
|
||||||
case 403:
|
class error_front
|
||||||
$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;
|
* @var
|
||||||
case 404:
|
*/
|
||||||
$errorHeader = "HTTP/1.1 404 Not Found";
|
private $errorNumber;
|
||||||
$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 />" ???
|
* Constructor.
|
||||||
|
*/
|
||||||
$errorText .= "<h3>".LAN_ERROR_45."</h3>";
|
public function __construct()
|
||||||
if($errReturnTo)
|
{
|
||||||
{
|
if(is_numeric(e_QUERY))
|
||||||
foreach ($errReturnTo as $url => $label)
|
{
|
||||||
{
|
$this->errorNumber = intval(e_QUERY);
|
||||||
$errorText .= "<a href='{$url}'>".$label."</a><br />";
|
}
|
||||||
}
|
|
||||||
$errorText .= '<br />';
|
$this->renderErrorPage();
|
||||||
}
|
}
|
||||||
$errorText .= "<a href='{$base_path}index.php'>".LAN_ERROR_20."</a><br />";
|
|
||||||
$errorText .= "<a href='{$base_path}search.php'>".LAN_ERROR_22."</a>";
|
/**
|
||||||
break;
|
* Renders the error page.
|
||||||
case 500:
|
*/
|
||||||
$errorHeader = "HTTP/1.1 500 Internal Server Error";
|
public function renderErrorPage()
|
||||||
$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>";
|
switch($this->errorNumber)
|
||||||
break;
|
{
|
||||||
case 999:
|
case 400:
|
||||||
if (E107_DEBUG_LEVEL)
|
header('HTTP/1.1 400 Bad Request');
|
||||||
{
|
|
||||||
echo LAN_ERROR_33."<br/><pre>\n";
|
$subtitle = LAN_ERROR_35; // Error 400 - Bad Request
|
||||||
print_r($_SERVER);
|
$caption = LAN_ERROR_45;
|
||||||
print_r($_REQUEST);
|
$content = LAN_ERROR_36 . '<br/>' . LAN_ERROR_3;
|
||||||
echo "\n</pre>\n";
|
break;
|
||||||
}
|
|
||||||
else
|
case 401:
|
||||||
{
|
header('HTTP/1.1 401 Unauthorized');
|
||||||
header("location: ".e_HTTP."index.php");
|
|
||||||
exit;
|
$subtitle = LAN_ERROR_1; // Error 401 - Authentication Failed
|
||||||
}
|
$caption = LAN_ERROR_45;
|
||||||
break;
|
$content = LAN_ERROR_2 . '<br/>' . LAN_ERROR_3;
|
||||||
|
break;
|
||||||
default :
|
|
||||||
$errorText = "<h1>".LAN_ERROR_13." (".$errorQuery.")</h1><div class='installh'>".LAN_ERROR_14."</div><br /><div class='smalltext'>".LAN_ERROR_15."</div>
|
case 403:
|
||||||
<br /><div class='installh'><a href='{$base_path}index.php'>".LAN_ERROR_20."</a></div>";
|
header('HTTP/1.1 403 Forbidden');
|
||||||
|
|
||||||
// default:
|
$subtitle = LAN_ERROR_4; // Error 403 - Access forbidden
|
||||||
// $errorText = LAN_ERROR_34." e_QUERY = '".e_QUERY."'<br/><a href='{$base_path}index.php'>".LAN_ERROR_20."</a>";
|
$caption = LAN_ERROR_45;
|
||||||
// break;
|
$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);
|
require_once(HEADERF);
|
||||||
|
new error_front();
|
||||||
e107::getRender()->tablerender(PAGE_NAME, $errorText);
|
|
||||||
require_once(FOOTERF);
|
require_once(FOOTERF);
|
||||||
?>
|
|
Reference in New Issue
Block a user