Changeset View
Changeset View
Standalone View
Standalone View
lib/Kolab/DAV/Auth/HTTPBasic.php
Show First 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | protected function _login($username, $password, $host, &$error = null) | ||||
if (empty($username)) { | if (empty($username)) { | ||||
return null; | return null; | ||||
} | } | ||||
$rcube = rcube::get_instance(); | $rcube = rcube::get_instance(); | ||||
$storage = $rcube->get_storage(); | $storage = $rcube->get_storage(); | ||||
$login_lc = $rcube->config->get('login_lc'); | $login_lc = $rcube->config->get('login_lc'); | ||||
$default_port = $rcube->config->get('default_port', 143); | $default_port = $rcube->config->get('default_port', 143); | ||||
$username_domain = $rcube->config->get('username_domain'); | |||||
// parse $host | // parse $host | ||||
$a_host = parse_url($host); | $a_host = parse_url($host); | ||||
if ($a_host['host']) { | if ($a_host['host']) { | ||||
$host = $a_host['host']; | $host = $a_host['host']; | ||||
$ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null; | $ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null; | ||||
if (!empty($a_host['port'])) { | if (!empty($a_host['port'])) { | ||||
$port = $a_host['port']; | $port = $a_host['port']; | ||||
} | } | ||||
else if ($ssl && $ssl != 'tls' && (!$default_port || $default_port == 143)) { | else if ($ssl && $ssl != 'tls' && (!$default_port || $default_port == 143)) { | ||||
$port = 993; | $port = 993; | ||||
} | } | ||||
} | } | ||||
if (!$port) { | if (!$port) { | ||||
$port = $default_port; | $port = $default_port; | ||||
} | } | ||||
// Check if we need to add/force domain to username | |||||
if (!empty($username_domain)) { | |||||
$domain = is_array($username_domain) ? $username_domain[$host] : $username_domain; | |||||
if ($domain = rcube_utils::parse_host((string)$domain, $host)) { | |||||
$pos = strpos($username, '@'); | |||||
// force configured domains | |||||
if ($pos !== false && $rcube->config->get('username_domain_forced')) { | |||||
$username = substr($username, 0, $pos) . '@' . $domain; | |||||
} | |||||
// just add domain if not specified | |||||
else if ($pos === false) { | |||||
$username .= '@' . $domain; | |||||
} | |||||
} | |||||
} | |||||
// Convert username to lowercase. If storage backend | // Convert username to lowercase. If storage backend | ||||
// is case-insensitive we need to store always the same username | // is case-insensitive we need to store always the same username | ||||
if ($login_lc) { | if ($login_lc) { | ||||
if ($login_lc == 2 || $login_lc === true) { | if ($login_lc == 2 || $login_lc === true) { | ||||
$username = mb_strtolower($username); | $username = mb_strtolower($username); | ||||
} | } | ||||
else if (strpos($username, '@')) { | else if (strpos($username, '@')) { | ||||
// lowercase domain name | // lowercase domain name | ||||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |