Index: trunk/core/kernel/utility/debugger.php
===================================================================
diff -u -r2581 -r2596
--- trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 2581)
+++ trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 2596)
@@ -6,41 +6,41 @@
{
return defined($const_name) && constant($const_name);
}
-
+
function dbg_safeDefine($const_name,$const_value)
{
if(!defined($const_name)) define($const_name,$const_value);
}
-
+
unset($_REQUEST['debug_host']); // this var messed up whole detection stuff :(
-
+
// Detect fact, that this session beeing debugged by Zend Studio
foreach($_REQUEST as $rq_name=>$rq_value)
{
if( substr($rq_name,0,6)=='debug_' )
{
dbg_safeDefine('DBG_ZEND_PRESENT', 1);
break;
- }
+ }
}
-
+
dbg_safeDefine('DBG_ZEND_PRESENT',0);
-
+
// 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_IGNORE_STRICT_ERRORS'=>1,
'DBG_DOMVIEWER'=>'/temp/domviewer.html',
- 'DOC_ROOT'=> str_replace('\\', '/', realpath($_SERVER['DOCUMENT_ROOT']) ), // windows hack
+ 'DOC_ROOT'=> str_replace('\\', '/', realpath($_SERVER['DOCUMENT_ROOT']) ), // windows hack
'DBG_LOCAL_BASE_PATH'=>'w:');
-
+
foreach($dbg_constMap as $dbg_constName=>$dbg_constValue)
{
dbg_safeDefine($dbg_constName,$dbg_constValue);
}
-
+
// only for IE, in case if no windows php script editor defined
/*if(!defined('WINDOWS_EDITOR'))
{
@@ -50,8 +50,8 @@
define('WINDOWS_EDITOR',$dbg_editors[$dbg_editor]['editor'].' '.$dbg_editors[$dbg_editor]['params']);
unset($dbg_editors,$dbg_editor);
}*/
-
- class Debugger
+
+ class Debugger
{
/**
* Debugger data for building report
@@ -62,27 +62,27 @@
var $ProfilerData = Array();
var $ProfilerTotals = Array();
var $RecursionStack = Array(); // prevent recursion when processing debug_backtrace() function results
-
+
var $TraceNextError=false;
-
+
var $Options = 0;
var $OptionsMap = Array('shutdown_func' => 1, 'error_handler' => 2,
'output_buffer' => 4, 'highlight_output' => 8);
-
-
+
+
var $longErrors=Array();
-
+
/**
* Amount of memory used by debugger itself
*
* @var Array
* @access private
*/
var $memoryUsage=Array();
-
+
var $IncludesData=Array();
var $IncludeLevel=0;
-
+
function Debugger()
{
$this->profileStart('kernel4_startup', 'Startup and Initialization of kernel4');
@@ -91,19 +91,19 @@
$this->memoryUsage['error_handling']=0; // memory amount used by error handler
$this->appendRequest();
}
-
+
function initOptions()
{
-
+
}
-
+
function mapLongError($msg)
{
$key=$this->generateID();
$this->longErrors[$key]=$msg;
return $key;
}
-
+
function setOption($name,$value)
{
if( !isset($this->OptionsMap[$name]) ) die('undefined debugger option: ['.$name.']
');
@@ -116,13 +116,13 @@
$this->Options=$this->Options&~$this->OptionsMap[$name];
}
}
-
+
function getOption($name)
{
if( !isset($this->OptionsMap[$name]) ) die('undefined debugger option: ['.$name.']
');
return ($this->Options & $this->OptionsMap[$name]) == $this->OptionsMap[$name];
}
-
+
/**
* Set's flag, that next error that occurs will
* be prepended by backtrace results
@@ -132,7 +132,7 @@
{
$this->TraceNextError=true;
}
-
+
function dumpVars()
{
$dumpVars = func_get_args();
@@ -141,12 +141,12 @@
$this->Data[] = Array('value' => $varValue, 'debug_type' => 'var_dump');
}
}
-
+
function prepareHTML($dataIndex)
{
$Data =& $this->Data[$dataIndex];
if($Data['debug_type'] == 'html') return $Data['html'];
-
+
switch($Data['debug_type'])
{
case 'error':
@@ -155,19 +155,19 @@
$ret .= ' in '.$fileLink.' on line '.$Data['line'].'';
return $ret;
break;
-
+
case 'var_dump':
return $this->highlightString( print_r($Data['value'], true) );
break;
-
+
case 'trace':
ini_set('memory_limit','500M');
$trace =& $Data['trace'];
-
+
//return 'sorry';
//return $this->highlightString(print_r($trace,true));
-
-
+
+
$i = 0; $traceCount = count($trace);
$ret = '';
while($i < $traceCount)
@@ -180,11 +180,11 @@
$ret .= 'Function: '.$this->getFileLink($traceRec['file'],$traceRec['line'],$func_name);
$ret .= ' in '.basename($traceRec['file']).' on line '.$traceRec['line'].'
';
}
- else
+ else
{
$ret .= 'no file information available';
}
-
+
// ensure parameter value is not longer then 200 symbols
$this->processTraceArguments($traceRec['args']);
$args = $this->highlightString(print_r($traceRec['args'], true));
@@ -193,20 +193,20 @@
}
return $ret;
break;
-
+
case 'profiler':
$profileKey = $Data['profile_key'];
$Data =& $this->ProfilerData[$profileKey];
$runtime = ($Data['ends'] - $Data['begins']); // in seconds
return 'Name: '.$Data['description'].'
Runtime: '.$runtime.'s';
break;
-
+
default:
return 'incorrect debug data';
break;
}
}
-
+
function processTraceArguments(&$traceArgs)
{
if(!$traceArgs) return '';
@@ -215,7 +215,7 @@
if( is_array($argValue) || is_object($argValue) )
{
if(is_object($argValue) && !in_array(get_class($argValue),$this->RecursionStack) )
- {
+ {
// object & not in stack - ok
array_push($this->RecursionStack, get_class($argValue));
settype($argValue,'array');
@@ -239,13 +239,13 @@
}
}
}
-
+
function cutStringForHTML($string)
{
if( strlen($string) > 200 ) $string = substr($string,0,50).' ...';
return $string;
}
-
+
/**
* Format SQL Query using predefined formatting
* and highlighting techniques
@@ -259,7 +259,7 @@
$sql = preg_replace('/(CREATE TABLE|DROP TABLE|SELECT|UPDATE|SET|REPLACE|INSERT|DELETE|VALUES|FROM|LEFT JOIN|INNER JOIN|LIMIT|WHERE|HAVING|GROUP BY|ORDER BY) /is', "\n\t$1 ",$sql);
return $this->highlightString($sql);
}
-
+
function highlightString($string)
{
if( dbg_ConstOn('DBG_USE_HIGHLIGHT') )
@@ -274,7 +274,7 @@
return $string;
}
}
-
+
function getFileLink($file, $lineno = 1, $title = '')
{
if(!$title) $title = $file;
@@ -283,36 +283,36 @@
{
return ''.$title.'';
}
- else
+ else
{
- return ''.$title.'';
+ return ''.$title.'';
}
-
+
}
-
+
function getLocalFile($remoteFile)
{
- return str_replace(DOC_ROOT, DBG_LOCAL_BASE_PATH, $remoteFile);
+ return str_replace(DOC_ROOT, DBG_LOCAL_BASE_PATH, $remoteFile);
}
-
+
function appendTrace()
{
$trace = debug_backtrace();
array_shift($trace);
$this->Data[] = Array('trace' => $trace, 'debug_type' => 'trace');
}
-
+
function appendMemoryUsage($msg, $used=null)
{
if (!isset($used)) $used = round(memory_get_usage()/1024);
$this->appendHTML('Memory usage '.$msg.' '.$used.'Kb');
}
-
+
function appendHTML($html)
{
- $this->Data[] = Array('html' => $html,'debug_type' => 'html');
+ $this->Data[] = Array('html' => $html,'debug_type' => 'html');
}
-
+
/**
* Change debugger info that was already generated before.
* Returns true if html was set.
@@ -326,9 +326,9 @@
{
if( !isset($this->Data[$index]) || $this->Data[$index]['debug_type'] != 'html' )
{
- return false;
+ return false;
}
-
+
switch ($type)
{
case 'append':
@@ -343,7 +343,7 @@
}
return true;
}
-
+
/**
* Move $debugLineCount lines of input from debug output
* end to beginning.
@@ -355,19 +355,19 @@
$lines = array_splice($this->Data,count($this->Data)-$debugLineCount,$debugLineCount);
$this->Data = array_merge($lines,$this->Data);
}
-
+
function moveAfterRow($new_row, $debugLineCount)
{
$lines = array_splice($this->Data,count($this->Data)-$debugLineCount,$debugLineCount);
$rows_before = array_splice($this->Data,0,$new_row,$lines);
$this->Data = array_merge($rows_before,$this->Data);
}
-
+
function appendRequest()
{
$script = $_SERVER['SCRIPT_FILENAME'];
$this->appendHTML('ScriptName: '.$this->getFileLink($script,1,basename($script)).' ('.dirname($script).')');
-
+
$this->appendHTML('DomViewer: ');
ob_start();
@@ -390,35 +390,35 @@
$src = isset($_GET[$key]) ? 'GE' : (isset($_POST[$key]) ? 'PO' : (isset($_COOKIE[$key]) ? 'CO' : '?') );
echo '