Index: trunk/kernel/include/debugger.php =================================================================== diff -u -r1122 -r1200 --- trunk/kernel/include/debugger.php (.../debugger.php) (revision 1122) +++ trunk/kernel/include/debugger.php (.../debugger.php) (revision 1200) @@ -1,18 +1,31 @@ $rq_value) + { + if( substr($rq_name,0,6)=='debug_' ) + { + define('DBG_ZEND_PRESENT',1); + break; + } + } - if(!defined('DBG_USE_HIGHLIGHT')) define('DBG_USE_HIGHLIGHT',1); + dbg_safeDefine('DBG_ZEND_PRESENT',0); - if(!defined('DBG_USE_SHUTDOWN_FUNC')) define('DBG_USE_SHUTDOWN_FUNC',1); - if(!defined('DBG_HANDLE_ERRORS')) define('DBG_HANDLE_ERRORS', isset($_REQUEST['debug_port']) ? 0 : 1); + // set default values for debugger constants + $dbg_constMap=Array('DBG_OPTIONS'=>0, + 'DBG_USE_HIGHLIGHT'=>1, + 'DBG_USE_SHUTDOWN_FUNC'=>DBG_ZEND_PRESENT?0:1, + 'DBG_HANDLE_ERRORS'=>DBG_ZEND_PRESENT?0:1, + 'DBG_SHOW_MEMORY_USAGE'=>1, + 'DOC_ROOT'=>$_SERVER['DOCUMENT_ROOT'], + 'WINDOWS_ROOT'=>'w:'); - if(!defined('DBG_RAISE_ON_WARNINGS')) define('DBG_RAISE_ON_WARNINGS',0); - if(!defined('DBG_SHOW_MEMORY_USAGE')) define('DBG_SHOW_MEMORY_USAGE',1); + foreach($dbg_constMap as $dbg_constName=>$dbg_constValue) + { + dbg_safeDefine($dbg_constName,$dbg_constValue); + } - if(!defined('DOC_ROOT')) define('DOC_ROOT',$_SERVER['DOCUMENT_ROOT']); - if(!defined('WINDOWS_ROOT')) define('WINDOWS_ROOT','w:'); - if(!defined('WINDOWS_EDITOR')) { $dbg_editor = 0; @@ -52,6 +65,7 @@ function Debugger() { + ini_set('display_errors',dbg_ConstOn('DBG_ZEND_PRESENT')?0:1); $this->memoryUsage['error_handling']=0; // memory amount used by error handler $this->appendRequest(); } @@ -419,6 +433,8 @@ */ function printReport($returnResult = false) { + if( dbg_ConstOn('DBG_ZEND_PRESENT') ) return; + dbg_safeDefine('DBG_RAISE_ON_WARNINGS',0); $this->memoryUsage['debugger_start']=memory_get_usage(); // show php session if any @@ -657,13 +673,13 @@ { $ret = ob_get_contents(); ob_clean(); - if( ConstOn('DBG_SHOW_MEMORY_USAGE') ) $ret.=$this->getMemoryUsageReport(); + if( dbg_ConstOn('DBG_SHOW_MEMORY_USAGE') ) $ret.=$this->getMemoryUsageReport(); return $ret; } else { ob_end_flush(); - if( ConstOn('DBG_SHOW_MEMORY_USAGE') ) echo $this->getMemoryUsageReport(); + if( dbg_ConstOn('DBG_SHOW_MEMORY_USAGE') ) echo $this->getMemoryUsageReport(); } } @@ -785,14 +801,18 @@ function memory_get_usage(){ return -1; } } - function ConstOn($const_name) + function dbg_ConstOn($const_name) { return defined($const_name)&&constant($const_name); } + function dbg_safeDefine($const_name,$const_value) + { + if(!defined($const_name)) define($const_name,$const_value); + } + $debugger = new Debugger(); - if(ConstOn('DBG_HANDLE_ERRORS')) set_error_handler( array(&$debugger,'saveError') ); - if(ConstOn('DBG_USE_SHUTDOWN_FUNC')) register_shutdown_function( array(&$debugger,'printReport') ); + if(dbg_ConstOn('DBG_HANDLE_ERRORS')) set_error_handler( array(&$debugger,'saveError') ); + if(dbg_ConstOn('DBG_USE_SHUTDOWN_FUNC')) register_shutdown_function( array(&$debugger,'printReport') ); - ?> \ No newline at end of file