aliroPage404.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*******************************************************************************
00004  * Aliro - the modern, accessible content management system
00005  *
00006  * Aliro is open source software, free to use, and licensed under GPL.
00007  * You can find the full licence at http://www.gnu.org/copyleft/gpl.html GNU/GPL
00008  *
00009  * The author freely draws attention to the fact that Aliro derives from Mambo,
00010  * software that is controlled by the Mambo Foundation.  However, this section
00011  * of code is totally new.  If it should contain any fragments that are similar
00012  * to Mambo, please bear in mind (1) there are only so many ways to do things
00013  * and (2) the author of Aliro is also the author and copyright owner for large
00014  * parts of Mambo 4.6.
00015  *
00016  * Tribute should be paid to all the developers who took Mambo to the stage
00017  * it had reached at the time Aliro was created.  It is a feature rich system
00018  * that contains a good deal of innovation.
00019  *
00020  * Your attention is also drawn to the fact that Aliro relies on other items of
00021  * open source software, which is very much in the spirit of open source.  Aliro
00022  * wishes to give credit to those items of code.  Please refer to
00023  * http://aliro.org/credits for details.  The credits are not included within
00024  * the Aliro package simply to avoid providing a marker that allows hackers to
00025  * identify the system.
00026  *
00027  * Copyright in this code is strictly reserved by its author, Martin Brampton.
00028  * If it seems appropriate, the copyright will be vested in the Aliro Organisation
00029  * at a suitable time.
00030  *
00031  * Copyright (c) 2007 Martin Brampton
00032  *
00033  * http://aliro.org
00034  *
00035  * counterpoint@aliro.org
00036  *
00037  * aliroPage404 should be developed to be much more user friendly.  At present
00038  * it simply provides some basic diagnostics when a page link does not work out.
00039  *
00040  */
00041 
00042 
00043 class aliroPage404 {
00044 
00045     public function __construct () {
00046         if (aliroComponentHandler::getInstance()->componentCount() AND aliroMenuHandler::getInstance()->getMenuCount('mainmenu')) {
00047             header ('HTTP/1.1 404 Not Found');
00048             $this->record404();
00049             $searchtext = $this->searchuri();
00050             $request = mosRequest::getInstance();
00051             $request->setPageTitle(T_('404 Error - page not found'));
00052             echo <<<PAGE_404
00053             <h3>Sorry! Page not found</h3>
00054             <p>
00055             This may be a problem with our system, and the issue has been logged for investigation.
00056             Or it could be that you have an outdated link.  For instance, if you were looking for
00057             the forum, it has been discontinued.  You can comment on Martin Brampton's blog, or if
00058             you were looking for discussion of Remository, click on the Remository link in the main
00059             menu, then go to the forum there.
00060             </p>
00061             <p>
00062             This page is also presented for an item that exists but is not available to you.  If
00063             you are not logged in, you might like to log in and try again.
00064             </p>
00065             <p>
00066             If you have any query you would like us to deal with, please use the CONTACT US facility
00067             from the main menu.  Note that it will not accept any valid URL for another site, as a
00068             measure against misuse by spammers.
00069             </p>
00070             <p>
00071             The following items have some connection with the URI you used to come here, so maybe
00072             they are what you were looking for?
00073             </p>
00074 PAGE_404;
00075 
00076             echo $searchtext;
00077         }
00078         else echo T_('This Aliro based web site is not yet configured with user data, please call back later');
00079     }
00080 
00081     private function record404 () {
00082         $uri = $_SERVER['REQUEST_URI'];
00083         $timestamp = date ('Y-m-d H:i:s');
00084         $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
00085         $post = base64_encode(serialize($_POST));
00086         $trace = aliroRequest::trace();
00087         aliroCoreDatabase::getInstance()->doSQL("INSERT INTO #__error_404 (uri, timestamp, referer, post, trace) VALUES ('$uri', '$timestamp', '$referer', '$post', '$trace') ON DUPLICATE KEY UPDATE timestamp = '$timestamp', referer='$referer', post='$post', trace='$trace'");
00088     }
00089 
00090     private function searchuri () {
00091         $uri = $_SERVER['REQUEST_URI'];
00092         $bits = explode ('/', $uri);
00093         for ($i=count($bits); $i>0; $i--) {
00094             $bit = $bits[$i-1];
00095             if ($bit) break;
00096         }
00097         $bit = str_replace(array('!', '%21'), array('',''), $bit);
00098         $searchword = preg_replace('/[^A-Za-z]/', ' ', $bit);
00099         $results = aliroMambotHandler::getInstance()->trigger('onSearch', array($searchword, 'all', 'popular'));
00100         $lines = array();
00101         $purifier = new HTMLPurifier;
00102         foreach ($results as $result) {
00103             if ($result) foreach ($result as $item) {
00104                 $item->text = $purifier->purify($item->text);
00105                 $item->text = strip_tags($item->text);
00106                 if (strlen($item->text) > 200) $item->text = substr($item->text,0,200).'...';
00107                 $lines[] = $item;
00108             }
00109         }
00110         $html = '';
00111         $sef = aliroSEF::getInstance();
00112         if (count($lines)) foreach ($lines as $line) {
00113             $html .= <<<SEARCH_LINE
00114 
00115             <p>
00116             <a href="{$sef->sefRelToAbs($line->href)}">$line->title</a>
00117             $line->section
00118             $line->text
00119             </p>
00120 
00121 SEARCH_LINE;
00122 
00123         }
00124         else $html = '<p>'.T_('Sorry, none found').'</p>';
00125         return $html;
00126     }
00127 
00128 }

Generated on Thu Apr 17 13:03:27 2008 for ALIRO by  doxygen 1.5.5