]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/prepend.php
Connect the rest of PhpWiki to the IniConfig system. Also the keyword regular expres...
[SourceForge/phpwiki.git] / lib / prepend.php
1 <?php
2 /* lib/prepend.php
3  *
4  * Things which must be done and defined before anything else.
5  */
6 $RCS_IDS = '';
7 function rcs_id ($id) { $GLOBALS['RCS_IDS'] .= "$id\n"; }
8 rcs_id('$Id: prepend.php,v 1.17 2004-04-19 23:13:03 zorloc Exp $');
9
10 define ('PHPWIKI_VERSION', '1.3.10pre');
11
12 // If your php was compiled with --enable-trans-sid it tries to
13 // add a PHPSESSID query argument to all URL strings when cookie
14 // support isn't detected in the client browser.  For reasons
15 // which aren't entirely clear (PHP bug) this screws up the URLs
16 // generated by PhpWiki.  Therefore, transparent session ids
17 // should be disabled.  This next line does that.
18 //
19 // (At the present time, you will not be able to log-in to PhpWiki,
20 // unless your browser supports cookies.)
21 @ini_set('session.use_trans_sid', 0);
22
23
24 // Used for debugging purposes
25 class DebugTimer {
26     function DebugTimer() {
27         $this->_start = $this->microtime();
28         if (function_exists('posix_times'))
29             $this->_times = posix_times();
30     }
31
32     /**
33      * @param string $which  One of 'real', 'utime', 'stime', 'cutime', 'sutime'
34      * @return float Seconds.
35      */
36     function getTime($which='real', $now=false) {
37         if ($which == 'real')
38             return $this->microtime() - $this->_start;
39
40         if (isset($this->_times)) {
41             if (!$now) $now = posix_times();
42             $ticks = $now[$which] - $this->_times[$which];
43             return $ticks / $this->_CLK_TCK();
44         }
45
46         return 0.0;           // Not available.
47     }
48
49     function getStats() {
50         if (!isset($this->_times)) {
51             // posix_times() not available.
52             return sprintf("real: %.3f", $this->getTime('real'));
53         }
54         $now = posix_times();
55         return sprintf("real: %.3f, user: %.3f, sys: %.3f",
56                        $this->getTime('real'),
57                        $this->getTime('utime', $now),
58                        $this->getTime('stime', $now));
59     }
60         
61     function _CLK_TCK() {
62         // FIXME: this is clearly not always right.
63         // But how to figure out the right value?
64         return 100.0;
65     }
66
67     function microtime(){
68         list($usec, $sec) = explode(" ", microtime());
69         return ((float)$usec + (float)$sec);
70     }
71 }
72 $RUNTIMER = new DebugTimer;
73
74 error_reporting(E_ALL);
75 require_once('lib/ErrorManager.php');
76 require_once('lib/WikiCallback.php');
77
78 // FIXME: deprecated
79 function ExitWiki($errormsg = false)
80 {
81     global $request;
82     static $in_exit = 0;
83
84     if (is_object($request))
85         $request->finish($errormsg); // NORETURN
86
87     if ($in_exit)
88         exit;
89     
90     $in_exit = true;
91
92     global $ErrorManager;
93     $ErrorManager->flushPostponedErrors();
94    
95     if(!empty($errormsg)) {
96         PrintXML(HTML::br(), $errormsg);
97         print "\n</body></html>";
98     }
99     exit;
100 }
101 if (!defined('DEBUG') or (defined('DEBUG') and DEBUG > 2)) {
102     $ErrorManager->setPostponedErrorMask(E_ALL); // ignore all errors
103     $ErrorManager->setFatalHandler(new WikiFunctionCb('ExitWiki'));
104 } else {
105     $ErrorManager->setPostponedErrorMask(E_USER_NOTICE | E_NOTICE);
106 }
107
108
109 // (c-file-style: "gnu")
110 // Local Variables:
111 // mode: php
112 // tab-width: 8
113 // c-basic-offset: 4
114 // c-hanging-comment-ender-p: nil
115 // indent-tabs-mode: nil
116 // End:   
117 ?>