Integrated Error Messages

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in the Customisations Database.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTICE: This forum is only for the announcement of new releases and/or updates of MODs. Any MOD support should be obtained through the Customisations Database in the support area designated for each MOD.

A direct link to support for each MOD is in the first post of the respective topic.
g unit
Registered User
Posts: 28
Joined: Wed Jun 27, 2007 3:16 am
Location: Pennsylvania, USA
Contact:

Re: Integrated Error Messages

Post by g unit »

Very nice mod. One question, though... I have the phpBB3 Portal installed, and I've created and index.php file in the root directory that pulls everything from the overall header, etc., etc... so the fact that it's running that file off the forums is transparent to the user. My site structure looks like this:

root/index.php
root/forums/index.php

When I installed this to the forums/ index, it works just fine, but it won't work for errors in the root directory. It just gives me the plain ol' error page. I hope that makes sense. I even put a copy of .htaccess in there, didn't work. I tried putting error.php in the root directory and pointing the .htaccess at that, and it wouldn't work... any ideas?

Here is My Site
The Pub Playin Killas is a DOD:S and COD:WaW Team.
User avatar
Muad''Dib
Registered User
Posts: 311
Joined: Tue Jun 12, 2007 6:20 pm
Contact:

Re: Integrated Error Messages

Post by Muad''Dib »

AllGo wrote:Fixed error.php to set the http error code correctly (for better behaviour with browsers and lots of crawler/search engines):

Code: Select all

