Credits to css-tricks for some of the code.
Information:
Someone needed it so I figured it would be useful to a ton of more users, note this may not handle all errors but you can add to it with ease. I just threw this together so I'm sorry for any confusion.
Step 1: Upload the error.php file to our MyBB root folder, you can change the name if you want.
Step 2: Create a global template in your AdminCP named "errors" and paste/save the following code.
Step 3: You will need to use .htaccess to specify and handle the error documents. Expand as needed...
Preview:
https://i.imgur.com/ioats22.png
Information:
Someone needed it so I figured it would be useful to a ton of more users, note this may not handle all errors but you can add to it with ease. I just threw this together so I'm sorry for any confusion.
Step 1: Upload the error.php file to our MyBB root folder, you can change the name if you want.
<?php
define('IN_MYBB', 1);
require_once('global.php');
$status = $_SERVER['REDIRECT_STATUS'];
$codes = array(
400 => array('400 Bad Request', 'The request cannot be fulfilled due to bad syntax.'),
401 => array('401 Login Error', 'It appears that the password and/or user-name you entered was incorrect.'),
403 => array('403 Forbidden', 'Sorry, employees and staff only.'),
404 => array('404 Missing', 'We\'re sorry, but the page you\'re looking for is missing, hiding, or maybe it moved somewhere else and forgot to tell you.'),
405 => array('405 Method Not Allowed', 'The method specified in the Request-Line is not allowed for the specified resource.'),
408 => array('408 Request Timeout', 'Your browser failed to send a request in the time allowed by the server.'),
414 => array('414 URL To Long', 'The URL you entered is longer than the maximum length.'),
500 => array('500 Internal Server Error', 'The request was unsuccessful due to an unexpected condition encountered by the server.'),
502 => array('502 Bad Gateway', 'The server received an invalid response from the upstream server while trying to fulfill the request.'),
504 => array('504 Gateway Timeout', 'The upstream server failed to send a request in the time allowed by the server.'),
);
$errortitle = $codes[$status][0];
$message = $codes[$status][1];
// Message that is displayed if an unknown error occurs or if they're viewing the error page directly.
if( $errortitle == false ) {
$errortitle = "Unknown Error";
$message = "An unknown error has occurred.";
}
add_breadcrumb($errortitle, "error.php");
eval("\$html = \"".$templates->get("errors")."\";");
output_page($html);
?>
Step 2: Create a global template in your AdminCP named "errors" and paste/save the following code.
<html>
<head>
<title>{$mybb->settings['bbname']} - Error</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="0" cellpadding="4" class="tborder">
<tbody>
<tr>
<td class="thead" colspan="1"><strong>{$errortitle}</strong></td>
</tr>
<tr>
<td class="trow1">{$message}</td>
</tr>
</tbody>
</table>
{$footer}
</body>
</html>
Step 3: You will need to use .htaccess to specify and handle the error documents. Expand as needed...
ErrorDocument 400 /error.php
ErrorDocument 401 /error.php
ErrorDocument 403 /error.php
ErrorDocument 404 /error.php
ErrorDocument 405 /error.php
ErrorDocument 408 /error.php
ErrorDocument 414 /error.php
ErrorDocument 500 /error.php
ErrorDocument 502 /error.php
ErrorDocument 504 /error.php
Preview:
https://i.imgur.com/ioats22.png