| | |
| | | * Garbage collector for cache entries. |
| | | * Remove all expired message cache records |
| | | */ |
| | | function rcmail_message_cache_gc() |
| | | function rcmail_cache_gc() |
| | | { |
| | | global $DB, $CONFIG; |
| | | |
| | | // no cache lifetime configured |
| | | if (empty($CONFIG['message_cache_lifetime'])) |
| | | return; |
| | | $rcmail = rcmail::get_instance(); |
| | | $db = $rcmail->get_dbh(); |
| | | |
| | | // get target timestamp |
| | | $ts = get_offset_time($CONFIG['message_cache_lifetime'], -1); |
| | | $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('messages')." |
| | | WHERE created < " . $db->fromunixtime($ts)); |
| | | |
| | | $db->query("DELETE FROM ".get_table_name('cache')." |
| | | WHERE created < " . $db->fromunixtime($ts)); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | $xml_rep_table['"'] = '"'; |
| | | $js_rep_table['"'] = '\\"'; |
| | | $js_rep_table["'"] = "\\'"; |
| | | $js_rep_table["\\"] = "\\\\"; |
| | | } |
| | | |
| | | // encode for XML |
| | |
| | | if ($charset!='UTF-8') |
| | | $str = rcube_charset_convert($str, RCMAIL_CHARSET,$charset); |
| | | |
| | | return preg_replace(array("/\r?\n/", "/\r/", '/<\\//'), array('\n', '\n', '<\\/'), addslashes(strtr($str, $js_rep_table))); |
| | | return preg_replace(array("/\r?\n/", "/\r/", '/<\\//'), array('\n', '\n', '<\\/'), strtr($str, $js_rep_table)); |
| | | } |
| | | |
| | | // no encoding given -> return original string |
| | |
| | | function parse_attrib_string($str) |
| | | { |
| | | $attrib = array(); |
| | | preg_match_all('/\s*([-_a-z]+)=(["\'])??(?(2)([^\2]+)\2|(\S+?))/Ui', stripslashes($str), $regs, PREG_SET_ORDER); |
| | | preg_match_all('/\s*([-_a-z]+)=(["\'])??(?(2)([^\2]*)\2|(\S+?))/Ui', stripslashes($str), $regs, PREG_SET_ORDER); |
| | | |
| | | // convert attributes to an associative array (name => value) |
| | | if ($regs) |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Output HTML editor scripts |
| | | * |
| | | * @param string Editor mode |
| | | */ |
| | | function rcube_html_editor($mode='') |
| | | { |
| | | global $OUTPUT, $CONFIG; |
| | | |
| | | $lang = $tinylang = strtolower(substr($_SESSION['language'], 0, 2)); |
| | | if (!file_exists(INSTALL_PATH . 'program/js/tiny_mce/langs/'.$tinylang.'.js')) |
| | | $tinylang = 'en'; |
| | | |
| | | $OUTPUT->include_script('tiny_mce/tiny_mce.js'); |
| | | $OUTPUT->include_script('editor.js'); |
| | | $OUTPUT->add_script('rcmail_editor_init("$__skin_path", "'.JQ($tinylang).'", '.intval($CONFIG['enable_spellcheck']).', "'.$mode.'");'); |
| | | } |
| | | |
| | | ?> |