]> git.mjollnir.org Git - s9y.git/commitdiff
Use HTTP 404 where needed
authorgarvinhicking <garvinhicking>
Thu, 14 Jun 2007 09:14:15 +0000 (09:14 +0000)
committergarvinhicking <garvinhicking>
Thu, 14 Jun 2007 09:14:15 +0000 (09:14 +0000)
docs/NEWS
index.php

index 8b432f3cd3d474bf78269f0cc46ca03c117957a8..0ffcb11d988235a374c44b445d9ddcb0379d6b87 100644 (file)
--- 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.
index 7e3ccfb4ced4cc2dee668fe9cc20de83f0aa6944..a9f33d5a66199117a7f95477a238ffe41d909b32 100644 (file)
--- 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)) {