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.21 2004-06-19 11:48:05 rurban Exp $');
10 define ('PHPWIKI_VERSION', '1.3.11pre');
13 * Returns true if current php version is at mimimum a.b.c
14 * Called: check_php_version(4,1)
16 function check_php_version ($a = '0', $b = '0', $c = '0') {
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));
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.
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);
35 // Used for debugging purposes
37 function DebugTimer() {
38 $this->_start = $this->microtime();
39 if (function_exists('posix_times'))
40 $this->_times = posix_times();
44 * @param string $which One of 'real', 'utime', 'stime', 'cutime', 'sutime'
45 * @return float Seconds.
47 function getTime($which='real', $now=false) {
49 return $this->microtime() - $this->_start;
51 if (isset($this->_times)) {
52 if (!$now) $now = posix_times();
53 $ticks = $now[$which] - $this->_times[$which];
54 return $ticks / $this->_CLK_TCK();
57 return 0.0; // Not available.
61 if (!isset($this->_times)) {
62 // posix_times() not available.
63 return sprintf("real: %.3f", $this->getTime('real'));
66 return sprintf("real: %.3f, user: %.3f, sys: %.3f",
67 $this->getTime('real'),
68 $this->getTime('utime', $now),
69 $this->getTime('stime', $now));
73 // FIXME: this is clearly not always right.
74 // But how to figure out the right value?
79 list($usec, $sec) = explode(" ", microtime());
80 return ((float)$usec + (float)$sec);
83 $RUNTIMER = new DebugTimer;
85 error_reporting(E_ALL);
86 require_once(dirname(__FILE__).'/ErrorManager.php');
87 require_once(dirname(__FILE__).'/WikiCallback.php');
90 function ExitWiki($errormsg = false)
95 if (is_object($request))
96 $request->finish($errormsg); // NORETURN
103 global $ErrorManager;
104 $ErrorManager->flushPostponedErrors();
106 if(!empty($errormsg)) {
107 PrintXML(HTML::br(), $errormsg);
108 print "\n</body></html>";
112 if (!defined('DEBUG') or (defined('DEBUG') and DEBUG > 2)) {
113 $ErrorManager->setPostponedErrorMask(E_ALL); // ignore all errors
114 $ErrorManager->setFatalHandler(new WikiFunctionCb('ExitWiki'));
116 $ErrorManager->setPostponedErrorMask(E_USER_NOTICE | E_NOTICE);
120 // (c-file-style: "gnu")
125 // c-hanging-comment-ender-p: nil
126 // indent-tabs-mode: nil