From: garvinhicking Date: Thu, 14 Jun 2007 09:14:15 +0000 (+0000) Subject: Use HTTP 404 where needed X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a78f3710bd18061ce6cff5ddd2c1ce2245307a2b;p=s9y.git Use HTTP 404 where needed --- diff --git a/docs/NEWS b/docs/NEWS index 8b432f3..0ffcb11 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,10 @@ Version 1.2 () ------------------------------------------------------------------------ + * When a category or entry does not exist, emit HTTP 404 message + template instead of "No entries to print" and HTTP 200 status. + (garvinhicking) + * Fix URL permalink lookup in some cases (garvinhicking, beta2) * Add admin backend templates for main area and the entry editor. diff --git a/index.php b/index.php index 7e3ccfb..a9f33d5 100644 --- a/index.php +++ b/index.php @@ -278,6 +278,9 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range if (is_array($title)) { $serendipity['head_title'] = htmlspecialchars($title[0]); $serendipity['head_subtitle'] = htmlspecialchars($serendipity['blogTitle']); + } else { + $serendipity['view'] = '404'; + header('HTTP/1.0 404 Not found'); } ob_start(); @@ -413,8 +416,14 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range } $cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']); - $serendipity['head_title'] = $cInfo['category_name']; - $serendipity['head_subtitle'] = $serendipity['blogTitle']; + + if (!is_array($cInfo)) { + $serendipity['view'] = '404'; + header('HTTP/1.0 404 Not found'); + } else { + $serendipity['head_title'] = $cInfo['category_name']; + $serendipity['head_subtitle'] = $serendipity['blogTitle']; + } include(S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); } else if ($is_multiauth || preg_match(PAT_PERMALINK_AUTHORS, $uri, $matches)) { @@ -452,8 +461,14 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range } $uInfo = serendipity_fetchUsers($serendipity['GET']['viewAuthor']); - $serendipity['head_title'] = sprintf(ENTRIES_BY, $uInfo[0]['realname']); - $serendipity['head_subtitle'] = $serendipity['blogTitle']; + + if (!is_array($uInfo)) { + $serendipity['view'] = '404'; + header('HTTP/1.0 404 Not found'); + } else { + $serendipity['head_title'] = sprintf(ENTRIES_BY, $uInfo[0]['realname']); + $serendipity['head_subtitle'] = $serendipity['blogTitle']; + } include(S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); } else if (preg_match(PAT_SEARCH, $uri, $matches)) {