From c30c898c4e7d0ebd3e2af25f05ba7f4e9565c6bc Mon Sep 17 00:00:00 2001 From: "green-ponies (jgen)" Date: Tue, 30 Aug 2011 16:38:46 -0400 Subject: [PATCH] Changing files to use the $page->add_http_header() method instead. --- contrib/danbooru_api/main.php | 32 +++++++++++++-------------- ext/handle_404/main.php | 3 ++- ext/upload/main.php | 3 ++- themes/danbooru/themelet.class.php | 2 +- themes/default/themelet.class.php | 2 +- themes/flat/themelet.class.php | 2 +- themes/lite/themelet.class.php | 2 +- themes/old_default/themelet.class.php | 2 +- themes/warm/themelet.class.php | 2 +- 9 files changed, 26 insertions(+), 24 deletions(-) diff --git a/contrib/danbooru_api/main.php b/contrib/danbooru_api/main.php index 4d11d655..b925d860 100644 --- a/contrib/danbooru_api/main.php +++ b/contrib/danbooru_api/main.php @@ -159,8 +159,8 @@ class DanbooruApi implements Extension { $fp = fopen($url, "r"); if(!$fp) { - header("HTTP/1.0 409 Conflict"); - header("X-Danbooru-Errors: fopen read error"); + $page->add_http_header("HTTP/1.0 409 Conflict"); + $page->add_http_header("X-Danbooru-Errors: fopen read error"); } $data = ""; @@ -193,8 +193,8 @@ class DanbooruApi implements Extension $filename = basename($url); } else { // Nothing was specified at all - header("HTTP/1.0 409 Conflict"); - header("X-Danbooru-Errors: no input files"); + $page->add_http_header("HTTP/1.0 409 Conflict"); + $page->add_http_header("X-Danbooru-Errors: no input files"); return; } @@ -206,8 +206,8 @@ class DanbooruApi implements Extension { if(strtolower($_REQUEST['md5']) != $hash) { - header("HTTP/1.0 409 Conflict"); - header("X-Danbooru-Errors: md5 mismatch"); + $page->add_http_header("HTTP/1.0 409 Conflict"); + $page->add_http_header("X-Danbooru-Errors: md5 mismatch"); return; } } @@ -217,11 +217,11 @@ class DanbooruApi implements Extension // Does it exist already? $existing = Image::by_hash($hash); if(!is_null($existing)) { - header("HTTP/1.0 409 Conflict"); - header("X-Danbooru-Errors: duplicate"); + $page->add_http_header("HTTP/1.0 409 Conflict"); + $page->add_http_header("X-Danbooru-Errors: duplicate"); $existinglink = make_link("post/view/" . $existing->id); if($danboorup_kludge) $existinglink=make_http($existinglink); - header("X-Danbooru-Location: $existinglink"); + $page->add_http_header("X-Danbooru-Location: $existinglink"); return; // wut! } @@ -246,21 +246,21 @@ class DanbooruApi implements Extension // Did we POST or GET this call? if($_SERVER['REQUEST_METHOD'] == 'POST') { - header("X-Danbooru-Location: $newid"); + $page->add_http_header("X-Danbooru-Location: $newid"); } else - header("Location: $newid"); + $page->add_http_header("Location: $newid"); } catch(UploadException $ex) { // Did something screw up? - header("HTTP/1.0 409 Conflict"); - header("X-Danbooru-Errors: exception - " . $ex->getMessage()); + $page->add_http_header("HTTP/1.0 409 Conflict"); + $page->add_http_header("X-Danbooru-Errors: exception - " . $ex->getMessage()); return; } } else { - header("HTTP/1.0 409 Conflict"); - header("X-Danbooru-Errors: authentication error"); + $page->add_http_header("HTTP/1.0 409 Conflict"); + $page->add_http_header("X-Danbooru-Errors: authentication error"); return; } } @@ -387,7 +387,7 @@ class DanbooruApi implements Extension if(($event->get_arg(1) == 'post') && ($event->get_arg(2) == 'show')) { $fixedlocation = make_link("post/view/" . $event->get_arg(3)); - header("Location: $fixedlocation"); + $page->add_http_header("Location: $fixedlocation"); } } diff --git a/ext/handle_404/main.php b/ext/handle_404/main.php index 3a9a2503..b7e80aa0 100644 --- a/ext/handle_404/main.php +++ b/ext/handle_404/main.php @@ -14,8 +14,9 @@ class Handle404 extends SimpleExtension { // hax. if($page->mode == "page" && (!isset($page->blocks) || $this->count_main($page->blocks) == 0)) { $h_pagename = html_escape(implode('/', $event->args)); - header("HTTP/1.0 404 Page Not Found"); log_debug("handle_404", "Hit 404: $h_pagename"); + + $page->add_http_header("HTTP/1.0 404 Page Not Found",5); $page->set_title("404"); $page->set_heading("404 - No Handler Found"); $page->add_block(new NavBlock()); diff --git a/ext/upload/main.php b/ext/upload/main.php index c9b3be48..167bce07 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -283,7 +283,8 @@ class Upload implements Extension { if($event->image_id == -1) { throw new UploadException("File type not recognised"); } - header("X-Shimmie-Image-ID: ".int_escape($event->image_id)); + //header("X-Shimmie-Image-ID: ".int_escape($event->image_id)); + $page->add_http_header("X-Shimmie-Image-ID: ".int_escape($event->image_id)); } catch(UploadException $ex) { $this->theme->display_upload_error($page, "Error with ".html_escape($file['name']), diff --git a/themes/danbooru/themelet.class.php b/themes/danbooru/themelet.class.php index 1c2d687c..2fa978a5 100644 --- a/themes/danbooru/themelet.class.php +++ b/themes/danbooru/themelet.class.php @@ -10,7 +10,7 @@ class Themelet { public function display_permission_denied(Page $page) { - header("HTTP/1.0 403 Permission Denied"); + $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"); } diff --git a/themes/default/themelet.class.php b/themes/default/themelet.class.php index de1f9b4e..159f8881 100644 --- a/themes/default/themelet.class.php +++ b/themes/default/themelet.class.php @@ -18,7 +18,7 @@ class Themelet { * A specific, common error message */ public function display_permission_denied(Page $page) { - header("HTTP/1.0 403 Permission Denied"); + $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"); } diff --git a/themes/flat/themelet.class.php b/themes/flat/themelet.class.php index 5cb25716..b79ccc73 100644 --- a/themes/flat/themelet.class.php +++ b/themes/flat/themelet.class.php @@ -18,7 +18,7 @@ class Themelet { * A specific, common error message */ public function display_permission_denied(Page $page) { - header("HTTP/1.0 403 Permission Denied"); + $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"); } diff --git a/themes/lite/themelet.class.php b/themes/lite/themelet.class.php index 59b403e2..8d57b147 100644 --- a/themes/lite/themelet.class.php +++ b/themes/lite/themelet.class.php @@ -18,7 +18,7 @@ class Themelet { * A specific, common error message */ public function display_permission_denied(Page $page) { - header("HTTP/1.0 403 Permission Denied"); + $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"); } diff --git a/themes/old_default/themelet.class.php b/themes/old_default/themelet.class.php index 09eb031e..41c5cf5e 100644 --- a/themes/old_default/themelet.class.php +++ b/themes/old_default/themelet.class.php @@ -16,7 +16,7 @@ class Themelet { * A specific, common error message */ public function display_permission_denied(Page $page) { - header("HTTP/1.0 403 Permission Denied"); + $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"); } diff --git a/themes/warm/themelet.class.php b/themes/warm/themelet.class.php index ddbad7a8..89f4dcf8 100644 --- a/themes/warm/themelet.class.php +++ b/themes/warm/themelet.class.php @@ -18,7 +18,7 @@ class Themelet { * A specific, common error message */ public function display_permission_denied(Page $page) { - header("HTTP/1.0 403 Permission Denied"); + $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"); }