Index: branches/unlabeled/unlabeled-1.63.4/core/kernel/utility/debugger.php =================================================================== diff -u -r7007 -r7008 --- branches/unlabeled/unlabeled-1.63.4/core/kernel/utility/debugger.php (.../debugger.php) (revision 7007) +++ branches/unlabeled/unlabeled-1.63.4/core/kernel/utility/debugger.php (.../debugger.php) (revision 7008) @@ -80,8 +80,16 @@ } // check IP before enabling debug mode + $ip_match = false; $ip_addresses = isset($dbg_options['DBG_IP']) ? explode(';', $dbg_options['DBG_IP']) : Array (); - if (!in_array($_SERVER['REMOTE_ADDR'], $ip_addresses)) { + foreach ($ip_addresses as $ip_address) { + if ($this->netMatch($ip_address, $_SERVER['REMOTE_ADDR'])) { + $ip_match = true; + break; + } + } + + if (!$ip_match) { define('DEBUG_MODE', 0); return ; } @@ -168,6 +176,43 @@ return $paArray1; } + function netMatch($network, $ip) { + + $network = trim($network); + $ip = trim($ip); + + if ($network == $ip) { + // comparing 2 ip addresses directly + return true; + } + + $d = strpos($network, '-'); + if ($d === false) { + // sigle subnet specified + $ip_arr = explode('/', $network); + + if (!preg_match("@\d*\.\d*\.\d*\.\d*@", $ip_arr[0], $matches)) { + $ip_arr[0] .= '.0'; // Alternate form 194.1.4/24 + } + + $network_long = ip2long($ip_arr[0]); + $x = ip2long($ip_arr[1]); + + $mask = long2ip($x) == $ip_arr[1] ? $x : (0xffffffff << (32 - $ip_arr[1])); + $ip_long = ip2long($ip); + + return ($ip_long & $mask) == ($network_long & $mask); + } + else { + // ip address range specified + $from = ip2long(trim(substr($network, 0, $d))); + $to = ip2long(trim(substr($network, $d + 1))); + + $ip = ip2long($ip); + return ($ip >= $from && $ip <= $to); + } + } + function InitReport() { if (!class_exists('kApplication')) return false; Index: branches/unlabeled/unlabeled-1.13.2/tools/debug_sample.php =================================================================== diff -u -r7007 -r7008 --- branches/unlabeled/unlabeled-1.13.2/tools/debug_sample.php (.../debug_sample.php) (revision 7007) +++ branches/unlabeled/unlabeled-1.13.2/tools/debug_sample.php (.../debug_sample.php) (revision 7008) @@ -6,7 +6,7 @@ // define('DBG_ZEND_PRESENT',0); // Set to 0 to debug debugger (because debugger automatically got disabled during zend debug sessions) $dbg_options = Array ( - 'DBG_IP' => '', // Define IP addreses, that are allowed to user debugger, semicolon separated. All allowed if none specified. + 'DBG_IP' => '193.68.72.64/26', // !!!REQUIRED!!! Define IP addreses, which are allowed to use debugger (semicolon separated) '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)