| | |
| | | * |
| | | * @see rcmail::text_exists() |
| | | */ |
| | | function rcube_label_exists($name, $domain=null) |
| | | function rcube_label_exists($name, $domain=null, &$ref_domain = null) |
| | | { |
| | | return rcmail::get_instance()->text_exists($name, $domain); |
| | | return rcmail::get_instance()->text_exists($name, $domain, $ref_domain); |
| | | } |
| | | |
| | | |
| | |
| | | // get target timestamp |
| | | $ts = get_offset_time($rcmail->config->get('message_cache_lifetime', '30d'), -1); |
| | | |
| | | $db->query("DELETE FROM ".get_table_name('messages')." |
| | | WHERE created < " . $db->fromunixtime($ts)); |
| | | $db->query("DELETE FROM ".get_table_name('cache_messages') |
| | | ." WHERE changed < " . $db->fromunixtime($ts)); |
| | | |
| | | $db->query("DELETE FROM ".get_table_name('cache')." |
| | | WHERE created < " . $db->fromunixtime($ts)); |
| | | $db->query("DELETE FROM ".get_table_name('cache_index') |
| | | ." WHERE changed < " . $db->fromunixtime($ts)); |
| | | |
| | | $db->query("DELETE FROM ".get_table_name('cache_thread') |
| | | ." WHERE changed < " . $db->fromunixtime($ts)); |
| | | |
| | | $db->query("DELETE FROM ".get_table_name('cache') |
| | | ." WHERE created < " . $db->fromunixtime($ts)); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | function format_date($date, $format=NULL) |
| | | { |
| | | global $CONFIG; |
| | | global $RCMAIL, $CONFIG; |
| | | |
| | | $ts = NULL; |
| | | |
| | |
| | | return ''; |
| | | |
| | | // get user's timezone |
| | | if ($CONFIG['timezone'] === 'auto') |
| | | $tz = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : date('Z')/3600; |
| | | else { |
| | | $tz = $CONFIG['timezone']; |
| | | if ($CONFIG['dst_active']) |
| | | $tz++; |
| | | } |
| | | $tz = $RCMAIL->config->get_timezone(); |
| | | |
| | | // convert time to user's timezone |
| | | $timestamp = $ts - date('Z', $ts) + ($tz * 3600); |
| | |
| | | // define date format depending on current time |
| | | if (!$format) { |
| | | if ($CONFIG['prettydate'] && $timestamp > $today_limit && $timestamp < $now) { |
| | | $format = $CONFIG['date_today'] ? $CONFIG['date_today'] : 'H:i'; |
| | | $format = $RCMAIL->config->get('date_today', $RCMAIL->config->get('time_format', 'H:i')); |
| | | $today = true; |
| | | } |
| | | else if ($CONFIG['prettydate'] && $timestamp > $week_limit && $timestamp < $now) |
| | | $format = $CONFIG['date_short'] ? $CONFIG['date_short'] : 'D H:i'; |
| | | $format = $RCMAIL->config->get('date_short', 'D H:i'); |
| | | else |
| | | $format = $CONFIG['date_long'] ? $CONFIG['date_long'] : 'd.m.Y H:i'; |
| | | $format = $RCMAIL->config->get('date_long', 'Y-m-d H:i'); |
| | | } |
| | | |
| | | // strftime() format |
| | |
| | | $out = ''; |
| | | |
| | | foreach ($arrFolders as $key => $folder) { |
| | | if (!empty($exceptions) && in_array($folder['id'], $exceptions)) { |
| | | if (empty($exceptions) || !in_array($folder['id'], $exceptions)) { |
| | | if (!$realnames && ($folder_class = rcmail_folder_classname($folder['id']))) |
| | | $foldername = rcube_label($folder_class); |
| | | else { |
| | | $foldername = $folder['name']; |
| | | |
| | | // shorten the folder name to a given length |
| | | if ($maxlength && $maxlength>1) |
| | | $foldername = abbreviate_string($foldername, $maxlength); |
| | | } |
| | | |
| | | $select->add(str_repeat(' ', $nestLevel*4) . $foldername, $folder['id']); |
| | | } |
| | | else if ($nestLevel) |
| | | continue; |
| | | } |
| | | |
| | | if (!$realnames && ($folder_class = rcmail_folder_classname($folder['id']))) |
| | | $foldername = rcube_label($folder_class); |
| | | else { |
| | | $foldername = $folder['name']; |
| | | |
| | | // shorten the folder name to a given length |
| | | if ($maxlength && $maxlength>1) |
| | | $foldername = abbreviate_string($foldername, $maxlength); |
| | | } |
| | | |
| | | $select->add(str_repeat(' ', $nestLevel*4) . $foldername, $folder['id']); |
| | | |
| | | if (!empty($folder['folders'])) |
| | | $out .= rcmail_render_folder_tree_select($folder['folders'], $mbox_name, $maxlength, |
| | |
| | | $RCMAIL->output->show_message('errorreadonly', 'error'); |
| | | } |
| | | else if ($err_code && ($err_str = $RCMAIL->imap->get_error_str())) { |
| | | $RCMAIL->output->show_message('servererrormsg', 'error', array('msg' => $err_str)); |
| | | // try to detect access rights problem and display appropriate message |
| | | if (stripos($err_str, 'Permission denied') !== false) |
| | | $RCMAIL->output->show_message('errornoperm', 'error'); |
| | | else |
| | | $RCMAIL->output->show_message('servererrormsg', 'error', array('msg' => $err_str)); |
| | | } |
| | | else if ($fallback) { |
| | | $RCMAIL->output->show_message($fallback, 'error', $fallback_args); |
| | |
| | | $hook = $RCMAIL->plugins->exec_hook('html_editor', array('mode' => $mode)); |
| | | |
| | | if ($hook['abort']) |
| | | return; |
| | | return; |
| | | |
| | | $lang = strtolower($_SESSION['language']); |
| | | |
| | |
| | | |
| | | $RCMAIL->output->include_script('tiny_mce/tiny_mce.js'); |
| | | $RCMAIL->output->include_script('editor.js'); |
| | | $RCMAIL->output->add_script(sprintf("rcmail_editor_init('\$__skin_path', '%s', %d, '%s');", |
| | | JQ($lang), intval($CONFIG['enable_spellcheck']), $mode), |
| | | 'foot'); |
| | | $RCMAIL->output->add_script(sprintf("rcmail_editor_init(%s)", |
| | | json_encode(array( |
| | | 'mode' => $mode, |
| | | 'skin_path' => '$__skin_path', |
| | | 'lang' => $lang, |
| | | 'spellcheck' => intval($CONFIG['enable_spellcheck']), |
| | | 'spelldict' => intval($CONFIG['spellcheck_dictionary']), |
| | | ))), 'foot'); |
| | | } |
| | | |
| | | |
| | |
| | | * @param string $from Sender address string |
| | | * @param array $mailto Array of recipient address strings |
| | | * @param array $smtp_error SMTP error array (reference) |
| | | * @param string $body_file Location of file with saved message body (reference) |
| | | * @param string $body_file Location of file with saved message body (reference), |
| | | * used when delay_file_io is enabled |
| | | * @param array $smtp_opts SMTP options (e.g. DSN request) |
| | | * |
| | | * @return boolean Send status. |
| | | */ |
| | | function rcmail_deliver_message(&$message, $from, $mailto, &$smtp_error, &$body_file, $smtp_opts=null) |
| | | function rcmail_deliver_message(&$message, $from, $mailto, &$smtp_error, &$body_file=null, $smtp_opts=null) |
| | | { |
| | | global $CONFIG, $RCMAIL; |
| | | |
| | |
| | | $temp_dir = $RCMAIL->config->get('temp_dir'); |
| | | $body_file = tempnam($temp_dir, 'rcmMsg'); |
| | | if (PEAR::isError($mime_result = $message->saveMessageBody($body_file))) { |
| | | raise_error(array('code' => 600, 'type' => 'php', |
| | | raise_error(array('code' => 650, 'type' => 'php', |
| | | 'file' => __FILE__, 'line' => __LINE__, |
| | | 'message' => "Could not create message: ".$mime_result->getMessage()), |
| | | TRUE, FALSE); |
| | |
| | | $msg_body = $message->get(); |
| | | |
| | | if (PEAR::isError($msg_body)) |
| | | raise_error(array('code' => 600, 'type' => 'php', |
| | | raise_error(array('code' => 650, 'type' => 'php', |
| | | 'file' => __FILE__, 'line' => __LINE__, |
| | | 'message' => "Could not create message: ".$msg_body->getMessage()), |
| | | TRUE, FALSE); |
| | |
| | | // Returns RFC2822 formatted current date in user's timezone |
| | | function rcmail_user_date() |
| | | { |
| | | global $CONFIG; |
| | | global $RCMAIL, $CONFIG; |
| | | |
| | | // get user's timezone |
| | | if ($CONFIG['timezone'] === 'auto') { |
| | | $tz = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : date('Z')/3600; |
| | | } |
| | | else { |
| | | $tz = $CONFIG['timezone']; |
| | | if ($CONFIG['dst_active']) |
| | | $tz++; |
| | | } |
| | | $tz = $RCMAIL->config->get_timezone(); |
| | | |
| | | $date = time() + $tz * 60 * 60; |
| | | $date = gmdate('r', $date); |
| | |
| | | if (!$RCMAIL->config->get('log_logins') || !$RCMAIL->user) |
| | | return; |
| | | |
| | | write_log('userlogins', sprintf('Successful login for %s (ID: %d) from %s', |
| | | $RCMAIL->user->get_username(), $RCMAIL->user->ID, rcmail_remote_ip())); |
| | | write_log('userlogins', sprintf('Successful login for %s (ID: %d) from %s in session %s', |
| | | $RCMAIL->user->get_username(), $RCMAIL->user->ID, rcmail_remote_ip(), session_id())); |
| | | } |
| | | |
| | | |
| | |
| | | $RCMAIL->output->send(); |
| | | } |
| | | |
| | | function rcube_upload_progress_init() |
| | | function rcube_upload_init() |
| | | { |
| | | global $RCMAIL; |
| | | |
| | |
| | | $RCMAIL->output->set_env('upload_progress_time', (int) $seconds); |
| | | } |
| | | } |
| | | |
| | | // find max filesize value |
| | | $max_filesize = parse_bytes(ini_get('upload_max_filesize')); |
| | | $max_postsize = parse_bytes(ini_get('post_max_size')); |
| | | if ($max_postsize && $max_postsize < $max_filesize) |
| | | $max_filesize = $max_postsize; |
| | | |
| | | $RCMAIL->output->set_env('max_filesize', $max_filesize); |
| | | $max_filesize = show_bytes($max_filesize); |
| | | $RCMAIL->output->set_env('filesizeerror', rcube_label(array( |
| | | 'name' => 'filesizeerror', 'vars' => array('size' => $max_filesize)))); |
| | | |
| | | return $max_filesize; |
| | | } |
| | | |
| | | /** |
| | |
| | | $RCMAIL->output->set_env('autocomplete_max', (int)$RCMAIL->config->get('autocomplete_max', 15)); |
| | | $RCMAIL->output->set_env('autocomplete_min_length', $RCMAIL->config->get('autocomplete_min_length')); |
| | | $RCMAIL->output->add_label('autocompletechars'); |
| | | } |
| | | |
| | | function rcmail_localize_folderpath($path) |
| | | { |
| | | global $RCMAIL; |
| | | |
| | | $protect_folders = $RCMAIL->config->get('protect_default_folders'); |
| | | $default_folders = (array) $RCMAIL->config->get('default_imap_folders'); |
| | | $delimiter = $RCMAIL->imap->get_hierarchy_delimiter(); |
| | | $path = explode($delimiter, $path); |
| | | $result = array(); |
| | | |
| | | foreach ($path as $idx => $dir) { |
| | | $directory = implode($delimiter, array_slice($path, 0, $idx+1)); |
| | | if ($protect_folders && in_array($directory, $default_folders)) { |
| | | unset($result); |
| | | $result[] = rcmail_localize_foldername($directory); |
| | | } |
| | | else { |
| | | $result[] = rcube_charset_convert($dir, 'UTF7-IMAP'); |
| | | } |
| | | } |
| | | |
| | | return implode($delimiter, $result); |
| | | } |