Avoid uninitialized/unused variables
| | |
| | | |
| | | $this->config = array_merge($this->config, $current); |
| | | |
| | | foreach ((array)$current['ldap_public'] as $key => $values) { |
| | | foreach (array_keys((array)$current['ldap_public']) as $key) { |
| | | $this->config['ldap_public'][$key] = $current['ldap_public'][$key]; |
| | | } |
| | | } |
| | |
| | | * Compare the local database schema with the reference schema |
| | | * required for this version of Roundcube |
| | | * |
| | | * @param boolean True if the schema schould be updated |
| | | * @param rcube_db Database object |
| | | * |
| | | * @return boolean True if the schema is up-to-date, false if not or an error occured |
| | | */ |
| | | function db_schema_check($DB, $update = false) |
| | | function db_schema_check($DB) |
| | | { |
| | | if (!$this->configured) |
| | | return false; |
| | |
| | | } |
| | | else { // check if all keys are numeric |
| | | $isnum = true; |
| | | foreach ($var as $key => $value) { |
| | | foreach (array_keys($var) as $key) { |
| | | if (!is_numeric($key)) { |
| | | $isnum = false; |
| | | break; |
| | |
| | | |
| | | function rcmail_temp_gc() |
| | | { |
| | | $rcmail = rcmail::get_instance()->temp_gc(); |
| | | rcmail::get_instance()->temp_gc(); |
| | | } |
| | | |
| | | function rcube_charset_convert($str, $from, $to=NULL) |
| | |
| | | $post_host = rcube_utils::get_input_value('_host', rcube_utils::INPUT_POST); |
| | | $post_user = rcube_utils::get_input_value('_user', rcube_utils::INPUT_POST); |
| | | |
| | | list($user, $domain) = explode('@', $post_user); |
| | | list(, $domain) = explode('@', $post_user); |
| | | |
| | | // direct match in default_host array |
| | | if ($default_host[$post_host] || in_array($post_host, array_values($default_host))) { |
| | |
| | | $token = rcube_utils::get_input_value('_token', $mode); |
| | | $sess_id = $_COOKIE[ini_get('session.name')]; |
| | | return !empty($sess_id) && $token == $this->get_request_token(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Create unique authorization hash |
| | | * |
| | | * @param string Session ID |
| | | * @param int Timestamp |
| | | * @return string The generated auth hash |
| | | */ |
| | | private function get_auth_hash($sess_id, $ts) |
| | | { |
| | | $auth_string = sprintf('rcmail*sess%sR%s*Chk:%s;%s', |
| | | $sess_id, |
| | | $ts, |
| | | $this->config->get('ip_check') ? $_SERVER['REMOTE_ADDR'] : '***.***.***.***', |
| | | $_SERVER['HTTP_USER_AGENT']); |
| | | |
| | | if (function_exists('sha1')) |
| | | return sha1($auth_string); |
| | | else |
| | | return md5($auth_string); |
| | | } |
| | | |
| | | |
| | |
| | | $collapsed = $this->config->get('collapsed_folders'); |
| | | |
| | | $out = ''; |
| | | foreach ($arrFolders as $key => $folder) { |
| | | foreach ($arrFolders as $folder) { |
| | | $title = null; |
| | | $folder_class = $this->folder_classname($folder['id']); |
| | | $is_collapsed = strpos($collapsed, '&'.rawurlencode($folder['id']).'&') !== false; |
| | |
| | | { |
| | | $out = ''; |
| | | |
| | | foreach ($arrFolders as $key => $folder) { |
| | | foreach ($arrFolders as $folder) { |
| | | // skip exceptions (and its subfolders) |
| | | if (!empty($opts['exceptions']) && in_array($folder['id'], $opts['exceptions'])) { |
| | | continue; |
| | |
| | | $out = array_merge($out, (array)$values); |
| | | } |
| | | else { |
| | | list($f, $type) = explode(':', $c); |
| | | list(, $type) = explode(':', $c); |
| | | $out[$type] = array_merge((array)$out[$type], (array)$values); |
| | | } |
| | | } |
| | |
| | | { |
| | | // 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, RCUBE_CHARSET); |
| | | $csv = rcube_charset::convert($csv, $charset); |
| | | $head = ''; |
| | |
| | | $this->map = array(); |
| | | |
| | | // Parse file |
| | | foreach (preg_split("/[\r\n]+/", $csv) as $i => $line) { |
| | | foreach (preg_split("/[\r\n]+/", $csv) as $line) { |
| | | $elements = $this->parse_line($line); |
| | | if (empty($elements)) { |
| | | continue; |
| | |
| | | $result[PDO::MYSQL_ATTR_FOUND_ROWS] = true; |
| | | |
| | | // Enable AUTOCOMMIT mode (#1488902) |
| | | $dsn_options[PDO::ATTR_AUTOCOMMIT] = true; |
| | | $result[PDO::ATTR_AUTOCOMMIT] = true; |
| | | |
| | | return $result; |
| | | } |
| | |
| | | $quoted = ''; |
| | | $lines = explode('<br>', $a[2]); |
| | | |
| | | foreach ($lines as $n => $line) |
| | | foreach ($lines as $line) |
| | | $quoted .= '>'.$line.'<br>'; |
| | | |
| | | $body = $a[1].'<span class="quotes">'.$quoted.'</span>'.$a[3]; |
| | |
| | | */ |
| | | protected function search_index($folder, $criteria='ALL', $charset=NULL, $sort_field=NULL) |
| | | { |
| | | $orig_criteria = $criteria; |
| | | |
| | | if (!$this->check_connection()) { |
| | | if ($this->threading) { |
| | | return new rcube_result_thread(); |
| | |
| | | */ |
| | | private function list_folders_update(&$result, $type = null) |
| | | { |
| | | $delim = $this->get_hierarchy_delimiter(); |
| | | $namespace = $this->get_namespace(); |
| | | $search = array(); |
| | | |
| | |
| | | $delimiter = $this->get_hierarchy_delimiter(); |
| | | |
| | | // find default folders and skip folders starting with '.' |
| | | foreach ($a_folders as $i => $folder) { |
| | | foreach ($a_folders as $folder) { |
| | | if ($folder[0] == '.') { |
| | | continue; |
| | | } |
| | |
| | | ." AND uid = ?", |
| | | $flags, $msg, $this->userid, $mailbox, (int) $message->uid); |
| | | |
| | | if ($this->db->affected_rows()) { |
| | | if ($this->db->affected_rows($res)) { |
| | | return; |
| | | } |
| | | } |
| | |
| | | $uids, true, array('FLAGS'), $index['modseq'], $qresync); |
| | | |
| | | if (!empty($result)) { |
| | | foreach ($result as $id => $msg) { |
| | | foreach ($result as $msg) { |
| | | $uid = $msg->uid; |
| | | // Remove deleted message |
| | | if ($this->skip_deleted && !empty($msg->flags['DELETED'])) { |
| | |
| | | } |
| | | |
| | | if (!empty($criteria)) { |
| | | $modseq = stripos($criteria, 'MODSEQ') !== false; |
| | | $params .= ($params ? ' ' : '') . $criteria; |
| | | } |
| | | else { |
| | |
| | | if ($skip_deleted && preg_match('/FLAGS \(([^)]+)\)/', $line, $matches)) { |
| | | $flags = explode(' ', strtoupper($matches[1])); |
| | | if (in_array('\\DELETED', $flags)) { |
| | | $deleted[$id] = $id; |
| | | continue; |
| | | } |
| | | } |
| | |
| | | // create array with header field:data |
| | | if (!empty($headers)) { |
| | | $headers = explode("\n", trim($headers)); |
| | | foreach ($headers as $hid => $resln) { |
| | | foreach ($headers as $resln) { |
| | | if (ord($resln[0]) <= 32) { |
| | | $lines[$ln] .= (empty($lines[$ln]) ? '' : "\n") . trim($resln); |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | while (list($lines_key, $str) = each($lines)) { |
| | | foreach ($lines as $str) { |
| | | list($field, $string) = explode(':', $str, 2); |
| | | |
| | | $field = strtolower($field); |
| | |
| | | |
| | | if (is_array($element)) { |
| | | reset($element); |
| | | while (list($key, $value) = each($element)) { |
| | | foreach ($element as $value) { |
| | | $string .= ' ' . self::r_implode($value); |
| | | } |
| | | } |
| | |
| | | // Build sub_fields filter |
| | | if (!empty($this->prop['sub_fields']) && is_array($this->prop['sub_fields'])) { |
| | | $this->sub_filter = ''; |
| | | foreach ($this->prop['sub_fields'] as $attr => $class) { |
| | | foreach ($this->prop['sub_fields'] as $class) { |
| | | if (!empty($class)) { |
| | | $class = is_array($class) ? array_pop($class) : $class; |
| | | $this->sub_filter .= '(objectClass=' . $class . ')'; |
| | |
| | | $mail_field = $this->fieldmap['email']; |
| | | |
| | | // try to extract surname and firstname from displayname |
| | | $reverse_map = array_flip($this->fieldmap); |
| | | $name_parts = preg_split('/[\s,.]+/', $save_data['name']); |
| | | |
| | | if ($sn_field && $missing[$sn_field]) { |
| | |
| | | // Remove attributes that need to be added separately (child objects) |
| | | $xfields = array(); |
| | | if (!empty($this->prop['sub_fields']) && is_array($this->prop['sub_fields'])) { |
| | | foreach ($this->prop['sub_fields'] as $xf => $xclass) { |
| | | foreach (array_keys($this->prop['sub_fields']) as $xf) { |
| | | if (!empty($newentry[$xf])) { |
| | | $xfields[$xf] = $newentry[$xf]; |
| | | unset($newentry[$xf]); |
| | |
| | | } |
| | | } |
| | | |
| | | foreach ($this->fieldmap as $col => $fld) { |
| | | foreach ($this->fieldmap as $fld) { |
| | | if ($fld) { |
| | | $val = $ldap_data[$fld]; |
| | | $old = $old_data[$fld]; |
| | |
| | | $vlv_active = $this->_vlv_set_controls($this->prop['groups'], $vlv_page+1, $page_size); |
| | | } |
| | | |
| | | $function = $this->_scope2func($this->prop['groups']['scope'], $ns_function); |
| | | $function = $this->_scope2func($this->prop['groups']['scope']); |
| | | $res = @$function($this->conn, $base_dn, $filter, array_unique(array('dn', 'objectClass', $name_attr, $email_attr, $sort_attr))); |
| | | if ($res === false) |
| | | { |
| | |
| | | |
| | | // parse headers from message/rfc822 part |
| | | if (!isset($structure->headers['subject']) && !isset($structure->headers['from'])) { |
| | | list($headers, $dump) = explode("\r\n\r\n", $this->get_part_content($structure->mime_id, null, true, 32768)); |
| | | list($headers, ) = explode("\r\n\r\n", $this->get_part_content($structure->mime_id, null, true, 32768)); |
| | | $structure->headers = rcube_mime::parse_headers($headers); |
| | | } |
| | | } |
| | |
| | | $doc->loadXML($file); |
| | | $xpath = new DOMXPath($doc); |
| | | $xpath->registerNamespace('rc', "http://pear.php.net/dtd/package-2.0"); |
| | | $data = array(); |
| | | |
| | | // XPaths of plugin metadata elements |
| | | $metadata = array( |
| | |
| | | $recipients = rcube_utils::explode_quoted_string(',', $recipients); |
| | | |
| | | reset($recipients); |
| | | while (list($k, $recipient) = each($recipients)) { |
| | | foreach ($recipients as $recipient) { |
| | | $a = rcube_utils::explode_quoted_string(' ', $recipient); |
| | | while (list($k2, $word) = each($a)) { |
| | | foreach ($a as $word) { |
| | | if (strpos($word, "@") > 0 && $word[strlen($word)-1] != '"') { |
| | | $word = preg_replace('/^<|>$/', '', trim($word)); |
| | | if (in_array($word, $addresses) === false) { |
| | |
| | | $out = array(); |
| | | $src = $mode == self::INPUT_GET ? $_GET : ($mode == self::INPUT_POST ? $_POST : $_REQUEST); |
| | | |
| | | foreach ($src as $key => $value) { |
| | | foreach (array_keys($src) as $key) { |
| | | $fname = $key[0] == '_' ? substr($key, 1) : $key; |
| | | if ($ignore && !preg_match('/^(' . $ignore . ')$/', $fname)) { |
| | | $out[$fname] = self::get_input_value($key, $mode); |
| | |
| | | $vcard_block = ''; |
| | | $in_vcard_block = false; |
| | | |
| | | foreach (preg_split("/[\r\n]+/", $data) as $i => $line) { |
| | | foreach (preg_split("/[\r\n]+/", $data) as $line) { |
| | | if ($in_vcard_block && !empty($line)) { |
| | | $vcard_block .= $line . "\n"; |
| | | } |
| | |
| | | $attrib['id'] = 'rcmdirectorylist'; |
| | | |
| | | $out = ''; |
| | | $local_id = '0'; |
| | | $jsdata = array(); |
| | | |
| | | $line_templ = html::tag('li', array( |
| | |
| | | |
| | | $groups_html = ''; |
| | | $groups = $RCMAIL->get_address_book($args['source'])->list_groups(); |
| | | $js_id = $RCMAIL->JQ($args['source']); |
| | | |
| | | if (!empty($groups)) { |
| | | $line_templ = html::tag('li', array( |
| | |
| | | $is_collapsed = strpos($RCMAIL->config->get('collapsed_abooks',''), '&'.rawurlencode($args['source']).'&') !== false; |
| | | $args['out'] .= html::div('treetoggle ' . ($is_collapsed ? 'collapsed' : 'expanded'), ' '); |
| | | |
| | | $jsdata = array(); |
| | | foreach ($groups as $group) { |
| | | $groups_html .= sprintf($line_templ, |
| | | rcube_utils::html_identifier('G' . $args['source'] . $group['ID'], true), |
| | |
| | | return false; |
| | | } |
| | | |
| | | $microformats = array('name' => 'fn', 'email' => 'email'); |
| | | |
| | | $form = array( |
| | | 'head' => array( // section 'head' is magic! |
| | | 'content' => array( |
| | |
| | | } |
| | | |
| | | |
| | | function rcmail_render_email_value($email, $col) |
| | | function rcmail_render_email_value($email) |
| | | { |
| | | return html::a(array( |
| | | 'href' => 'mailto:' . $email, |
| | |
| | | } |
| | | |
| | | |
| | | function rcmail_render_url_value($url, $col) |
| | | function rcmail_render_url_value($url) |
| | | { |
| | | $prefix = preg_match('!^(http|ftp)s?://!', $url) ? '' : 'http://'; |
| | | return html::a(array( |
| | |
| | | { |
| | | global $MESSAGE; |
| | | |
| | | list($form_start, $form_end) = get_form_tags($attrib); |
| | | list($form_start,) = get_form_tags($attrib); |
| | | |
| | | $out = ''; |
| | | $part = strtolower($attrib['part']); |
| | |
| | | |
| | | function rcmail_compose_header_from($attrib) |
| | | { |
| | | global $MESSAGE, $OUTPUT, $RCMAIL, $compose_mode; |
| | | global $MESSAGE, $OUTPUT, $RCMAIL, $COMPOSE, $compose_mode; |
| | | |
| | | // pass the following attributes to the form class |
| | | $field_attrib = array('name' => '_from'); |
| | |
| | | |
| | | function rcmail_prepare_message_body() |
| | | { |
| | | global $RCMAIL, $MESSAGE, $COMPOSE, $compose_mode, $LINE_LENGTH, $HTML_MODE; |
| | | global $RCMAIL, $MESSAGE, $COMPOSE, $compose_mode, $HTML_MODE; |
| | | |
| | | // use posted message body |
| | | if (!empty($_POST['_message'])) { |
| | |
| | | |
| | | function rcmail_compose_body($attrib) |
| | | { |
| | | global $RCMAIL, $CONFIG, $OUTPUT, $MESSAGE, $compose_mode, $LINE_LENGTH, $HTML_MODE, $MESSAGE_BODY; |
| | | global $RCMAIL, $CONFIG, $OUTPUT, $MESSAGE, $compose_mode, $HTML_MODE, $MESSAGE_BODY; |
| | | |
| | | list($form_start, $form_end) = get_form_tags($attrib); |
| | | unset($attrib['form']); |
| | |
| | | $cid_map = rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml); |
| | | |
| | | $date = format_date($MESSAGE->headers->date, $RCMAIL->config->get('date_long')); |
| | | $charset = $RCMAIL->output->get_charset(); |
| | | |
| | | if (!$bodyIsHtml) { |
| | | $prefix = "\n\n\n-------- " . rcube_label('originalmessage') . " --------\n"; |
| | |
| | | |
| | | function rcmail_create_draft_body($body, $bodyIsHtml) |
| | | { |
| | | global $MESSAGE, $OUTPUT, $COMPOSE; |
| | | global $MESSAGE, $COMPOSE; |
| | | |
| | | /** |
| | | * add attachments |
| | |
| | | global $RCMAIL, $COMPOSE, $compose_mode; |
| | | |
| | | $loaded_attachments = array(); |
| | | foreach ((array)$COMPOSE['attachments'] as $id => $attachment) { |
| | | foreach ((array)$COMPOSE['attachments'] as $attachment) { |
| | | $loaded_attachments[$attachment['name'] . $attachment['mimetype']] = $attachment; |
| | | } |
| | | |
| | |
| | | $names = array(); |
| | | |
| | | $loaded_attachments = array(); |
| | | foreach ((array)$COMPOSE['attachments'] as $id => $attachment) { |
| | | foreach ((array)$COMPOSE['attachments'] as $attachment) { |
| | | $loaded_attachments[$attachment['name'] . $attachment['mimetype']] = $attachment; |
| | | } |
| | | |
| | |
| | | $select->add(Q(rcube_label('plaintoggle')), 'plain'); |
| | | |
| | | return $select->show($useHtml ? 'html' : 'plain'); |
| | | |
| | | /* |
| | | foreach ($choices as $value => $text) { |
| | | $attrib['id'] = '_' . $value; |
| | | $attrib['value'] = $value; |
| | |
| | | } |
| | | |
| | | return $selector; |
| | | */ |
| | | } |
| | | |
| | | |
| | |
| | | if (!in_array('threads', $a_show_cols)) |
| | | array_unshift($a_show_cols, 'threads'); |
| | | |
| | | $skin_path = $_SESSION['skin_path'] = $CONFIG['skin_path']; |
| | | $_SESSION['skin_path'] = $CONFIG['skin_path']; |
| | | |
| | | // set client env |
| | | $OUTPUT->add_gui_object('messagelist', $attrib['id']); |
| | |
| | | $thead = $head_replace ? rcmail_message_list_head($_SESSION['list_attrib'], $a_show_cols) : NULL; |
| | | |
| | | // get name of smart From/To column in folder context |
| | | if (($f = array_search('fromto', $a_show_cols)) !== false) { |
| | | if (array_search('fromto', $a_show_cols) !== false) { |
| | | $smart_col = rcmail_message_list_smart_column_name(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // loop through message headers |
| | | foreach ($a_headers as $n => $header) { |
| | | foreach ($a_headers as $header) { |
| | | if (empty($header)) |
| | | continue; |
| | | |
| | |
| | | global $RCMAIL; |
| | | |
| | | $skin_path = $_SESSION['skin_path']; |
| | | $image_tag = html::img(array('src' => "%s%s", 'alt' => "%s")); |
| | | |
| | | // check to see if we have some settings for sorting |
| | | $sort_col = $_SESSION['sort_col']; |
| | |
| | | $cells = array(); |
| | | |
| | | // get name of smart From/To column in folder context |
| | | if (($f = array_search('fromto', $a_show_cols)) !== false) { |
| | | if (array_search('fromto', $a_show_cols) !== false) { |
| | | $smart_col = rcmail_message_list_smart_column_name(); |
| | | } |
| | | |
| | |
| | | */ |
| | | function rcmail_message_headers($attrib, $headers=null) |
| | | { |
| | | global $OUTPUT, $MESSAGE, $PRINT_MODE, $RCMAIL; |
| | | global $MESSAGE, $PRINT_MODE, $RCMAIL; |
| | | static $sa_attrib; |
| | | |
| | | // keep header table attrib |
| | |
| | | $header_attrib[$regs[1]] = $value; |
| | | |
| | | if (!empty($MESSAGE->parts)) { |
| | | foreach ($MESSAGE->parts as $i => $part) { |
| | | foreach ($MESSAGE->parts as $part) { |
| | | if ($part->type == 'headers') { |
| | | $out .= html::div('message-partheaders', rcmail_message_headers(sizeof($header_attrib) ? $header_attrib : null, $part->headers)); |
| | | } |
| | |
| | | |
| | | $sent = rcmail_deliver_message($compose, $identity['email'], $mailto, $smtp_error, $body_file, $options); |
| | | |
| | | if ($sent) |
| | | { |
| | | if ($sent) { |
| | | $RCMAIL->storage->set_flag($message->uid, 'MDNSENT'); |
| | | return true; |
| | | } |
| | |
| | | |
| | | function rcmail_message_buttons() |
| | | { |
| | | global $MESSAGE, $RCMAIL, $CONFIG; |
| | | global $RCMAIL; |
| | | |
| | | $mbox = $RCMAIL->storage->get_folder(); |
| | | $delim = $RCMAIL->storage->get_hierarchy_delimiter(); |
| | | $dbox = $CONFIG['drafts_mbox']; |
| | | $dbox = $RCMAIL->config->get('drafts_mbox'); |
| | | |
| | | // the message is not a draft |
| | | if ($mbox != $dbox && strpos($mbox, $dbox.$delim) !== 0) { |
| | |
| | | |
| | | $out = $form_start; |
| | | |
| | | foreach ($SECTIONS[$CURR_SECTION]['blocks'] as $idx => $block) { |
| | | foreach ($SECTIONS[$CURR_SECTION]['blocks'] as $block) { |
| | | if (!empty($block['options'])) { |
| | | $table = new html_table(array('cols' => 2)); |
| | | |
| | |
| | | $noselect = false; |
| | | $classes = array($i%2 ? 'even' : 'odd'); |
| | | |
| | | $folder_js = Q($folder['id']); |
| | | $folder_utf8 = rcube_charset_convert($folder['id'], 'UTF7-IMAP'); |
| | | $display_folder = str_repeat(' ', $folder['level']) |
| | | . Q($protected ? rcmail_localize_foldername($folder['id']) : $folder['name']); |
| | |
| | | $a_threaded = (array) $RCMAIL->config->get('message_threading', array()); |
| | | $oldprefix = '/^' . preg_quote($oldname . $delimiter, '/') . '/'; |
| | | |
| | | foreach ($a_threaded as $key => $val) { |
| | | foreach (array_keys($a_threaded) as $key) { |
| | | if ($key == $oldname) { |
| | | unset($a_threaded[$key]); |
| | | $a_threaded[$newname] = true; |