Index: tools/debug_sample.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- tools/debug_sample.php (revision 15908) +++ tools/debug_sample.php (revision ) @@ -15,7 +15,7 @@ // define('MAINTENANCE_MODE_FRONT', MaintenanceMode::NONE); // Set to MaintenanceMode::SOFT for SOFT Maintenance mode, set to MaintenanceMode::HARD for HARD Maintenance mode (no DB load) // define('MAINTENANCE_MODE_ADMIN', MaintenanceMode::NONE); // Set to MaintenanceMode::SOFT for SOFT Maintenance mode, set to MaintenanceMode::HARD for HARD Maintenance mode (no DB load) // define('MAINTENANCE_MODE_IPS', ''); // Define IP addresses/hosts, which will be able to continue accessing website -// define('DBG_REQUREST_LOG', '/path/to/file');// Log all user requests to site into filename specified +// define('DBG_REQUEST_LOG', 1);// Log all user requests to site into "System Log" // define('DBG_ZEND_PRESENT', 0); // Set to 0 to debug debugger (because debugger automatically got disabled during zend debug sessions) // define('SA_IP', '173.9.192.210'); // Define IP addresses, from which super admin are allowed to login // define('DBG_CAPTURE_STATISTICS', 1); // Capture performance statistics \ No newline at end of file Index: core/kernel/utility/http_query.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/kernel/utility/http_query.php (revision 15910) +++ core/kernel/utility/http_query.php (revision ) @@ -715,46 +715,6 @@ return $ret; } - function writeRequestLog($filename) - { - $log_file = (defined('RESTRICTED') ? RESTRICTED : FULL_PATH) . '/' . $filename; - - if ( is_writable(dirname($log_file)) ) { - $fp = fopen($log_file, 'a'); - - if ( $fp ) { - $session = $this->Application->recallObject('Session'); - /* @var $session Session */ - - $user_id = $session->GetField('PortalUserId'); - $admin_mark = $this->Application->isAdmin ? 'ADMIN' : 'FRONT'; - - $data = '[' . date('D M d H:i:s Y') . '] ' . $admin_mark . '; ip: ' . $this->getClientIp() . '; user_id: ' . $user_id . '; sid: ' . $this->Application->GetSID() . '; request: ' . "\n"; - if ( $this->Get ) { - $data .= "_GET:\n" . print_r($this->Get, true); - } - - if ( $this->Post ) { - $data .= "_POST:\n" . print_r($this->Post, true); - } - - if ( $this->Cookie ) { - $data .= "_COOKIE:\n" . print_r($this->Cookie, true); - } - $data .= str_repeat('=', 100) . "\n"; - - fwrite($fp, $data); - fclose($fp); - } - else { - trigger_error('Request Log directory not writable', E_USER_WARNING); - } - } - else { - trigger_error('Request Log directory not writable', E_USER_WARNING); - } - } - /** * Checks, that url is empty * @@ -800,4 +760,34 @@ return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; } + + /** + * Returns headers + * + * @return array + * @access public + */ + public function getHeaders() + { + if ( function_exists('apache_request_headers') ) { + // If apache_request_headers() exists... + $headers = apache_request_headers(); + + if ( $headers ) { + return $headers; // And works... Use it + } + } + + $headers = array(); + + foreach ( array_keys($_SERVER) as $server_key ) { + if ( substr($server_key, 0, 5) == 'HTTP_' ) { + $header_name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($server_key, 0, 5))))); + $headers[$header_name] = $_SERVER[$server_key]; + } + } + + return $headers; + } + } Index: core/kernel/processors/main_processor.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/kernel/processors/main_processor.php (revision 15928) +++ core/kernel/processors/main_processor.php (revision ) @@ -1045,7 +1045,7 @@ header('Pragma: public'); // Getting headers sent by the client. - $headers = $this->_requestHeaders(); + $headers = $this->Application->HttpQuery->getHeaders(); // Checking if the client is validating his cache and if it is current. if ( isset($headers['If-Modified-Since']) && (strtotime($headers['If-Modified-Since']) > $last_modified - $params['cache']) ) { @@ -1067,29 +1067,6 @@ } return ''; - } - - protected function _requestHeaders() - { - if ( function_exists('apache_request_headers') ) { - // If apache_request_headers() exists... - $headers = apache_request_headers(); - - if ($headers) { - return $headers; // And works... Use it - } - } - - $headers = Array (); - - foreach (array_keys($_SERVER) as $skey) { - if (substr($skey, 0, 5) == 'HTTP_') { - $headername = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($skey, 0, 5))))); - $headers[$headername] = $_SERVER[$skey]; - } - } - - return $headers; } function Header($params) Index: core/kernel/utility/logger.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/kernel/utility/logger.php (revision 15928) +++ core/kernel/utility/logger.php (revision ) @@ -457,10 +457,13 @@ */ public function addRequestData() { - $request_data = Array (); + $request_data = array( + 'Headers' => $this->Application->HttpQuery->getHeaders(), + ); + - $request_variables = Array ('_GET' => $_GET, '_POST' => $_POST, '_COOKIE' => $_COOKIE); + $request_variables = Array('_GET' => $_GET, '_POST' => $_POST, '_COOKIE' => $_COOKIE); - foreach ($request_variables as $title => $data) { + foreach ( $request_variables as $title => $data ) { if ( !$data ) { continue; } @@ -724,7 +727,7 @@ { if ( !$this->_logRecord || $this->_logRecord['LogLevel'] > $this->_maxLogLevel || $this->_state == self::STATE_DISABLED ) { // nothing to save OR less detailed logging requested OR disabled - return true; + return false; } $this->_logRecord['LogMemoryUsed'] = memory_get_usage(); \ No newline at end of file Index: core/kernel/application.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/kernel/application.php (revision 15945) +++ core/kernel/application.php (revision ) @@ -2016,9 +2016,7 @@ $user->SetError('UserLogin', 'session_expired', 'la_text_sess_expired'); } - if ( ($user_id != USER_GUEST) && defined('DBG_REQUREST_LOG') && DBG_REQUREST_LOG ) { - $this->HttpQuery->writeRequestLog(DBG_REQUREST_LOG); - } + $this->HandleEvent(new kEvent('adm:OnLogHttpRequest')); if ( $user_id != USER_GUEST ) { // normal users + root Index: core/units/admin/admin_events_handler.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/units/admin/admin_events_handler.php (revision 15943) +++ core/units/admin/admin_events_handler.php (revision ) @@ -1195,6 +1195,24 @@ echo $popup_info['PopupWidth'] . 'x' . $popup_info['PopupHeight']; } } + + /** + * Writes HTTP request to System Log + * + * @param kEvent $event + * @return void + * @access public + */ + public function OnLogHttpRequest(kEvent $event) + { + if ( defined('DBG_REQUEST_LOG') && DBG_REQUEST_LOG && $this->Application->LoggedIn() ) { + $log = $this->Application->log('HTTP_REQUEST')->addRequestData(); + + if ( !$log->write() ) { + trigger_error('Unable to log Http Request due disabled "System Log"', E_USER_WARNING); + } + } + } } /** \ No newline at end of file