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 $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 }