Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2008-08-19 18:14:14


Author: danieljames
Date: 2008-08-19 18:14:13 EDT (Tue, 19 Aug 2008)
New Revision: 48230
URL: http://svn.boost.org/trac/boost/changeset/48230

Log:
Introduce a general purpose error function, and use it to add 404 errors for feed based pages when the entry isn't in the feed.

Added:
   website/public_html/beta/common/code/boost_error_page.php
      - copied, changed from r48212, /website/public_html/beta/users/download/entry.php
Text files modified:
   website/public_html/beta/common/code/boost_error_page.php | 33 +++++++++++++++++++--------------
   website/public_html/beta/users/download/entry.php | 5 +++++
   website/public_html/beta/users/history/entry.php | 5 +++++
   website/public_html/beta/users/news/entry.php | 5 +++++
   4 files changed, 34 insertions(+), 14 deletions(-)

Copied: website/public_html/beta/common/code/boost_error_page.php (from r48212, /website/public_html/beta/users/download/entry.php)
==============================================================================
--- /website/public_html/beta/users/download/entry.php (original)
+++ website/public_html/beta/common/code/boost_error_page.php 2008-08-19 18:14:13 EDT (Tue, 19 Aug 2008)
@@ -1,14 +1,22 @@
 <?php
-require_once(dirname(__FILE__) . '/../../common/code/boost_feed.php');
-$_downloads = new boost_feed(dirname(__FILE__) . '/../../feed/downloads.rss', '/users/download');
-$_guid = basename($_SERVER["PATH_INFO"]);
+function error_page_404($location = null) {
+ if(!$location && isset($_SERVER['REQUEST_URI'])) {
+ $location = $_SERVER['REQUEST_URI'];
+ }
+
+ error_page('HTTP/1.0 404 Not Found', '404 Not Found',
+ $location ? 'File "' . $location . '" not found.' : null);
+}
+
+function error_page($header, $title, $message) {
+ if($header) header($header);
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 <head>
- <title><?php print $_downloads->db[$_guid]['title']; ?></title>
+ <title><?php print htmlentities($title); ?></title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <link rel="icon" href="/favicon.ico" type="image/ico" />
   <link rel="stylesheet" type="text/css" href="/style/section-boost.css" />
@@ -26,20 +34,14 @@
         <div class="section" id="intro">
           <div class="section-0">
             <div class="section-title">
- <h1><?php print $_downloads->db[$_guid]['title']; ?></h1>
+ <h1><?php print htmlentities($title); ?></h1>
             </div>
 
+ <?php if($message) : ?>
             <div class="section-body">
- <h2><span class=
- "news-title"><?php print $_downloads->db[$_guid]['title']; ?></span></h2>
-
- <p><span class=
- "news-date"><?php print $_downloads->db[$_guid]['date']; ?></span></p>
-
- <div class="news-description">
- <?php print $_downloads->db[$_guid]['description']; ?>
- </div>
+ <p><?php print htmlentities($message); ?></p>
             </div>
+ <?php endif ?>
           </div>
         </div>
       </div>
@@ -71,3 +73,6 @@
   </div>
 </body>
 </html>
+<?php
+}
+?>

Modified: website/public_html/beta/users/download/entry.php
==============================================================================
--- website/public_html/beta/users/download/entry.php (original)
+++ website/public_html/beta/users/download/entry.php 2008-08-19 18:14:13 EDT (Tue, 19 Aug 2008)
@@ -2,6 +2,11 @@
 require_once(dirname(__FILE__) . '/../../common/code/boost_feed.php');
 $_downloads = new boost_feed(dirname(__FILE__) . '/../../feed/downloads.rss', '/users/download');
 $_guid = basename($_SERVER["PATH_INFO"]);
+if(!isset($_downloads->db[$_guid])) {
+ require_once(dirname(__FILE__) . '/../../common/code/boost_error_page.php');
+ error_page_404();
+ exit(0);
+}
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Modified: website/public_html/beta/users/history/entry.php
==============================================================================
--- website/public_html/beta/users/history/entry.php (original)
+++ website/public_html/beta/users/history/entry.php 2008-08-19 18:14:13 EDT (Tue, 19 Aug 2008)
@@ -2,6 +2,11 @@
 require_once(dirname(__FILE__) . '/../../common/code/boost_feed.php');
 $_history = new boost_feed(dirname(__FILE__) . '/../../feed/history.rss', '/users/history');
 $_guid = basename($_SERVER["PATH_INFO"]);
+if(!isset($_history->db[$_guid])) {
+ require_once(dirname(__FILE__) . '/../../common/code/boost_error_page.php');
+ error_page_404();
+ exit(0);
+}
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Modified: website/public_html/beta/users/news/entry.php
==============================================================================
--- website/public_html/beta/users/news/entry.php (original)
+++ website/public_html/beta/users/news/entry.php 2008-08-19 18:14:13 EDT (Tue, 19 Aug 2008)
@@ -2,6 +2,11 @@
 require_once(dirname(__FILE__) . '/../../common/code/boost_feed.php');
 $_news = new boost_feed(dirname(__FILE__) . '/../../feed/news.rss', '/users/news');
 $_guid = basename($_SERVER["PATH_INFO"]);
+if(!isset($_news->db[$_guid])) {
+ require_once(dirname(__FILE__) . '/../../common/code/boost_error_page.php');
+ error_page_404();
+ exit(0);
+}
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk