static function updateSettings($settings) { // Make sure errors are handled by PHP when we read, including our own debug output. $oldHandleType = eZDebug::setHandleType(self::HANDLE_TO_PHP); if (isset($settings['debug-log-files-enabled'])) { $GLOBALS['eZDebugLogFileEnabled'] = $settings['debug-log-files-enabled']; if (isset($GLOBALS["eZDebugGlobalInstance"])) { $GLOBALS["eZDebugGlobalInstance"]->GlobalLogFileEnabled = $settings['debug-log-files-enabled']; } } if (isset($settings['debug-styles'])) { $GLOBALS['eZDebugStyles'] = $settings['debug-styles']; } if (isset($settings['always-log']) and is_array($settings['always-log'])) { $GLOBALS['eZDebugAlwaysLog'] = $settings['always-log']; } if (isset($settings['log-only'])) { $GLOBALS['eZDebugLogOnly'] = $settings['log-only'] == 'enabled'; } $notDebugByIP = true; $debugEnabled = $settings['debug-enabled']; if ($settings['debug-enabled'] and $settings['debug-by-ip']) { $ipAddress = eZSys::serverVariable('REMOTE_ADDR', true); if ($ipAddress) { $debugEnabled = false; foreach ($settings['debug-ip-list'] as $itemToMatch) { if (preg_match("/^(([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+))(\\/([0-9]+)\$|\$)/", $itemToMatch, $matches)) { if ($matches[6]) { if (eZDebug::isIPInNet($ipAddress, $matches[1], $matches[7])) { $debugEnabled = true; $notDebugByIP = false; break; } } else { if ($matches[1] == $ipAddress) { $debugEnabled = true; $notDebugByIP = false; break; } } } } } else { $debugEnabled = in_array('commandline', $settings['debug-ip-list']) && php_sapi_name() == 'cli'; } } if ($settings['debug-enabled'] and isset($settings['debug-by-user']) and $settings['debug-by-user'] and $notDebugByIP) { $debugUserIDList = $settings['debug-user-list'] ? $settings['debug-user-list'] : array(); $GLOBALS['eZDebugUserIDList'] = $debugUserIDList; // We enable the debug temporarily. // In checkDebugByUser() will be last(final) check for debug by user id. $debugEnabled = true; } $GLOBALS['eZDebugEnabled'] = $debugEnabled; eZDebug::setHandleType($oldHandleType); }
static function isUserIPInList($ipList) { $ipAddress = eZSys::clientIP(); if ($ipAddress) { $result = false; foreach ($ipList as $itemToMatch) { if (preg_match("/^(([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+))(\\/([0-9]+)\$|\$)/", $itemToMatch, $matches)) { if ($matches[6]) { if (eZDebug::isIPInNet($ipAddress, $matches[1], $matches[7])) { $result = true; break; } } else { if ($matches[1] == $ipAddress) { $result = true; break; } } } } } else { $result = in_array('commandline', $ipList) && php_sapi_name() == 'cli'; } return $result; }
static function debugbyip() { //If DebugByIP is enabled, then we only want output going to the valid IPs $moduleINI = eZINI::instance('site.ini'); if ($moduleINI->variable('DebugSettings', 'DebugByIP') == "enabled") { $ipAddress = eZSys::serverVariable('REMOTE_ADDR', true); if ($ipAddress) { foreach ($moduleINI->variable('DebugSettings', 'DebugIPList') as $itemToMatch) { if (preg_match("/^(([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+))(\\/([0-9]+)\$|\$)/", $itemToMatch, $matches)) { if ($matches[6]) { if (eZDebug::isIPInNet($ipAddress, $matches[1], $matches[7])) { return TRUE; } } else { if ($matches[1] == $ipAddress) { return TRUE; break; } } } } //IP is not in list if we get here } //Enabled but no IP address returned by REMOTE_ADDR return FALSE; } else { //Not enabled return TRUE; } }