Ignore:
Timestamp:
Apr 20, 2010 12:04:33 PM (3 years ago)
Author:
alec
Message:
  • Add HTTP_X_REAL_IP and HTTP_X_FORWARDED_FOR to successful logins log (#1486441)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/main.inc

    r3510 r3513  
    11421142 
    11431143/** 
     1144 * Write login data (name, ID, IP address) to the 'userlogins' log file. 
     1145 */ 
     1146function rcmail_log_login() 
     1147{ 
     1148  global $RCMAIL; 
     1149 
     1150  if (!$RCMAIL->config->get('log_logins') || !$RCMAIL->user) 
     1151    return; 
     1152 
     1153  $address = $_SERVER['REMOTE_ADDR']; 
     1154  // append the NGINX X-Real-IP header, if set 
     1155  if (!empty($_SERVER['HTTP_X_REAL_IP'])) { 
     1156    $remote_ip[] = 'X-Real-IP: ' . $_SERVER['HTTP_X_REAL_IP']; 
     1157  } 
     1158  // append the X-Forwarded-For header, if set 
     1159  if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { 
     1160    $remote_ip[] = 'X-Forwarded-For: ' . $_SERVER['HTTP_X_FORWARDED_FOR']; 
     1161  } 
     1162 
     1163  if (!empty($remote_ip)) 
     1164    $address .= '(' . implode(',', $remote_ip) . ')'; 
     1165 
     1166  write_log('userlogins', sprintf('Successful login for %s (ID: %d) from %s', 
     1167    $RCMAIL->user->get_username(), $RCMAIL->user->ID, $address)); 
     1168} 
     1169 
     1170 
     1171/** 
    11441172 * @access private 
    11451173 */ 
Note: See TracChangeset for help on using the changeset viewer.