<?php
/** 
*
* @package phpBB3
* @version $Id: $
* @copyright (c) 2008 Francis W. Fisher (Phantom) http://radoncube.com/
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/error');

$base_url = generate_board_url() . '/';

$template->assign_vars(array(
	'S_ERROR_PAGE'	=> true,
	'U_FORUM_BASE'	=> $base_url,
));

//set title of error page
$msg_title = $user->lang['ERROR_TITLE'];

$mode = request_var('mode', 0);

function HTTPStatus($num) {
  
   static $http = array (
       '100' => "HTTP/1.1 100 Continue",
       '101' => "HTTP/1.1 101 Switching Protocols",
       '200' => "HTTP/1.1 200 OK",
       '201' => "HTTP/1.1 201 Created",
       '202' => "HTTP/1.1 202 Accepted",
       '203' => "HTTP/1.1 203 Non-Authoritative Information",
       '204' => "HTTP/1.1 204 No Content",
       '205' => "HTTP/1.1 205 Reset Content",
       '206' => "HTTP/1.1 206 Partial Content",
       '300' => "HTTP/1.1 300 Multiple Choices",
       '301' => "HTTP/1.1 301 Moved Permanently",
       '302' => "HTTP/1.1 302 Found",
       '303' => "HTTP/1.1 303 See Other",
       '304' => "HTTP/1.1 304 Not Modified",
       '305' => "HTTP/1.1 305 Use Proxy",
       '307' => "HTTP/1.1 307 Temporary Redirect",
       '400' => "HTTP/1.1 400 Bad Request",
       '401' => "HTTP/1.1 401 Unauthorized",
       '402' => "HTTP/1.1 402 Payment Required",
       '403' => "HTTP/1.1 403 Forbidden",
       '404' => "HTTP/1.1 404 Not Found",
       '405' => "HTTP/1.1 405 Method Not Allowed",
       '406' => "HTTP/1.1 406 Not Acceptable",
       '407' => "HTTP/1.1 407 Proxy Authentication Required",
       '408' => "HTTP/1.1 408 Request Time-out",
       '409' => "HTTP/1.1 409 Conflict",
       '410' => "HTTP/1.1 410 Gone",
       '411' => "HTTP/1.1 411 Length Required",
       '412' => "HTTP/1.1 412 Precondition Failed",
       '413' => "HTTP/1.1 413 Request Entity Too Large",
       '414' => "HTTP/1.1 414 Request-URI Too Large",
       '415' => "HTTP/1.1 415 Unsupported Media Type",
       '416' => "HTTP/1.1 416 Requested range not satisfiable",
       '417' => "HTTP/1.1 417 Expectation Failed",
       '500' => "HTTP/1.1 500 Internal Server Error",
       '501' => "HTTP/1.1 501 Not Implemented",
       '502' => "HTTP/1.1 502 Bad Gateway",
       '503' => "HTTP/1.1 503 Service Unavailable",
       '504' => "HTTP/1.1 504 Gateway Time-out"       
   );
  
   header($http[$num]);
}
HTTPStatus($mode);
meta_refresh(5, $base_url);

switch ($mode)
{
	case '400':
   	trigger_error('ERROR_BAD_REQUEST');
	break;
	case '401':
		trigger_error('ERROR_AUTH_REQUIRED');
	break;
	case '403':
		trigger_error('ERROR_FORBIDDEN');
	break;
	case '404':
		trigger_error('ERROR_NOT_FOUND');
	break;
	case '500':
		trigger_error('ERROR_INT_SERVER');
	break;
	default:
		trigger_error('ERROR_UNKNOWN');
	break;
}

?>
Is:

Code: Select all

function HTTPStatus($num) {
necessary.. I tried to access an error page and analyze the headers sent from the server both with and without that function and still got the correct headers.
User avatar
GoBieN
Registered User
Posts: 546
Joined: Fri Mar 05, 2004 5:22 pm
Location: Belgium
Contact:

Re: Integrated Error Messages

Post by GoBieN »

Muad''Dib wrote:
AllGo wrote:Fixed error.php to set the http error code correctly (for better behaviour with browsers and lots of crawler/search engines):

Code: Select all

<?php
/** 
*
* @package phpBB3
* @version $Id: $
* @copyright (c) 2008 Francis W. Fisher (Phantom) http://radoncube.com/
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/error');

$base_url = generate_board_url() . '/';

$template->assign_vars(array(
	'S_ERROR_PAGE'	=> true,
	'U_FORUM_BASE'	=> $base_url,
));

//set title of error page
$msg_title = $user->lang['ERROR_TITLE'];

$mode = request_var('mode', 0);

function HTTPStatus($num) {
  
   static $http = array (
       '100' => "HTTP/1.1 100 Continue",
       '101' => "HTTP/1.1 101 Switching Protocols",
       '200' => "HTTP/1.1 200 OK",
       '201' => "HTTP/1.1 201 Created",
       '202' => "HTTP/1.1 202 Accepted",
       '203' => "HTTP/1.1 203 Non-Authoritative Information",
       '204' => "HTTP/1.1 204 No Content",
       '205' => "HTTP/1.1 205 Reset Content",
       '206' => "HTTP/1.1 206 Partial Content",
       '300' => "HTTP/1.1 300 Multiple Choices",
       '301' => "HTTP/1.1 301 Moved Permanently",
       '302' => "HTTP/1.1 302 Found",
       '303' => "HTTP/1.1 303 See Other",
       '304' => "HTTP/1.1 304 Not Modified",
       '305' => "HTTP/1.1 305 Use Proxy",
       '307' => "HTTP/1.1 307 Temporary Redirect",
       '400' => "HTTP/1.1 400 Bad Request",
       '401' => "HTTP/1.1 401 Unauthorized",
       '402' => "HTTP/1.1 402 Payment Required",
       '403' => "HTTP/1.1 403 Forbidden",
       '404' => "HTTP/1.1 404 Not Found",
       '405' => "HTTP/1.1 405 Method Not Allowed",
       '406' => "HTTP/1.1 406 Not Acceptable",
       '407' => "HTTP/1.1 407 Proxy Authentication Required",
       '408' => "HTTP/1.1 408 Request Time-out",
       '409' => "HTTP/1.1 409 Conflict",
       '410' => "HTTP/1.1 410 Gone",
       '411' => "HTTP/1.1 411 Length Required",
       '412' => "HTTP/1.1 412 Precondition Failed",
       '413' => "HTTP/1.1 413 Request Entity Too Large",
       '414' => "HTTP/1.1 414 Request-URI Too Large",
       '415' => "HTTP/1.1 415 Unsupported Media Type",
       '416' => "HTTP/1.1 416 Requested range not satisfiable",
       '417' => "HTTP/1.1 417 Expectation Failed",
       '500' => "HTTP/1.1 500 Internal Server Error",
       '501' => "HTTP/1.1 501 Not Implemented",
       '502' => "HTTP/1.1 502 Bad Gateway",
       '503' => "HTTP/1.1 503 Service Unavailable",
       '504' => "HTTP/1.1 504 Gateway Time-out"       
   );
  
   header($http[$num]);
}
HTTPStatus($mode);
meta_refresh(5, $base_url);

switch ($mode)
{
	case '400':
   	trigger_error('ERROR_BAD_REQUEST');
	break;
	case '401':
		trigger_error('ERROR_AUTH_REQUIRED');
	break;
	case '403':
		trigger_error('ERROR_FORBIDDEN');
	break;
	case '404':
		trigger_error('ERROR_NOT_FOUND');
	break;
	case '500':
		trigger_error('ERROR_INT_SERVER');
	break;
	default:
		trigger_error('ERROR_UNKNOWN');
	break;
}

?>
Is:

Code: Select all

function HTTPStatus($num) {
necessary.. I tried to access an error page and analyze the headers sent from the server both with and without that function and still got the correct headers.
When you browse to an non-existing page, the webserver send the correct headers (404), it's normally not needed to put in the script. (see also a few pages back in this thread)
User avatar
DoYouSpeakWak
Registered User
Posts: 2310
Joined: Fri Jul 25, 2008 1:32 pm
Location: Island of Wak-Wak
Contact:

Re: Integrated Error Messages

Post by DoYouSpeakWak »

This doesnt work properly.

Iwe installed it and it works fine when pointing it at /error.php?mode=404, but if i try /thispage_do_not_exits.php or /nonexistingfolder/ i just get the normal apache error.

I tryed the mod rewrite suggested earlier but my host doesnt allow mod rewrites. So how do i get this working ?

Server has:
PHP: 5.2.6
Mysql 5.0.67-community
Test done on localhost. Not on our live board in signature

DYSW
Whatever you share comes back. Support the phpBB Communities
My Validated and Released Modifications
Offering paid services. 10+ years of experience with phpBB3 and as System Administrator.
User avatar
GoBieN
Registered User
Posts: 546
Joined: Fri Mar 05, 2004 5:22 pm
Location: Belgium
Contact:

Re: Integrated Error Messages

Post by GoBieN »

DoYouSpeakWak wrote:This doesnt work properly.

Iwe installed it and it works fine when pointing it at /error.php?mode=404, but if i try /thispage_do_not_exits.php or /nonexistingfolder/ i just get the normal apache error.

I tryed the mod rewrite suggested earlier but my host doesnt allow mod rewrites. So how do i get this working ?

Server has:
PHP: 5.2.6
Mysql 5.0.67-community
Test done on localhost. Not on our live board in signature

DYSW
This works very good, it's not the mods fault if your host has disabled htaccess settings.
User avatar
DoYouSpeakWak
Registered User
Posts: 2310
Joined: Fri Jul 25, 2008 1:32 pm
Location: Island of Wak-Wak
Contact:

Re: Integrated Error Messages

Post by DoYouSpeakWak »

The modrewrite is not a part of the mod and nobody can expect everybody to have modrewrite.

I did everything that was listed in the xml. If this mod doesnt work without modrewrites please specify it at the first post so nobody waste there time on it.

DYSW
Whatever you share comes back. Support the phpBB Communities
My Validated and Released Modifications
Offering paid services. 10+ years of experience with phpBB3 and as System Administrator.
User avatar
A_O_C
Registered User
Posts: 2383
Joined: Sun Jul 01, 2007 11:26 pm
Location: phpbb_

Re: Integrated Error Messages

Post by A_O_C »

this MOD works fine (my host allows .htaccess), even if i browse to
DoYouSpeakWak wrote:/thispage_do_not_exits.php or /nonexistingfolder/
this must be a problem with your host DoYouSpeakWak. ;)
User avatar
DoYouSpeakWak
Registered User
Posts: 2310
Joined: Fri Jul 25, 2008 1:32 pm
Location: Island of Wak-Wak
Contact:

Re: Integrated Error Messages

Post by DoYouSpeakWak »

My host and localserver allow htaccess and the changes done to /htaccess according to the mod worked fine. But few hosts at least around here allow mod rewrites as this one below. (suggested by someone earlier)

RewriteEngine On
Rewritecond %{REQUEST_FILENAME} !-f
RewriteRule \.php$ /nonexistentfile

Does this mod work without this mod rewrite for anyone ?

DYSW
Whatever you share comes back. Support the phpBB Communities
My Validated and Released Modifications
Offering paid services. 10+ years of experience with phpBB3 and as System Administrator.
User avatar
A_O_C
Registered User
Posts: 2383
Joined: Sun Jul 01, 2007 11:26 pm
Location: phpbb_

Re: Integrated Error Messages

Post by A_O_C »

correct...
User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21292
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: Integrated Error Messages

Post by RMcGirr83 »

DoYouSpeakWak wrote: RewriteEngine On
Rewritecond %{REQUEST_FILENAME} !-f
RewriteRule \.php$ /nonexistentfile

Does this mod work without this mod rewrite for anyone ?

DYSW
Yep, works for me without that.
Appreciate the extensions/mods/support then buy me a beerImage
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
User avatar
GoBieN
Registered User
Posts: 546
Joined: Fri Mar 05, 2004 5:22 pm
Location: Belgium
Contact:

Re: Integrated Error Messages

Post by GoBieN »

DoYouSpeakWak wrote:My host and localserver allow htaccess and the changes done to /htaccess according to the mod worked fine. But few hosts at least around here allow mod rewrites as this one below. (suggested by someone earlier)

RewriteEngine On
Rewritecond %{REQUEST_FILENAME} !-f
RewriteRule \.php$ /nonexistentfile

Does this mod work without this mod rewrite for anyone ?

DYSW
This code is not part of the original mod and is only for people that cannot specify custom errorpages.
I only need this in my htaccess:

Code: Select all

ErrorDocument 400 /phpBB3/error.php?mode=400
ErrorDocument 401 /phpBB3/error.php?mode=401
ErrorDocument 403 /phpBB3/error.php?mode=403
ErrorDocument 404 /phpBB3/error.php?mode=404
ErrorDocument 500 /phpBB3/error.php?mode=500
User avatar
DoYouSpeakWak
Registered User
Posts: 2310
Joined: Fri Jul 25, 2008 1:32 pm
Location: Island of Wak-Wak
Contact:

Re: Integrated Error Messages

Post by DoYouSpeakWak »

Mmm i got the same and its not working. Ill test all the file edtis etc for a 5 time. Something might come up. Thx for confirming it works without the mod rewrite
Whatever you share comes back. Support the phpBB Communities
My Validated and Released Modifications
Offering paid services. 10+ years of experience with phpBB3 and as System Administrator.
User avatar
Spider M. Mann
Registered User
Posts: 73
Joined: Sat Dec 01, 2007 3:06 pm

Re: Integrated Error Messages

Post by Spider M. Mann »

GoBieN wrote:This code is not part of the original mod and is only for people that cannot specify custom errorpages.
That is half correct. The specified code is not part of the original mod and just a workaround for a known issue when using php5:
Spider M. Mann wrote:404 (not found) condition for php scripts does not go to 404 error handling. You will instead get this error message:
No input file specified.
The !-f in the rewrite condition checks to see if the requested .php location exists and is a real file. If not, the rewrite rule will direct to the chosen error document.

@DoYouSpeakWak, I'm not quite sure what to tell you if you are having the same issue and cannot use the rewrite rule. Perhaps your host is susceptible to begging. ;) Or maybe they can help to find another workaround.

I can tell you that the mod works fine without the rewrite rule.
User avatar
Nikikin
Registered User
Posts: 2
Joined: Wed Dec 07, 2005 8:18 pm
Location: Poland, Kielce
Contact:

Re: Integrated Error Messages

Post by Nikikin »

Here is the Polish Translation:

Code: Select all

<?php
/**
*
* groups [Polish]
*
* @package language
* @version $Id: $
* @copyright (c) 2008 Francis W. Fisher (Phantom) http://radoncube.com/ 
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
* @translate by Nikikin
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

if (empty($lang) || !is_array($lang))
{
	$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

$lang = array_merge($lang, array(
	'ERROR_TITLE'				=> 'Błąd',
	'ERROR_BAD_REQUEST'			=> 'Błąd 400: Nieprawidłowe Żądanie',
	'ERROR_AUTH_REQUIRED'		=> 'Błąd 401: Bark Autoryzacji',
	'ERROR_FORBIDDEN'			=> 'Błąd 403: Zakaz Dostępu',
	'ERROR_NOT_FOUND'			=> 'Błąd 404: Pliku Nie Znaleziono',
	'ERROR_INT_SERVER'			=> 'Błąd 500: Wewnętrzny Błąd Serwera',
	'ERROR_UNKNOWN'				=> 'Nieznany Błąd Serwera',
));
?>
And for download:

[The extension rar has been deactivated and can no longer be displayed.]

psych0569fj
Registered User
Posts: 29
Joined: Fri Feb 08, 2008 3:28 pm

Re: Integrated Error Messages

Post by psych0569fj »

Code: Select all

       case '404':
          trigger_error('ERROR_NOT_FOUND');
in error.php and replace ERROR_NOT_FOUND with the image that you want eg. <img src="error.png" />. Be sure to keep the single quotes.
Is there a way to replace the trigger_error so it displays the original 'ERROR_NOT_FOUND' message as well as some additional info/code?

For example:

Error 404: File Not Found
Due to a recent forum upgrade, many of your links/bookmarks have changed. Please visit [domain.tld].


Also, is there a way to have the new error pages apply to the site and all subdirectories? (like root/adm/YYY.XXX and root/images/YYY.XXX)
Locked

Return to “[3.0.x] MOD Database Releases”