aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2017-04-11 05:11:57 +0200
committerThomas Lange <code@nerdmind.de>2017-04-11 05:15:49 +0200
commit7a1b8f471ca133b6ca99cd4e440e6614a7c18537 (patch)
tree79e9e8fbd20db4db18e531eaa792bf20ed539ae9
parent6feb5fe0d45196af4a9b2b058cefdd15f6007522 (diff)
downloadblog-7a1b8f471ca133b6ca99cd4e440e6614a7c18537.tar.gz
blog-7a1b8f471ca133b6ca99cd4e440e6614a7c18537.tar.xz
blog-7a1b8f471ca133b6ca99cd4e440e6614a7c18537.zip
Methods "error403" and "error404" has been added to the "Application" class; several files has been changed.
-rw-r--r--admin/page/delete.php2
-rw-r--r--admin/page/index.php2
-rw-r--r--admin/page/update.php2
-rw-r--r--admin/post/delete.php2
-rw-r--r--admin/post/index.php2
-rw-r--r--admin/post/update.php2
-rw-r--r--admin/user/delete.php2
-rw-r--r--admin/user/index.php2
-rw-r--r--admin/user/update.php2
-rw-r--r--core/namespace/Application.php19
-rw-r--r--core/namespace/Router.php2
-rw-r--r--system/page/list.php2
-rw-r--r--system/page/main.php2
-rw-r--r--system/post/list.php2
-rw-r--r--system/post/main.php2
-rw-r--r--system/user/list.php2
-rw-r--r--system/user/main.php2
17 files changed, 33 insertions, 18 deletions
diff --git a/admin/page/delete.php b/admin/page/delete.php
index 163bbdb..33d30a5 100644
--- a/admin/page/delete.php
+++ b/admin/page/delete.php
@@ -66,7 +66,7 @@ try {
# CATCH: Page\Exception
#===============================================================================
catch(Page\Exception $Exception) {
- Application::exit(404);
+ Application::error404();
}
?>
diff --git a/admin/page/index.php b/admin/page/index.php
index 56233a9..9a9bdfa 100644
--- a/admin/page/index.php
+++ b/admin/page/index.php
@@ -19,7 +19,7 @@ $currentSite = HTTP::GET('site') ?? 1;
$currentSite = abs(intval($currentSite));
if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
- Application::exit(404);
+ Application::error404();
}
#===============================================================================
diff --git a/admin/page/update.php b/admin/page/update.php
index 857631d..03f05ef 100644
--- a/admin/page/update.php
+++ b/admin/page/update.php
@@ -91,6 +91,6 @@ try {
# CATCH: Page\Exception
#===============================================================================
catch(Page\Exception $Exception) {
- Application::exit(404);
+ Application::error404();
}
?> \ No newline at end of file
diff --git a/admin/post/delete.php b/admin/post/delete.php
index 82e71da..f271364 100644
--- a/admin/post/delete.php
+++ b/admin/post/delete.php
@@ -66,7 +66,7 @@ try {
# CATCH: Post\Exception
#===============================================================================
catch(Post\Exception $Exception) {
- Application::exit(404);
+ Application::error404();
}
?>
diff --git a/admin/post/index.php b/admin/post/index.php
index bf7afdf..ad735cd 100644
--- a/admin/post/index.php
+++ b/admin/post/index.php
@@ -19,7 +19,7 @@ $currentSite = HTTP::GET('site') ?? 1;
$currentSite = abs(intval($currentSite));
if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
- Application::exit(404);
+ Application::error404();
}
#===============================================================================
diff --git a/admin/post/update.php b/admin/post/update.php
index 65b9045..37dccfe 100644
--- a/admin/post/update.php
+++ b/admin/post/update.php
@@ -91,6 +91,6 @@ try {
# CATCH: Post\Exception
#===============================================================================
catch(Post\Exception $Exception) {
- Application::exit(404);
+ Application::error404();
}
?> \ No newline at end of file
diff --git a/admin/user/delete.php b/admin/user/delete.php
index ed8f925..5a1400a 100644
--- a/admin/user/delete.php
+++ b/admin/user/delete.php
@@ -66,7 +66,7 @@ try {
# CATCH: User\Exception
#===============================================================================
catch(User\Exception $Exception) {
- Application::exit(404);
+ Application::error404();
}
?>
diff --git a/admin/user/index.php b/admin/user/index.php
index 3dca93a..5f43eee 100644
--- a/admin/user/index.php
+++ b/admin/user/index.php
@@ -19,7 +19,7 @@ $currentSite = HTTP::GET('site') ?? 1;
$currentSite = abs(intval($currentSite));
if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
- Application::exit(404);
+ Application::error404();
}
#===============================================================================
diff --git a/admin/user/update.php b/admin/user/update.php
index cab582e..07965cd 100644
--- a/admin/user/update.php
+++ b/admin/user/update.php
@@ -84,6 +84,6 @@ try {
# CATCH: User\Exception
#===============================================================================
catch(User\Exception $Exception) {
- Application::exit(404);
+ Application::error404();
}
?> \ No newline at end of file
diff --git a/core/namespace/Application.php b/core/namespace/Application.php
index 329d56d..17cd020 100644
--- a/core/namespace/Application.php
+++ b/core/namespace/Application.php
@@ -137,11 +137,26 @@ class Application {
}
#===============================================================================
- # Exit application with
+ # Exit application with a custom HTTP status code
#===============================================================================
public static function exit($code = 500) {
http_response_code($code);
- $code === 404 AND require_once ROOT.'404.php';
+ exit();
+ }
+
+ #===============================================================================
+ # Exit application with the 403 error page
+ #===============================================================================
+ public static function error403() {
+ require_once ROOT.'403.php';
+ exit();
+ }
+
+ #===============================================================================
+ # Exit application with the 404 error page
+ #===============================================================================
+ public static function error404() {
+ require_once ROOT.'404.php';
exit();
}
}
diff --git a/core/namespace/Router.php b/core/namespace/Router.php
index f0e7e2a..b6221d1 100644
--- a/core/namespace/Router.php
+++ b/core/namespace/Router.php
@@ -57,7 +57,7 @@ class Router {
}
if($route_found === FALSE) {
- require_once ROOT.'404.php';
+ Application::error404();
}
}
}
diff --git a/system/page/list.php b/system/page/list.php
index 7c3956e..0879065 100644
--- a/system/page/list.php
+++ b/system/page/list.php
@@ -14,7 +14,7 @@ $currentSite = HTTP::GET('site') ?? 1;
$currentSite = abs(intval($currentSite));
if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
- Application::exit(404);
+ Application::error404();
}
#===============================================================================
diff --git a/system/page/main.php b/system/page/main.php
index 28de93a..22d0ec7 100644
--- a/system/page/main.php
+++ b/system/page/main.php
@@ -78,7 +78,7 @@ catch(Page\Exception $Exception) {
}
catch(Page\Exception $Exception) {
- Application::exit(404);
+ Application::error404();
}
}
diff --git a/system/post/list.php b/system/post/list.php
index 7b0630c..908f7b8 100644
--- a/system/post/list.php
+++ b/system/post/list.php
@@ -14,7 +14,7 @@ $currentSite = HTTP::GET('site') ?? 1;
$currentSite = abs(intval($currentSite));
if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
- Application::exit(404);
+ Application::error404();
}
#===============================================================================
diff --git a/system/post/main.php b/system/post/main.php
index 1797d67..0b69023 100644
--- a/system/post/main.php
+++ b/system/post/main.php
@@ -78,7 +78,7 @@ catch(Post\Exception $Exception) {
}
catch(Post\Exception $Exception) {
- Application::exit(404);
+ Application::error404();
}
}
diff --git a/system/user/list.php b/system/user/list.php
index b724fe8..2e1e4f1 100644
--- a/system/user/list.php
+++ b/system/user/list.php
@@ -14,7 +14,7 @@ $currentSite = HTTP::GET('site') ?? 1;
$currentSite = abs(intval($currentSite));
if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
- Application::exit(404);
+ Application::error404();
}
#===============================================================================
diff --git a/system/user/main.php b/system/user/main.php
index 7dcd6da..8b7bc79 100644
--- a/system/user/main.php
+++ b/system/user/main.php
@@ -93,6 +93,6 @@ catch(User\Exception $Exception) {
}
catch(User\Exception $Exception) {
- Application::exit(404);
+ Application::error404();
}
} \ No newline at end of file