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.23 2004-11-01 10:43:57 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);
34 if (defined('DEBUG') and (DEBUG & 8) and extension_loaded("xdebug")) {
39 // Used for debugging purposes
41 function DebugTimer() {
42 $this->_start = $this->microtime();
43 if (function_exists('posix_times'))
44 $this->_times = posix_times();
48 * @param string $which One of 'real', 'utime', 'stime', 'cutime', 'sutime'
49 * @return float Seconds.
51 function getTime($which='real', $now=false) {
53 return $this->microtime() - $this->_start;
55 if (isset($this->_times)) {
56 if (!$now) $now = posix_times();
57 $ticks = $now[$which] - $this->_times[$which];
58 return $ticks / $this->_CLK_TCK();
61 return 0.0; // Not available.
65 if (!isset($this->_times)) {
66 // posix_times() not available.
67 return sprintf("real: %.3f", $this->getTime('real'));
70 return sprintf("real: %.3f, user: %.3f, sys: %.3f",
71 $this->getTime('real'),
72 $this->getTime('utime', $now),
73 $this->getTime('stime', $now));
77 // FIXME: this is clearly not always right.
78 // But how to figure out the right value?
83 list($usec, $sec) = explode(" ", microtime());
84 return ((float)$usec + (float)$sec);
87 $RUNTIMER = new DebugTimer;
89 if (defined('E_STRICT') and (E_ALL & E_STRICT)) // strict php5?
90 error_reporting(E_ALL & ~E_STRICT); // exclude E_STRICT
92 error_reporting(E_ALL); // php4
93 //echo " prepend: ", error_reporting();
95 require_once(dirname(__FILE__).'/ErrorManager.php');
96 require_once(dirname(__FILE__).'/WikiCallback.php');
99 function ExitWiki($errormsg = false)
104 if (is_object($request))
105 $request->finish($errormsg); // NORETURN
112 global $ErrorManager;
113 $ErrorManager->flushPostponedErrors();
115 if(!empty($errormsg)) {
116 PrintXML(HTML::br(), $errormsg);
117 print "\n</body></html>";
121 if (!defined('DEBUG') or (defined('DEBUG') and DEBUG > 2)) {
122 $ErrorManager->setPostponedErrorMask(E_ALL); // ignore all errors
123 $ErrorManager->setFatalHandler(new WikiFunctionCb('ExitWiki'));
125 $ErrorManager->setPostponedErrorMask(E_USER_NOTICE | E_NOTICE);
129 // (c-file-style: "gnu")
134 // c-hanging-comment-ender-p: nil
135 // indent-tabs-mode: nil