Define RCUBE_CHARSET in place of RCMAIL_CHARSET for naming consistency
| | |
| | | define('RCUBE_INPUT_GPC', rcube_utils::INPUT_GPC); |
| | | |
| | | define('JS_OBJECT_NAME', rcmail::JS_OBJECT_NAME); |
| | | define('RCMAIL_CHARSET', RCUBE_CHARSET); |
| | | |
| | | function get_table_name($table) |
| | | { |
| | |
| | | $this->output->set_env('task', $this->task); |
| | | $this->output->set_env('action', $this->action); |
| | | $this->output->set_env('comm_path', $this->comm_path); |
| | | $this->output->set_charset(RCMAIL_CHARSET); |
| | | $this->output->set_charset(RCUBE_CHARSET); |
| | | |
| | | // add some basic labels to client |
| | | $this->output->add_label('loading', 'servererror', 'requesttimedout', 'refreshing'); |
| | |
| | | |
| | | // framework constants |
| | | define('RCUBE_VERSION', '0.9-git'); |
| | | define('RCMAIL_CHARSET', 'UTF-8'); |
| | | define('RCUBE_CHARSET', 'UTF-8'); |
| | | |
| | | if (!defined('RCUBE_LIB_DIR')) { |
| | | define('RCUBE_LIB_DIR', dirname(__FILE__).'/'); |
| | |
| | | |
| | | // set internal encoding for mbstring extension |
| | | if (extension_loaded('mbstring')) { |
| | | mb_internal_encoding(RCMAIL_CHARSET); |
| | | @mb_regex_encoding(RCMAIL_CHARSET); |
| | | mb_internal_encoding(RCUBE_CHARSET); |
| | | @mb_regex_encoding(RCUBE_CHARSET); |
| | | } |
| | | |
| | | // Register autoloader |
| | |
| | | */ |
| | | public static function quote($str) |
| | | { |
| | | return @htmlspecialchars($str, ENT_COMPAT, RCMAIL_CHARSET); |
| | | return @htmlspecialchars($str, ENT_COMPAT, RCUBE_CHARSET); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | $storage = $this->get_storage(); |
| | | |
| | | $storage->set_charset($this->config->get('default_charset', RCMAIL_CHARSET)); |
| | | $storage->set_charset($this->config->get('default_charset', RCUBE_CHARSET)); |
| | | |
| | | if ($default_folders = $this->config->get('default_folders')) { |
| | | $storage->set_default_folders($default_folders); |
| | |
| | | * |
| | | * @param string Input string |
| | | * @param string Suspected charset of the input string |
| | | * @param string Target charset to convert to; defaults to RCMAIL_CHARSET |
| | | * @param string Target charset to convert to; defaults to RCUBE_CHARSET |
| | | * |
| | | * @return string Converted string |
| | | */ |
| | |
| | | static $mbstring_sch = null; |
| | | static $conv = null; |
| | | |
| | | $to = empty($to) ? RCMAIL_CHARSET : $to; |
| | | $to = empty($to) ? RCUBE_CHARSET : $to; |
| | | $from = self::parse_charset($from); |
| | | |
| | | // It is a common case when UTF-16 charset is used with US-ASCII content (#1488654) |
| | |
| | | |
| | | // fix default imap folders encoding |
| | | foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder) |
| | | $this->prop[$folder] = rcube_charset::convert($this->prop[$folder], RCMAIL_CHARSET, 'UTF7-IMAP'); |
| | | $this->prop[$folder] = rcube_charset::convert($this->prop[$folder], RCUBE_CHARSET, 'UTF7-IMAP'); |
| | | |
| | | if (!empty($this->prop['default_folders'])) |
| | | foreach ($this->prop['default_folders'] as $n => $folder) |
| | | $this->prop['default_folders'][$n] = rcube_charset::convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP'); |
| | | $this->prop['default_folders'][$n] = rcube_charset::convert($folder, RCUBE_CHARSET, 'UTF7-IMAP'); |
| | | |
| | | // set PHP error logging according to config |
| | | if ($this->prop['debug_level'] & 1) { |
| | |
| | | |
| | | if ($sql_arr['vcard']) { |
| | | unset($sql_arr['email']); |
| | | $vcard = new rcube_vcard($sql_arr['vcard'], RCMAIL_CHARSET, false, $this->vcard_fieldmap); |
| | | $vcard = new rcube_vcard($sql_arr['vcard'], RCUBE_CHARSET, false, $this->vcard_fieldmap); |
| | | $record += $vcard->get_assoc() + $sql_arr; |
| | | } |
| | | else { |
| | |
| | | $words = ''; |
| | | |
| | | // copy values into vcard object |
| | | $vcard = new rcube_vcard($record['vcard'] ? $record['vcard'] : $save_data['vcard'], RCMAIL_CHARSET, false, $this->vcard_fieldmap); |
| | | $vcard = new rcube_vcard($record['vcard'] ? $record['vcard'] : $save_data['vcard'], RCUBE_CHARSET, false, $this->vcard_fieldmap); |
| | | $vcard->reset(); |
| | | foreach ($save_data as $key => $values) { |
| | | list($field, $section) = explode(':', $key); |
| | |
| | | // convert to UTF-8 |
| | | $head = substr($csv, 0, 4096); |
| | | $fallback = rcube::get_instance()->config->get('default_charset', 'ISO-8859-1'); // fallback to Latin-1? |
| | | $charset = rcube_charset::detect($head, RCMAIL_CHARSET); |
| | | $charset = rcube_charset::detect($head, RCUBE_CHARSET); |
| | | $csv = rcube_charset::convert($csv, $charset); |
| | | $head = ''; |
| | | |
| | |
| | | return $charset; |
| | | } |
| | | |
| | | return RCMAIL_CHARSET; |
| | | return RCUBE_CHARSET; |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public static function wordwrap($string, $width=75, $break="\n", $cut=false, $charset=null) |
| | | { |
| | | if ($charset && function_exists('mb_internal_encoding')) |
| | | if ($charset && function_exists('mb_internal_encoding')) { |
| | | mb_internal_encoding($charset); |
| | | } |
| | | |
| | | $para = preg_split('/\r?\n/', $string); |
| | | $string = ''; |
| | |
| | | } |
| | | } |
| | | |
| | | if ($charset && function_exists('mb_internal_encoding')) |
| | | mb_internal_encoding(RCMAIL_CHARSET); |
| | | if ($charset && function_exists('mb_internal_encoding')) { |
| | | mb_internal_encoding(RCUBE_CHARSET); |
| | | } |
| | | |
| | | return $string; |
| | | } |
| | |
| | | |
| | | protected $app; |
| | | protected $config; |
| | | protected $charset = RCMAIL_CHARSET; |
| | | protected $charset = RCUBE_CHARSET; |
| | | protected $env = array(); |
| | | protected $pagetitle = ''; |
| | | protected $object_handlers = array(); |
| | |
| | | // trigger hook with final HTML content to be sent |
| | | $hook = $this->app->plugins->exec_hook("send_page", array('content' => $output)); |
| | | if (!$hook['abort']) { |
| | | if ($this->charset != RCMAIL_CHARSET) { |
| | | echo rcube_charset::convert($hook['content'], RCMAIL_CHARSET, $this->charset); |
| | | if ($this->charset != RCUBE_CHARSET) { |
| | | echo rcube_charset::convert($hook['content'], RCUBE_CHARSET, $this->charset); |
| | | } |
| | | else { |
| | | echo $hook['content']; |
| | |
| | | function get_xml() |
| | | { |
| | | // send output |
| | | $out = '<?xml version="1.0" encoding="'.RCMAIL_CHARSET.'"?><spellresult charschecked="'.mb_strlen($this->content).'">'; |
| | | $out = '<?xml version="1.0" encoding="'.RCUBE_CHARSET.'"?><spellresult charschecked="'.mb_strlen($this->content).'">'; |
| | | |
| | | foreach ($this->matches as $item) { |
| | | $out .= '<c o="'.$item[1].'" l="'.$item[2].'">'; |
| | |
| | | $word = $item[0]; |
| | | } |
| | | else { |
| | | $word = mb_substr($this->content, $item[1], $item[2], RCMAIL_CHARSET); |
| | | $word = mb_substr($this->content, $item[1], $item[2], RCUBE_CHARSET); |
| | | } |
| | | $result[$word] = is_array($item[4]) ? implode("\t", $item[4]) : $item[4]; |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | $this->plink = pspell_new($this->lang, null, null, RCMAIL_CHARSET, PSPELL_FAST); |
| | | $this->plink = pspell_new($this->lang, null, null, RCUBE_CHARSET, PSPELL_FAST); |
| | | } |
| | | |
| | | if (!$this->plink) { |
| | |
| | | || !empty($this->options['ignore_caps']) || !empty($this->options['dictionary']) |
| | | ) { |
| | | foreach ($matches as $idx => $m) { |
| | | $word = mb_substr($text, $m[1], $m[2], RCMAIL_CHARSET); |
| | | $word = mb_substr($text, $m[1], $m[2], RCUBE_CHARSET); |
| | | // skip exceptions |
| | | if ($this->is_exception($word)) { |
| | | unset($matches[$idx]); |
| | |
| | | $result = array(); |
| | | |
| | | foreach ($matches as $m) { |
| | | $result[] = mb_substr($text, $m[1], $m[2], RCMAIL_CHARSET); |
| | | $result[] = mb_substr($text, $m[1], $m[2], RCUBE_CHARSET); |
| | | } |
| | | |
| | | return $result; |
| | |
| | | /** |
| | | * Constructor |
| | | */ |
| | | public function __construct($vcard = null, $charset = RCMAIL_CHARSET, $detect = false, $fieldmap = array()) |
| | | public function __construct($vcard = null, $charset = RCUBE_CHARSET, $detect = false, $fieldmap = array()) |
| | | { |
| | | if (!empty($fielmap)) |
| | | $this->extend_fieldmap($fieldmap); |
| | |
| | | * @param string Charset of string values |
| | | * @param boolean True if loading a 'foreign' vcard and extra heuristics for charset detection is required |
| | | */ |
| | | public function load($vcard, $charset = RCMAIL_CHARSET, $detect = false) |
| | | public function load($vcard, $charset = RCUBE_CHARSET, $detect = false) |
| | | { |
| | | self::$values_decoded = false; |
| | | $this->raw = self::vcard_decode($vcard); |
| | |
| | | } |
| | | // vcard has encoded values and charset should be detected |
| | | else if ($detect && self::$values_decoded && |
| | | ($detected_charset = self::detect_encoding(self::vcard_encode($this->raw))) && $detected_charset != RCMAIL_CHARSET) { |
| | | ($detected_charset = self::detect_encoding(self::vcard_encode($this->raw))) && $detected_charset != RCUBE_CHARSET) { |
| | | $this->raw = self::charset_convert($this->raw, $detected_charset); |
| | | } |
| | | |
| | |
| | | if (preg_match('/charset=/i', substr($data, 0, 2048))) |
| | | $charset = null; |
| | | // detect charset and convert to utf-8 |
| | | else if (($charset = self::detect_encoding($data)) && $charset != RCMAIL_CHARSET) { |
| | | else if (($charset = self::detect_encoding($data)) && $charset != RCUBE_CHARSET) { |
| | | $data = rcube_charset::convert($data, $charset); |
| | | $data = preg_replace(array('/^[\xFE\xFF]{2}/', '/^\xEF\xBB\xBF/', '/^\x00+/'), '', $data); // also remove BOM |
| | | $charset = RCMAIL_CHARSET; |
| | | $charset = RCUBE_CHARSET; |
| | | } |
| | | |
| | | $vcard_block = ''; |