From 6feb5fe0d45196af4a9b2b058cefdd15f6007522 Mon Sep 17 00:00:00 2001
From: Thomas Lange <code@nerdmind.de>
Date: Tue, 11 Apr 2017 04:10:46 +0200
Subject: Error pages for HTTP status code 403 and 404 moved to another
 location (preparations for the next commits in which the system directory
 will be moved to a non-public directory).

---
 .ht-nginx                      |  4 ++--
 .htaccess                      |  4 ++--
 403.php                        | 32 ++++++++++++++++++++++++++++++++
 404.php                        | 32 ++++++++++++++++++++++++++++++++
 core/namespace/Application.php |  2 +-
 core/namespace/Router.php      |  3 +--
 system/403.php                 | 27 ---------------------------
 system/404.php                 | 27 ---------------------------
 8 files changed, 70 insertions(+), 61 deletions(-)
 create mode 100644 403.php
 create mode 100644 404.php
 delete mode 100644 system/403.php
 delete mode 100644 system/404.php

diff --git a/.ht-nginx b/.ht-nginx
index 9d3053f..010f488 100644
--- a/.ht-nginx
+++ b/.ht-nginx
@@ -12,8 +12,8 @@
 #===============================================================================
 # Error documents
 #===============================================================================
-error_page 403 /system/403.php;
-error_page 404 /system/404.php;
+error_page 403 /403.php;
+error_page 404 /404.php;
 
 #===============================================================================
 # Forbidden directories
diff --git a/.htaccess b/.htaccess
index 2a87ccc..950f985 100644
--- a/.htaccess
+++ b/.htaccess
@@ -17,8 +17,8 @@ RewriteEngine On
 #===============================================================================
 # ErrorDocument handler
 #===============================================================================
-ErrorDocument 403 /system/403.php
-ErrorDocument 404 /system/404.php
+ErrorDocument 403 /403.php
+ErrorDocument 404 /404.php
 
 #===============================================================================
 # Forbidden directories
diff --git a/403.php b/403.php
new file mode 100644
index 0000000..7b6a168
--- /dev/null
+++ b/403.php
@@ -0,0 +1,32 @@
+<?php
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+if(!defined('ROOT')) {
+	require_once 'core/application.php';
+}
+
+#===============================================================================
+# Send HTTP status code
+#===============================================================================
+http_response_code(403);
+
+#===============================================================================
+# TRY: Template\Exception
+#===============================================================================
+try {
+	$MainTemplate = Template\Factory::build('main');
+	$MainTemplate->set('NAME', '403 Forbidden');
+	$MainTemplate->set('HEAD', ['NAME' => '403 Forbidden']);
+	$MainTemplate->set('HTML', Template\Factory::build('403'));
+
+	echo $MainTemplate;
+}
+
+#===============================================================================
+# CATCH: Template\Exception
+#===============================================================================
+catch(Template\Exception $Exception) {
+	$Exception->defaultHandler();
+}
+?>
\ No newline at end of file
diff --git a/404.php b/404.php
new file mode 100644
index 0000000..be2ca1b
--- /dev/null
+++ b/404.php
@@ -0,0 +1,32 @@
+<?php
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+if(!defined('ROOT')) {
+	require_once 'core/application.php';
+}
+
+#===============================================================================
+# Send HTTP status code
+#===============================================================================
+http_response_code(404);
+
+#===============================================================================
+# TRY: Template\Exception
+#===============================================================================
+try {
+	$MainTemplate = Template\Factory::build('main');
+	$MainTemplate->set('NAME', '404 Not Found');
+	$MainTemplate->set('HEAD', ['NAME' => '404 Not Found']);
+	$MainTemplate->set('HTML', Template\Factory::build('404'));
+
+	echo $MainTemplate;
+}
+
+#===============================================================================
+# CATCH: Template\Exception
+#===============================================================================
+catch(Template\Exception $Exception) {
+	$Exception->defaultHandler();
+}
+?>
\ No newline at end of file
diff --git a/core/namespace/Application.php b/core/namespace/Application.php
index a43871e..329d56d 100644
--- a/core/namespace/Application.php
+++ b/core/namespace/Application.php
@@ -141,7 +141,7 @@ class Application {
 	#===============================================================================
 	public static function exit($code = 500) {
 		http_response_code($code);
-		$code === 404 AND require_once(ROOT."system/404.php");
+		$code === 404 AND require_once ROOT.'404.php';
 		exit();
 	}
 }
diff --git a/core/namespace/Router.php b/core/namespace/Router.php
index ad46033..f0e7e2a 100644
--- a/core/namespace/Router.php
+++ b/core/namespace/Router.php
@@ -57,8 +57,7 @@ class Router {
 		}
 
 		if($route_found === FALSE) {
-			http_response_code(404);
-			require_once 'system/404.php';
+			require_once ROOT.'404.php';
 		}
 	}
 }
diff --git a/system/403.php b/system/403.php
deleted file mode 100644
index 04f1568..0000000
--- a/system/403.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-#===============================================================================
-# INCLUDE: Main configuration
-#===============================================================================
-if(!defined('ROOT')) {
-	require_once '../core/application.php';
-}
-
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
-	$MainTemplate = Template\Factory::build('main');
-	$MainTemplate->set('NAME', '403 Forbidden');
-	$MainTemplate->set('HEAD', ['NAME' => '403 Forbidden']);
-	$MainTemplate->set('HTML', Template\Factory::build('403'));
-
-	echo $MainTemplate;
-}
-
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
-catch(Template\Exception $Exception) {
-	$Exception->defaultHandler();
-}
-?>
\ No newline at end of file
diff --git a/system/404.php b/system/404.php
deleted file mode 100644
index 53ec9bd..0000000
--- a/system/404.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-#===============================================================================
-# INCLUDE: Main configuration
-#===============================================================================
-if(!defined('ROOT')) {
-	require_once '../core/application.php';
-}
-
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
-	$MainTemplate = Template\Factory::build('main');
-	$MainTemplate->set('NAME', '404 Not Found');
-	$MainTemplate->set('HEAD', ['NAME' => '404 Not Found']);
-	$MainTemplate->set('HTML', Template\Factory::build('404'));
-
-	echo $MainTemplate;
-}
-
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
-catch(Template\Exception $Exception) {
-	$Exception->defaultHandler();
-}
-?>
\ No newline at end of file
-- 
cgit v1.2.3