diff --git a/contrib/event_log/main.php b/contrib/event_log/main.php index 7b82221a..90edb18c 100644 --- a/contrib/event_log/main.php +++ b/contrib/event_log/main.php @@ -56,7 +56,7 @@ class EventLog implements Extension { $this->theme->display_page($event->page, $events); } else { - $this->theme->display_error($event->page, "Denied", "Only admins can see the event log"); + $this->theme->display_permission_denied($event->page); } } if($event instanceof UserBlockBuildingEvent) { diff --git a/contrib/ipban/main.php b/contrib/ipban/main.php index 0f3b8629..abe05e10 100644 --- a/contrib/ipban/main.php +++ b/contrib/ipban/main.php @@ -70,8 +70,7 @@ class IPBan implements Extension { } } else { - header("HTTP/1.0 403 Access Denied"); - $this->theme->display_error($event->page, "Permission Denied", "This page is for admins only"); + $this->theme->display_permission_denied($event->page); } } diff --git a/contrib/wiki/main.php b/contrib/wiki/main.php index 8f3d099a..55ae778c 100644 --- a/contrib/wiki/main.php +++ b/contrib/wiki/main.php @@ -93,7 +93,7 @@ class Wiki implements Extension { $event->page->set_redirect(make_link("wiki/$u_title")); } else { - $this->theme->display_error($event->page, "Denied", "You do not have permission to edit this page"); + $this->theme->display_permission_denied($event->page); } } else if(is_null($content)) { diff --git a/ext/admin/main.php b/ext/admin/main.php index 457f0e7d..2a4eed5f 100644 --- a/ext/admin/main.php +++ b/ext/admin/main.php @@ -19,9 +19,7 @@ class AdminPage implements Extension { if(($event instanceof PageRequestEvent) && $event->page_matches("admin")) { if(!$event->user->is_admin()) { - //$event->page->add_header("HTTP/1.0 403 Access Denied"); - header("HTTP/1.0 403 Access Denied"); - $this->theme->display_error($event->page, "Permission Denied", "This page is for admins only"); + $this->theme->display_permission_denied($event->page); } else { if($event->get_arg(0) == "delete_image") { diff --git a/ext/comment/main.php b/ext/comment/main.php index f9511ea2..e29f5e7c 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -93,7 +93,7 @@ class CommentList implements Extension { } } else { - $this->theme->display_error($event->page, "Denied", "Only admins can delete comments"); + $this->theme->display_permission_denied($event->page); } } else if($event->get_arg(0) == "list") { diff --git a/ext/setup/main.php b/ext/setup/main.php index 105a66fd..dfe75e61 100644 --- a/ext/setup/main.php +++ b/ext/setup/main.php @@ -140,7 +140,7 @@ class Setup implements Extension { if(($event instanceof PageRequestEvent) && $event->page_matches("setup")) { global $user; if(!$user->is_admin()) { - $this->theme->display_error($event->page, "Permission Denied", "This page is for admins only"); + $this->theme->display_permission_denied($event->page); } else { if($event->get_arg(0) == "save") { diff --git a/ext/upload/main.php b/ext/upload/main.php index 55f3752a..4a9bc56a 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -46,7 +46,7 @@ class Upload implements Extension { $this->theme->display_upload_status($event->page, $ok); } else { - $this->theme->display_error($event->page, "Upload Denied", "Anonymous posting is disabled"); + $this->theme->display_permission_denied($event->page); } } else if(!empty($_GET['url'])) { @@ -61,7 +61,7 @@ class Upload implements Extension { $this->theme->display_upload_status($event->page, $ok); } else { - $this->theme->display_error($event->page, "Upload Denied", "Anonymous posting is disabled"); + $this->theme->display_permission_denied($event->page); } } else { diff --git a/themes/danbooru/themelet.class.php b/themes/danbooru/themelet.class.php index ca18e4df..7e0b54e4 100644 --- a/themes/danbooru/themelet.class.php +++ b/themes/danbooru/themelet.class.php @@ -9,6 +9,12 @@ class Themelet { } + public function display_permission_denied($page) { + header("HTTP/1.0 403 Permission Denied"); + $this->display_error($page, "Permission Denied", "You do not have permission to access this page"); + } + + public function build_thumb_html($image, $query=null) { global $config; $h_view_link = make_link("post/view/{$image->id}", $query); diff --git a/themes/default/themelet.class.php b/themes/default/themelet.class.php index 046bf22a..93e3c5f9 100644 --- a/themes/default/themelet.class.php +++ b/themes/default/themelet.class.php @@ -12,6 +12,15 @@ class Themelet { } + /** + * A specific, common error message + */ + public function display_permission_denied($page) { + header("HTTP/1.0 403 Permission Denied"); + $this->display_error($page, "Permission Denied", "You do not have permission to access this page"); + } + + /** * Generic thumbnail code; returns HTML rather than adding * a block since thumbs tend to go inside blocks...