summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
Diffstat (limited to 'program')
-rw-r--r--program/include/main.inc96
-rw-r--r--program/include/session.inc2
-rw-r--r--program/js/app.js41
-rw-r--r--program/steps/error.inc4
-rw-r--r--program/steps/mail/func.inc6
-rw-r--r--program/steps/settings/manage_folders.inc4
6 files changed, 97 insertions, 56 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index ae7d50b9f..0d3cf82bb 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -39,40 +39,12 @@ function rcmail_startup($task='mail')
// check client
$BROWSER = rcube_browser();
- // load config file
- include_once('config/main.inc.php');
- $CONFIG = is_array($rcmail_config) ? $rcmail_config : array();
-
- // load host-specific configuration
- rcmail_load_host_config($CONFIG);
-
- $CONFIG['skin_path'] = $CONFIG['skin_path'] ? unslashify($CONFIG['skin_path']) : 'skins/default';
-
- // load db conf
- include_once('config/db.inc.php');
- $CONFIG = array_merge($CONFIG, $rcmail_config);
-
- if (empty($CONFIG['log_dir']))
- $CONFIG['log_dir'] = $INSTALL_PATH.'logs';
- else
- $CONFIG['log_dir'] = unslashify($CONFIG['log_dir']);
-
- // set PHP error logging according to config
- if ($CONFIG['debug_level'] & 1)
- {
- ini_set('log_errors', 1);
- ini_set('error_log', $CONFIG['log_dir'].'/errors');
- }
- if ($CONFIG['debug_level'] & 4)
- ini_set('display_errors', 1);
- else
- ini_set('display_errors', 0);
-
+ // load configuration
+ $CONFIG = rcmail_load_config();
// set session garbage collecting time according to session_lifetime
if (!empty($CONFIG['session_lifetime']))
- ini_set('session.gc_maxlifetime', ($CONFIG['session_lifetime']+2)*60);
-
+ ini_set('session.gc_maxlifetime', ($CONFIG['session_lifetime']) * 120);
// prepare DB connection
require_once('include/rcube_'.(empty($CONFIG['db_backend']) ? 'db' : $CONFIG['db_backend']).'.inc');
@@ -80,7 +52,7 @@ function rcmail_startup($task='mail')
$DB = new rcube_db($CONFIG['db_dsnw'], $CONFIG['db_dsnr'], $CONFIG['db_persistent']);
$DB->sqlite_initials = $INSTALL_PATH.'SQL/sqlite.initial.sql';
$DB->db_connect('w');
-
+
// we can use the database for storing session data
if (!$DB->is_error())
include_once('include/session.inc');
@@ -129,6 +101,44 @@ function rcmail_startup($task='mail')
}
+// load roundcube configuration into global var
+function rcmail_load_config()
+ {
+ global $INSTALL_PATH;
+
+ // load config file
+ include_once('config/main.inc.php');
+ $conf = is_array($rcmail_config) ? $rcmail_config : array();
+
+ // load host-specific configuration
+ rcmail_load_host_config($conf);
+
+ $conf['skin_path'] = $conf['skin_path'] ? unslashify($conf['skin_path']) : 'skins/default';
+
+ // load db conf
+ include_once('config/db.inc.php');
+ $conf = array_merge($conf, $rcmail_config);
+
+ if (empty($conf['log_dir']))
+ $conf['log_dir'] = $INSTALL_PATH.'logs';
+ else
+ $conf['log_dir'] = unslashify($conf['log_dir']);
+
+ // set PHP error logging according to config
+ if ($conf['debug_level'] & 1)
+ {
+ ini_set('log_errors', 1);
+ ini_set('error_log', $conf['log_dir'].'/errors');
+ }
+ if ($conf['debug_level'] & 4)
+ ini_set('display_errors', 1);
+ else
+ ini_set('display_errors', 0);
+
+ return $conf;
+ }
+
+
// load a host-specific config file if configured
function rcmail_load_host_config(&$config)
{
@@ -169,15 +179,24 @@ function rcmail_auth_hash($sess_id, $ts)
function rcmail_authenticate_session()
{
$now = mktime();
- $valid = ($_COOKIE['sessauth'] == rcmail_auth_hash(session_id(), $_SESSION['auth_time']));
+ $valid = ($_COOKIE['sessauth'] == rcmail_auth_hash(session_id(), $_SESSION['auth_time']) ||
+ $_COOKIE['sessauth'] == rcmail_auth_hash(session_id(), $_SESSION['last_auth']));
// renew auth cookie every 5 minutes (only for GET requests)
if (!$valid || ($_SERVER['REQUEST_METHOD']!='POST' && $now-$_SESSION['auth_time'] > 300))
{
+ $_SESSION['last_auth'] = $_SESSION['auth_time'];
$_SESSION['auth_time'] = $now;
setcookie('sessauth', rcmail_auth_hash(session_id(), $now));
}
-
+
+ if (!$valid)
+ write_log('timeouts',
+ "REQUEST: " . var_export($_REQUEST, true) .
+ "\nEXPECTED: " . rcmail_auth_hash(session_id(), $_SESSION['auth_time']) .
+ "\nOR LAST: " . rcmail_auth_hash(session_id(), $_SESSION['last_auth']) .
+ "\nSESSION: " . var_export($_SESSION, true));
+
return $valid;
}
@@ -353,11 +372,15 @@ function load_gui()
$javascript .= "$JS_OBJECT_NAME.set_env('$js_config_var', '" . $CONFIG[$js_config_var] . "');\n";
}
}
+
+ // don't wait for page onload. Call init at the bottom of the page (delayed)
+ $javascript_foot = "if (window.call_init)\n call_init('$JS_OBJECT_NAME');";
if (!empty($GLOBALS['_framed']))
$javascript .= "$JS_OBJECT_NAME.set_env('framed', true);\n";
- $OUTPUT->add_script($javascript);
+ $OUTPUT->add_script($javascript, 'head');
+ $OUTPUT->add_script($javascript_foot, 'foot');
$OUTPUT->include_script('common.js');
$OUTPUT->include_script('app.js');
$OUTPUT->scripts_path = 'program/js/';
@@ -1802,6 +1825,9 @@ function console($msg)
function write_log($name, $line)
{
global $CONFIG;
+
+ if (!is_string($line))
+ $line = var_export($line, true);
$log_entry = sprintf("[%s]: %s\n",
date("d-M-Y H:i:s O", mktime()),
diff --git a/program/include/session.inc b/program/include/session.inc
index 00ca29915..dc7714777 100644
--- a/program/include/session.inc
+++ b/program/include/session.inc
@@ -45,7 +45,7 @@ function sess_read($key)
if ($sql_arr = $DB->fetch_assoc($sql_result))
{
- $SESS_CHANGED = mktime(); //$sql_arr['changed'];
+ $SESS_CHANGED = $sql_arr['changed'];
if (strlen($sql_arr['vars']))
return $sql_arr['vars'];
diff --git a/program/js/app.js b/program/js/app.js
index 1b7312f89..8d2f1ed5b 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -49,9 +49,9 @@ function rcube_webmail()
'application/x-shockwave-flash');
// default environment vars
- this.env.keep_alive = 60; // seconds
+ this.env.keep_alive = 50; // seconds
this.env.request_timeout = 180; // seconds
- this.env.draft_autosave = 300; // seconds
+ this.env.draft_autosave = 0; // seconds
// set environment variable
@@ -148,7 +148,10 @@ function rcube_webmail()
{
this.enable_command('add-attachment', 'send-attachment', 'remove-attachment', 'send', true);
if (this.env.spellcheck)
- this.enable_command('spellcheck', true);
+ {
+ this.env.spellcheck.spelling_state_observer = function(s){ rcube_webmail_client.set_spellcheck_state(s); };
+ this.set_spellcheck_state('ready');
+ }
if (this.env.drafts_mailbox)
this.enable_command('savedraft', true);
}
@@ -930,8 +933,11 @@ function rcube_webmail()
break;
case 'spellcheck':
- if (this.env.spellcheck && this.env.spellcheck.spellCheck)
+ if (this.env.spellcheck && this.env.spellcheck.spellCheck && this.spellcheck_ready)
+ {
this.env.spellcheck.spellCheck(this.env.spellcheck.check_link);
+ this.set_spellcheck_state('checking');
+ }
break;
case 'savedraft':
@@ -942,7 +948,8 @@ function rcube_webmail()
break;
// if saving Drafts is disabled in main.inc.php
- if (!this.env.drafts_mailbox)
+ // or if compose form did not change
+ if (!this.env.drafts_mailbox || this.cmp_hash == this.compose_field_hash())
break;
this.set_busy(true, 'savingmessage');
@@ -2025,6 +2032,13 @@ function rcube_webmail()
};
+ this.set_spellcheck_state = function(s)
+ {
+ this.spellcheck_ready = (s=='check_spelling' || s=='ready');
+ this.enable_command('spellcheck', this.spellcheck_ready);
+ };
+
+
this.auto_save_start = function()
{
if (this.env.draft_autosave)
@@ -2783,7 +2797,7 @@ function rcube_webmail()
this.reset_folder_rename = function()
{
var cell = this.name_input ? this.name_input.parentNode : null;
- if (cell && this.edit_folder)
+ if (cell && this.edit_folder && this.env.subscriptionrows[this.edit_folder])
cell.innerHTML = this.env.subscriptionrows[this.edit_folder][1];
this.edit_folder = null;
@@ -3568,7 +3582,7 @@ function rcube_webmail()
case 'expunge':
this.enable_command('select-all', 'select-none', 'expunge', this.env.messagecount ? true : false);
- break;
+ break;
}
request_obj.reset();
@@ -3886,6 +3900,12 @@ function rcube_http_request()
} // end class rcube_http_request
+// helper function to call the init method with a delay
+function call_init(o)
+ {
+ if (window[o] && window[o].init)
+ setTimeout(o+'.init()', 200);
+ }
function console(str)
{
@@ -3893,10 +3913,3 @@ function console(str)
document.debugform.console.value += str+'\n--------------------------------------\n';
}
-
-// set onload handler
-window.onload = function(e)
- {
- if (window.rcube_webmail_client)
- rcube_webmail_client.init();
- };
diff --git a/program/steps/error.inc b/program/steps/error.inc
index 2d87a9da4..f616ba1bf 100644
--- a/program/steps/error.inc
+++ b/program/steps/error.inc
@@ -69,11 +69,11 @@ else
{
$__error_title = "SERVICE CURRENTLY NOT AVAILABLE!";
$__error_text = "Please contact your server-administrator.";
-
+
if (($CONFIG['debug_level'] & 4) && $ERROR_MESSAGE)
$__error_text = $ERROR_MESSAGE;
else
- $__error_text = 'Error No. '.dechex($ERROR_CODE).')';
+ $__error_text = 'Error No. ['.dechex($ERROR_CODE).']';
}
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 0cd6652ad..827f13100 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -1245,9 +1245,9 @@ function rcmail_first_text_part($message_struct)
{
global $IMAP;
- if (!is_array($message_struct['parts']))
- return FALSE;
-
+ if (empty($message_struct['parts']))
+ return $message_struct['UID'] ? $IMAP->get_body($message_struct['UID']) : false;
+
// check all message parts
foreach ($message_struct['parts'] as $pid => $part)
{
diff --git a/program/steps/settings/manage_folders.inc b/program/steps/settings/manage_folders.inc
index af0c829ef..e938908cf 100644
--- a/program/steps/settings/manage_folders.inc
+++ b/program/steps/settings/manage_folders.inc
@@ -73,10 +73,12 @@ else if ($_action=='rename-folder')
if ($rename && $REMOTE_REQUEST)
{
- $commands = sprintf("this.replace_folder_row('%s','%s','%s');",
+ $commands = sprintf("this.replace_folder_row('%s','%s','%s');\n",
rep_specialchars_output(get_input_value('_folder_oldname', RCUBE_INPUT_GET), 'js'),
rep_specialchars_output($rename, 'js'),
rep_specialchars_output(rcube_charset_convert($rename, 'UTF-7'), 'js'));
+
+ $commands .= "this.reset_folder_rename();\n";
rcube_remote_response($commands);
}