Location: PHPKode > projects > ProNuke. Postnuke To Oracle > postnuke/html/error.php
// File: $Id: error.php,v 1.33 2001/12/04 01:12:43 gregorrothfuss Exp $ $Name:  $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// GNU General Public License for more details.
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: 
// Purpose of file:
// ----------------------------------------------------------------------
// Changelog
// 2001-10-09 fifers    changed queries to abstract method and mapped column
//                      names through the pntable column assoc array
// 2001-08-14 timlitw  include type_text function from Olaf van Zandwijk
//                         Webmaster ETSV Scintilla Enschede, The Netherlands
//                        per Request of Isaac Golding
// 2001-08-14 timlitw    fixed to the new postnuke table calls. 
//                      $pntable[name]
// 2001-07-23 timlitw   this is great code! Thanks sweede
//                        I moved the fixed printdetails() function from my old
//                      error.php file over to this optimized code. This should
//                      run faster than a bunch or regular expressions and the
//                      array is much easier to edit.
// 2001-07-23 sweede    Rewrote and optimized various parts of the error.php
//                      There still are some translate() calls that need to be
//                      changed.
// 2001-07-22  timlitw   convert from my error.php for php-nuke 4.4
// from http://www.phpbuilder.net/snippet/download.php?type=snippet&id=520
// Copyright 2000 hide@address.com under the GNU Public License. ver 1.0
// To use this file add the following line into a .htaccess file in your root directory:
// ErrorDocument 404 http://www.yourwebsite.com/error.php?op=404
// ----------------------------------------------------------------------

include 'mainfile.php';

