From c442f822fb9b961f7a92930e572edb52159391d3 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 8 Nov 2012 20:22:34 +0100 Subject: Simplify keep-alive action. Now the interval is based on session_lifetime, which means it's executed only if needed for session keeping (reset interval on every action). Temporarily remove check-recent request, it will be replaced by new global system refresh request in future. Use keep_alive setting as auto-refresh request interval (allow no-refresh mode) --- program/include/rcmail.php | 11 +++-------- program/include/rcube.php | 30 +++--------------------------- program/include/rcube_session.php | 20 +------------------- program/js/app.js | 29 +++++++++++++++-------------- 4 files changed, 22 insertions(+), 68 deletions(-) (limited to 'program') diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 3728e5d19..a755aa846 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -94,9 +94,6 @@ class rcmail extends rcube // create user object $this->set_user(new rcube_user($_SESSION['user_id'])); - // configure session (after user config merge!) - $this->session_configure(); - // set task and action properties $this->set_task(rcube_utils::get_input_value('_task', rcube_utils::INPUT_GPC)); $this->action = asciiwords(rcube_utils::get_input_value('_action', rcube_utils::INPUT_GPC)); @@ -320,10 +317,9 @@ class rcmail extends rcube if (!($this->output instanceof rcube_output_html)) $this->output = new rcube_output_html($this->task, $framed); - // set keep-alive/check-recent interval - if ($this->session && ($keep_alive = $this->session->get_keep_alive())) { - $this->output->set_env('keep_alive', $keep_alive); - } + // set keep-alive interval + $this->output->set_env('keep_alive', $this->config->get('keep_alive', 0)); + $this->output->set_env('session_lifetime', $this->config->get('session_lifetime', 0) * 60); if ($framed) { $this->comm_path .= '&_framed=1'; @@ -522,7 +518,6 @@ class rcmail extends rcube // Configure environment $this->set_user($user); $this->set_storage_prop(); - $this->session_configure(); // fix some old settings according to namespace prefix $this->fix_namespace_settings($user); diff --git a/program/include/rcube.php b/program/include/rcube.php index 0e40b3c6b..9c1a6d84a 100644 --- a/program/include/rcube.php +++ b/program/include/rcube.php @@ -434,6 +434,9 @@ class rcube $this->session->register_gc_handler(array($this, 'temp_gc')); $this->session->register_gc_handler(array($this, 'cache_gc')); + $this->session->set_secret($this->config->get('des_key') . dirname($_SERVER['SCRIPT_NAME'])); + $this->session->set_ip_check($this->config->get('ip_check')); + // start PHP session (if not in CLI mode) if ($_SERVER['REMOTE_ADDR']) { session_start(); @@ -441,33 +444,6 @@ class rcube } - /** - * Configure session object internals - */ - public function session_configure() - { - if (!$this->session) { - return; - } - - $lifetime = $this->config->get('session_lifetime', 0) * 60; - $keep_alive = $this->config->get('keep_alive'); - - // set keep-alive/check-recent interval - if ($keep_alive) { - // be sure that it's less than session lifetime - if ($lifetime) { - $keep_alive = min($keep_alive, $lifetime - 30); - } - $keep_alive = max(60, $keep_alive); - $this->session->set_keep_alive($keep_alive); - } - - $this->session->set_secret($this->config->get('des_key') . dirname($_SERVER['SCRIPT_NAME'])); - $this->session->set_ip_check($this->config->get('ip_check')); - } - - /** * Garbage collector function for temp files. * Remove temp files older than two days diff --git a/program/include/rcube_session.php b/program/include/rcube_session.php index 6192466cd..c71efa2aa 100644 --- a/program/include/rcube_session.php +++ b/program/include/rcube_session.php @@ -43,7 +43,6 @@ class rcube_session private $secret = ''; private $ip_check = false; private $logging = false; - private $keep_alive = 0; private $memcache; /** @@ -525,24 +524,6 @@ class rcube_session $this->now = $now - ($now % ($this->lifetime / 2)); } - /** - * Setter for keep_alive interval - */ - public function set_keep_alive($keep_alive) - { - $this->keep_alive = $keep_alive; - - if ($this->lifetime < $keep_alive) - $this->set_lifetime($keep_alive + 30); - } - - /** - * Getter for keep_alive interval - */ - public function get_keep_alive() - { - return $this->keep_alive; - } /** * Getter for remote IP saved with this session @@ -552,6 +533,7 @@ class rcube_session return $this->ip; } + /** * Setter for cookie encryption secret */ diff --git a/program/js/app.js b/program/js/app.js index 7764c6c86..f372c0f9e 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -952,9 +952,6 @@ function rcube_webmail() break; } - // re-set keep-alive timeout - this.start_keepalive(); - this.submit_messageform(true); break; @@ -6077,6 +6074,9 @@ function rcube_webmail() $('').attr('href', url).appendTo(document.body).get(0).click(); else target.location.href = url; + + // reset keep-alive interval + this.start_keepalive(); }; // send a http request to the server @@ -6105,6 +6105,9 @@ function rcube_webmail() success: function(data){ ref.http_response(data); }, error: function(o, status, err) { ref.http_error(o, status, err, lock, action); } }); + + // reset keep-alive interval + this.start_keepalive(); }; // send a http POST request to the server @@ -6137,6 +6140,9 @@ function rcube_webmail() success: function(data){ ref.http_response(data); }, error: function(o, status, err) { ref.http_error(o, status, err, lock, action); } }); + + // reset keep-alive interval + this.start_keepalive(); }; // aborts ajax request @@ -6264,6 +6270,9 @@ function rcube_webmail() this.triggerEvent('responseafter', {response: response}); this.triggerEvent('responseafter'+response.action, {response: response}); + + // reset keep-alive interval + this.start_keepalive(); }; // handle HTTP request errors @@ -6288,8 +6297,6 @@ function rcube_webmail() // re-send keep-alive requests after 30 seconds if (action == 'keep-alive') setTimeout(function(){ ref.keep_alive(); ref.start_keepalive(); }, 30000); - else if (action == 'check-recent') - setTimeout(function(){ ref.check_for_recent(false); ref.start_keepalive(); }, 30000); }; // post the given form to a hidden iframe @@ -6459,20 +6466,16 @@ function rcube_webmail() } }; - - // starts interval for keep-alive/check-recent signal + // starts interval for keep-alive signal this.start_keepalive = function() { - if (!this.env.keep_alive || this.env.framed) + if (!this.env.session_lifetime || this.env.framed || this.task == 'login' || this.env.action == 'print') return; if (this._int) clearInterval(this._int); - if (this.task == 'mail' && this.gui_objects.mailboxlist) - this._int = setInterval(function(){ ref.check_for_recent(false); }, this.env.keep_alive * 1000); - else if (this.task != 'login' && this.env.action != 'print') - this._int = setInterval(function(){ ref.keep_alive(); }, this.env.keep_alive * 1000); + this._int = setInterval(function(){ ref.keep_alive(); }, this.env.session_lifetime * 0.5 * 1000); }; // sends keep-alive signal @@ -6493,8 +6496,6 @@ function rcube_webmail() if (refresh) { lock = this.set_busy(true, 'checkingmail'); url._refresh = 1; - // reset check-recent interval - this.start_keepalive(); } if (this.gui_objects.messagelist) -- cgit v1.2.3 From aa83596b0bec71af8d96ee346d7a625709bf0750 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sat, 10 Nov 2012 12:13:53 +0100 Subject: Clarify keep-alive setting, move it to User Interface section, change label to "Refresh (check for new messages, etc.)", allow no-refresh mode. --- config/main.inc.php.dist | 7 +++---- program/localization/en_US/labels.inc | 2 +- program/steps/settings/func.inc | 35 ++++++++++++++++++----------------- program/steps/settings/save_prefs.inc | 28 +++++++++++++++------------- 4 files changed, 37 insertions(+), 35 deletions(-) (limited to 'program') diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist index dafee72f1..64312b6a9 100644 --- a/config/main.inc.php.dist +++ b/config/main.inc.php.dist @@ -241,7 +241,6 @@ $rcmail_config['skin_include_php'] = false; $rcmail_config['display_version'] = false; // Session lifetime in minutes -// must be greater than 'keep_alive'/60 $rcmail_config['session_lifetime'] = 10; // Session domain: .example.org @@ -500,7 +499,6 @@ $rcmail_config['recipients_separator'] = ','; $rcmail_config['max_pagesize'] = 200; // Minimal value of user's 'keep_alive' setting (in seconds) -// Must be less than 'session_lifetime' $rcmail_config['min_keep_alive'] = 60; // Enables files upload indicator. Requires APC installed and enabled apc.rfc1867 option. @@ -780,8 +778,9 @@ $rcmail_config['read_when_deleted'] = true; // Use 'Purge' to remove messages marked as deleted $rcmail_config['flag_for_deletion'] = false; -// Default interval for keep-alive/check-recent requests (in seconds) -// Must be greater than or equal to 'min_keep_alive' and less than 'session_lifetime' +// Default interval for auto-refresh requests (in seconds) +// These are requests for system state updates e.g. checking for new messages, etc. +// Setting it to 0 disables the feature. $rcmail_config['keep_alive'] = 60; // If true all folders will be checked for recent messages diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc index 2b1397f02..1999bad13 100644 --- a/program/localization/en_US/labels.inc +++ b/program/localization/en_US/labels.inc @@ -414,7 +414,7 @@ $labels['always'] = 'always'; $labels['showinlineimages'] = 'Display attached images below the message'; $labels['autosavedraft'] = 'Automatically save draft'; $labels['everynminutes'] = 'every $n minute(s)'; -$labels['keepalive'] = 'Check for new messages on'; +$labels['refreshinterval'] = 'Refresh (check for new messages, etc.)'; $labels['never'] = 'never'; $labels['immediately'] = 'immediately'; $labels['messagesdisplaying'] = 'Displaying Messages'; diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index 8bef2ff51..27e1e1346 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -237,6 +237,24 @@ function rcmail_user_prefs($current=null) ); } + if (!isset($no_override['keep_alive'])) { + $field_id = 'rcmfd_keep_alive'; + $select_keep_alive = new html_select(array('name' => '_keep_alive', 'id' => $field_id)); + + $select_keep_alive->add(rcube_label('never'), 0); + foreach (array(1, 3, 5, 10, 15, 30, 60) as $min) { + if (!$config['min_keep_alive'] || $config['min_keep_alive'] <= $min * 60) { + $label = rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))); + $select_keep_alive->add($label, $min); + } + } + + $blocks['main']['options']['keep_alive'] = array( + 'title' => html::label($field_id, Q(rcube_label('refreshinterval'))), + 'content' => $select_keep_alive->show($config['keep_alive']/60), + ); + } + // show drop-down for available skins if (!isset($no_override['skin'])) { $skins = rcmail_get_skins(); @@ -370,23 +388,6 @@ function rcmail_user_prefs($current=null) 'content' => $input_pagesize->show($size ? $size : 50), ); } - - if (!isset($no_override['keep_alive'])) { - $field_id = 'rcmfd_keep_alive'; - $select_keep_alive = new html_select(array('name' => '_keep_alive', 'id' => $field_id)); - - foreach(array(1, 3, 5, 10, 15, 30, 60) as $min) - if((!$config['min_keep_alive'] || $config['min_keep_alive'] <= $min * 60) - && (!$config['session_lifetime'] || $config['session_lifetime'] > $min)) { - $select_keep_alive->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min); - } - - $blocks['new_message']['options']['keep_alive'] = array( - 'title' => html::label($field_id, Q(rcube_label('keepalive'))), - 'content' => $select_keep_alive->show($config['keep_alive']/60), - ); - } - if (!isset($no_override['check_all_folders'])) { $field_id = 'rcmfd_check_all_folders'; $input_check_all = new html_checkbox(array('name' => '_check_all_folders', 'id' => $field_id, 'value' => 1)); diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc index db7b134c4..2f22be7c4 100644 --- a/program/steps/settings/save_prefs.inc +++ b/program/steps/settings/save_prefs.inc @@ -33,7 +33,8 @@ switch ($CURR_SECTION) 'date_format' => isset($_POST['_date_format']) ? get_input_value('_date_format', RCUBE_INPUT_POST) : $CONFIG['date_format'], 'time_format' => isset($_POST['_time_format']) ? get_input_value('_time_format', RCUBE_INPUT_POST) : ($CONFIG['time_format'] ? $CONFIG['time_format'] : 'H:i'), 'prettydate' => isset($_POST['_pretty_date']) ? TRUE : FALSE, - 'skin' => isset($_POST['_skin']) ? get_input_value('_skin', RCUBE_INPUT_POST) : $CONFIG['skin'], + 'keep_alive' => isset($_POST['_keep_alive']) ? intval($_POST['_keep_alive'])*60 : $CONFIG['keep_alive'], + 'skin' => isset($_POST['_skin']) ? get_input_value('_skin', RCUBE_INPUT_POST) : $CONFIG['skin'], ); // compose derived date/time format strings @@ -50,7 +51,6 @@ switch ($CURR_SECTION) 'preview_pane_mark_read' => isset($_POST['_preview_pane_mark_read']) ? intval($_POST['_preview_pane_mark_read']) : $CONFIG['preview_pane_mark_read'], 'autoexpand_threads' => isset($_POST['_autoexpand_threads']) ? intval($_POST['_autoexpand_threads']) : 0, 'mdn_requests' => isset($_POST['_mdn_requests']) ? intval($_POST['_mdn_requests']) : 0, - 'keep_alive' => isset($_POST['_keep_alive']) ? intval($_POST['_keep_alive'])*60 : $CONFIG['keep_alive'], 'check_all_folders' => isset($_POST['_check_all_folders']) ? TRUE : FALSE, 'mail_pagesize' => is_numeric($_POST['_mail_pagesize']) ? max(2, intval($_POST['_mail_pagesize'])) : $CONFIG['mail_pagesize'], ); @@ -157,16 +157,16 @@ switch ($CURR_SECTION) $a_user_prefs['timezone'] = (string) $a_user_prefs['timezone']; - break; - case 'mailbox': - - // force keep_alive - if (isset($a_user_prefs['keep_alive'])) { - $a_user_prefs['keep_alive'] = max(60, $CONFIG['min_keep_alive'], $a_user_prefs['keep_alive']); - if (!empty($CONFIG['session_lifetime'])) - $a_user_prefs['keep_alive'] = min($CONFIG['session_lifetime']*60, $a_user_prefs['keep_alive']); + if (isset($a_user_prefs['keep_alive']) && !empty($CONFIG['min_keep_alive'])) { + if ($a_user_prefs['keep_alive'] > $CONFIG['min_keep_alive']) { + $a_user_prefs['keep_alive'] = $CONFIG['min_keep_alive']; + } } + break; + + case 'mailbox': + // force min size if ($a_user_prefs['mail_pagesize'] < 1) $a_user_prefs['mail_pagesize'] = 10; @@ -174,7 +174,8 @@ switch ($CURR_SECTION) if (isset($CONFIG['max_pagesize']) && ($a_user_prefs['mail_pagesize'] > $CONFIG['max_pagesize'])) $a_user_prefs['mail_pagesize'] = (int) $CONFIG['max_pagesize']; - break; + break; + case 'addressbook': // force min size @@ -184,7 +185,8 @@ switch ($CURR_SECTION) if (isset($CONFIG['max_pagesize']) && ($a_user_prefs['addressbook_pagesize'] > $CONFIG['max_pagesize'])) $a_user_prefs['addressbook_pagesize'] = (int) $CONFIG['max_pagesize']; - break; + break; + case 'folders': // special handling for 'default_folders' @@ -199,7 +201,7 @@ switch ($CURR_SECTION) } } - break; + break; } // Save preferences -- cgit v1.2.3 From 77de23fa939338546a3e049459ffd29edd9058c2 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 11 Nov 2012 10:32:05 +0100 Subject: Added cross-task 'refresh' request for system state updates --- CHANGELOG | 2 + index.php | 4 +- program/include/rcmail.php | 5 ++- program/js/app.js | 75 +++++++++++++++++++++++---------- program/localization/en_US/messages.inc | 1 + program/steps/mail/check_recent.inc | 10 +++-- program/steps/mail/func.inc | 1 + 7 files changed, 70 insertions(+), 28 deletions(-) (limited to 'program') diff --git a/CHANGELOG b/CHANGELOG index 02fe0e2ce..dea6c1993 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ CHANGELOG Roundcube Webmail =========================== +- Improved keep-alive action. Now the interval is based on session_lifetime +- Added cross-task 'refresh' request for system state updates - Fix AREA links handling (#1488792) - Better client-side timezone detection using the jsTimezoneDetect library (#1488725) - Fix possible HTTP DoS on error in keep-alive requests (#1488782) diff --git a/index.php b/index.php index 0ad371a4a..05fc641b5 100644 --- a/index.php +++ b/index.php @@ -249,7 +249,6 @@ $plugin = $RCMAIL->plugins->exec_hook('ready', array('task' => $RCMAIL->task, 'a $RCMAIL->set_task($plugin['task']); $RCMAIL->action = $plugin['action']; - // handle special actions if ($RCMAIL->action == 'keep-alive') { $OUTPUT->reset(); @@ -282,7 +281,8 @@ while ($redirects < 5) { else if (($stepfile = $RCMAIL->get_action_file()) && is_file($incfile = INSTALL_PATH . 'program/steps/'.$RCMAIL->task.'/'.$stepfile) ) { - include $incfile; + // include action file only once (in case it don't exit) + include_once $incfile; $redirects++; } else { diff --git a/program/include/rcmail.php b/program/include/rcmail.php index a755aa846..04b87e48c 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -332,7 +332,7 @@ class rcmail extends rcube $this->output->set_charset(RCMAIL_CHARSET); // add some basic labels to client - $this->output->add_label('loading', 'servererror', 'requesttimedout'); + $this->output->add_label('loading', 'servererror', 'requesttimedout', 'refreshing'); return $this->output; } @@ -770,6 +770,7 @@ class rcmail extends rcube } } + /** * Registers action aliases for current task * @@ -784,6 +785,7 @@ class rcmail extends rcube } } + /** * Returns current action filename * @@ -798,6 +800,7 @@ class rcmail extends rcube return strtr($this->action, '-', '_') . '.inc'; } + /** * Fixes some user preferences according to namespace handling change. * Old Roundcube versions were using folder names with removed namespace prefix. diff --git a/program/js/app.js b/program/js/app.js index f372c0f9e..25fddf10c 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -482,7 +482,8 @@ function rcube_webmail() this.onloads[i](); } - // start keep-alive interval + // start keep-alive and refresh intervals + this.start_refresh(); this.start_keepalive(); }; @@ -880,10 +881,6 @@ function rcube_webmail() this.show_message(this.env.first_uid); break; - case 'checkmail': - this.check_for_recent(true); - break; - case 'compose': url = {}; @@ -2061,6 +2058,15 @@ function rcube_webmail() } }; + // sends request to check for recent messages + this.checkmail = function() + { + var lock = this.set_busy(true, 'checkingmail'), + params = this.check_recent_params(); + + this.http_request('check-recent', params, lock); + }; + // list messages of a specific mailbox using filter this.filter_mailbox = function(filter) { @@ -6125,7 +6131,7 @@ function rcube_webmail() // trigger plugin hook var result = this.triggerEvent('request'+action, postdata); if (result !== undefined) { - // abort if one the handlers returned false + // abort if one of the handlers returned false if (result === false) return false; else @@ -6237,6 +6243,7 @@ function rcube_webmail() } break; + case 'refresh': case 'check-recent': case 'getunread': case 'search': @@ -6469,13 +6476,25 @@ function rcube_webmail() // starts interval for keep-alive signal this.start_keepalive = function() { - if (!this.env.session_lifetime || this.env.framed || this.task == 'login' || this.env.action == 'print') + if (!this.env.session_lifetime || this.env.framed || this.env.extwin || this.task == 'login' || this.env.action == 'print') return; - if (this._int) - clearInterval(this._int); + if (this._keepalive) + clearInterval(this._keepalive); - this._int = setInterval(function(){ ref.keep_alive(); }, this.env.session_lifetime * 0.5 * 1000); + this._keepalive = setInterval(function(){ ref.keep_alive(); }, this.env.session_lifetime * 0.5 * 1000); + }; + + // starts interval for refresh signal + this.start_refresh = function() + { + if (!this.env.keep_alive || this.env.framed || this.env.extwin || this.task == 'login' || this.env.action == 'print') + return; + + if (this._refresh) + clearInterval(this._refresh); + + this._refresh = setInterval(function(){ ref.refresh(); }, this.env.keep_alive * 1000); }; // sends keep-alive signal @@ -6485,27 +6504,39 @@ function rcube_webmail() this.http_request('keep-alive'); }; - // sends request to check for recent messages - this.check_for_recent = function(refresh) + // sends refresh signal + this.refresh = function() { - if (this.busy) + if (this.busy) { + // try again after 10 seconds + setTimeout(function(){ ref.refresh(); ref.start_refresh(); }, 10000); return; + } - var lock, url = {_mbox: this.env.mailbox}; + var params = {}, lock = this.set_busy(true, 'refreshing'); - if (refresh) { - lock = this.set_busy(true, 'checkingmail'); - url._refresh = 1; - } + if (this.task == 'mail' && this.gui_objects.mailboxlist) + params = this.check_recent_params(); + + // plugins should bind to 'requestrefresh' event to add own params + this.http_request('refresh', params, lock); + }; + // returns check-recent request parameters + this.check_recent_params = function() + { + var params = {_mbox: this.env.mailbox}; + + if (this.gui_objects.mailboxlist) + params._folderlist = 1; if (this.gui_objects.messagelist) - url._list = 1; + params._list = 1; if (this.gui_objects.quotadisplay) - url._quota = 1; + params._quota = 1; if (this.env.search_request) - url._search = this.env.search_request; + params._search = this.env.search_request; - this.http_request('check-recent', url, lock); + return params; }; diff --git a/program/localization/en_US/messages.inc b/program/localization/en_US/messages.inc index cabc9998b..a858d0acf 100644 --- a/program/localization/en_US/messages.inc +++ b/program/localization/en_US/messages.inc @@ -37,6 +37,7 @@ $messages['invalidhost'] = 'Invalid server name.'; $messages['nomessagesfound'] = 'No messages found in this mailbox.'; $messages['loggedout'] = 'You have successfully terminated the session. Good bye!'; $messages['mailboxempty'] = 'Mailbox is empty.'; +$messages['refreshing'] = 'Refreshing...'; $messages['loading'] = 'Loading...'; $messages['uploading'] = 'Uploading file...'; $messages['uploadingmany'] = 'Uploading files...'; diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc index 1a1b08c60..90d17c15b 100644 --- a/program/steps/mail/check_recent.inc +++ b/program/steps/mail/check_recent.inc @@ -19,8 +19,14 @@ +-----------------------------------------------------------------------+ */ +// If there's no folder or messages list, there's nothing to update +// This can happen on 'refresh' request +if (empty($_REQUEST['_folderlist']) && empty($_REQUEST['_list'])) { + return; +} + $current = $RCMAIL->storage->get_folder(); -$check_all = !empty($_GET['_refresh']) || (bool)$RCMAIL->config->get('check_all_folders'); +$check_all = $RCMAIL->action != 'refresh' || (bool)$RCMAIL->config->get('check_all_folders'); // list of folders to check if ($check_all) { @@ -102,6 +108,4 @@ foreach ($a_mailboxes as $mbox_name) { } } -$RCMAIL->plugins->exec_hook('keep_alive', array()); - $OUTPUT->send(); diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index f128a3834..374ab7571 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -1810,6 +1810,7 @@ $OUTPUT->add_handlers(array( // register action aliases $RCMAIL->register_action_map(array( + 'refresh' => 'check_recent.inc', 'preview' => 'show.inc', 'print' => 'show.inc', 'moveto' => 'move_del.inc', -- cgit v1.2.3 From 92eb10e7732716beec8b227693d62cb9a79b9db6 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 12 Nov 2012 14:30:19 +0100 Subject: Don't throw error when plugin doesn't register 'refresh' action handler --- program/include/rcube_plugin_api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'program') diff --git a/program/include/rcube_plugin_api.php b/program/include/rcube_plugin_api.php index 107c81026..c473b0b17 100644 --- a/program/include/rcube_plugin_api.php +++ b/program/include/rcube_plugin_api.php @@ -327,7 +327,7 @@ class rcube_plugin_api if (isset($this->actions[$action])) { call_user_func($this->actions[$action]); } - else { + else if (rcube::get_instance()->action != 'refresh') { rcube::raise_error(array('code' => 524, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "No handler found for action $action"), true, true); -- cgit v1.2.3 From f226549d4f8f258deca9e165ef857252b79d2ee0 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 12 Nov 2012 14:50:49 +0100 Subject: Renamed config options: keep_alive to refresh_interval, min_keep_alive to min_refresh_interval --- CHANGELOG | 1 + config/main.inc.php.dist | 6 +++--- installer/rcube_install.php | 3 --- program/include/rcmail.php | 4 ++-- program/include/rcube_config.php | 2 ++ program/js/app.js | 5 ++--- program/steps/settings/func.inc | 16 ++++++++-------- program/steps/settings/save_prefs.inc | 8 ++++---- 8 files changed, 22 insertions(+), 23 deletions(-) (limited to 'program') diff --git a/CHANGELOG b/CHANGELOG index 6c50340cc..d0473c675 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ CHANGELOG Roundcube Webmail - Improved keep-alive action. Now the interval is based on session_lifetime (#1488507) - Added cross-task 'refresh' request for system state updates (#1488507) +- Renamed config options: keep_alive to refresh_interval, min_keep_alive to min_refresh_interval - Fix AREA links handling (#1488792) - Better client-side timezone detection using the jsTimezoneDetect library (#1488725) - Fix possible HTTP DoS on error in keep-alive requests (#1488782) diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist index 64312b6a9..1b7ae5a54 100644 --- a/config/main.inc.php.dist +++ b/config/main.inc.php.dist @@ -498,8 +498,8 @@ $rcmail_config['recipients_separator'] = ','; // don't let users set pagesize to more than this value if set $rcmail_config['max_pagesize'] = 200; -// Minimal value of user's 'keep_alive' setting (in seconds) -$rcmail_config['min_keep_alive'] = 60; +// Minimal value of user's 'refresh_interval' setting (in seconds) +$rcmail_config['min_refresh_interval'] = 60; // Enables files upload indicator. Requires APC installed and enabled apc.rfc1867 option. // By default refresh time is set to 1 second. You can set this value to true @@ -781,7 +781,7 @@ $rcmail_config['flag_for_deletion'] = false; // Default interval for auto-refresh requests (in seconds) // These are requests for system state updates e.g. checking for new messages, etc. // Setting it to 0 disables the feature. -$rcmail_config['keep_alive'] = 60; +$rcmail_config['refresh_interval'] = 60; // If true all folders will be checked for recent messages $rcmail_config['check_all_folders'] = false; diff --git a/installer/rcube_install.php b/installer/rcube_install.php index d1dce9d0e..06c57c0ac 100644 --- a/installer/rcube_install.php +++ b/installer/rcube_install.php @@ -342,9 +342,6 @@ class rcube_install } } - if ($current['keep_alive'] && $current['session_lifetime'] < $current['keep_alive']) - $current['session_lifetime'] = max(10, ceil($current['keep_alive'] / 60) * 2); - $this->config = array_merge($this->config, $current); foreach ((array)$current['ldap_public'] as $key => $values) { diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 04b87e48c..99a68e81d 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -317,8 +317,8 @@ class rcmail extends rcube if (!($this->output instanceof rcube_output_html)) $this->output = new rcube_output_html($this->task, $framed); - // set keep-alive interval - $this->output->set_env('keep_alive', $this->config->get('keep_alive', 0)); + // set refresh interval + $this->output->set_env('refresh_interval', $this->config->get('refresh_interval', 0)); $this->output->set_env('session_lifetime', $this->config->get('session_lifetime', 0) * 60); if ($framed) { diff --git a/program/include/rcube_config.php b/program/include/rcube_config.php index 1f165ba4a..bbc3e9c6e 100644 --- a/program/include/rcube_config.php +++ b/program/include/rcube_config.php @@ -43,6 +43,8 @@ class rcube_config 'mail_pagesize' => 'pagesize', 'addressbook_pagesize' => 'pagesize', 'reply_mode' => 'top_posting', + 'refresh_interval' => 'keep_alive', + 'min_refresh_interval' => 'min_keep_alive', ); diff --git a/program/js/app.js b/program/js/app.js index 25fddf10c..fb9c299ec 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -44,7 +44,6 @@ function rcube_webmail() this.identifier_expr = new RegExp('[^0-9a-z\-_]', 'gi'); // default environment vars - this.env.keep_alive = 60; // seconds this.env.request_timeout = 180; // seconds this.env.draft_autosave = 0; // seconds this.env.comm_path = './'; @@ -6488,13 +6487,13 @@ function rcube_webmail() // starts interval for refresh signal this.start_refresh = function() { - if (!this.env.keep_alive || this.env.framed || this.env.extwin || this.task == 'login' || this.env.action == 'print') + if (!this.env.refresh_interval || this.env.framed || this.env.extwin || this.task == 'login' || this.env.action == 'print') return; if (this._refresh) clearInterval(this._refresh); - this._refresh = setInterval(function(){ ref.refresh(); }, this.env.keep_alive * 1000); + this._refresh = setInterval(function(){ ref.refresh(); }, this.env.refresh_interval * 1000); }; // sends keep-alive signal diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index 27e1e1346..876e02761 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -237,21 +237,21 @@ function rcmail_user_prefs($current=null) ); } - if (!isset($no_override['keep_alive'])) { - $field_id = 'rcmfd_keep_alive'; - $select_keep_alive = new html_select(array('name' => '_keep_alive', 'id' => $field_id)); + if (!isset($no_override['refresh_interval'])) { + $field_id = 'rcmfd_refresh_interval'; + $select_refresh_interval = new html_select(array('name' => '_refresh_interval', 'id' => $field_id)); - $select_keep_alive->add(rcube_label('never'), 0); + $select_refresh_interval->add(rcube_label('never'), 0); foreach (array(1, 3, 5, 10, 15, 30, 60) as $min) { - if (!$config['min_keep_alive'] || $config['min_keep_alive'] <= $min * 60) { + if (!$config['min_refresh_interval'] || $config['min_refresh_interval'] <= $min * 60) { $label = rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))); - $select_keep_alive->add($label, $min); + $select_refresh_interval->add($label, $min); } } - $blocks['main']['options']['keep_alive'] = array( + $blocks['main']['options']['refresh_interval'] = array( 'title' => html::label($field_id, Q(rcube_label('refreshinterval'))), - 'content' => $select_keep_alive->show($config['keep_alive']/60), + 'content' => $select_refresh_interval->show($config['refresh_interval']/60), ); } diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc index 2f22be7c4..5daab0d24 100644 --- a/program/steps/settings/save_prefs.inc +++ b/program/steps/settings/save_prefs.inc @@ -33,7 +33,7 @@ switch ($CURR_SECTION) 'date_format' => isset($_POST['_date_format']) ? get_input_value('_date_format', RCUBE_INPUT_POST) : $CONFIG['date_format'], 'time_format' => isset($_POST['_time_format']) ? get_input_value('_time_format', RCUBE_INPUT_POST) : ($CONFIG['time_format'] ? $CONFIG['time_format'] : 'H:i'), 'prettydate' => isset($_POST['_pretty_date']) ? TRUE : FALSE, - 'keep_alive' => isset($_POST['_keep_alive']) ? intval($_POST['_keep_alive'])*60 : $CONFIG['keep_alive'], + 'refresh_interval' => isset($_POST['_refresh_interval']) ? intval($_POST['_refresh_interval'])*60 : $CONFIG['refresh_interval'], 'skin' => isset($_POST['_skin']) ? get_input_value('_skin', RCUBE_INPUT_POST) : $CONFIG['skin'], ); @@ -157,9 +157,9 @@ switch ($CURR_SECTION) $a_user_prefs['timezone'] = (string) $a_user_prefs['timezone']; - if (isset($a_user_prefs['keep_alive']) && !empty($CONFIG['min_keep_alive'])) { - if ($a_user_prefs['keep_alive'] > $CONFIG['min_keep_alive']) { - $a_user_prefs['keep_alive'] = $CONFIG['min_keep_alive']; + if (isset($a_user_prefs['refresh_interval']) && !empty($CONFIG['min_refresh_interval'])) { + if ($a_user_prefs['refresh_interval'] > $CONFIG['min_refresh_interval']) { + $a_user_prefs['refresh_interval'] = $CONFIG['min_refresh_interval']; } } -- cgit v1.2.3