4 * Things which must be done and defined before anything else.
7 // see lib/stdlib.php: phpwiki_version()
8 define('PHPWIKI_VERSION', '1.5.3');
10 // A new php-5.1.x feature: Turn off php-5.1.x auto_globals_jit = On, or use this mess below.
11 if (empty($GLOBALS['HTTP_SERVER_VARS'])) {
12 $GLOBALS['HTTP_SERVER_VARS'] =& $_SERVER;
13 $GLOBALS['HTTP_ENV_VARS'] =& $_ENV;
14 $GLOBALS['HTTP_GET_VARS'] =& $_GET;
15 $GLOBALS['HTTP_POST_VARS'] =& $_POST;
16 $GLOBALS['HTTP_SESSION_VARS'] =& $_SESSION;
17 $GLOBALS['HTTP_COOKIE_VARS'] =& $_COOKIE;
18 $GLOBALS['HTTP_REQUEST_VARS'] =& $_REQUEST;
21 // catch connection failures on upgrade
22 if (isset($GLOBALS['HTTP_GET_VARS']['action'])
23 and $GLOBALS['HTTP_GET_VARS']['action'] == 'upgrade'
25 define('ADODB_ERROR_HANDLER_TYPE', E_USER_WARNING);
27 // If your php was compiled with --enable-trans-sid it tries to
28 // add a PHPSESSID query argument to all URL strings when cookie
29 // support isn't detected in the client browser. For reasons
30 // which aren't entirely clear (PHP bug) this screws up the URLs
31 // generated by PhpWiki. Therefore, transparent session ids
32 // should be disabled. This next line does that.
34 // (At the present time, you will not be able to log-in to PhpWiki,
35 // unless your browser supports cookies.)
36 @ini_set('session.use_trans_sid', 0);
38 if (defined('DEBUG') and (DEBUG & 8) and extension_loaded("xdebug")) {
39 xdebug_start_trace("trace"); // on Dbgp protocol add 2
42 if (defined('DEBUG') and (DEBUG & 32) and extension_loaded("apd")) {
43 apd_set_pprof_trace();
46 // Used for debugging purposes
51 $this->_start = $this->microtime();
52 // Function 'posix_times' does not exist on Windows
53 if (function_exists('posix_times')) {
54 $this->_times = posix_times();
59 * @param string $which One of 'real', 'utime', 'stime', 'cutime', 'sutime'
61 * @return float Seconds.
63 function getTime($which = 'real', $now = array())
65 if ($which == 'real') {
66 return $this->microtime() - $this->_start;
69 if (isset($this->_times)) {
73 $ticks = $now[$which] - $this->_times[$which];
74 return $ticks / $this->_CLK_TCK();
77 return 0.0; // Not available.
82 if (!isset($this->_times)) {
83 // posix_times() not available.
84 return sprintf("real: %.3f", $this->getTime('real'));
87 return sprintf("real: %.3f, user: %.3f, sys: %.3f",
88 $this->getTime('real'),
89 $this->getTime('utime', $now),
90 $this->getTime('stime', $now));
95 // FIXME: this is clearly not always right.
96 // But how to figure out the right value?
102 list($usec, $sec) = explode(" ", microtime());
103 return ((float)$usec + (float)$sec);
107 $RUNTIMER = new DebugTimer;
108 require_once(dirname(__FILE__) . '/ErrorManager.php');
109 require_once(dirname(__FILE__) . '/WikiCallback.php');
112 function ExitWiki($errormsg = false)
117 if (is_object($request) and method_exists($request, "finish"))
118 $request->finish($errormsg); // NORETURN
125 global $ErrorManager;
126 $ErrorManager->flushPostponedErrors();
128 if (!empty($errormsg)) {
129 PrintXML(HTML::br(), $errormsg);
130 print "\n</body></html>";
135 if (!defined('DEBUG') or (defined('DEBUG') and DEBUG > 2)) {
136 $ErrorManager->setPostponedErrorMask(E_ALL); // ignore all errors
137 $ErrorManager->setFatalHandler(new WikiFunctionCb('ExitWiki'));
139 $ErrorManager->setPostponedErrorMask(E_USER_NOTICE | E_NOTICE);
146 // c-hanging-comment-ender-p: nil
147 // indent-tabs-mode: nil