Index: branches/unlabeled/unlabeled-1.50.4/core/kernel/startup.php
===================================================================
diff -u -r6708 -r7007
--- branches/unlabeled/unlabeled-1.50.4/core/kernel/startup.php (.../startup.php) (revision 6708)
+++ branches/unlabeled/unlabeled-1.50.4/core/kernel/startup.php (.../startup.php) (revision 7007)
@@ -78,7 +78,7 @@
if( file_exists(FULL_PATH.'/debug.php') )
{
include_once(FULL_PATH.'/debug.php');
- if( constOn('DEBUG_MODE') ) {
+ if(isset($dbg_options['DEBUG_MODE']) && $dbg_options['DEBUG_MODE']) {
$debugger_start = getmicrotime();
include_once(KERNEL_PATH.'/utility/debugger.php');
$debugger_end = getmicrotime();
Index: branches/unlabeled/unlabeled-1.63.4/core/kernel/utility/debugger.php
===================================================================
diff -u -r6706 -r7007
--- branches/unlabeled/unlabeled-1.63.4/core/kernel/utility/debugger.php (.../debugger.php) (revision 6706)
+++ branches/unlabeled/unlabeled-1.63.4/core/kernel/utility/debugger.php (.../debugger.php) (revision 7007)
@@ -70,11 +70,23 @@
* @var string
*/
var $baseURL = '';
-
+
function Debugger()
{
- global $start;
-
+ global $start, $dbg_options;
+ // check if user haven't defined DEBUG_MODE contant directly
+ if (defined('DEBUG_MODE') && DEBUG_MODE) {
+ die('error: contant DEBUG_MODE defined directly, please use $dbg_options array instead');
+ }
+
+ // check IP before enabling debug mode
+ $ip_addresses = isset($dbg_options['DBG_IP']) ? explode(';', $dbg_options['DBG_IP']) : Array ();
+ if (!in_array($_SERVER['REMOTE_ADDR'], $ip_addresses)) {
+ define('DEBUG_MODE', 0);
+ return ;
+ }
+
+ // debug is allowed for user, continue initialization
$this->InitDebugger();
$this->profileStart('kernel4_startup', 'Startup and Initialization of kernel4', $start);
$this->profileStart('script_runtime', 'Script runtime', $start);
@@ -85,14 +97,16 @@
$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 :(
+ global $dbg_options;
+
+ unset($_REQUEST['debug_host'], $_REQUEST['debug_fastfile'], $dbg_options['DBG_IP']); // this var messed up whole detection stuff :(
// Detect fact, that this session beeing debugged by Zend Studio
foreach ($_REQUEST as $rq_name => $rq_value) {
@@ -101,7 +115,7 @@
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
@@ -122,6 +136,9 @@
$dbg_constMap['DBG_EDITOR'] = 'c:\Program Files\Zend\ZendStudio-5.2.0\bin\ZDE.exe %F';
}
+ // user defined options override debugger defaults
+ $dbg_constMap = $this->array_merge_recursive2($dbg_constMap, $dbg_options);
+
foreach ($dbg_constMap as $dbg_constName => $dbg_constValue) {
$this->safeDefine($dbg_constName, $dbg_constValue);
}
@@ -138,6 +155,19 @@
}
}
+ function array_merge_recursive2($paArray1, $paArray2)
+ {
+ if (!is_array($paArray1) or !is_array($paArray2)) {
+ return $paArray2;
+ }
+
+ foreach ($paArray2 AS $sKey2 => $sValue2) {
+ $paArray1[$sKey2] = isset($paArray1[$sKey2]) ? array_merge_recursive2($paArray1[$sKey2], $sValue2) : $sValue2;
+ }
+
+ return $paArray1;
+ }
+
function InitReport()
{
if (!class_exists('kApplication')) return false;
Index: branches/unlabeled/unlabeled-1.13.2/tools/debug_sample.php
===================================================================
diff -u -r6431 -r7007
--- branches/unlabeled/unlabeled-1.13.2/tools/debug_sample.php (.../debug_sample.php) (revision 6431)
+++ branches/unlabeled/unlabeled-1.13.2/tools/debug_sample.php (.../debug_sample.php) (revision 7007)
@@ -1,102 +1,68 @@
'', // Define IP addreses, that are allowed to user debugger, semicolon separated. All allowed if none specified.
+ 'DEBUG_MODE' => 1, // Debug mode is allowed/disabled (note: set DBG_IP to use this one)
+// 'DBG_LOCAL_BASE_PATH' => 'w:', // Folder name on mapped drive, where site resides
+// 'DBG_TOOLBAR_BUTTONS' => 1, // Show "Show Debugger" & "Refresh Frame" buttons (on front)
- return in_array($_SERVER['REMOTE_ADDR'], $ip_addresses) &&
- !(defined('IS_INSTALL') && IS_INSTALL);
- }
-
- /**
- * Performs initial debugger configuration by defining control constants
- *
- */
- function InitDebugger()
- {
- if (!DebugAllowed()) {
- // debug is not allowed
- return false;
- }
- define('DEBUG_MODE', 1); // Debug mode is allowed
+// 'DBG_USE_HIGHLIGHT' => 0, // Use "highlight_string" php function for debugger output formatting
+// 'DBG_RAISE_ON_WARNINGS' => 1, // Show debugger output in case of any non-fatal error
+ 'DBG_SQL_PROFILE' => 1, // Profile SQL queries
+ 'DBG_SQL_FAILURE' => defined('IS_INSTALL') && IS_INSTALL ? 0 : 1, // treat sql errors as fatal errors except for installation process
+
+ 'DBG_SHOW_HTTPQUERY' => 1, // Show http query content (parsed user submit, GPC)
+ 'DBG_SHOW_SESSIONDATA' => 1, // Show session data (at script finish)
+
+ 'DBG_EDIT_HELP' => 1, // Show help filename on help screen
+// 'DBG_HELP' => 1, // Show FCK editor when viewing help screen
+
+// 'DBG_FORCE_THEME' => 1, // Use this theme_id instead of one in url
+ 'DBG_PHRASES' => 1, // Add ability to translate phrases on the fly (K4 templates only)
+// 'DBG_WINDOW_WIDTH' => 700, // Set custom debugger layer width (in pixels)
+
+// 'DBG_REDIRECT' => 1, // Show links with redirect url instead of performing it (useful in events debugging)
+
+// 'DBG_VALIDATE_CONFIGS' => 1, // Check that config fields match ones from database
+// 'DBG_SHOW_TAGS' => 1, // Show tags beeing processed
+ );
- define('DBG_LOCAL_BASE_PATH', 'w:'); // Folder name on mapped drive, where site resides
-// define('DBG_TOOLBAR_BUTTONS', 1); // Show "Show Debugger" & "Refresh Frame" buttons (on front)
-// define('DBG_USE_HIGHLIGHT', 0); // Use "highlight_string" php function for debugger output formatting
-// define('DBG_RAISE_ON_WARNINGS',1); // Show debugger output in case of any non-fatal error
- define('DBG_SQL_PROFILE',1); // Profile SQL queries
- define('DBG_SQL_FAILURE', defined('IS_INSTALL') && IS_INSTALL ? 0 : 1); // treat sql errors as fatal errors except for installation process
-
- define('DBG_SHOW_HTTPQUERY', 1); // Show http query content (parsed user submit, GPC)
- define('DBG_SHOW_SESSIONDATA', 1); // Show session data (at script finish)
-
- define('DBG_EDIT_HELP', 1); // Show help filename on help screen
-// define('DBG_HELP', 1); // Show FCK editor when viewing help screen
-
-// define('DBG_FORCE_THEME', 1); // Use this theme_id instead of one in url
- define('DBG_PHRASES', 1); // Add ability to translate phrases on the fly (K4 templates only)
- define('DBG_WINDOW_WIDTH', 700);// Set custom debugger layer width (in pixels)
-
-// define('DBG_REDIRECT', 1); // Show links with redirect url instead of performing it (useful in events debugging)
-// define('DBG_ZEND_PRESENT',0); // Set to 0 to debug debugger (because debugger automatically got disabled during zend debug sessions)
-// define('DBG_VALIDATE_CONFIGS',1); // Check that config fields match ones from database
-// define('DBG_SHOW_TAGS', 1); // Show tags beeing processed
-
// for ADODB to work: begin
define('ADODB_OUTP', 'dbg_SQLLog');
function dbg_SQLLog($msg, $new_line = false) { }
// for ADODB to work: end
+
function isSkipTable($sql)
{
+// return false;
+
// don't show sqls that use one or more tables from list below
static $skipTables = Array( 'PermissionConfig','SessionData','Permissions',
- 'Phrase','Cache','Modules','PermCache','Events',
+ 'Phrase','Cache','Modules','Events',
'PersistantSessionData','EmailQueue','UserSession',
'ThemeFiles', 'Language','ConfigurationValues');
- // make exception for scripts listed below
- $filename = basename($_SERVER['PHP_SELF']);
- switch ($filename) {
- case 'session_list.php':
- $allow_tables = Array('UserSession', 'SessionData');
- break;
-
- default:
- $allow_tables = Array();
- break;
- }
-
- foreach ($allow_tables as $allowed_table) {
- unset($skipTables[ array_search($allowed_table, $skipTables)]);
- }
-
foreach ($skipTables as $table) {
- if( tableMatch($table,$sql) ) {
+ if( dbg_tableMatch($table, $sql) ) {
return true;
}
}
+
return false;
}
- function tableMatch($table_name,$sql)
+ function dbg_tableMatch($table_name,$sql)
{
static $prefix = '';
$prefix = defined('TABLE_PREFIX')?TABLE_PREFIX:GetTablePrefix();
return strpos($sql,$prefix.$table_name)!==false;
}
- }
+
?>