From f07d238b1b4d75b34639be873dcc1b1627404ae7 Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Fri, 28 May 2010 09:54:32 -0400 Subject: [PATCH] - Add 'imap_timeout' option (#1486760) --- CHANGELOG | 1 + program/include/rcmail.php | 9 +++++---- config/main.inc.php.dist | 6 ++++++ program/include/rcube_imap_generic.php | 11 +++++++++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7ee8fbd..73e7483 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG RoundCube Webmail =========================== +- Add 'imap_timeout' option (#1486760) - Fix forwarding of messages with winmail attachments - Fix handling of uuencoded attachments in message body (#1485839) - Added list_mailboxes hook in rcube_imap::list_unsubscribed() (#1486668) diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist index 15b6f9f..b1da159 100644 --- a/config/main.inc.php.dist +++ b/config/main.inc.php.dist @@ -80,6 +80,9 @@ // after login. Set to True if you've got this case. $rcmail_config['imap_force_caps'] = false; +// IMAP connection timeout, in seconds. Default: 0 (no limit) +$rcmail_config['imap_timeout'] = 0; + // ---------------------------------- // SMTP // ---------------------------------- @@ -111,6 +114,9 @@ // localhost if that isn't defined. $rcmail_config['smtp_helo_host'] = ''; +// SMTP connection timeout, in seconds. Default: 0 (no limit) +$rcmail_config['smtp_timeout'] = 0; + // ---------------------------------- // SYSTEM // ---------------------------------- diff --git a/program/include/rcmail.php b/program/include/rcmail.php index ddbe5c9..652dbd0 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -428,10 +428,11 @@ // can save time detecting them using NAMESPACE and LIST $options = array( 'auth_method' => $this->config->get('imap_auth_type', 'check'), - 'delimiter' => isset($_SESSION['imap_delimiter']) ? $_SESSION['imap_delimiter'] : $this->config->get('imap_delimiter'), - 'rootdir' => isset($_SESSION['imap_root']) ? $_SESSION['imap_root'] : $this->config->get('imap_root'), - 'debug_mode' => (bool) $this->config->get('imap_debug', 0), - 'force_caps' => (bool) $this->config->get('imap_force_caps'), + 'delimiter' => isset($_SESSION['imap_delimiter']) ? $_SESSION['imap_delimiter'] : $this->config->get('imap_delimiter'), + 'rootdir' => isset($_SESSION['imap_root']) ? $_SESSION['imap_root'] : $this->config->get('imap_root'), + 'debug_mode' => (bool) $this->config->get('imap_debug', 0), + 'force_caps' => (bool) $this->config->get('imap_force_caps'), + 'timeout' => (int) $this->config->get('imap_timeout', 0), ); $this->imap->set_options($options); diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php index d159b90..7796e0a 100644 --- a/program/include/rcube_imap_generic.php +++ b/program/include/rcube_imap_generic.php @@ -611,14 +611,21 @@ $host = $this->prefs['ssl_mode'] . '://' . $host; } - $this->fp = @fsockopen($host, $this->prefs['port'], $errno, $errstr, 10); + // Connect + if ($this->prefs['timeout'] > 0) + $this->fp = @fsockopen($host, $this->prefs['port'], $errno, $errstr, $this->prefs['timeout']); + else + $this->fp = @fsockopen($host, $this->prefs['port'], $errno, $errstr); + if (!$this->fp) { $this->error = sprintf("Could not connect to %s:%d: %s", $host, $this->prefs['port'], $errstr); $this->errornum = -2; return false; } - stream_set_timeout($this->fp, 10); + if ($this->prefs['timeout'] > 0) + stream_set_timeout($this->fp, $this->prefs['timeout']); + $line = trim(fgets($this->fp, 8192)); if ($this->prefs['debug_mode'] && $line) { -- Gitblit v1.9.1