diff options
Diffstat (limited to 'program/include')
-rw-r--r-- | program/include/rcmail.php | 51 | ||||
-rw-r--r-- | program/include/rcmail_output_json.php | 7 |
2 files changed, 41 insertions, 17 deletions
diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 62f6b6c46..0483f0e18 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -481,15 +481,22 @@ class rcmail extends rcube $port = $config['default_port']; } - /* Modify username with domain if required - Inspired by Marco <P0L0_notspam_binware.org> - */ - // Check if we need to add domain - if (!empty($config['username_domain']) && strpos($username, '@') === false) { - if (is_array($config['username_domain']) && isset($config['username_domain'][$host])) - $username .= '@'.rcube_utils::parse_host($config['username_domain'][$host], $host); - else if (is_string($config['username_domain'])) - $username .= '@'.rcube_utils::parse_host($config['username_domain'], $host); + // Check if we need to add/force domain to username + if (!empty($config['username_domain'])) { + $domain = is_array($config['username_domain']) ? $config['username_domain'][$host] : $config['username_domain']; + + if ($domain = rcube_utils::parse_host((string)$domain, $host)) { + $pos = strpos($username, '@'); + + // force configured domains + if (!empty($config['username_domain_forced']) && $pos !== false) { + $username = substr($username, 0, $pos) . '@' . $domain; + } + // just add domain if not specified + else if ($pos === false) { + $username .= '@' . $domain; + } + } } if (!isset($config['login_lc'])) { @@ -954,22 +961,32 @@ class rcmail extends rcube /** * Write login data (name, ID, IP address) to the 'userlogins' log file. */ - public function log_login() + public function log_login($user = null, $failed_login = false, $error_code = 0) { if (!$this->config->get('log_logins')) { return; } - $user_name = $this->get_user_name(); - $user_id = $this->get_user_id(); + // failed login + if ($failed_login) { + $message = sprintf('Failed login for %s from %s in session %s (error: %d)', + $user, rcube_utils::remote_ip(), session_id(), $error_code); + } + // successful login + else { + $user_name = $this->get_user_name(); + $user_id = $this->get_user_id(); - if (!$user_id) { - return; + if (!$user_id) { + return; + } + + $message = sprintf('Successful login for %s (ID: %d) from %s in session %s', + $user_name, $user_id, rcube_utils::remote_ip(), session_id()); } - self::write_log('userlogins', - sprintf('Successful login for %s (ID: %d) from %s in session %s', - $user_name, $user_id, rcube_utils::remote_ip(), session_id())); + // log login + self::write_log('userlogins', $message); } diff --git a/program/include/rcmail_output_json.php b/program/include/rcmail_output_json.php index def6ee42c..d0e1eec64 100644 --- a/program/include/rcmail_output_json.php +++ b/program/include/rcmail_output_json.php @@ -227,6 +227,13 @@ class rcmail_output_json extends rcmail_output if (!empty($this->callbacks)) $response['callbacks'] = $this->callbacks; + // trigger generic hook where plugins can put additional content to the response + $hook = $this->app->plugins->exec_hook("render_response", array('response' => $response)); + + // save some memory + $response = $hook['response']; + unset($hook['response']); + echo self::json_serialize($response); } |