Index: trunk/core/kernel/startup.php
===================================================================
diff -u -r4771 -r4880
--- trunk/core/kernel/startup.php (.../startup.php) (revision 4771)
+++ trunk/core/kernel/startup.php (.../startup.php) (revision 4880)
@@ -24,8 +24,7 @@
$vars = parse_portal_ini(FULL_PATH.'/config.php');
- if($vars === false)
- {
+ if ($vars === false) {
global $rootURL;
echo 'In-Portal is probably not installed, or configuration file is missing.
';
echo 'Please use the installation script to fix the problem.
';
@@ -68,7 +67,7 @@
$debugger_start = getmicrotime();
include_once(KERNEL_PATH.'/utility/debugger.php');
$debugger_end = getmicrotime();
- if (isset($debugger) && dbg_ConstOn('DBG_PROFILE_INCLUDES')) {
+ if (isset($debugger) && constOn('DBG_PROFILE_INCLUDES')) {
$debugger->profileStart('inc_globals', KERNEL_PATH.'/globals.php', $globals_start);
$debugger->profileFinish('inc_globals', KERNEL_PATH.'/globals.php', $globals_end);
$debugger->profilerAddTotal('includes', 'inc_globals');
Index: trunk/core/kernel/session/session.php
===================================================================
diff -u -r4867 -r4880
--- trunk/core/kernel/session/session.php (.../session.php) (revision 4867)
+++ trunk/core/kernel/session/session.php (.../session.php) (revision 4880)
@@ -659,23 +659,19 @@
function PrintSession($comment='')
{
- if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_SHOW_SESSIONDATA') )
- {
- global $debugger;
- $debugger->appendHTML('SessionStorage ('.$comment.'):');
+ if($this->Application->isDebugMode() && constOn('DBG_SHOW_SESSIONDATA')) {
+ $this->Application->Debugger->appendHTML('SessionStorage ('.$comment.'):');
$session_data = $this->Data->GetParams();
ksort($session_data);
- foreach($session_data as $session_key => $session_value)
- {
- if( IsSerialized($session_value) )
- {
+ foreach ($session_data as $session_key => $session_value) {
+ if (IsSerialized($session_value)) {
$session_data[$session_key] = unserialize($session_value);
}
}
- $debugger->dumpVars($session_data);
+ $this->Application->Debugger->dumpVars($session_data);
// to insert after HTTPQuery if it's visible
- $new_row = dbg_ConstOn('DBG_SHOW_HTTPQUERY') ? 4 : 2;
+ $new_row = constOn('DBG_SHOW_HTTPQUERY') ? 4 : 2;
//$debugger->moveAfterRow($new_row,2);
}
Index: trunk/core/kernel/utility/cache.php
===================================================================
diff -u -r4758 -r4880
--- trunk/core/kernel/utility/cache.php (.../cache.php) (revision 4758)
+++ trunk/core/kernel/utility/cache.php (.../cache.php) (revision 4880)
@@ -17,7 +17,7 @@
parent::Params($params_str);
$this->Conn =& $this->Application->GetADODBConnection();
- $this->debugCache = $this->Application->isDebugMode() && dbg_ConstOn('DBG_CACHE');
+ $this->debugCache = $this->Application->isDebugMode() && constOn('DBG_CACHE');
}
/**
Index: trunk/kernel/units/users/users_event_handler.php
===================================================================
diff -u -r4873 -r4880
--- trunk/kernel/units/users/users_event_handler.php (.../users_event_handler.php) (revision 4873)
+++ trunk/kernel/units/users/users_event_handler.php (.../users_event_handler.php) (revision 4880)
@@ -225,7 +225,7 @@
$next_template = $this->Application->GetVar('next_template');
if ($next_template == '_ses_redirect') {
$location = $this->Application->BaseURL().$this->Application->RecallVar($next_template);
- if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_REDIRECT') )
+ if( $this->Application->isDebugMode() && constOn('DBG_REDIRECT') )
{
$this->Application->Debugger->appendTrace();
echo "Debug output above!!! Proceed to redirect: $location
";
Index: trunk/core/kernel/parser/template_parser.php
===================================================================
diff -u -r4029 -r4880
--- trunk/core/kernel/parser/template_parser.php (.../template_parser.php) (revision 4029)
+++ trunk/core/kernel/parser/template_parser.php (.../template_parser.php) (revision 4880)
@@ -419,7 +419,7 @@
{
if ($tag_data == '__COMMENT__') continue;
//Create tag object from passed tag data
- if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_SHOW_TAGS') )
+ if( $this->Application->isDebugMode() && constOn('DBG_SHOW_TAGS') )
{
global $debugger;
$debugger->appendHTML('mode: '.$this->SkipModeName().' tag '.$debugger->highlightString($tag_data).' in '.$debugger->getFileLink($debugger->getLocalFile(FULL_PATH.THEMES_PATH.'/'.$this->TemplateName).'.tpl', $this->CurrentLineNumber(), '', true));
@@ -462,13 +462,13 @@
function ParseBlock($params, $force_pass_params=0, $as_template=false)
{
- if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_SHOW_TAGS') )
+ if( $this->Application->isDebugMode() && constOn('DBG_SHOW_TAGS') )
{
global $debugger;
$debugger->appendHTML('ParseBlock '.$params['name'].' pass_params is '.$params['pass_params'].' force is '.$force_pass_params.' in '.$debugger->getFileLink($debugger->getLocalFile(FULL_PATH.THEMES_PATH.'/'.$this->TemplateName).'.tpl', $this->CurrentLineNumber(), '', true));
}
- /*if ( $this->Application->isDebugMode() && dbg_ConstOn('DBG_PRE_PARSE') ) {
+ /*if ( $this->Application->isDebugMode() && constOn('DBG_PRE_PARSE') ) {
global $debugger;
$debugger->CurrentPreParsedBlock = $params['name'];
}*/
Index: trunk/core/units/users/users_event_handler.php
===================================================================
diff -u -r4873 -r4880
--- trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 4873)
+++ trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 4880)
@@ -225,7 +225,7 @@
$next_template = $this->Application->GetVar('next_template');
if ($next_template == '_ses_redirect') {
$location = $this->Application->BaseURL().$this->Application->RecallVar($next_template);
- if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_REDIRECT') )
+ if( $this->Application->isDebugMode() && constOn('DBG_REDIRECT') )
{
$this->Application->Debugger->appendTrace();
echo "Debug output above!!! Proceed to redirect: $location
";
Index: trunk/core/kernel/utility/factory.php
===================================================================
diff -u -r4802 -r4880
--- trunk/core/kernel/utility/factory.php (.../factory.php) (revision 4802)
+++ trunk/core/kernel/utility/factory.php (.../factory.php) (revision 4880)
@@ -93,7 +93,7 @@
return $false;
}
- if ($this->Application->isDebugMode() && dbg_ConstOn('DBG_FACTORY')) {
+ if ($this->Application->isDebugMode() && constOn('DBG_FACTORY')) {
global $debugger;
$debugger->appendHTML('Creating object: Pseudo class: '.$pseudo_class.' Prefix: '.$name);
$debugger->appendTrace();
@@ -146,7 +146,7 @@
return $false;
}
- if ($this->Application->isDebugMode() && dbg_ConstOn('DBG_FACTORY')) {
+ if ($this->Application->isDebugMode() && constOn('DBG_FACTORY')) {
global $debugger;
$debugger->appendHTML('Creating object: Pseudo class: '.$pseudo_class.' Prefix: '.$name);
$debugger->appendTrace();
@@ -244,7 +244,7 @@
$pseudo_class = array_shift($func_args);
$class =& ref_call_user_func_array( Array($real_class,'makeClass'), $func_args );
}
- if( defined('DEBUG_MODE') && DEBUG_MODE && dbg_ConstOn('DBG_PROFILE_MEMORY') )
+ if( defined('DEBUG_MODE') && DEBUG_MODE && constOn('DBG_PROFILE_MEMORY') )
{
$mem_after = memory_get_usage();
$time_after = getmicrotime();
Index: trunk/kernel/include/adodb/adodb.inc.php
===================================================================
diff -u -r4814 -r4880
--- trunk/kernel/include/adodb/adodb.inc.php (.../adodb.inc.php) (revision 4814)
+++ trunk/kernel/include/adodb/adodb.inc.php (.../adodb.inc.php) (revision 4880)
@@ -724,9 +724,8 @@
ADOConnection::outp( "=----\n($this->databaseType): ".($sqlTxt)." \n-----\n",false);
flush();
- $profileSQLs = dbg_ConstOn('DBG_SQL_PROFILE');
- if($profileSQLs)
- {
+ $profileSQLs = constOn('DBG_SQL_PROFILE');
+ if ($profileSQLs) {
$isSkipTable = isSkipTable($sql);
$queryID = $debugger->generateID();
if(!$isSkipTable) $debugger->profileStart('sql_'.$queryID, $debugger->formatSQL($sql) );
@@ -756,12 +755,12 @@
$e = $this->ErrorNo();
$m = $this->ErrorMsg();
- $errorLevel = dbg_ConstOn('DBG_SQL_FAILURE') && !dbg_ConstOn('IS_INSTALL') ? E_USER_ERROR : E_USER_WARNING;
+ $errorLevel = constOn('DBG_SQL_FAILURE') && !constOn('IS_INSTALL') ? E_USER_ERROR : E_USER_WARNING;
$debugger->dumpVars($_REQUEST);
$debugger->appendTrace();
$error_msg = ''.$m.' ('.$e.')
SQL: '.$debugger->formatSQL($sql);
- $long_id=$debugger->mapLongError($error_msg);
+ $long_id = $debugger->mapLongError($error_msg);
trigger_error( substr($m.' ('.$e.') ['.$sql.']',0,1000).' #'.$long_id, $errorLevel);
ADOConnection::outp($e .': '. $m );
Index: trunk/core/kernel/languages/phrases_cache.php
===================================================================
diff -u -r4758 -r4880
--- trunk/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 4758)
+++ trunk/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 4880)
@@ -103,11 +103,11 @@
$original_label = $label;
$label = strtoupper($label);
- if( isset($this->Phrases[$label]) )
- {
+ if(isset($this->Phrases[$label])) {
$translated_label = $this->Phrases[$label];
- if(defined('DEBUG_MODE') && DEBUG_MODE && dbg_ConstOn('DBG_PHRASES_HILIGHT') && !$this->Application->IsAdmin())
+ if (defined('DEBUG_MODE') && DEBUG_MODE && constOn('DBG_PHRASES_HIGHLIGHT') && !$this->Application->IsAdmin()) {
$translated_label = ''.$translated_label.' '.$original_label.'';
+ }
return $translated_label;
}
@@ -125,8 +125,7 @@
if ($res === false || count($res) == 0)
{
$translation = '!'.$label.'!';
- if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_PHRASES') )
- {
+ if($this->Application->isDebugMode() && constOn('DBG_PHRASES')) {
list($edit_tpl, $index_file) = $this->Application->IsAdmin() ? Array('regional/phrases_edit', 'index4.php') : Array('phrases_edit', 'index.php');
$edit_url = $this->Application->HREF($edit_tpl,'',Array('m_opener'=>'d','phrases_label'=>$original_label,'phrases_event'=>'OnNew', 'pass'=>'all,phrases'), $index_file );
Index: trunk/core/kernel/processors/tag_processor.php
===================================================================
diff -u -r4607 -r4880
--- trunk/core/kernel/processors/tag_processor.php (.../tag_processor.php) (revision 4607)
+++ trunk/core/kernel/processors/tag_processor.php (.../tag_processor.php) (revision 4880)
@@ -45,10 +45,8 @@
$Method = $tag;
if(method_exists($this, $Method))
{
- if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_SHOW_TAGS') )
- {
- global $debugger;
- $debugger->appendHTML('Processing PreParsed Tag '.$Method.' in '.$this->Prefix);
+ if ($this->Application->isDebugMode() && constOn('DBG_SHOW_TAGS')) {
+ $this->Application->Debugger->appendHTML('Processing PreParsed Tag '.$Method.' in '.$this->Prefix);
}
//echo htmlspecialchars($tag->GetFullTag()).'
';
Index: trunk/core/kernel/utility/debugger/debugger.js
===================================================================
diff -u -r4858 -r4880
--- trunk/core/kernel/utility/debugger/debugger.js (.../debugger.js) (revision 4858)
+++ trunk/core/kernel/utility/debugger/debugger.js (.../debugger.js) (revision 4880)
@@ -149,6 +149,7 @@
document.getElementById('debug_row_1').style.display = 'none';
this.IsQueried = true;
this.DebuggerDIV.scrollTop = this.IsFatalError ? 10000000 : 0;
+ this.DebuggerDIV.scrollLeft = 0;
}
Debugger.prototype.errorCallback = function(p_req, p_pass) {
Index: trunk/kernel/include/syscache.php
===================================================================
diff -u -r3282 -r4880
--- trunk/kernel/include/syscache.php (.../syscache.php) (revision 3282)
+++ trunk/kernel/include/syscache.php (.../syscache.php) (revision 4880)
@@ -181,7 +181,7 @@
return $i;
}
- function &EditCacheItem($name,$value,$module="",$expire=0,$context="",$GroupList="")
+ function EditCacheItem($name,$value,$module="",$expire=0,$context="",$GroupList="")
{
if(strlen($context))
{
Index: trunk/core/kernel/application.php
===================================================================
diff -u -r4850 -r4880
--- trunk/core/kernel/application.php (.../application.php) (revision 4850)
+++ trunk/core/kernel/application.php (.../application.php) (revision 4880)
@@ -189,19 +189,16 @@
{
if($this->InitDone) return false;
- if( defined('DEBUG_MODE') && $this->isDebugMode() && dbg_ConstOn('DBG_PROFILE_MEMORY') )
- {
+ if(defined('DEBUG_MODE') && $this->isDebugMode() && constOn('DBG_PROFILE_MEMORY')) {
$this->Debugger->appendMemoryUsage('Application before Init:');
}
- if( !$this->isDebugMode() && !constOn('DBG_ZEND_PRESENT') )
- {
+ if (!$this->isDebugMode() && !constOn('DBG_ZEND_PRESENT')) {
error_reporting(0);
ini_set('display_errors', 0);
}
- if( !constOn('DBG_ZEND_PRESENT') )
- {
+ if (!constOn('DBG_ZEND_PRESENT')) {
$error_handler = set_error_handler( Array(&$this,'handleError') );
- if($error_handler) $this->errorHandlers[] = $error_handler;
+ if ($error_handler) $this->errorHandlers[] = $error_handler;
}
$this->Conn = new kDBConnection(SQL_TYPE, Array(&$this, 'handleSQLError') );
@@ -586,12 +583,9 @@
{
$event_manager =& $this->recallObject('EventManager');
- if( $this->isDebugMode() && dbg_ConstOn('DBG_SHOW_HTTPQUERY') )
- {
- global $debugger;
- $http_query =& $this->recallObject('HTTPQuery');
- $debugger->appendHTML('HTTPQuery:');
- $debugger->dumpVars($http_query->_Params);
+ if($this->isDebugMode() && constOn('DBG_SHOW_HTTPQUERY')) {
+ $this->Debugger->appendHTML('HTTPQuery:');
+ $this->Debugger->dumpVars($this->HttpQuery->_Params);
}
$event_manager->ProcessRequest();
@@ -609,8 +603,7 @@
*/
function Run()
{
- if( $this->isDebugMode() && dbg_ConstOn('DBG_PROFILE_MEMORY') )
- {
+ if($this->isDebugMode() && constOn('DBG_PROFILE_MEMORY')) {
$this->Debugger->appendMemoryUsage('Application before Run:');
}
@@ -643,15 +636,13 @@
}*/
}
- if( $this->isDebugMode() && dbg_ConstOn('DBG_PROFILE_MEMORY') )
- {
+ if($this->isDebugMode() && constOn('DBG_PROFILE_MEMORY')) {
$this->Debugger->appendMemoryUsage('Application before Parsing:');
}
$this->HTML = $this->Parser->Parse( $template_cache->GetTemplateBody($t), $t );
- if( $this->isDebugMode() && dbg_ConstOn('DBG_PROFILE_MEMORY') )
- {
+ if ($this->isDebugMode() && constOn('DBG_PROFILE_MEMORY')) {
$this->Debugger->appendMemoryUsage('Application after Parsing:');
}
}
@@ -670,13 +661,11 @@
*/
function Done()
{
- if( $this->isDebugMode() && dbg_ConstOn('DBG_PROFILE_MEMORY') )
- {
+ if ($this->isDebugMode() && constOn('DBG_PROFILE_MEMORY')) {
$this->Debugger->appendMemoryUsage('Application before Done:');
}
- if( $this->GetVar('admin') )
- {
+ if ($this->GetVar('admin')) {
$reg = '/('.preg_quote(BASE_PATH, '/').'.*\.html)(#.*){0,1}(")/sU';
$this->HTML = preg_replace($reg, "$1?admin=1$2$3", $this->HTML);
}
@@ -688,7 +677,7 @@
flush();
- if ($this->isDebugMode() && dbg_ConstOn('DBG_CACHE')) {
+ if ($this->isDebugMode() && constOn('DBG_CACHE')) {
$cache =& $this->recallObject('Cache');
$cache->printStatistics();
}
@@ -1335,36 +1324,22 @@
//echo " location : $location
";
- if( $this->isDebugMode() && dbg_ConstOn('DBG_REDIRECT') )
- {
- /*if( function_exists('apache_response_headers') )
- {
- $this->Debugger->appendHTML('Apache Responce Headers');
- $this->Debugger->dumpVars( apache_response_headers() );
-
- $this->Debugger->appendHTML('Apache Request Headers');
- $this->Debugger->dumpVars( apache_request_headers() );
- }*/
+ if ($this->isDebugMode() && constOn('DBG_REDIRECT')) {
$this->Debugger->appendTrace();
echo "Debug output above!!! Proceed to redirect: $a_location
";
}
- else
- {
- if($js_redirect)
- {
+ else {
+ if ($js_redirect) {
$this->SetVar('t', 'redirect');
$this->SetVar('redirect_to_js', addslashes($a_location) );
$this->SetVar('redirect_to', $a_location);
return true;
}
- else
- {
- if(headers_sent() != '')
- {
+ else {
+ if (headers_sent() != '') {
echo '';
}
- else
- {
+ else {
header("$location");
}
}
Index: trunk/core/kernel/globals.php
===================================================================
diff -u -r4758 -r4880
--- trunk/core/kernel/globals.php (.../globals.php) (revision 4758)
+++ trunk/core/kernel/globals.php (.../globals.php) (revision 4880)
@@ -315,7 +315,7 @@
$ch = curl_init($url);
$dbg = false;
- if (defined('DEBUG_MODE') && DEBUG_MODE && dbg_ConstOn('DBG_CURL')) {
+ if (defined('DEBUG_MODE') && DEBUG_MODE && constOn('DBG_CURL')) {
$dbg = true;
safeDefine('DBG_CURL_LOGFILE', '/curl.log');
$log = fopen(FULL_PATH.DBG_CURL_LOGFILE, 'a');
Index: trunk/core/kernel/parser/construct_tags.php
===================================================================
diff -u -r3530 -r4880
--- trunk/core/kernel/parser/construct_tags.php (.../construct_tags.php) (revision 3530)
+++ trunk/core/kernel/parser/construct_tags.php (.../construct_tags.php) (revision 4880)
@@ -219,7 +219,7 @@
global $debugger;
- $dbg_functions = $this->Application->isDebugMode() && dbg_ConstOn('DBG_PRINT_PREPARSED');
+ $dbg_functions = $this->Application->isDebugMode() && constOn('DBG_PRINT_PREPARSED');
$f_body = '';
//echo "
";
Index: trunk/core/kernel/utility/debugger.php
===================================================================
diff -u -r4859 -r4880
--- trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 4859)
+++ trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 4880)
@@ -1,56 +1,13 @@
$rq_value) {
- if (substr($rq_name, 0, 6) == 'debug_') {
- dbg_safeDefine('DBG_ZEND_PRESENT', 1);
- break;
- }
- }
-
- dbg_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_OPTIONS' => 0,*/
- '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
- );
-
- 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('DBG_EDITOR')) {
- $dbg_editor = 0;
- $dbg_editors[0] = Array('editor' => 'c:\Program Files\UltraEdit\uedit32.exe', 'params' => '%F/%L');
- $dbg_editors[1] = Array('editor' => 'c:\Program Files\Zend\ZendStudio-5.2.0\bin\ZDE.exe', 'params' => '%F');
- define('DBG_EDITOR', $dbg_editors[$dbg_editor]['editor'].' '.$dbg_editors[$dbg_editor]['params']);
- unset($dbg_editors, $dbg_editor);
- }*/
-
class Debugger {
+ /**
+ * Set to true if fatal error occured
+ *
+ * @var bool
+ */
var $IsFatalError = false;
/**
@@ -59,6 +16,7 @@
* @var Array
*/
var $Data = Array();
+
var $ProfilerData = Array();
var $ProfilerTotals = Array();
var $ProfilerTotalCount = Array();
@@ -70,9 +28,6 @@
*/
var $RecursionStack = Array();
- var $Options = 0;
- var $OptionsMap = Array('shutdown_func' => 1, 'error_handler' => 2, 'output_buffer' => 4, 'highlight_output' => 8);
-
var $scrollbarWidth = 0;
/**
@@ -82,14 +37,6 @@
*/
var $longErrors = Array();
- /**
- * Amount of memory used by debugger itself
- *
- * @var Array
- * @access private
- */
- var $memoryUsage = Array();
-
var $IncludesData = Array();
var $IncludeLevel = 0;
@@ -127,16 +74,69 @@
function Debugger()
{
global $start;
+
+ $this->InitDebugger();
$this->profileStart('kernel4_startup', 'Startup and Initialization of kernel4', $start);
$this->profileStart('script_runtime', 'Script runtime', $start);
- ini_set('display_errors', dbg_ConstOn('DBG_ZEND_PRESENT') ? 0 : 1); // show errors on screen in case if not in Zend Studio debugging
- $this->memoryUsage['error_handling'] = 0; // memory amount used by error handler
+ ini_set('display_errors', $this->constOn('DBG_ZEND_PRESENT') ? 0 : 1); // show errors on screen in case if not in Zend Studio debugging
$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 :(
+
+ // Detect fact, that this session beeing debugged by Zend Studio
+ foreach ($_REQUEST as $rq_name => $rq_value) {
+ if (substr($rq_name, 0, 6) == 'debug_') {
+ $this->safeDefine('DBG_ZEND_PRESENT', 1);
+ 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
+ $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';
+ }
+
+ foreach ($dbg_constMap as $dbg_constName => $dbg_constValue) {
+ $this->safeDefine($dbg_constName, $dbg_constValue);
+ }
+ }
+
+ function constOn($const_name)
+ {
+ return defined($const_name) && constant($const_name);
+ }
+
+ function safeDefine($const_name, $const_value) {
+ if (!defined($const_name)) {
+ define($const_name, $const_value);
+ }
+ }
+
function InitReport()
{
if (!class_exists('kApplication')) return false;
@@ -161,34 +161,7 @@
$this->longErrors[$key] = $msg;
return $key;
}
-
- /*function initOptions()
- {
-
- }
-
- function setOption($name, $value)
- {
- if (!isset($this->OptionsMap[$name])) {
- die('undefined debugger option: ['.$name.']
');
- }
-
- if ($value) {
- $this->Options |= $this->OptionsMap[$name];
- }
- else {
- $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];
- }*/
-
+
/**
* Appends all passed variable values (wihout variable names) to debug output
*
@@ -384,7 +357,7 @@
function highlightString($string)
{
- if (!dbg_ConstOn('DBG_USE_HIGHLIGHT')) {
+ if (!$this->constOn('DBG_USE_HIGHLIGHT')) {
return $string;
}
@@ -672,54 +645,54 @@
return '';
}
- if (dbg_ConstOn('DBG_SKIP_REPORTING') || dbg_ConstOn('DBG_ZEND_PRESENT')) return '';
-
+ if ($this->constOn('DBG_SKIP_REPORTING') || $this->constOn('DBG_ZEND_PRESENT')) return '';
+
+ $debugger_start = memory_get_usage();
+
if (defined('SPACER_URL')) {
$this->dummyImage = SPACER_URL;
}
$this->InitReport(); // set parameters required by AJAX
// defined here, because user can define this contant while script is running, not event before debugger is started
- dbg_safeDefine('DBG_RAISE_ON_WARNINGS', 0);
-
- $this->memoryUsage['debugger_start'] = memory_get_usage();
+ $this->safeDefine('DBG_RAISE_ON_WARNINGS', 0);
$this->appendSession(); // show php session if any
// ensure, that 1st line of debug output always is this one:
$this->appendHTML('[Reload Frame] [Hide Debugger] [Current Time: '.date('H:i:s').']');
$this->moveToBegin(1);
- if (dbg_ConstOn('DBG_SQL_PROFILE') && isset($this->ProfilerTotals['sql'])) {
+ if ($this->constOn('DBG_SQL_PROFILE') && isset($this->ProfilerTotals['sql'])) {
// sql query profiling was enabled -> show totals
$this->appendHTML('SQL Total time: '.$this->ProfilerTotals['sql'].' Number of queries: '.$this->ProfilerTotalCount['sql']);
}
- if (dbg_ConstOn('DBG_PROFILE_INCLUDES') && isset($this->ProfilerTotals['includes'])) {
+ if ($this->constOn('DBG_PROFILE_INCLUDES') && isset($this->ProfilerTotals['includes'])) {
// included file profiling was enabled -> show totals
$this->appendHTML('Included Files Total time: '.$this->ProfilerTotals['includes'].' Number of includes: '.$this->ProfilerTotalCount['includes']);
}
- if (dbg_ConstOn('DBG_PROFILE_MEMORY')) {
+ if ($this->constOn('DBG_PROFILE_MEMORY')) {
// detailed memory usage reporting by objects was enabled -> show totals
$this->appendHTML('Memory used by Objects: '.round($this->ProfilerTotals['objects'] / 1024, 2).'Kb');
}
- /*if (dbg_ConstOn('DBG_INCLUDED_FILES')) {
+ /*if ($this->constOn('DBG_INCLUDED_FILES')) {
$files = get_included_files();
$this->appendHTML('Included files:');
foreach ($files as $file) {
$this->appendHTML($this->getFileLink($this->getLocalFile($file)).' ('.round(filesize($file) / 1024, 2).'Kb)');
}
}*/
- /*if (dbg_ConstOn('DBG_PROFILE_INCLUDES')) {
- $this->appendHTML('Included files statistics:'.( dbg_ConstOn('DBG_SORT_INCLUDES_MEM') ? ' (sorted by memory usage)':''));
+ /*if ($this->constOn('DBG_PROFILE_INCLUDES')) {
+ $this->appendHTML('Included files statistics:'.( $this->constOn('DBG_SORT_INCLUDES_MEM') ? ' (sorted by memory usage)':''));
$totals = Array( 'mem' => 0, 'time' => 0);
$totals_configs = Array( 'mem' => 0, 'time' => 0);
if (is_array($this->IncludesData['mem'])) {
- if ( dbg_ConstOn('DBG_SORT_INCLUDES_MEM') ) {
+ if ( $this->constOn('DBG_SORT_INCLUDES_MEM') ) {
array_multisort($this->IncludesData['mem'], SORT_DESC, $this->IncludesData['file'], $this->IncludesData['time'], $this->IncludesData['level']);
}
foreach ($this->IncludesData['file'] as $key => $file_name) {
@@ -777,30 +750,26 @@
window.focus();
memoryUsage['debugger_finish'] = memory_get_usage();
- $this->memoryUsage['print_report'] = $this->memoryUsage['debugger_finish'] - $this->memoryUsage['debugger_start'];
- $this->memoryUsage['total'] = $this->memoryUsage['print_report'] + $this->memoryUsage['error_handling'];
- $this->memoryUsage['application'] = memory_get_usage() - $this->memoryUsage['total'];
- $this->memoryUsage['debugfile_size'] = filesize($debug_file);
+ $memory_used = $debugger_start - $this->ProfilerTotals['error_handling'];
if ($returnResult) {
$ret = ob_get_contents();
if ($clean_output_buffer) {
ob_clean();
}
- $ret .= $this->getMemoryUsageReport();
+ $ret .= $this->getShortReport($memory_used);
$this->reportDone = true;
return $ret;
}
else {
- if (!dbg_ConstOn('DBG_HIDE_FULL_REPORT')) {
+ if (!$this->constOn('DBG_HIDE_FULL_REPORT')) {
$this->breakOutofBuffering();
}
elseif ($clean_output_buffer) {
ob_clean();
}
- echo $this->getMemoryUsageReport();
+ echo $this->getShortReport($memory_used);
$this->reportDone = true;
}
@@ -812,32 +781,29 @@
* @return string
* @access private
*/
- function getMemoryUsageReport()
+ function getShortReport($memory_used)
{
$info = Array(
- 'Application' => 'MEM:application',
- 'Script runtime'=> 'PROFILE:script_runtime',
- '-' => 'SEP:-',
- 'printReport' => 'MEM:print_report',
- 'saveError' => 'MEM:error_handling',
- 'Debug Total' => 'MEM:total',
- 'Debug FileSize'=> 'MEM:debugfile_size'
+ 'Script Runtime' => 'PROFILE:script_runtime',
+ '-' => 'SEP:-',
+ 'Notice / Warning' => 'PROFILE_TC:error_handling',
+ 'SQLs Count' => 'PROFILE_TC:sql',
);
- $ret = '';
+ $ret = 'Application: | '.$this->formatSize($memory_used).' ('.$memory_used.') |
';
foreach ($info as $title => $value_key) {
list ($record_type, $record_data) = explode(':', $value_key, 2);
switch ($record_type) {
- case 'MEM':
- $ret .= ''.$title.': | '.$this->formatSize($this->memoryUsage[$record_data]).' ('.$this->memoryUsage[$record_data].') |
';
- break;
-
- case 'PROFILE':
+ case 'PROFILE': // profiler totals value
$Data =& $this->ProfilerData[$record_data];
$profile_time = ($Data['ends'] - $Data['begins']); // in seconds
- $ret .= ''.$title.': | '.sprintf('%.5f', $profile_time).'s |
';
+ $ret .= ''.$title.': | '.sprintf('%.5f', $profile_time).' s |
';
break;
-
+
+ case 'PROFILE_TC': // profile totals record count
+ $ret .= ''.$title.': | '.$this->ProfilerTotalCount[$record_data].' |
';
+ break;
+
case 'SEP':
$ret .= ' |
';
break;
@@ -859,16 +825,15 @@
*/
function saveError($errno, $errstr, $errfile = '', $errline = '', $errcontext = '')
{
- $memory_used = Array();
- $memory_used['begin'] = memory_get_usage();
+ $this->ProfilerData['error_handling']['begins'] = memory_get_usage();
$errorType = $this->getErrorNameByCode($errno);
if (!$errorType) {
trigger_error('Unknown error type ['.$errno.']', E_USER_ERROR);
return false;
}
- if (dbg_ConstOn('DBG_IGNORE_STRICT_ERRORS') && defined('E_STRICT') && ($errno == E_STRICT)) return;
+ if ($this->constOn('DBG_IGNORE_STRICT_ERRORS') && defined('E_STRICT') && ($errno == E_STRICT)) return;
if (preg_match('/(.*)#([\d]+)$/', $errstr, $rets) ) {
// replace short message with long one (due triger_error limitations on message size)
@@ -887,13 +852,13 @@
}
$this->Data[] = Array('no' => $errno, 'str' => $errstr, 'file' => $errfile, 'line' => $errline, 'context' => $errcontext, 'debug_type' => 'error');
- $memory_used['end'] = memory_get_usage();
- $this->memoryUsage['error_handling'] += $memory_used['end'] - $memory_used['begin'];
+ $this->ProfilerData['error_handling']['ends'] = memory_get_usage();
+ $this->profilerAddTotal('error_handling', 'error_handling');
if (substr($errorType, 0, 5) == 'Fatal') {
$this->breakOutofBuffering(false);
$this->IsFatalError = true;
if (ob_get_level()) ob_flush();
- if (!dbg_ConstOn('DBG_USE_SHUTDOWN_FUNC')) {
+ if (!$this->constOn('DBG_USE_SHUTDOWN_FUNC')) {
$this->printReport();
}
exit;
@@ -963,7 +928,7 @@
}
function AttachToApplication() {
- if (!dbg_ConstOn('DBG_HANDLE_ERRORS')) return true;
+ if (!$this->constOn('DBG_HANDLE_ERRORS')) return true;
if (class_exists('kApplication')) {
restore_error_handler();
@@ -972,7 +937,7 @@
$application->errorHandlers[] = Array(&$this, 'saveError');
}
else {
- set_error_handler( Array(&$this, 'saveError') );
+ set_error_handler(Array(&$this, 'saveError'));
}
}
}
@@ -981,11 +946,11 @@
function memory_get_usage(){ return -1; }
}
- if(!dbg_ConstOn('DBG_ZEND_PRESENT')) {
+ if (!Debugger::constOn('DBG_ZEND_PRESENT')) {
$debugger = new Debugger();
}
- if (dbg_ConstOn('DBG_USE_SHUTDOWN_FUNC')) {
+ if (Debugger::constOn('DBG_USE_SHUTDOWN_FUNC')) {
register_shutdown_function( Array(&$debugger, 'printReport') );
}
}
Index: trunk/kernel/parser.php
===================================================================
diff -u -r4590 -r4880
--- trunk/kernel/parser.php (.../parser.php) (revision 4590)
+++ trunk/kernel/parser.php (.../parser.php) (revision 4880)
@@ -56,7 +56,7 @@
return isset($m_var_list_update[$name]) ? $m_var_list_update[$name] : $m_var_list[$name];
}
-function &LoadRelatedItems(&$Relations,&$RelatedItems,$ResourceId)
+function LoadRelatedItems(&$Relations,&$RelatedItems,$ResourceId)
{
global $objItemTypes;
Index: trunk/index.php
===================================================================
diff -u -r4858 -r4880
--- trunk/index.php (.../index.php) (revision 4858)
+++ trunk/index.php (.../index.php) (revision 4880)
@@ -16,20 +16,6 @@
$end = getmicrotime();
-/*if ($application->isDebugMode() && !dbg_ConstOn('DBG_SKIP_REPORTING')) {
- echo '
-
-
- Memory used: |
- '.round(memory_get_usage()/1024/1024, 1).' MB ('.memory_get_usage().') |
-
-
- Time used: |
- '.round(($end - $start), 5).' sec |
-
-
';
-}*/
-
//print_pre(get_included_files());
function getmicrotime()
Index: trunk/admin/index.php
===================================================================
diff -u -r4858 -r4880
--- trunk/admin/index.php (.../index.php) (revision 4858)
+++ trunk/admin/index.php (.../index.php) (revision 4880)
@@ -17,20 +17,6 @@
$end = getmicrotime();
-/*if ($application->isDebugMode() && !dbg_ConstOn('DBG_SKIP_REPORTING')) {
- echo '
-
-
- Memory used: |
- '.round(memory_get_usage()/1024/1024, 1).' MB ('.memory_get_usage().') |
-
-
- Time used: |
- '.round(($end - $start), 5).' sec |
-
-
';
-}*/
-
function getmicrotime()
{
list($usec, $sec) = explode(" ", microtime());
Index: trunk/core/kernel/utility/unit_config_reader.php
===================================================================
diff -u -r4867 -r4880
--- trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 4867)
+++ trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 4880)
@@ -315,7 +315,7 @@
}
}
- if ( $this->Application->isDebugMode() && dbg_ConstOn('DBG_VALIDATE_CONFIGS') && isset($config['TableName']) )
+ if ( $this->Application->isDebugMode() && constOn('DBG_VALIDATE_CONFIGS') && isset($config['TableName']) )
{
global $debugger;
$tablename = $config['TableName'];
Index: trunk/kernel/units/help/help_tag_processor.php
===================================================================
diff -u -r4665 -r4880
--- trunk/kernel/units/help/help_tag_processor.php (.../help_tag_processor.php) (revision 4665)
+++ trunk/kernel/units/help/help_tag_processor.php (.../help_tag_processor.php) (revision 4880)
@@ -38,7 +38,7 @@
$help_file = FULL_PATH.'/'.$module_path.'module_help/'.$title_preset.'.txt';
- if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_EDIT_HELP') )
+ if( $this->Application->isDebugMode() && constOn('DBG_EDIT_HELP') )
{
global $debugger;
$ret = 'Help file: '.$debugger->getLocalFile($help_file).'
';
@@ -50,7 +50,7 @@
$help_data = file_exists($help_file) ? file_get_contents($help_file) : false;
- if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_HELP') )
+ if( $this->Application->isDebugMode() && constOn('DBG_HELP') )
{
$this->Application->Factory->includeClassFile('FCKeditor');
$oFCKeditor = new FCKeditor('HelpContent');
Index: trunk/core/units/help/help_tag_processor.php
===================================================================
diff -u -r4665 -r4880
--- trunk/core/units/help/help_tag_processor.php (.../help_tag_processor.php) (revision 4665)
+++ trunk/core/units/help/help_tag_processor.php (.../help_tag_processor.php) (revision 4880)
@@ -38,7 +38,7 @@
$help_file = FULL_PATH.'/'.$module_path.'module_help/'.$title_preset.'.txt';
- if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_EDIT_HELP') )
+ if( $this->Application->isDebugMode() && constOn('DBG_EDIT_HELP') )
{
global $debugger;
$ret = 'Help file: '.$debugger->getLocalFile($help_file).'
';
@@ -50,7 +50,7 @@
$help_data = file_exists($help_file) ? file_get_contents($help_file) : false;
- if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_HELP') )
+ if( $this->Application->isDebugMode() && constOn('DBG_HELP') )
{
$this->Application->Factory->includeClassFile('FCKeditor');
$oFCKeditor = new FCKeditor('HelpContent');
Index: trunk/core/kernel/processors/main_processor.php
===================================================================
diff -u -r4840 -r4880
--- trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 4840)
+++ trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 4880)
@@ -816,7 +816,7 @@
function ConstOn($params)
{
$name = $this->SelectParam($params,'name,const');
- return $this->Application->isDebugMode() && dbg_ConstOn($name);
+ return constOn($name);
}
function SetDefaultCategory($params)