- Support dynamic hostname (%d/%n) variables in configuration options (#1485438)

release-0.6
alecpl 14 years ago
parent 05a631a43c
commit bb8721aaeb

@ -1,6 +1,7 @@
CHANGELOG RoundCube Webmail
===========================
- Support dynamic hostname (%d/%n) variables in configuration options (#1485438)
- Add 'messages_list' hook (#1486266)
- Add request* event triggers in http_post/http_request (#1486054)
- Fix use RFC-compliant line-delimiter when saving messages on IMAP (#1486712)

@ -61,6 +61,10 @@ $rcmail_config['smtp_debug'] = false;
// leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// Supported replacement variables:
// %n - http hostname ($_SERVER['SERVER_NAME'])
// %d - domain (http hostname without the first part)
// For example %n = mail.domain.tld, %d = domain.tld
$rcmail_config['default_host'] = '';
// TCP port used for IMAP connections
@ -90,7 +94,11 @@ $rcmail_config['imap_timeout'] = 0;
// SMTP server host (for sending mails).
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// If left blank, the PHP mail() function is used
// Use %h variable as replacement for user's IMAP hostname
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - http hostname ($_SERVER['SERVER_NAME'])
// %d - domain (http hostname without the first part)
// For example %n = mail.domain.tld, %d = domain.tld
$rcmail_config['smtp_server'] = '';
// SMTP port (default is 25; 465 for SSL)
@ -176,6 +184,11 @@ $rcmail_config['username_domain'] = '';
// This domain will be used to form e-mail addresses of new users
// Specify an array with 'host' => 'domain' values to support multiple hosts
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - http hostname ($_SERVER['SERVER_NAME'])
// %d - domain (http hostname without the first part)
// For example %n = mail.domain.tld, %d = domain.tld
$rcmail_config['mail_domain'] = '';
// Password charset.
@ -374,6 +387,11 @@ $rcmail_config['ldap_public'] = array();
*
$rcmail_config['ldap_public']['Verisign'] = array(
'name' => 'Verisign.com',
// Replacement variables supported in host names:
// %h - user's IMAP hostname
// %n - http hostname ($_SERVER['SERVER_NAME'])
// %d - domain (http hostname without the first part)
// For example %n = mail.domain.tld, %d = domain.tld
'hosts' => array('directory.verisign.com'),
'port' => 389,
'use_tls' => false,

@ -1532,6 +1532,7 @@ function rcube_https_check($port=null, $use_https=true)
return false;
}
// for backward compatibility
function rcube_sess_unset($var_name=null)
{
@ -1541,6 +1542,21 @@ function rcube_sess_unset($var_name=null)
}
// Replaces hostname variables
function rcube_parse_host($name)
{
// %n - host
$n = preg_replace('/:\d+$/', '', $_SERVER['SERVER_NAME']);
// %d - domain name without first part, e.g. %d=mail.domain.tld, %m=domain.tld
$d = preg_replace('/^[^\.]+\./', '', $n);
// %h - IMAP host
$h = $_SESSION['imap_host'];
$name = str_replace(array('%n', '%d', '%h'), array($n, $d, $h), $name);
return $name;
}
/**
* E-mail address validation
*/

@ -575,7 +575,7 @@ class rcmail
if (!$allowed)
return false;
}
else if (!empty($config['default_host']) && $host != $config['default_host'])
else if (!empty($config['default_host']) && $host != rcube_parse_host($config['default_host']))
return false;
// parse $host URL
@ -743,7 +743,7 @@ class rcmail
$host = get_input_value('_host', RCUBE_INPUT_POST);
}
else
$host = $default_host;
$host = rcube_parse_host($default_host);
return $host;
}

@ -277,12 +277,12 @@ class rcube_config
$domain = $this->prop['mail_domain'][$host];
}
else if (!empty($this->prop['mail_domain']))
$domain = $this->prop['mail_domain'];
$domain = rcube_parse_host($this->prop['mail_domain']);
return $domain;
}
/**
* Getter for error state
*

@ -99,6 +99,7 @@ class rcube_ldap extends rcube_addressbook
foreach ($this->prop['hosts'] as $host)
{
$host = rcube_parse_host($host);
$this->_debug("C: Connect [$host".($this->prop['port'] ? ':'.$this->prop['port'] : '')."]");
if ($lc = @ldap_connect($host, $this->prop['port']))

@ -73,7 +73,7 @@ class rcube_smtp
'smtp_timeout' => $RCMAIL->config->get('smtp_timeout'),
));
$smtp_host = str_replace('%h', $_SESSION['imap_host'], $CONFIG['smtp_server']);
$smtp_host = rcube_parse_host($CONFIG['smtp_server']);
// when called from Installer it's possible to have empty $smtp_host here
if (!$smtp_host) $smtp_host = 'localhost';
$smtp_port = is_numeric($CONFIG['smtp_port']) ? $CONFIG['smtp_port'] : 25;

Loading…
Cancel
Save