From bd31bcd79aba9ea3fc62f6266ceb23811c4a7acc Mon Sep 17 00:00:00 2001 From: "green-ponies (jgen)" Date: Tue, 30 Aug 2011 16:24:10 -0400 Subject: [PATCH] The page class now supports both HTML headers and HTTP headers. From the comment: FIXME: should be $page->blah --- core/page.class.php | 18 ++++++++++++++---- ext/image/main.php | 8 ++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/core/page.class.php b/core/page.class.php index 254f7619..b1940cd3 100644 --- a/core/page.class.php +++ b/core/page.class.php @@ -109,6 +109,7 @@ class Page { var $subheading = ""; var $quicknav = ""; var $html_headers = array(); + var $http_headers = array(); var $blocks = array(); /** @publicsection */ @@ -144,8 +145,9 @@ class Page { /** * Add a http header to be sent to the client. */ - public function add_header($line) { - die("Function is not impliemented yet."); + public function add_http_header($line, $position=50) { + while(isset($this->http_headers[$position])) $position++; + $this->http_headers[$position] = $line; } /** @@ -164,9 +166,17 @@ class Page { */ public function display() { global $page; + + add_http_header("Content-type: {$this->type}", 1); + add_http_header("X-Powered-By: SCore-".SCORE_VERSION, 2); - header("Content-type: {$this->type}"); - header("X-Powered-By: SCore-".SCORE_VERSION); + if (!headers_sent()) { + foreach($this->http_headers as $head){ + header($head); + } + } else { + print "Error: Headers have already been sent to the client."; + } switch($this->mode) { case "page": diff --git a/ext/image/main.php b/ext/image/main.php index 67f2ccc7..aea0ff54 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -367,13 +367,13 @@ class ImageIO extends SimpleExtension { } $gmdate_mod = gmdate('D, d M Y H:i:s', filemtime($file)) . ' GMT'; - // FIXME: should be $page->blah if($if_modified_since == $gmdate_mod) { - header("HTTP/1.0 304 Not Modified"); + $page->add_http_header("HTTP/1.0 304 Not Modified",3); } else { - header("Last-Modified: $gmdate_mod"); - header("Expires: Fri, 2 Sep 2101 12:42:42 GMT"); // War was beginning + /* FIXME: The Expires date Needs to be admin-configurable */ + $page->add_http_header("Last-Modified: $gmdate_mod"); + $page->add_http_header("Expires: Fri, 2 Sep 2101 12:42:42 GMT"); // War was beginning } } else {