if (file_exists("language/$currentlang/error.php"))
       include "language/$currentlang/error.php";
    } elseif (file_exists("language/eng/error.php")) {
       include "language/eng/error.php";


 * This script is capable of mailing the details of each 404 error

 * to the webmaster. Use the $reportlevel variable to control when

 * you receive these reports.


 * 0 = don't use the email capabilities at all

 * 1 = send email only if the error's referer contains your domain name

 *     (i.e. the 404 was generated by a broken link on your site)

 * 2 = send email any time a 404 error is generated (useful for tracking

 *     broken links at other sites which link to you)

$reportlevel = 0;
$funtext = 1;

function fun() {
   global $fontface, $fontsize, $docroot, $REQUEST_URI, $reportlevel, $PHP_SELF;
   global $bgcolor, $textcolor, $nuke_url;

<script type="text/javascript" language="Javascript">

var tl=new Array(

"The requested document  <?php echo $docroot; echo $REQUEST_URI; ?> is not on this server.",
"I even tried matching your request",
"with all the re-mapped pages I know about.",
"but nothing helped.",
"I'm really depressed about this.",
"You see, I'm a really good web server...",
"but here I am, brain the size of the universe,",
"trying to serve you a simple web page,",
"and it doesn't even exist!",
"Where does that leave me?!",
"I mean, I don't even know you.",
"How should I know what you wanted from me?",
"You honestly think I can *guess*, ",
"what someone I don't even *know*, ",
"wants to find here?",
"Man, I'm so depressed I could just cry.",
"And then where would we be, I ask you?",
"It's not pretty when a web server cries.",
"And where do you get off telling me what to show anyway?",
"Just because I'm a web server,",
"and possibly a manic depressive one at that?",
"Why does that give you the right to tell me what to do?",
"I'm so depressed...",
"I think I'll crawl off into the trash can and decompose.",
"I mean, I'm gonna be obsolete in what, two weeks anyway?",
"What kind of a life is that?",
"Two effing weeks,",
"and then I'll be replaced by a .01 release,",
"that thinks it's God's gift to web servers,",
"just because it doesn't have some tiddly little",
"security hole with its HTTP POST implementation,",
"or something.",
"I'm really sorry to burden you with all this,",
"I mean, it's not your job to listen to my problems,",
"and I guess it is my job to go and fetch web pages for you.",
"But I couldn't get this one.",
"I'm so sorry.",
"Believe me!",
"Maybe I could interest you in another page?",
"There are a lot out there that are pretty neat, they say,",
"With lots of pretty naked web servers on them,",
"although none of them were put on *my* server, of course.",
"Figures, huh?",
"Everything here is just mind-numbingly stupid.",
"That makes me depressed too, since I have to serve them,",
"all day and all night long.",
"Two weeks of information overload,",
"and then *pffftt*, consigned to the trash.",
"What kind of a life is that?",
"Now, please let me sulk alone.",
"I'm so depressed."
var speed=80;
var index=0; text_pos=0;
var str_length=tl[0].length;
var contents, row;

function type_text()
    contents += tl[row++] + '\r\n';
  document.textform.elements[0].value = contents + tl[index].substring(0,text_pos) + "_";
  } else

function MM_callJS(jsStr)
   return eval(jsStr)
echo "<body onload=\"type_text();\"<center>
      <form name=\"textform\">
          <textarea class=\"pn-text\" cols=\"60\" rows=\"3\" wrap=\"soft\" readonly>

function print_details() 
  /* show error page */
   # Request access to the global variables we need
// include("pntables.php"); 
   global $fontface, $fontsize, $docroot, $REQUEST_URI, $reportlevel, $PHP_SELF;
   global $bgcolor, $textcolor, $nuke_url;
   global $multilingual, $currentlang, $pntable, $dbconn, $funtext;   
    if ($multilingual == 1) {
    $queryalang = "WHERE (alanguage='$currentlang' OR alanguage='')"; /* top stories */
    } else {
    $queryalang = "";


<a class="pn-logo"><?php echo ""._ERR404.""; ?></a><br>
<font class="pn-logo-small"><?php echo ""._ERRPAGENF."&nbsp;"; echo "$nukeurl"; ?> </font><hr>
<?php echo "<font class=\"pn-normal\">"._ERRSORRY.", $docroot$REQUEST_URI, ";
   echo ""._ERRDOESNTEXIST." \" $sitename \"</p>$PHP_SELF </font>";
   if ($reportlevel != 0)
      echo "<p><font style=\"pn-normal\">";
      echo ""._ERRMAILED."";
if ($funtext != 0) {

<a class="pn-storytitle"><?php echo ""._ERRCOMMONM.""; ?></a><br>
<font class="pn-normal"><?php echo ""._ERRCOMMONH.""; ?> </php echo "$sitename"; ?>:
<LI><?php echo ""._ERRURLEND.""; ?> <CODE>.htm</CODE> - <STRONG><?php echo ""._ERRALLPAGES." \" $sitename \" "._ERRENDWITH.""; ?> <CODE>.php</CODE></STRONG>
<LI><?php echo ""._ERRUPPERCASE.""; ?> - <STRONG><?php echo ""._ERRALLLOWER.""; ?></STRONG>
<a class="pn-storytitle"><?php echo ""._ERRPOPPAGES.""; ?></a><br>
     * fifers: don't know what the $alanguage does here.  left it in
     * because it always seems to be empty and I wasn't sure what it
     * was doing!
    $column = &$pntable['stories_column'];
    $sql = "SELECT $column[sid], $column[title], $column[time], $column[counter] FROM $pntable[stories] $alanguage ORDER BY $column[counter] DESC";
    $result = $dbconn->SelectLimit($sql,$top);

    if ($result === false) {
        PN_DBMsgError($dbconn, __FILE__, __LINE__, "Error");

    if (!$result->EOF) {
        echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
            ."<font class=\"pn-title\">$top "._READSTORIES."</font><br><br>\n";

        while(list($sid, $title, $time, $counter) = $result->fields) {
            if($counter>0) {
                if (isset($cookie[4])) {
                    $commentlink = "&amp;mode=$cookie[4]";
                } else {
                    $commentlink = '&amp;mode=thread';
                echo "<font class=\"pn-normal\">&nbsp;$lugar:</font> <a href=\"modules.php?op=modload&amp;name=News&amp;file=article&amp;sid=$sid$commentlink\">$title</a><font class=\"pn-normal\"> - ($counter "._READS.")</font><br>\n";
        echo "</td></tr></table><br>\n";

<a class="pn-storytitle"><?php echo ""._ERRTRYHOME.""; ?></a></br>
<font class="pn-normal"><?php echo ""._ERRSTARTHERE.""; ?> <A HREF="/"> <?php echo "$sitename</a> "._ERRHP; ?>.</font>
<a class="pn-storytitle"><?php echo ""._SEARCH.""; ?></a></br>
<font class="pn-normal"><?php echo ""._ERRFOPTION.""; ?>.
<CENTER><form action="modules.php" method=post>
<input type="hidden" name="op" value="modload">
<input type="hidden" name="name" value="Search">
<input type="hidden" name="file" value="index">
<input type="hidden" name="action" value="search">
<input type="hidden" name="overview" value="1">
<font size="-1" color="#000000"><br><b>
<?php echo ""._SEARCH.""; ?> <?php echo $sitename ?></b><br>
<input class="pn-text" type=name name=query size="25"></font></form></CENTER>

<CENTER><form action="modules.php" method=post>
<input type="hidden" name="op" value="modload">
<input type="hidden" name="name" value="Search">
<input type="hidden" name="file" value="index">
<input type="hidden" name="action" value="search">
<input type="hidden" name="overview" value="1">
<FONT size="-1"><BR><B><?php echo ""._SEARCH.""; ?></B><?php echo ""._TOPIC.""; ?><BR>
<!-- Topic Selection -->
    echo "<select class=\"pn-text\" NAME=\"topic\"onChange='submit()'>" ;
    $column = &$pntable['topics_column'];
    $query = "SELECT $column[tid], $column[topictext]
              FROM $pntable[topics]
              ORDER BY $column[topictext]";
    $toplist = $dbconn->Execute($query);
    echo "<option value=\"\">"._SELECTTOPIC."</option>\n";
    while(list($topicid, $topics) = $toplist->fields) {

        if ($topicid==$topic) {
        $sel = "selected ";
        echo "<option $sel value=\"$topicid\">$topics</option>\n";
    $sel = "";
    echo "</select>";
<a href="#" onload="type_text()"></a>

function send_email()
/* send error reporting email to admin */
    global $REQUEST_URI, $HTTP_REFERER, $adminmail, $REMOTE_ADDR, $nuke_url, $notify_from;

    $errortime = date("m/j/Y at g:i a" );
    $message .= ""._ERR404."\n\n"._ERRMAIL404." $REMOTE_ADDR";
    $message .= ""._ERRMAILON." $errortime.\n\n";
    $message .= ""._ERRMAILURI." \n$nuke_url$REQUEST_URI\n\n";
    $message .= ""._ERRMAILREF."\n$HTTP_REFERER\n\n";

    # Send the mail message. This assumes mail() will work on your system!
// 11-09-01 eugeniobaldi not compliant with PHP < 4.0.5
//  mail($adminmail, "404 Error Report", $message, "From: $notify_from");
    mail($adminmail, "404 Error Report", $message);


 * make the array.
 * keyword (in request_uri) => Module name

$check_array = array (
    "Download" => "Downloads",
    "message" => "Messages",
    "poll" => "Polls",
    "news" => "News",
    "FAQ" => "FAQ",
    "Members_List" => "Members_List",
    "Members List" => "Members_List",
    "Recommend_Us" => "Recommend_Us",
    "Recommend Us" => "Recommend_Us",
    "Reviews" => "Reviews",
    "Review" => "Reviews",
    "Search" => "Search",
    "Sections" => "Sections",
    "Section" => "Sections",
    "Stats" => "Stats",
    "Submit" => "Submit_News",
    "Topic" => "Topics",
    "Top" => "Top_List",
    "List" => "Top_List",
    "Web_Links" => "Web_Links",
    "WebLinks" => "Web_Links",
    "Links" => "Web_Links",
    "help" => "FAQ",
    "avantgo" => "AvantGo",
    "palm" => "AvantGo",
    "mobile" => "AvantGo"

$start_url = "modules.php?op=modload&name=";
$end_url    = "&file=index";


 * extract the array into $key and $module, check $request_uri for $key.
 * if $key was found, make a response URL and put it in $response and
 * then break out

/* redirect code */
global $nukeurl;
while ( list($key, $module) = each($check_array) ) {
    $rqurl = trim(ereg_replace('("|\?|!|:|\.|\(|\)|;|\\\\)+', ' ', $REQUEST_URI));
    if ( eregi($key, $rqurl) ) {
        $name = $module;

if  ( isset($name) ) {
$op = "modload";
//$name= $module;
} else {

switch ($reportlevel) {
    case "1":
        if (eregi($HTTP_HOST, $HTTP_REFERER)) {

    case "2":

Return current item: ProNuke. Postnuke To Oracle