alecpl
2010-05-19 b62a0d2d23db19f3e69937de0f162294c98cdbc9
program/include/main.inc
@@ -1141,6 +1141,34 @@
/**
 * Write login data (name, ID, IP address) to the 'userlogins' log file.
 */
function rcmail_log_login()
{
  global $RCMAIL;
  if (!$RCMAIL->config->get('log_logins') || !$RCMAIL->user)
    return;
  $address = $_SERVER['REMOTE_ADDR'];
  // append the NGINX X-Real-IP header, if set
  if (!empty($_SERVER['HTTP_X_REAL_IP'])) {
    $remote_ip[] = 'X-Real-IP: ' . $_SERVER['HTTP_X_REAL_IP'];
  }
  // append the X-Forwarded-For header, if set
  if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $remote_ip[] = 'X-Forwarded-For: ' . $_SERVER['HTTP_X_FORWARDED_FOR'];
  }
  if (!empty($remote_ip))
    $address .= '(' . implode(',', $remote_ip) . ')';
  write_log('userlogins', sprintf('Successful login for %s (ID: %d) from %s',
    $RCMAIL->user->get_username(), $RCMAIL->user->ID, $address));
}
/**
 * @access private
 */
function rcube_timer()
@@ -1431,15 +1459,15 @@
{
  global $CONFIG;
  if ($folder_id == 'INBOX')
    return 'inbox';
  // for these mailboxes we have localized labels and css classes
  foreach (array('sent', 'drafts', 'trash', 'junk') as $smbx)
  {
    if ($folder_id == $CONFIG[$smbx.'_mbox'])
      return $smbx;
  }
  if ($folder_id == 'INBOX')
    return 'inbox';
}
@@ -1560,8 +1588,15 @@
    if (!$dns_check || !rcmail::get_instance()->config->get('email_dns_check'))
      return true;
    if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' && version_compare(PHP_VERSION, '5.3.0', '<'))
      return true;
    if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' && version_compare(PHP_VERSION, '5.3.0', '<')) {
      $lookup = array();
      @exec("nslookup -type=MX " . escapeshellarg($domain_part) . " 2>&1", $lookup);
      foreach ($lookup as $line) {
        if (strpos($line, 'MX preference'))
          return true;
      }
      return false;
    }
    // find MX record(s)
    if (getmxrr($domain_part, $mx_records))