Index: branches/unlabeled/unlabeled-1.63.4/core/kernel/utility/debugger.php =================================================================== diff -u -r6706 -r7007 --- branches/unlabeled/unlabeled-1.63.4/core/kernel/utility/debugger.php (.../debugger.php) (revision 6706) +++ branches/unlabeled/unlabeled-1.63.4/core/kernel/utility/debugger.php (.../debugger.php) (revision 7007) @@ -70,11 +70,23 @@ * @var string */ var $baseURL = ''; - + function Debugger() { - global $start; - + global $start, $dbg_options; + // check if user haven't defined DEBUG_MODE contant directly + if (defined('DEBUG_MODE') && DEBUG_MODE) { + die('error: contant DEBUG_MODE defined directly, please use $dbg_options array instead'); + } + + // check IP before enabling debug mode + $ip_addresses = isset($dbg_options['DBG_IP']) ? explode(';', $dbg_options['DBG_IP']) : Array (); + if (!in_array($_SERVER['REMOTE_ADDR'], $ip_addresses)) { + define('DEBUG_MODE', 0); + return ; + } + + // debug is allowed for user, continue initialization $this->InitDebugger(); $this->profileStart('kernel4_startup', 'Startup and Initialization of kernel4', $start); $this->profileStart('script_runtime', 'Script runtime', $start); @@ -85,14 +97,16 @@ $this->scrollbarWidth = $this->isGecko() ? 22 : 25; // vertical scrollbar width differs in Firefox and other browsers $this->appendRequest(); } - + /** * Set's default values to constants debugger uses * */ function InitDebugger() { - unset($_REQUEST['debug_host'], $_REQUEST['debug_fastfile']); // this var messed up whole detection stuff :( + global $dbg_options; + + unset($_REQUEST['debug_host'], $_REQUEST['debug_fastfile'], $dbg_options['DBG_IP']); // this var messed up whole detection stuff :( // Detect fact, that this session beeing debugged by Zend Studio foreach ($_REQUEST as $rq_name => $rq_value) { @@ -101,7 +115,7 @@ break; } } - + $this->safeDefine('DBG_ZEND_PRESENT', 0); // set this constant value to 0 (zero) to debug debugger using Zend Studio // set default values for debugger constants @@ -122,6 +136,9 @@ $dbg_constMap['DBG_EDITOR'] = 'c:\Program Files\Zend\ZendStudio-5.2.0\bin\ZDE.exe %F'; } + // user defined options override debugger defaults + $dbg_constMap = $this->array_merge_recursive2($dbg_constMap, $dbg_options); + foreach ($dbg_constMap as $dbg_constName => $dbg_constValue) { $this->safeDefine($dbg_constName, $dbg_constValue); } @@ -138,6 +155,19 @@ } } + function array_merge_recursive2($paArray1, $paArray2) + { + if (!is_array($paArray1) or !is_array($paArray2)) { + return $paArray2; + } + + foreach ($paArray2 AS $sKey2 => $sValue2) { + $paArray1[$sKey2] = isset($paArray1[$sKey2]) ? array_merge_recursive2($paArray1[$sKey2], $sValue2) : $sValue2; + } + + return $paArray1; + } + function InitReport() { if (!class_exists('kApplication')) return false;