4 * Things which must be done and defined before anything else.
7 function rcs_id ($id) { $GLOBALS['RCS_IDS'] .= "$id\n"; }
8 rcs_id('$Id: prepend.php,v 1.2 2001-02-14 05:22:49 dairiki Exp $');
10 error_reporting(E_ALL);
12 define ('FATAL_ERRORS',
13 E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR);
14 define ('WARNING_ERRORS',
15 E_WARNING | E_CORE_WARNING | E_COMPILE_WARNING | E_USER_WARNING);
16 define ('NOTICE_ERRORS', E_NOTICE | E_USER_NOTICE);
18 $PostponedErrorMask = 0;
19 $PostponedErrors = array();
21 function PostponeErrorMessages ($newmask = -1)
23 global $PostponedErrorMask, $PostponedErrors;
26 return $PostponedErrorMask;
28 $oldmask = $PostponedErrorMask;
29 $PostponedErrorMask = $newmask;
32 while ($i < sizeof($PostponedErrors))
34 list ($errno, $message) = $PostponedErrors[$i];
35 if (($errno & $newmask) == 0)
38 array_splice($PostponedErrors, $i, 1);
47 function ExitWiki($errormsg = false)
52 if($exitwiki) // just in case CloseDataBase calls us
56 PostponeErrorMessages(0); // Spew postponed messages.
58 if(!empty($errormsg)) {
59 print "<P><hr noshade><h2>" . gettext("WikiFatalError") . "</h2>\n";
61 print "\n</BODY></HTML>";
69 function PostponeErrorHandler ($errno, $errstr, $errfile, $errline)
71 global $PostponedErrorMask, $PostponedErrors;
72 static $inHandler = 0;
74 if ($inHandler++ != 0)
75 return; // prevent recursion.
77 if (($errno & NOTICE_ERRORS) != 0)
79 else if (($errno & WARNING_ERRORS) != 0)
84 $errfile = ereg_replace('^' . getcwd() . '/', '', $errfile);
85 $message = sprintf("<br>%s:%d: <b>%s</b>[%d]: %s<br>\n",
86 htmlspecialchars($errfile),
87 $errline, $what, $errno,
88 htmlspecialchars($errstr));
93 PostponeErrorMessages(0); // Spew postponed messages.
98 else if (($errno & error_reporting()) != 0)
100 if (($errno & $PostponedErrorMask) != 0)
102 $PostponedErrors[] = array($errno, $message);
112 set_error_handler('PostponeErrorHandler');
114 PostponeErrorMessages(E_ALL);
117 function SearchPath ($file, $missing_ok = false, $path = false)
119 if (ereg('^/', $file))
120 return $file; // absolute path.
123 $path = $GLOBALS['DataPath'];
125 while (list($i, $dir) = each($path))
127 if (file_exists("$dir/$file"))
132 ExitWiki("$file: file not found");
138 // c-file-style: "ellemtel"