Please test them.
<?php if (isset($err["auth_imaphost"])) formerr($err["auth_imaphost"]); ?>
</TD>
<TD>
- <?php print_string("auth_imaphost","auth") ?>
+ <?php print_string("auth_imaphost","auth") ?>
+ <?php print_string("auth_multiplehosts","auth") ?>
</TD>
</TR>
global $CFG;
- switch ($CFG->auth_imaptype) {
- case "imapssl":
- $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/ssl}";
- break;
-
- case "imapcert":
- $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/ssl/novalidate-cert}";
- break;
-
- case "imaptls":
- $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/notls}";
- break;
-
- default:
- $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport}";
+ $hosts = split(';', $CFG->auth_imaphost); // Could be multiple hosts
+
+ foreach ($hosts as $host) { // Try each host in turn
+
+ $host = trim($host);
+
+ switch ($CFG->auth_imaptype) {
+ case "imapssl":
+ $host = '{'.$host.":$CFG->auth_imapport/imap/ssl}";
+ break;
+
+ case "imapcert":
+ $host = '{'.$host.":$CFG->auth_imapport/imap/ssl/novalidate-cert}";
+ break;
+
+ case "imaptls":
+ $host = '{'.$host.":$CFG->auth_imapport/imap/notls}";
+ break;
+
+ default:
+ $host = '{'.$host.":$CFG->auth_imapport}";
+ }
+
+ error_reporting(0);
+ $connection = imap_open($host, $username, $password, OP_HALFOPEN);
+ error_reporting($CFG->debug);
+
+ if ($connection) {
+ imap_close($connection);
+ return true;
+ }
}
- error_reporting(0);
- $connection = imap_open($host, $username, $password, OP_HALFOPEN);
- error_reporting($CFG->debug);
-
- if ($connection) {
- imap_close($connection);
- return true;
-
- } else {
- return false;
- }
+ return false; // No match
}
</TD>
<TD>
<?php print_string("auth_nntphost","auth") ?>
+ <?php print_string("auth_multiplehosts","auth") ?>
</TD>
</TR>
global $CFG;
- $host = "{".$CFG->auth_nntphost.":$CFG->auth_nntpport/nntp}";
+ $hosts = split(';', $CFG->auth_nntphost); // Could be multiple hosts
- error_reporting(0);
- $connection = imap_open($host, $username, $password, OP_HALFOPEN);
- error_reporting($CFG->debug);
+ foreach ($hosts as $host) { // Try each host in turn
+ $host = '{'.trim($host).":$CFG->auth_nntpport/nntp}";
- if ($connection) {
- imap_close($connection);
- return true;
+ error_reporting(0);
+ $connection = imap_open($host, $username, $password, OP_HALFOPEN);
+ error_reporting($CFG->debug);
- } else {
- return false;
+ if ($connection) {
+ imap_close($connection);
+ return true;
+ }
}
+
+ return false; // No match
}
</TD>
<TD>
<?php print_string("auth_pop3host","auth") ?>
+ <?php print_string("auth_multiplehosts","auth") ?>
</TD>
</TR>
global $CFG;
- switch ($CFG->auth_pop3type) {
- case "pop3":
- $host = "{".$CFG->auth_pop3host.":$CFG->auth_pop3port/pop3}INBOX";
- break;
- case "pop3notls":
- $host = "{".$CFG->auth_pop3host.":$CFG->auth_pop3port/pop3/notls}INBOX";
- break;
- case "pop3cert":
- $host = "{".$CFG->auth_pop3host.":$CFG->auth_pop3port/pop3/ssl/novalidate-cert}INBOX";
- break;
+ $hosts = split(';', $CFG->auth_pop3host); // Could be multiple hosts
+
+ foreach ($hosts as $host) { // Try each host in turn
+
+ $host = trim($host);
+
+ switch ($CFG->auth_pop3type) {
+ case "pop3":
+ $host = '{'.$host.":$CFG->auth_pop3port/pop3}INBOX";
+ break;
+ case "pop3notls":
+ $host = '{'.$host.":$CFG->auth_pop3port/pop3/notls}INBOX";
+ break;
+ case "pop3cert":
+ $host = '{'.$host.":$CFG->auth_pop3port/pop3/ssl/novalidate-cert}INBOX";
+ break;
+ }
+
+ error_reporting(0);
+ $connection = imap_open($host, $username, $password, OP_HALFOPEN);
+ error_reporting($CFG->debug);
+
+ if ($connection) {
+ imap_close($connection);
+ return true;
+ }
}
- error_reporting(0);
- $connection = imap_open($host, $username, $password, OP_HALFOPEN);
- error_reporting($CFG->debug);
-
- if ($connection) {
- imap_close($connection);
- return true;
-
- } else {
- return false;
- }
+ return false; // No matches found
}
$string['auth_ldaptitle'] = 'Use an LDAP server';
$string['auth_manualdescription'] = 'This method removes any way for users to create their own accounts. All accounts must be manually created by the admin user.';
$string['auth_manualtitle'] = 'Manual accounts only';
+$string['auth_multiplehosts'] = 'Multiple hosts can be specified (eg host1.com;host2.com;host3.com';
$string['auth_nntpdescription'] = 'This method uses an NNTP server to check whether a given username and password is valid.';
$string['auth_nntphost'] = 'The NNTP server address. Use the IP number, not DNS name.';
$string['auth_nntpport'] = 'Server port (119 is the most common)';