L
ler
Гость
Создаем в корне error.php
Создаем templates/default/error.tpl
Добавляем в конец .htaccess
Добавляем в language/lang_russian/lang_main.php
Добавляем в language/lang_english/lang_main.php
Картинку кидаем в images/404.png
Для других ошибок кидайте изображения в эту же папку с соответсвующими именами 410.png 500.png итд
PHP:
<?php
define('IN_PHPBB', true);
define('BB_ROOT', './');
require(BB_ROOT .'common.php');
// Start session management
$user->session_start();
$status = (int)$_SERVER['REDIRECT_STATUS'];
//print_r($status);
$codes = array(
400 => array($lang['HTTP_ERRORS'][400][0], $lang['HTTP_ERRORS'][400][1]),
403 => array($lang['HTTP_ERRORS'][403][0], $lang['HTTP_ERRORS'][403][1]),
404 => array($lang['HTTP_ERRORS'][404][0], $lang['HTTP_ERRORS'][404][1]),
405 => array($lang['HTTP_ERRORS'][405][0], $lang['HTTP_ERRORS'][405][1]),
408 => array($lang['HTTP_ERRORS'][408][0], $lang['HTTP_ERRORS'][408][1]),
410 => array($lang['HTTP_ERRORS'][410][0], $lang['HTTP_ERRORS'][410][1]),
500 => array($lang['HTTP_ERRORS'][500][0], $lang['HTTP_ERRORS'][500][1]),
502 => array($lang['HTTP_ERRORS'][502][0], $lang['HTTP_ERRORS'][502][1]),
503 => array($lang['HTTP_ERRORS'][503][0], $lang['HTTP_ERRORS'][503][1]),
504 => array($lang['HTTP_ERRORS'][504][0], $lang['HTTP_ERRORS'][504][1]),
);
$title = $codes[$status][0];
$message = $codes[$status][1];
if ($title == false || strlen($status) != 3)
{
$message = $lang['HTTP_ERRORS']['MESSAGE'];
}
//var_dump($lang['HTTP_ERRORS']);
$template->assign_vars(array(
'MESSAGE' => $message,
'PAGE_TITLE' => "{$lang['ERROR']} $title",
'IMG' => ($status AND file_exists("./images/".$status.".png")) ? '/images/'.$status.'.png' : '',
));
print_page('error.tpl');
Создаем templates/default/error.tpl
HTML:
<p class="nav"><a href="{U_INDEX}">{T_INDEX}</a></p>
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
<tr>
<th>{PAGE_TITLE}</th>
</tr>
<tr>
<td class="row1" align="center">
<span class="gen">
<p>{MESSAGE}</p>
<!-- IF IMG -->
<hr />
<img src="{IMG}" />
<!-- ENDIF -->
</span>
</td>
</tr>
</table>
<div class="bottom_info">
<div class="spacer_4"></div>
<div id="timezone">
<p>{LAST_VISIT_DATE}</p>
<p>{CURRENT_TIME}</p>
<p>{S_TIMEZONE}</p>
</div>
<div class="clear"></div>
</div>
Добавляем в конец .htaccess
Код:
ErrorDocument 400 /error.php
ErrorDocument 403 /error.php
ErrorDocument 404 /error.php
ErrorDocument 405 /error.php
ErrorDocument 408 /error.php
ErrorDocument 410 /error.php
ErrorDocument 500 /error.php
ErrorDocument 502 /error.php
ErrorDocument 503 /error.php
ErrorDocument 504 /error.php
Добавляем в language/lang_russian/lang_main.php
Код:
$lang['HTTP_ERRORS']['MESSAGE']= 'Неправильный код HTTP ошибки';
$lang['HTTP_ERRORS'] = array(
400 => array('400 Плохой запрос!', 'Запрос не может быть обработан из-за синтаксической ошибки.'),
403 => array('403 Запрещено!', 'Сервер отказывает в выполнении вашего запроса.'),
404 => array('404 Не найдено!', 'Запрашиваемая страница не найдена на сервере.'),
405 => array('405 Метод не допускается!', 'Указанный в запросе метод не допускается для заданного ресурса.'),
408 => array('408 Время ожидания истекло!', 'Ваш браузер не отправил информацию на сервер за отведенное время.'),
410 => array('410 Документ удален', 'Документ существовал ранее, но умышленно удален навсегда.'),
500 => array('500 Внутренняя ошибка сервера!', 'Запрос не может быть обработан из-за внутренней ошибки сервера.'),
502 => array('502 Плохой шлюз!', 'Сервер получил неправильный ответ при попытке передачи запроса.'),
503 => array('503 Сервис недоступен!', 'Сервер временно не имеет возможности обрабатывать запросы по техническим причинам.'),
504 => array('504 Истекло время ожидания шлюза!', 'Вышестоящий сервер не ответил за установленное время.'),
);
Добавляем в language/lang_english/lang_main.php
Код:
$lang['HTTP_ERRORS']['MESSAGE']= 'Wrong code of HTTP Error';
$lang['HTTP_ERRORS'] = array(
400 => array('400 Bad Request!', 'The request cannot be fulfilled due to bad syntax.'),
403 => array('403 Forbidden!', 'The request was a valid request, but the server is refusing to respond to it. Unlike a 401 Unauthorized response, authenticating will make no difference. On servers where authentication is required, this commonly means that the provided credentials were successfully authenticated but that the credentials still do not grant the client permission to access the resource (e.g. a recognized user attempting to access restricted content).'),
404 => array('404 Not Found!', 'The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible.'),
405 => array('405 Method Not Allowed!', 'A request was made of a resource using a request method not supported by that resource; for example, using GET on a form which requires data to be presented via POST, or using PUT on a read-only resource.'),
408 => array('408 Request Timeout!', 'The server timed out waiting for the request. According to W3 HTTP specifications: "The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time."'),
410 => array('410 Gone', 'Indicates that the resource requested is no longer available and will not be available again. This should be used when a resource has been intentionally removed and the resource should be purged. Upon receiving a 410 status code, the client should not request the resource again in the future. Clients such as search engines should remove the resource from their indices. Most use cases do not require clients and search engines to purge the resource, and a "404 Not Found" may be used instead.'),
500 => array('500 Internal Server Error!', 'A generic error message, given when no more specific message is suitable.'),
502 => array('502 Bad Gateway!', 'The server was acting as a gateway or proxy and received an invalid response from the upstream server.'),
503 => array('503 Service Unavailable!', 'The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.'),
504 => array('504 Gateway Timeout!', 'The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.'),
);
Картинку кидаем в images/404.png
Для других ошибок кидайте изображения в эту же папку с соответсвующими именами 410.png 500.png итд