Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/utility/debugger.php
Show First 20 Lines • Show All 246 Lines • ▼ Show 20 Line(s) | |||||
* Debugger data for building report | * Debugger data for building report | ||||
* | * | ||||
* @var Array | * @var Array | ||||
* @access private | * @access private | ||||
*/ | */ | ||||
private $Data = Array (); | private $Data = Array (); | ||||
/** | /** | ||||
* Data index, that represents a header ending. | |||||
* | |||||
* @var integer | |||||
*/ | |||||
private $HeaderEndingDataIndex = 0; | |||||
/** | |||||
* Holds information about each profiler record (start/end/description) | * Holds information about each profiler record (start/end/description) | ||||
* | * | ||||
* @var Array | * @var Array | ||||
* @access private | * @access private | ||||
*/ | */ | ||||
private $ProfilerData = Array (); | private $ProfilerData = Array (); | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Line(s) | |||||
error_reporting(E_ALL & ~E_STRICT); | error_reporting(E_ALL & ~E_STRICT); | ||||
// show errors on screen in case if not in Zend Studio debugging | // show errors on screen in case if not in Zend Studio debugging | ||||
ini_set('display_errors', DebuggerUtil::constOn('DBG_ZEND_PRESENT') ? 0 : 1); | ini_set('display_errors', DebuggerUtil::constOn('DBG_ZEND_PRESENT') ? 0 : 1); | ||||
// vertical scrollbar width differs in Firefox and other browsers | // vertical scrollbar width differs in Firefox and other browsers | ||||
$this->scrollbarWidth = $this->isGecko() ? 22 : 25; | $this->scrollbarWidth = $this->isGecko() ? 22 : 25; | ||||
$this->appendRequest(); | // Mark place, where request information will be inserted. | ||||
$this->HeaderEndingDataIndex = count($this->Data); | |||||
} | } | ||||
/** | /** | ||||
* Set's default values to constants debugger uses | * Set's default values to constants debugger uses | ||||
* | * | ||||
*/ | */ | ||||
function InitDebugger() | function InitDebugger() | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 676 Lines • ▼ Show 20 Line(s) | |||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function appendHTML($html) | public function appendHTML($html) | ||||
{ | { | ||||
$this->Data[] = Array ('html' => $html, 'debug_type' => 'html'); | $this->Data[] = Array ('html' => $html, 'debug_type' => 'html'); | ||||
} | } | ||||
/** | /** | ||||
* Inserts HTML code without transformations at given position | |||||
* | |||||
* @param string $html HTML. | |||||
* @param integer $position Position. | |||||
* | |||||
* @return integer | |||||
*/ | |||||
public function insertHTML($html, $position) | |||||
{ | |||||
array_splice( | |||||
$this->Data, | |||||
$position, | |||||
0, | |||||
array( | |||||
array('html' => $html, 'debug_type' => 'html'), | |||||
) | |||||
); | |||||
return $position + 1; | |||||
} | |||||
/** | |||||
* Returns instance of FirePHP class | * Returns instance of FirePHP class | ||||
* | * | ||||
* @return FirePHP | * @return FirePHP | ||||
* @link http://www.firephp.org/HQ/Use.htm | * @link http://www.firephp.org/HQ/Use.htm | ||||
*/ | */ | ||||
function firePHP() | function firePHP() | ||||
{ | { | ||||
require_once('FirePHPCore/FirePHP.class.php'); | require_once('FirePHPCore/FirePHP.class.php'); | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | |||||
{ | { | ||||
if ( isset($_SERVER['SCRIPT_FILENAME']) ) { | if ( isset($_SERVER['SCRIPT_FILENAME']) ) { | ||||
$script = $_SERVER['SCRIPT_FILENAME']; | $script = $_SERVER['SCRIPT_FILENAME']; | ||||
} | } | ||||
else { | else { | ||||
$script = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF']; | $script = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF']; | ||||
} | } | ||||
$this->appendHTML('ScriptName: <b>' . $this->getFileLink($script, 1, basename($script)) . '</b> (<b>' . dirname($script) . '</b>)'); | $insert_at_index = $this->HeaderEndingDataIndex; | ||||
$insert_at_index = $this->insertHTML( | |||||
'ScriptName: <b>' . $this->getFileLink($script, 1, basename($script)) . '</b> (<b>' . dirname($script) . '</b>)', | |||||
$insert_at_index | |||||
); | |||||
if ( $this->_isAjax ) { | if ( $this->_isAjax ) { | ||||
$this->appendHTML('RequestURI: ' . $_SERVER['REQUEST_URI'] . ' (QS Length:' . strlen($_SERVER['QUERY_STRING']) . ')'); | $insert_at_index = $this->insertHTML( | ||||
'RequestURI: ' . $_SERVER['REQUEST_URI'] . ' (QS Length:' . strlen($_SERVER['QUERY_STRING']) . ')', | |||||
$insert_at_index | |||||
); | |||||
} | } | ||||
$tools_html = ' <table style="width: ' . $this->getWindowWidth() . 'px;"> | $tools_html = ' <table style="width: ' . $this->getWindowWidth() . 'px;"> | ||||
<tr> | <tr> | ||||
<td>' . $this->_getDomViewerHTML() . '</td> | <td>' . $this->_getDomViewerHTML() . '</td> | ||||
<td>' . $this->_getToolsHTML() . '</td> | <td>' . $this->_getToolsHTML() . '</td> | ||||
</tr> | </tr> | ||||
</table>'; | </table>'; | ||||
$this->appendHTML($tools_html); | $insert_at_index = $this->insertHTML($tools_html, $insert_at_index); | ||||
ob_start(); | ob_start(); | ||||
?> | ?> | ||||
<table border="0" cellspacing="0" cellpadding="0" class="dbg_flat_table" style="width: <?php echo $this->getWindowWidth(); ?>px;"> | <table border="0" cellspacing="0" cellpadding="0" class="dbg_flat_table" style="width: <?php echo $this->getWindowWidth(); ?>px;"> | ||||
<thead style="font-weight: bold;"> | <thead style="font-weight: bold;"> | ||||
<td width="20">Src</td><td>Name</td><td>Value</td> | <td width="20">Src</td><td>Name</td><td>Value</td> | ||||
</thead> | </thead> | ||||
<?php | <?php | ||||
$super_globals = Array ('GE' => $_GET, 'PO' => $_POST, 'CO' => $_COOKIE); | if ( is_object($this->Application) ) { | ||||
$super_globals = array( | |||||
'GE' => $this->Application->HttpQuery->Get, | |||||
'PO' => $this->Application->HttpQuery->Post, | |||||
'CO' => $this->Application->HttpQuery->Cookie, | |||||
); | |||||
} | |||||
else { | |||||
$super_globals = array('GE' => $_GET, 'PO' => $_POST, 'CO' => $_COOKIE); | |||||
} | |||||
foreach ($super_globals as $prefix => $data) { | foreach ($super_globals as $prefix => $data) { | ||||
foreach ($data as $key => $value) { | foreach ($data as $key => $value) { | ||||
if ( !is_array($value) && trim($value) == '' ) { | if ( !is_array($value) && trim($value) == '' ) { | ||||
$value = '<b class="debug_error">no value</b>'; | $value = '<b class="debug_error">no value</b>'; | ||||
} | } | ||||
else { | else { | ||||
$value = htmlspecialchars($this->print_r($value, true), ENT_QUOTES, 'UTF-8'); | $value = htmlspecialchars($this->print_r($value, true), ENT_QUOTES, 'UTF-8'); | ||||
} | } | ||||
echo '<tr><td>' . $prefix . '</td><td>' . $key . '</td><td>' . $value . '</td></tr>'; | echo '<tr><td>' . $prefix . '</td><td>' . $key . '</td><td>' . $value . '</td></tr>'; | ||||
} | } | ||||
} | } | ||||
?> | ?> | ||||
</table> | </table> | ||||
<?php | <?php | ||||
$this->appendHTML(ob_get_contents()); | $this->insertHTML(ob_get_contents(), $insert_at_index); | ||||
ob_end_clean(); | ob_end_clean(); | ||||
} | } | ||||
/** | /** | ||||
* Appends php session content to debugger output | * Appends php session content to debugger output | ||||
* | * | ||||
* @return void | * @return void | ||||
* @access private | * @access private | ||||
▲ Show 20 Lines • Show All 305 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
$this->InitReport(); // set parameters required by AJAX | $this->InitReport(); // set parameters required by AJAX | ||||
// defined here, because user can define this constant while script is running, not event before debugger is started | // defined here, because user can define this constant while script is running, not event before debugger is started | ||||
DebuggerUtil::safeDefine('DBG_RAISE_ON_WARNINGS', 0); | DebuggerUtil::safeDefine('DBG_RAISE_ON_WARNINGS', 0); | ||||
DebuggerUtil::safeDefine('DBG_TOOLBAR_BUTTONS', 1); | DebuggerUtil::safeDefine('DBG_TOOLBAR_BUTTONS', 1); | ||||
$this->appendRequest(); | |||||
$this->appendSession(); // show php session if any | $this->appendSession(); // show php session if any | ||||
// ensure, that 1st line of debug output always is this one: | // ensure, that 1st line of debug output always is this one: | ||||
$top_line = '<table cellspacing="0" cellpadding="0" style="width: ' . $this->getWindowWidth() . 'px; margin: 0px;"><tr><td align="left" width="50%">[<a href="javascript:window.location.reload();">Reload Frame</a>] [<a href="javascript:$Debugger.Toggle(27);">Hide Debugger</a>] [<a href="javascript:$Debugger.Clear();">Clear Debugger</a>]</td><td align="right" width="50%">[Current Time: <b>' . date('H:i:s') . '</b>] [File Size: <b>#DBG_FILESIZE#</b>]</td></tr><tr><td align="left" colspan="2" style="padding-top: 5px;">' . $this->getFilterDropdown() . '</td></tr></table>'; | $top_line = '<table cellspacing="0" cellpadding="0" style="width: ' . $this->getWindowWidth() . 'px; margin: 0px;"><tr><td align="left" width="50%">[<a href="javascript:window.location.reload();">Reload Frame</a>] [<a href="javascript:$Debugger.Toggle(27);">Hide Debugger</a>] [<a href="javascript:$Debugger.Clear();">Clear Debugger</a>]</td><td align="right" width="50%">[Current Time: <b>' . date('H:i:s') . '</b>] [File Size: <b>#DBG_FILESIZE#</b>]</td></tr><tr><td align="left" colspan="2" style="padding-top: 5px;">' . $this->getFilterDropdown() . '</td></tr></table>'; | ||||
$this->appendHTML($top_line); | $this->appendHTML($top_line); | ||||
$this->moveToBegin(1); | $this->moveToBegin(1); | ||||
▲ Show 20 Lines • Show All 568 Lines • Show Last 20 Lines |