Index: branches/RC/core/kernel/utility/debugger.php
===================================================================
diff -u -r11295 -r11316
--- branches/RC/core/kernel/utility/debugger.php (.../debugger.php) (revision 11295)
+++ branches/RC/core/kernel/utility/debugger.php (.../debugger.php) (revision 11316)
@@ -95,6 +95,13 @@
*/
var $LastMoment;
+ /**
+ * Determines, that current request is AJAX request
+ *
+ * @var bool
+ */
+ var $_isAjax = false;
+
function Debugger()
{
global $start, $dbg_options;
@@ -167,30 +174,38 @@
$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
- $dbg_constMap = Array(
- 'DBG_USE_HIGHLIGHT' => 1, // highlight output same as php code using "highlight_string" function
- 'DBG_WINDOW_WIDTH' => 700, // set width of debugger window (in pixels) for better viewing large amount of debug data
- 'DBG_USE_SHUTDOWN_FUNC' => DBG_ZEND_PRESENT ? 0 : 1, // use shutdown function to include debugger code into output
- 'DBG_HANDLE_ERRORS' => DBG_ZEND_PRESENT ? 0 : 1, // handle all allowed by php (see php manual) errors instead of default handler
- 'DBG_IGNORE_STRICT_ERRORS' => 1, // ignore PHP5 errors about private/public view modified missing in class declarations
- 'DBG_DOMVIEWER' => '/temp/domviewer.html', // path to DOMViewer on website
- 'DOC_ROOT' => str_replace('\\', '/', realpath($_SERVER['DOCUMENT_ROOT']) ), // windows hack
- 'DBG_LOCAL_BASE_PATH' => 'w:', // replace DOC_ROOT in filenames (in errors) using this path
- );
+ $dbg_constMap = Array (
+ 'DBG_USE_HIGHLIGHT' => 1, // highlight output same as php code using "highlight_string" function
+ 'DBG_WINDOW_WIDTH' => 700, // set width of debugger window (in pixels) for better viewing large amount of debug data
+ 'DBG_USE_SHUTDOWN_FUNC' => DBG_ZEND_PRESENT ? 0 : 1, // use shutdown function to include debugger code into output
+ 'DBG_HANDLE_ERRORS' => DBG_ZEND_PRESENT ? 0 : 1, // handle all allowed by php (see php manual) errors instead of default handler
+ 'DBG_IGNORE_STRICT_ERRORS' => 1, // ignore PHP5 errors about private/public view modified missing in class declarations
+ 'DBG_DOMVIEWER' => '/temp/domviewer.html', // path to DOMViewer on website
+ 'DOC_ROOT' => str_replace('\\', '/', realpath($_SERVER['DOCUMENT_ROOT']) ), // windows hack
+ 'DBG_LOCAL_BASE_PATH' => 'w:', // replace DOC_ROOT in filenames (in errors) using this path
+ );
// only for IE, in case if no windows php script editor defined
if (!defined('DBG_EDITOR')) {
// $dbg_constMap['DBG_EDITOR'] = 'c:\Program Files\UltraEdit\uedit32.exe %F/%L';
$dbg_constMap['DBG_EDITOR'] = 'c:\Program Files\Zend\ZendStudio-5.2.0\bin\ZDE.exe %F';
}
- if (isset($_REQUEST['ajax']) && $_REQUEST['ajax'] && constOn('DBG_SKIP_AJAX')) {
- $this->safeDefine('DBG_SKIP_REPORTING', 1);
+ // debugger is initialized before kHTTPQuery, so do jQuery headers check here too
+ if (array_key_exists('HTTP_X_REQUESTED_WITH', $_SERVER) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
+ $this->_isAjax = true;
}
+ elseif (array_key_exists('ajax', $_GET) && $_GET['ajax'] == 'yes') {
+ $this->_isAjax = true;
+ }
// user defined options override debugger defaults
$dbg_constMap = $this->array_merge_recursive2($dbg_constMap, $dbg_options);
+ if ($this->_isAjax && array_key_exists('DBG_SKIP_AJAX', $dbg_constMap) && $dbg_constMap['DBG_SKIP_AJAX']) {
+ $dbg_constMap['DBG_SKIP_REPORTING'] = 1;
+ }
+
// when validation configs, don't show sqls for better validation error displaying
if (array_key_exists('DBG_VALIDATE_CONFIGS', $dbg_constMap) && $dbg_constMap['DBG_VALIDATE_CONFIGS']) {
$dbg_constMap['DBG_SQL_PROFILE'] = 0;
@@ -540,7 +555,7 @@
$tab_count--;
if ($return_output) {
- return $output;
+ return $output;
}
else {
echo $output;
@@ -634,6 +649,11 @@
$string = str_replace( Array('_no_match_string_', '_n_m_s_'), Array('\\', '/'), $string);
+ if (strlen($string) >= 65536) {
+ // preg_replace will fail, when string is longer, then 65KB
+ return str_replace(Array ('<?php ', '?>'), '', $string);
+ }
+
return preg_replace('/<\?(.*)php (.*)\?>/Us', '\\2', $string);
}
@@ -772,7 +792,7 @@
}
$this->appendHTML('ScriptName: '.$this->getFileLink($script, 1, basename($script)).' ('.dirname($script).')');
- if (isset($_REQUEST['ajax']) && $_REQUEST['ajax'] == 'yes') {
+ if ($this->_isAjax) {
$this->appendHTML('RequestURI: '.$_SERVER['REQUEST_URI'].' (QS Length:'.strlen($_SERVER['QUERY_STRING']).')');
}
@@ -1092,10 +1112,9 @@
}
}
- $is_ajax = isset($_GET['ajax']) && $_GET['ajax'] == 'yes';
$skip_reporting = $this->constOn('DBG_SKIP_REPORTING') || $this->constOn('DBG_ZEND_PRESENT');
- if (($is_ajax && !constOn('DBG_SKIP_AJAX')) || !$skip_reporting) {
+ if (($this->_isAjax && !$this->constOn('DBG_SKIP_AJAX')) || !$skip_reporting) {
$debug_file = $this->tempFolder.'/debug_'.$this->rowSeparator.'.txt';
if (file_exists($debug_file)) unlink($debug_file);