]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/prepend.php
fix PHP Fatal error: Call to undefined function: finish() in phpwiki-1.3.11/lib...
[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.30 2004-12-26 14:10:33 rurban Exp $');
9
10 define('PHPWIKI_VERSION', '1.3.11pre-20041223');
11
12 /** 
13  * Returns true if current php version is at mimimum a.b.c 
14  * Called: check_php_version(4,1)
15  */
16 function check_php_version ($a = '0', $b = '0', $c = '0') {
17     static $PHP_VERSION;
18     if (!isset($PHP_VERSION))
19         $PHP_VERSION = substr( str_pad( preg_replace('/\D/','', PHP_VERSION), 3, '0'), 0, 3);
20     return ($PHP_VERSION >= ($a.$b.$c));
21 }
22
23 // If your php was compiled with --enable-trans-sid it tries to
24 // add a PHPSESSID query argument to all URL strings when cookie
25 // support isn't detected in the client browser.  For reasons
26 // which aren't entirely clear (PHP bug) this screws up the URLs
27 // generated by PhpWiki.  Therefore, transparent session ids
28 // should be disabled.  This next line does that.
29 //
30 // (At the present time, you will not be able to log-in to PhpWiki,
31 // unless your browser supports cookies.)
32 @ini_set('session.use_trans_sid', 0);
33
34 if (defined('DEBUG') and (DEBUG & 8) and extension_loaded("xdebug")) {
35     xdebug_start_trace();
36     xdebug_enable();
37 }
38
39 // Used for debugging purposes
40 class DebugTimer {
41     function DebugTimer() {
42         $this->_start = $this->microtime();
43         if (function_exists('posix_times'))
44             $this->_times = posix_times();
45     }
46
47     /**
48      * @param string $which  One of 'real', 'utime', 'stime', 'cutime', 'sutime'
49      * @return float Seconds.
50      */
51     function getTime($which='real', $now=false) {
52         if ($which == 'real')
53             return $this->microtime() - $this->_start;
54
55         if (isset($this->_times)) {
56             if (!$now) $now = posix_times();
57             $ticks = $now[$which] - $this->_times[$which];
58             return $ticks / $this->_CLK_TCK();
59         }
60
61         return 0.0;           // Not available.
62     }
63
64     function getStats() {
65         if (!isset($this->_times)) {
66             // posix_times() not available.
67             return sprintf("real: %.3f", $this->getTime('real'));
68         }
69         $now = posix_times();
70         return sprintf("real: %.3f, user: %.3f, sys: %.3f",
71                        $this->getTime('real'),
72                        $this->getTime('utime', $now),
73                        $this->getTime('stime', $now));
74     }
75         
76     function _CLK_TCK() {
77         // FIXME: this is clearly not always right.
78         // But how to figure out the right value?
79         return 100.0;
80     }
81
82     function microtime(){
83         list($usec, $sec) = explode(" ", microtime());
84         return ((float)$usec + (float)$sec);
85     }
86 }
87 $RUNTIMER = new DebugTimer;
88 /*
89 if (defined('E_STRICT') and (E_ALL & E_STRICT)) // strict php5?
90     error_reporting(E_ALL & ~E_STRICT);         // exclude E_STRICT
91 else
92     error_reporting(E_ALL); // php4
93 //echo " prepend: ", error_reporting();
94 */
95 require_once(dirname(__FILE__).'/ErrorManager.php');
96 require_once(dirname(__FILE__).'/WikiCallback.php');
97
98 // FIXME: deprecated
99 function ExitWiki($errormsg = false)
100 {
101     global $request;
102     static $in_exit = 0;
103
104     if (is_object($request) and method_exists($request,"finish"))
105         $request->finish($errormsg); // NORETURN
106
107     if ($in_exit)
108         exit;
109     
110     $in_exit = true;
111
112     global $ErrorManager;
113     $ErrorManager->flushPostponedErrors();
114    
115     if(!empty($errormsg)) {
116         PrintXML(HTML::br(), $errormsg);
117         print "\n</body></html>";
118     }
119     exit;
120 }
121 if (!defined('DEBUG') or (defined('DEBUG') and DEBUG > 2)) {
122     $ErrorManager->setPostponedErrorMask(E_ALL); // ignore all errors
123     $ErrorManager->setFatalHandler(new WikiFunctionCb('ExitWiki'));
124 } else {
125     $ErrorManager->setPostponedErrorMask(E_USER_NOTICE | E_NOTICE);
126 }
127
128
129 // (c-file-style: "gnu")
130 // Local Variables:
131 // mode: php
132 // tab-width: 8
133 // c-basic-offset: 4
134 // c-hanging-comment-ender-p: nil
135 // indent-tabs-mode: nil
136 // End:   
137 ?>