diff --git a/ground/app.php b/ground/app.php index 926cb9d..6aaed35 100644 --- a/ground/app.php +++ b/ground/app.php @@ -109,7 +109,8 @@ class App public static function error404($message = '') { header("HTTP/1.0 404 Not Found"); - die($message ? $message : '404 - Not Found'); + PageController::action404($message ? $message : '404 - Not Found'); + die; } // Пытаемся восстановить пользователя из сессии diff --git a/ground/controllers/PageController.php b/ground/controllers/PageController.php index cee25a1..5b7fc64 100644 --- a/ground/controllers/PageController.php +++ b/ground/controllers/PageController.php @@ -60,6 +60,12 @@ class PageController extends Controller self::addStyle('/css/fotorama.css'); $point = Point::model()->getByPK($pointId); + + if (!isset($point->id)) + { + App::error404(); + } + $point->descriptionHtml = nl2br($point->description); $point->name = htmlspecialchars($point->name); App::setConfig('title', $point->name. ' - wikipoints.ru'); @@ -91,4 +97,10 @@ class PageController extends Controller } } + static function action404($message) + { + self::renderPartial('error404.php', array( + 'point' => Point::model()->getRandom(), + )); + } } diff --git a/ground/views/error404.php b/ground/views/error404.php new file mode 100644 index 0000000..582d758 --- /dev/null +++ b/ground/views/error404.php @@ -0,0 +1,19 @@ + + + + Ошибка 404 - страница не найдена! + + +

Ошибка 404 - страница не найдена!

+
+
+ +
+

Не беда! Возможно вас заинтересует точка «name ?>»?

+ + + +
+
+ + \ No newline at end of file diff --git a/public/.htaccess b/public/.htaccess index 354ec3a..f0de519 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -1,6 +1,8 @@ AddDefaultCharset utf-8 RewriteEngine On +ErrorDocument 404 /page/404/ + RewriteBase / RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-f