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 15945) +++ 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/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/kernel/utility/logger.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/kernel/utility/logger.php (revision 15945) +++ core/kernel/utility/logger.php (revision ) @@ -468,6 +468,7 @@ $request_data[$title] = $data; } + $request_data['HEADERS'] = $this->Application->HttpQuery->getHeaders(); $this->_logRecord['LogRequestData'] = serialize($request_data); return $this; \ No newline at end of file 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 15945) +++ core/units/admin/admin_events_handler.php (revision ) @@ -1195,6 +1195,27 @@ 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) + { + $session = $this->Application->recallObject('Session'); + /* @var $session Session */ + + $user_id = $session->GetField('PortalUserId'); + + if ( ($user_id != USER_GUEST) && defined('DBG_REQUREST_LOG') && DBG_REQUREST_LOG ) { + $log = $this->Application->log('HTTP_REQUEST'); + $log->addRequestData(); + $log->write(); + } + } } /** \ 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 15945) +++ 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 * @@ -799,5 +759,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 $skey) { + if (substr($skey, 0, 5) == 'HTTP_') { + $headername = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($skey, 0, 5))))); + $headers[$headername] = $_SERVER[$skey]; + } + } + + return $headers; } }