diff --git a/contrib/artists/main.php b/contrib/artists/main.php index 4c2422fa..1717ec27 100644 --- a/contrib/artists/main.php +++ b/contrib/artists/main.php @@ -161,8 +161,7 @@ class Artists extends Extension { if(!$user->is_anonymous()){ $this->theme->new_artist_composer(); }else{ - $errMessage = "You must be registered and logged in to create a new artist."; - $this->theme->display_error($page, "Error", $errMessage); + $this->theme->display_error(401, "Error", "You must be registered and logged in to create a new artist."); } break; } @@ -179,8 +178,7 @@ class Artists extends Extension { $newArtistID = $this->add_artist(); if ($newArtistID == -1) { - $errMessage = "Error when entering artist data."; - $this->theme->display_error($page, "Error", $errMessage); + $this->theme->display_error(400, "Error", "Error when entering artist data."); } else { @@ -190,8 +188,7 @@ class Artists extends Extension { } else { - $errMessage = "You must be registered and logged in to create a new artist."; - $this->theme->display_error($page, "Error", $errMessage); + $this->theme->display_error(401, "Error", "You must be registered and logged in to create a new artist."); } break; } @@ -236,8 +233,7 @@ class Artists extends Extension { $userIsAdmin = $user->is_admin(); $this->theme->sidebar_options("editor", $artistID, $userIsAdmin); }else{ - $errMessage = "You must be registered and logged in to edit an artist."; - $this->theme->display_error($page, "Error", $errMessage); + $this->theme->display_error(401, "Error", "You must be registered and logged in to edit an artist."); } break; } diff --git a/contrib/forum/main.php b/contrib/forum/main.php index 15e8e092..5593db9e 100644 --- a/contrib/forum/main.php +++ b/contrib/forum/main.php @@ -109,7 +109,7 @@ class Forum extends Extension { if($hasErrors) { - $this->theme->display_error($page, "Error", $errors); + $this->theme->display_error(500, "Error", $errors); $this->theme->display_new_thread_composer($page, $_POST["message"], $_POST["title"], false); break; } @@ -149,7 +149,7 @@ class Forum extends Extension { if ($hasErrors) { - $this->theme->display_error($page, "Error", $errors); + $this->theme->display_error(500, "Error", $errors); $this->theme->display_new_post_composer($page, $_POST["threadID"], $_POST["message"], $_POST["title"], false); break; } @@ -166,7 +166,7 @@ class Forum extends Extension { { $page->set_mode("redirect"); $page->set_redirect(make_link("forum/index")); - //$this->theme->display_error($page, "Invalid action", "You should check forum/index."); + //$this->theme->display_error(400, "Invalid action", "You should check forum/index."); break; } } diff --git a/contrib/pm/main.php b/contrib/pm/main.php index 2bf841c0..0b6fa827 100644 --- a/contrib/pm/main.php +++ b/contrib/pm/main.php @@ -108,7 +108,7 @@ class PrivMsg extends Extension { $pm_id = int_escape($event->get_arg(1)); $pm = $database->get_row("SELECT * FROM private_message WHERE id = :id", array("id" => $pm_id)); if(is_null($pm)) { - $this->theme->display_error($page, "No such PM", "There is no PM #$pm_id"); + $this->theme->display_error(404, "No such PM", "There is no PM #$pm_id"); } else if(($pm["to_id"] == $user->id) || $user->is_admin()) { $from_user = User::by_id(int_escape($pm["from_id"])); @@ -124,7 +124,7 @@ class PrivMsg extends Extension { $pm_id = int_escape($_POST["pm_id"]); $pm = $database->get_row("SELECT * FROM private_message WHERE id = :id", array("id" => $pm_id)); if(is_null($pm)) { - $this->theme->display_error($page, "No such PM", "There is no PM #$pm_id"); + $this->theme->display_error(404, "No such PM", "There is no PM #$pm_id"); } else if(($pm["to_id"] == $user->id) || $user->is_admin()) { $database->execute("DELETE FROM private_message WHERE id = :id", array("id" => $pm_id)); @@ -146,7 +146,7 @@ class PrivMsg extends Extension { } break; default: - $this->theme->display_error($page, "Invalid action", "That's not something you can do with a PM"); + $this->theme->display_error(400, "Invalid action", "That's not something you can do with a PM"); break; } } diff --git a/contrib/resize/main.php b/contrib/resize/main.php index 58991875..caba3ed4 100644 --- a/contrib/resize/main.php +++ b/contrib/resize/main.php @@ -115,7 +115,7 @@ class ResizeImage extends Extension { $image = Image::by_id($image_id); if(is_null($image)) { - $this->theme->display_error($page, "Image not found", "No image in the database has the ID #$image_id"); + $this->theme->display_error(404, "Image not found", "No image in the database has the ID #$image_id"); } else { /* Check if options were given to resize an image. */ diff --git a/ext/alias_editor/main.php b/ext/alias_editor/main.php index cfbf1777..f03f0bac 100755 --- a/ext/alias_editor/main.php +++ b/ext/alias_editor/main.php @@ -37,7 +37,7 @@ class AliasEditor extends Extension { $page->set_redirect(make_link("alias/list")); } catch(AddAliasException $ex) { - $this->theme->display_error($page, "Error adding alias", $ex->getMessage()); + $this->theme->display_error(500, "Error adding alias", $ex->getMessage()); } } } @@ -91,11 +91,11 @@ class AliasEditor extends Extension { $page->set_redirect(make_link("alias/list")); } else { - $this->theme->display_error($page, "No File Specified", "You have to upload a file"); + $this->theme->display_error(400, "No File Specified", "You have to upload a file"); } } else { - $this->theme->display_error($page, "Admins Only", "Only admins can edit the alias list"); + $this->theme->display_error(401, "Admins Only", "Only admins can edit the alias list"); } } } diff --git a/ext/comment/main.php b/ext/comment/main.php index dac233fa..b67068eb 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -123,7 +123,7 @@ class CommentList extends Extension { $page->set_redirect(make_link("post/view/".int_escape($_POST['image_id']))); } catch(CommentPostingException $ex) { - $this->theme->display_error($page, "Comment Blocked", $ex->getMessage()); + $this->theme->display_error(403, "Comment Blocked", $ex->getMessage()); } } } diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php index 911274e5..3329aaa5 100644 --- a/ext/ext_manager/main.php +++ b/ext/ext_manager/main.php @@ -99,7 +99,7 @@ class ExtManager extends Extension { $page->set_redirect(make_link("ext_manager")); } else { - $this->theme->display_error($page, "File Operation Failed", + $this->theme->display_error(500, "File Operation Failed", "The extension folder isn't writable by the web server :("); } } diff --git a/ext/upload/main.php b/ext/upload/main.php index 6bd6f7f9..fc0a2edd 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -141,7 +141,7 @@ class Upload extends Extension { $image_old = Image::by_id($image_id); if(is_null($image_old)) { - $this->theme->display_error($page, "Image not found", "No image in the database has the ID #$image_id"); + $this->theme->display_error(404, "Image not found", "No image in the database has the ID #$image_id"); } if(count($_FILES) + count($_POST) > 0) { diff --git a/ext/user/main.php b/ext/user/main.php index 80f73471..a83b7516 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -97,7 +97,7 @@ class UserPage extends Extension { else if($event->get_arg(0) == "recover") { $user = User::by_name($_POST['username']); if(is_null($user)) { - $this->theme->display_error($page, "Error", "There's no user with that name"); + $this->theme->display_error(404, "Error", "There's no user with that name"); } if(is_null($user->email)) { // @@ -111,7 +111,7 @@ class UserPage extends Extension { $this->theme->display_signup_page($page); } else if($_POST['pass1'] != $_POST['pass2']) { - $this->theme->display_error($page, "Password Mismatch", "Passwords don't match"); + $this->theme->display_error(400, "Password Mismatch", "Passwords don't match"); } else { try { @@ -126,7 +126,7 @@ class UserPage extends Extension { $page->set_redirect(make_link("user")); } catch(UserCreationException $ex) { - $this->theme->display_error($page, "User Creation Error", $ex->getMessage()); + $this->theme->display_error(400, "User Creation Error", $ex->getMessage()); } } } @@ -155,14 +155,14 @@ class UserPage extends Extension { if($event->page_matches("user")) { $display_user = ($event->count_args() == 0) ? $user : User::by_name($event->get_arg(0)); if($event->count_args() == 0 && $user->is_anonymous()) { - $this->theme->display_error($page, "Not Logged In", + $this->theme->display_error(401, "Not Logged In", "You aren't logged in. First do that, then you can see your stats."); } else if(!is_null($display_user) && ($display_user->id != $config->get_int("anon_id"))) { send_event(new UserPageBuildingEvent($display_user)); } else { - $this->theme->display_error($page, "No Such User", + $this->theme->display_error(404, "No Such User", "If you typed the ID by hand, try again; if you came from a link on this ". "site, it might be bug report time..."); } @@ -285,7 +285,7 @@ class UserPage extends Extension { } else { log_warning("user", "Failed to log in as ".html_escape($name)." [$hash]"); - $this->theme->display_error($page, "Error", "No user with those details was found"); + $this->theme->display_error(401, "Error", "No user with those details was found"); } } @@ -345,7 +345,7 @@ class UserPage extends Extension { global $database; if($user->is_anonymous()) { - $this->theme->display_error($page, "Error", "You aren't logged in"); + $this->theme->display_error(401, "Error", "You aren't logged in"); } else if(isset($_POST['id']) && isset($_POST['pass1']) && isset($_POST['pass2'])) { $id = $_POST['id']; @@ -355,11 +355,11 @@ class UserPage extends Extension { $duser = User::by_id($id); if((!$user->can("change_user_info")) && ($duser->name != $user->name)) { - $this->theme->display_error($page, "Error", + $this->theme->display_error(401, "Error", "You need to be an admin to change other people's passwords"); } else if($pass1 != $pass2) { - $this->theme->display_error($page, "Error", "Passwords don't match"); + $this->theme->display_error(400, "Error", "Passwords don't match"); } else { // FIXME: send_event() @@ -384,7 +384,7 @@ class UserPage extends Extension { global $database; if($user->is_anonymous()) { - $this->theme->display_error($page, "Error", "You aren't logged in"); + $this->theme->display_error(401, "Error", "You aren't logged in"); } else if(isset($_POST['id']) && isset($_POST['address'])) { $id = $_POST['id']; @@ -393,7 +393,7 @@ class UserPage extends Extension { $duser = User::by_id($id); if((!$user->can("change_user_info")) && ($duser->name != $user->name)) { - $this->theme->display_error($page, "Error", + $this->theme->display_error(401, "Error", "You need to be an admin to change other people's addressess"); } else { diff --git a/ext/view/main.php b/ext/view/main.php index 4c4eb074..e7e26091 100644 --- a/ext/view/main.php +++ b/ext/view/main.php @@ -88,7 +88,7 @@ class ViewImage extends Extension { $image = Image::by_id($image_id); if(is_null($image)) { - $this->theme->display_error($page, "Image not found", "Image $image_id could not be found"); + $this->theme->display_error(404, "Image not found", "Image $image_id could not be found"); return; } @@ -100,7 +100,7 @@ class ViewImage extends Extension { } if(is_null($image)) { - $this->theme->display_error($page, "Image not found", "No more images"); + $this->theme->display_error(404, "Image not found", "No more images"); return; } @@ -121,7 +121,7 @@ class ViewImage extends Extension { $this->theme->display_admin_block($page, $iabbe->parts); } else { - $this->theme->display_error($page, "Image not found", "No image in the database has the ID #$image_id"); + $this->theme->display_error(404, "Image not found", "No image in the database has the ID #$image_id"); } } diff --git a/themes/danbooru/themelet.class.php b/themes/danbooru/themelet.class.php index e3277c3b..3a13c679 100644 --- a/themes/danbooru/themelet.class.php +++ b/themes/danbooru/themelet.class.php @@ -1,7 +1,9 @@ add_http_header("HTTP/1.0 $code $title"); $page->set_title($title); $page->set_heading($title); $page->add_block(new NavBlock()); @@ -10,9 +12,7 @@ class Themelet { public function display_permission_denied() { - global $page; - $page->add_http_header("HTTP/1.0 403 Permission Denied"); - $this->display_error($page, "Permission Denied", "You do not have permission to access this page"); + $this->display_error(403, "Permission Denied", "You do not have permission to access this page"); } diff --git a/themes/default/themelet.class.php b/themes/default/themelet.class.php index 785eaa1d..c4860c99 100644 --- a/themes/default/themelet.class.php +++ b/themes/default/themelet.class.php @@ -6,7 +6,9 @@ class Themelet { /** * Generic error message display */ - public function display_error(Page $page, $title, $message) { + public function display_error(/*int*/ $code, /*string*/ $title, /*string*/ $message) { + global $page; + $page->add_http_header("HTTP/1.0 $code $title"); $page->set_title($title); $page->set_heading($title); $page->add_block(new NavBlock()); @@ -18,9 +20,7 @@ class Themelet { * A specific, common error message */ public function display_permission_denied() { - global $page; - $page->add_http_header("HTTP/1.0 403 Permission Denied"); - $this->display_error($page, "Permission Denied", "You do not have permission to access this page"); + $this->display_error(403, "Permission Denied", "You do not have permission to access this page"); } diff --git a/themes/flat/themelet.class.php b/themes/flat/themelet.class.php index 4b564971..78144eb7 100644 --- a/themes/flat/themelet.class.php +++ b/themes/flat/themelet.class.php @@ -6,7 +6,9 @@ class Themelet { /** * Generic error message display */ - public function display_error(Page $page, $title, $message) { + public function display_error(/*int*/ $code, /*string*/ $title, /*string*/ $message) { + global $page; + $page->add_http_header("HTTP/1.0 $code $title"); $page->set_title($title); $page->set_heading($title); $page->add_block(new NavBlock()); @@ -18,9 +20,7 @@ class Themelet { * A specific, common error message */ public function display_permission_denied() { - global $page; - $page->add_http_header("HTTP/1.0 403 Permission Denied"); - $this->display_error($page, "Permission Denied", "You do not have permission to access this page"); + $this->display_error(403, "Permission Denied", "You do not have permission to access this page"); } diff --git a/themes/futaba/themelet.class.php b/themes/futaba/themelet.class.php index 75ca217a..97970ffa 100644 --- a/themes/futaba/themelet.class.php +++ b/themes/futaba/themelet.class.php @@ -4,7 +4,9 @@ class Themelet { /** * Generic error message display */ - public function display_error(Page $page, $title, $message) { + public function display_error(/*int*/ $code, /*string*/ $title, /*string*/ $message) { + global $page; + $page->add_http_header("HTTP/1.0 $code $title"); $page->set_title($title); $page->set_heading($title); $page->add_block(new NavBlock()); @@ -16,9 +18,7 @@ class Themelet { * A specific, common error message */ public function display_permission_denied() { - global $page; - $page->add_http_header("HTTP/1.0 403 Permission Denied"); - $this->display_error($page, "Permission Denied", "You do not have permission to access this page"); + $this->display_error(403, "Permission Denied", "You do not have permission to access this page"); } diff --git a/themes/lite/themelet.class.php b/themes/lite/themelet.class.php index 85a915ba..28a0cc65 100644 --- a/themes/lite/themelet.class.php +++ b/themes/lite/themelet.class.php @@ -6,7 +6,9 @@ class Themelet { /** * Generic error message display */ - public function display_error(Page $page, $title, $message) { + public function display_error(/*int*/ $code, /*string*/ $title, /*string*/ $message) { + global $page; + $page->add_http_header("HTTP/1.0 $code $title"); $page->set_title($title); $page->set_heading($title); $page->add_block(new NavBlock()); @@ -18,9 +20,7 @@ class Themelet { * A specific, common error message */ public function display_permission_denied() { - global $page; - $page->add_http_header("HTTP/1.0 403 Permission Denied"); - $this->display_error($page, "Permission Denied", "You do not have permission to access this page"); + $this->display_error(403, "Permission Denied", "You do not have permission to access this page"); } diff --git a/themes/old_default/themelet.class.php b/themes/old_default/themelet.class.php index 8767f6a3..cb5c132a 100644 --- a/themes/old_default/themelet.class.php +++ b/themes/old_default/themelet.class.php @@ -4,7 +4,9 @@ class Themelet { /** * Generic error message display */ - public function display_error(Page $page, $title, $message) { + public function display_error(/*int*/ $code, /*string*/ $title, /*string*/ $message) { + global $page; + $page->add_http_header("HTTP/1.0 $code $title"); $page->set_title($title); $page->set_heading($title); $page->add_block(new NavBlock()); @@ -16,9 +18,7 @@ class Themelet { * A specific, common error message */ public function display_permission_denied() { - global $page; - $page->add_http_header("HTTP/1.0 403 Permission Denied"); - $this->display_error($page, "Permission Denied", "You do not have permission to access this page"); + $this->display_error(403, "Permission Denied", "You do not have permission to access this page"); } diff --git a/themes/warm/themelet.class.php b/themes/warm/themelet.class.php index 0df5758f..88c47c03 100644 --- a/themes/warm/themelet.class.php +++ b/themes/warm/themelet.class.php @@ -6,7 +6,9 @@ class Themelet { /** * Generic error message display */ - public function display_error(Page $page, $title, $message) { + public function display_error(/*int*/ $code, /*string*/ $title, /*string*/ $message) { + global $page; + $page->add_http_header("HTTP/1.0 $code $title"); $page->set_title($title); $page->set_heading($title); $page->add_block(new NavBlock()); @@ -18,9 +20,7 @@ class Themelet { * A specific, common error message */ public function display_permission_denied() { - global $page; - $page->add_http_header("HTTP/1.0 403 Permission Denied"); - $this->display_error($page, "Permission Denied", "You do not have permission to access this page"); + $this->display_error(403, "Permission Denied", "You do not have permission to access this page"); }