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.15 2003-03-07 02:47:32 dairiki Exp $');
10 // Used for debugging purposes
12 function DebugTimer() {
13 $this->_start = $this->microtime();
14 if (function_exists('posix_times'))
15 $this->_times = posix_times();
19 * @param string $which One of 'real', 'utime', 'stime', 'cutime', 'sutime'
20 * @return float Seconds.
22 function getTime($which='real', $now=false) {
24 return $this->microtime() - $this->_start;
26 if (isset($this->_times)) {
27 if (!$now) $now = posix_times();
28 $ticks = $now[$which] - $this->_times[$which];
29 return $ticks / $this->_CLK_TCK();
32 return 0.0; // Not available.
36 if (!isset($this->_times)) {
37 // posix_times() not available.
38 return sprintf("real: %.3f", $this->getTime('real'));
41 return sprintf("real: %.3f, user: %.3f, sys: %.3f",
42 $this->getTime('real'),
43 $this->getTime('utime', $now),
44 $this->getTime('stime', $now));
48 // FIXME: this is clearly not always right.
49 // But how to figure out the right value?
54 list($usec, $sec) = explode(" ", microtime());
55 return ((float)$usec + (float)$sec);
58 $RUNTIMER = new DebugTimer;
60 error_reporting(E_ALL);
61 require_once('lib/ErrorManager.php');
62 require_once('lib/WikiCallback.php');
65 function ExitWiki($errormsg = false)
70 if (is_object($request))
71 $request->finish($errormsg); // NORETURN
79 $ErrorManager->flushPostponedErrors();
81 if(!empty($errormsg)) {
82 PrintXML(HTML::br(), $errormsg);
83 print "\n</body></html>";
87 if (!defined('DEBUG') or (defined('DEBUG') and DEBUG > 2)) {
88 $ErrorManager->setPostponedErrorMask(E_ALL);
89 $ErrorManager->setFatalHandler(new WikiFunctionCb('ExitWiki'));
93 $ErrorManager->setPostponedErrorMask(E_USER_NOTICE | E_NOTICE);
97 // (c-file-style: "gnu")
102 // c-hanging-comment-ender-p: nil
103 // indent-tabs-mode: nil