00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
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 aliroRequest::getInstance()->setPageTitle(T_('404 Error - page not found'));
00051 echo <<<PAGE_404
00052 <h3>Sorry! Page not found</h3>
00053 <p>
00054 This may be a problem with our system, and the issue
00055 has been logged for investigation. Or it could be that
00056 you have an outdated link.
00057 </p>
00058 <p>
00059 This page is also presented for an item that exists
00060 but is not available to you. If you are not logged in,
00061 you might like to log in and try again.
00062 </p>
00063 <p>
00064 If you have any query you would like us to deal with,
00065 please use the CONTACT US facility from the main menu.
00066 </p>
00067 <p>
00068 The following items have some connection with the URI
00069 you used to come here, so maybe they are what you were
00070 looking for?
00071 </p>
00072 PAGE_404;
00073
00074 echo $searchtext;
00075 }
00076 else echo T_('This Aliro based web site is not yet configured with user data, please call back later');
00077 }
00078
00079 private function record404 () {
00080 $uri = $_SERVER['REQUEST_URI'];
00081 $timestamp = date ('Y-m-d H:i:s');
00082 $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
00083 $post = base64_encode(serialize($_POST));
00084 $trace = aliroRequest::trace();
00085 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'");
00086 }
00087
00088 private function searchuri () {
00089 $uri = $_SERVER['REQUEST_URI'];
00090 $bits = explode ('/', $uri);
00091 for ($i=count($bits); $i>0; $i--) {
00092 $bit = $bits[$i-1];
00093 if ($bit) break;
00094 }
00095 $bit = str_replace(array('!', '%21'), array('',''), $bit);
00096 $searchword = preg_replace('/[^A-Za-z]/', ' ', $bit);
00097 $results = aliroMambotHandler::getInstance()->trigger('onSearch', array($searchword, 'all', 'popular'));
00098 $lines = array();
00099 $purifier = new HTMLPurifier;
00100 foreach ($results as $result) {
00101 if ($result) foreach ($result as $item) {
00102 if (empty($item->text)) continue;
00103 $item->text = $purifier->purify($item->text);
00104 $item->text = strip_tags($item->text);
00105 if (strlen($item->text) > 200) $item->text = substr($item->text,0,200).'...';
00106 if (!isset($item->section)) $item->section = '';
00107 $lines[] = $item;
00108 }
00109 }
00110 $html = '';
00111 $sef = aliroSEF::getInstance();
00112 if (count($lines)) foreach ($lines as $line) {
00113 $section = isset($line->section) ? $line->section : '';
00114 $html .= <<<SEARCH_LINE
00115
00116 <p>
00117 <a href="{$sef->sefRelToAbs($line->href)}">$line->title</a>
00118 $section
00119 $line->text
00120 </p>
00121
00122 SEARCH_LINE;
00123
00124 }
00125 else $html = '<p>'.T_('Sorry, none found').'</p>';
00126 return $html;
00127 }
00128
00129 }