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.38 2005-08-06 13:06:22 rurban Exp $');
10 define('PHPWIKI_VERSION', '1.3.11_20050806');
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 /** PHP5 deprecated old-style globals if !ini_get('register_long_arrays').
25 * We want to work with those old ones instead of the new superglobals,
28 foreach (array('SERVER','REQUEST','GET','POST','SESSION','ENV','COOKIE') as $k) {
29 if (!isset($GLOBALS['HTTP_'.$k.'_VARS']) and isset($GLOBALS['_'.$k]))
30 $GLOBALS['HTTP_'.$k.'_VARS'] =& $GLOBALS['_'.$k];
34 // If your php was compiled with --enable-trans-sid it tries to
35 // add a PHPSESSID query argument to all URL strings when cookie
36 // support isn't detected in the client browser. For reasons
37 // which aren't entirely clear (PHP bug) this screws up the URLs
38 // generated by PhpWiki. Therefore, transparent session ids
39 // should be disabled. This next line does that.
41 // (At the present time, you will not be able to log-in to PhpWiki,
42 // unless your browser supports cookies.)
43 @ini_set('session.use_trans_sid', 0);
45 if (defined('DEBUG') and (DEBUG & 8) and extension_loaded("xdebug")) {
46 xdebug_start_trace("trace"); // on Dbgp protocol add 2
50 // Used for debugging purposes
52 function DebugTimer() {
53 $this->_start = $this->microtime();
54 if (function_exists('posix_times'))
55 $this->_times = posix_times();
59 * @param string $which One of 'real', 'utime', 'stime', 'cutime', 'sutime'
60 * @return float Seconds.
62 function getTime($which='real', $now=false) {
64 return $this->microtime() - $this->_start;
66 if (isset($this->_times)) {
67 if (!$now) $now = posix_times();
68 $ticks = $now[$which] - $this->_times[$which];
69 return $ticks / $this->_CLK_TCK();
72 return 0.0; // Not available.
76 if (!isset($this->_times)) {
77 // posix_times() not available.
78 return sprintf("real: %.3f", $this->getTime('real'));
81 return sprintf("real: %.3f, user: %.3f, sys: %.3f",
82 $this->getTime('real'),
83 $this->getTime('utime', $now),
84 $this->getTime('stime', $now));
88 // FIXME: this is clearly not always right.
89 // But how to figure out the right value?
94 list($usec, $sec) = explode(" ", microtime());
95 return ((float)$usec + (float)$sec);
98 $RUNTIMER = new DebugTimer;
100 if (defined('E_STRICT') and (E_ALL & E_STRICT)) // strict php5?
101 error_reporting(E_ALL & ~E_STRICT); // exclude E_STRICT
103 error_reporting(E_ALL); // php4
104 //echo " prepend: ", error_reporting();
106 require_once(dirname(__FILE__).'/ErrorManager.php');
107 require_once(dirname(__FILE__).'/WikiCallback.php');
110 function ExitWiki($errormsg = false)
115 if (is_object($request) and method_exists($request,"finish"))
116 $request->finish($errormsg); // NORETURN
123 global $ErrorManager;
124 $ErrorManager->flushPostponedErrors();
126 if(!empty($errormsg)) {
127 PrintXML(HTML::br(), $errormsg);
128 print "\n</body></html>";
132 if (!defined('DEBUG') or (defined('DEBUG') and DEBUG > 2)) {
133 $ErrorManager->setPostponedErrorMask(E_ALL); // ignore all errors
134 $ErrorManager->setFatalHandler(new WikiFunctionCb('ExitWiki'));
136 $ErrorManager->setPostponedErrorMask(E_USER_NOTICE | E_NOTICE);
140 // (c-file-style: "gnu")
145 // c-hanging-comment-ender-p: nil
146 // indent-tabs-mode: nil