Exemplo n.º 1
0
 function url_action_new($get)
 {
     global $user;
     global $imap;
     global $sticky_url;
     if ($user->logged_in) {
         do_work_hook('new_page_start');
         $user->page_data['new_link_class'] = 'current_page';
         $user->dsp_page = 'new';
         $user->page_data['mailbox_page'] = 1;
         $user->page_data['sort_by'] = 'ARRIVAL';
         $new_page_data = array();
         $grand_total = 0;
         $unread_folder_count = 0;
         $configured_folders = 0;
         if (isset($_SESSION['user_settings']['folder_check'])) {
             $_SESSION['unseen_status'] = $imap->get_unseen_status($_SESSION['user_settings']['folder_check']);
             $configured_folders = count($_SESSION['user_settings']['folder_check']);
             foreach ($_SESSION['user_settings']['folder_check'] as $v) {
                 $new_page_data[$v] = array();
                 list($total, $uids) = $imap->select_mailbox($v, false, true);
                 if ($total) {
                     if (!empty($uids)) {
                         if (isset($_SESSION['frozen_folders'][$v])) {
                             $new_uids = array();
                             foreach ($uids as $uid) {
                                 if (in_array($uid, $_SESSION['uid_cache'][$v]['uids'])) {
                                     $new_uids[] = $uid;
                                 }
                             }
                             $uids = $new_uids;
                         }
                         $total = count($uids);
                         $new_page_data[$v] = array('total' => $total, 'headers' => $this->sort_messages($imap->get_mailbox_page($v, $uids, false), $v));
                     }
                     $unread_folder_count++;
                     $grand_total += $total;
                 }
             }
         }
         if ($grand_total > 14) {
             $user->page_data['top_link'] = '<a href="' . $sticky_url . '#top">' . $user->str[186] . '</a>';
         }
         //$_SESSION['total_unread'] = $grand_total;
         $user->page_title .= ' | New Mail |';
         $user->page_data['grand_total'] = $grand_total;
         $user->page_data['configured_folders'] = $configured_folders;
         $user->page_data['unread_folder_count'] = $unread_folder_count;
         $user->page_data['new_page_data'] = $new_page_data;
         $user->page_data['folders'] = $_SESSION['folders'];
     }
 }
Exemplo n.º 2
0
 function url_action_options($get)
 {
     global $user;
     global $imap;
     global $sticky_url;
     if ($user->logged_in) {
         do_work_hook('options_page_start');
         $user->page_data['options_link_class'] = 'current_page';
         $user->dsp_page = 'options';
         $user->page_title .= ' | ' . $user->str[4] . ' |';
         $user->page_data['folders'] = $_SESSION['folders'];
         $user->page_data['top_link'] = '<a href="' . $sticky_url . '#top">' . $user->str[186] . '</a>';
     }
 }
Exemplo n.º 3
0
 function url_action_about($get)
 {
     global $user;
     global $imap;
     global $conf;
     global $hastymail_version;
     global $hm_utils_mod;
     if ($user->logged_in) {
         do_work_hook('about_page_start');
         $user->page_data['about_link_class'] = 'current_page';
         $user->dsp_page = 'about';
         $user->page_title .= ' | ' . $user->str[2] . ' |';
         $user->page_data['version'] = $hastymail_version;
         if (isset($_SESSION['imap_banner'])) {
             $user->page_data['banner'] = $_SESSION['imap_banner'];
         } else {
             $user->page_data['banner'] = '';
         }
         $user->page_data['caps'] = $_SESSION['imap_capability'];
         $user->page_data['imap_server'] = $imap->server;
         $user->page_data['server_time'] = date("r");
         $user->page_data['folders'] = $_SESSION['folders'];
         if (isset($conf['plugins'])) {
             $user->page_data['plugins'] = implode(', ', $conf['plugins']);
         } else {
             $user->page_data['plugins'] = '';
         }
         if ($imap->use_folder_cache) {
             $user->page_data['fcache_flag'] = $user->str[534];
         } else {
             $user->page_data['fcache_flag'] = $user->str[535];
         }
         if ($imap->use_uid_cache) {
             $user->page_data['ucache_flag'] = $user->str[534];
         } else {
             $user->page_data['ucache_flag'] = $user->str[535];
         }
         if ($imap->use_header_cache) {
             $user->page_data['hcache_flag'] = $user->str[534];
         } else {
             $user->page_data['hcache_flag'] = $user->str[535];
         }
         if ($hm_utils_mod) {
             $user->page_data['mod_util_flag'] = $user->str[534];
         } else {
             $user->page_data['mod_util_flag'] = $user->str[535];
         }
         if ($user->ajax_enabled) {
             $user->page_data['ajax_flag'] = $user->str[534];
         } else {
             $user->page_data['ajax_flag'] = $user->str[535];
         }
         if (isset($_SERVER['HTTP_HOST'])) {
             $user->page_data['host'] = $_SERVER['HTTP_HOST'];
         } else {
             $user->page_data['host'] = $user->str[500];
         }
         if (isset($_SERVER['SERVER_ADMIN'])) {
             $user->page_data['admin'] = $_SERVER['SERVER_ADMIN'];
         } else {
             $user->page_data['admin'] = $user->str[500];
         }
         if (isset($_SERVER['SERVER_SOFTWARE'])) {
             $user->page_data['server'] = $_SERVER['SERVER_SOFTWARE'];
         } else {
             $user->page_data['server'] = $user->str[500];
         }
         if (isset($_SERVER['HTTP_USER_AGENT'])) {
             $user->page_data['browser'] = $_SERVER['HTTP_USER_AGENT'];
         } else {
             $user->page_data['browser'] = $user->str[500];
         }
         if (isset($_SERVER['REMOTE_ADDR'])) {
             $user->page_data['ip'] = $_SERVER['REMOTE_ADDR'];
         } else {
             $user->page_data['ip'] = $user->str[500];
         }
     }
 }
Exemplo n.º 4
0
 function form_action_compose_send($form, $post)
 {
     global $user;
     global $imap;
     global $conf;
     global $message;
     global $hastymail_version;
     global $smtp;
     global $include_path;
     global $fd;
     $path = $conf['attachments_path'];
     if ($user->logged_in) {
         if (isset($post['contacts_visible']) && $post['contacts_visible']) {
             $user->page_data['contact_browse'] = true;
         }
         require_once $include_path . 'lib' . $fd . 'smtp_class.php';
         $message = hm_new('mime', $post['compose_session']);
         if (!isset($_SESSION['user_settings']['compose_hide_mailer']) || !$_SESSION['user_settings']['compose_hide_mailer']) {
             $message->set_header('x_Mailer', $hastymail_version);
         }
         if (isset($post['compose_to'])) {
             $message->to = $post['compose_to'];
         }
         if (isset($post['compose_cc'])) {
             $message->cc = $post['compose_cc'];
         }
         if (isset($post['compose_bcc'])) {
             $message->bcc = $post['compose_bcc'];
         }
         if (isset($post['compose_references'])) {
             $message->references = $post['compose_references'];
         }
         if (isset($post['compose_in_reply_to'])) {
             $message->in_reply_to = $post['compose_in_reply_to'];
         }
         if (isset($post['message_id'])) {
             $message->message_id = $post['message_id'];
         }
         if (isset($post['compose_from'])) {
             if (isset($_SESSION['user_settings']['profiles'][$post['compose_from']])) {
                 $from_atts = $_SESSION['user_settings']['profiles'][$post['compose_from']];
                 $message->from = '"' . $from_atts['profile_name'] . '" <' . $from_atts['profile_address'] . '> ';
                 $message->from_address = $from_atts['profile_address'];
                 if (isset($from_atts['profile_reply_to']) && $from_atts['profile_reply_to']) {
                     $message->reply_to = '<' . $from_atts['profile_address'] . '>';
                 }
             }
         }
         if ($message->from_address) {
             $recipients = $message->get_recipient_addresses();
             if (!empty($recipients)) {
                 $message->subject = $post['compose_subject'];
                 $message->body = $post['compose_message'];
                 $priortiy = 0;
                 if (isset($post['compose_priority']) && $post['compose_priority']) {
                     $priortiy = (int) $post['compose_priority'];
                 }
                 if ($priortiy && $priortiy != 3) {
                     $message->set_header('x_Priority', $priortiy);
                 }
                 if (isset($post['compose_mdn']) && $post['compose_mdn']) {
                     $message->set_header('disposition_Notification_To', $message->from_address);
                 }
                 $smtp = hm_new('smtp');
                 $res = $smtp->connect();
                 if (!$res) {
                     do_work_hook('message_send', array($message->body));
                     $res = $smtp->send_message($message->from_address, $recipients, $message);
                     if ($res) {
                         if ($smtp->smtp_err) {
                             $res .= '<br />' . $smtp->smtp_err;
                         }
                         $this->form_vals = $post;
                         $this->errors[] = $res;
                     } else {
                         $user->page_data['sent'] = 1;
                         $this->errors[] = $user->str[355];
                         $this->form_redirect = true;
                         if (isset($post['compose_in_reply_to']) && $post['compose_in_reply_to']) {
                             $this->perform_imap_action('ANSWERED', $post['reply_box'], array($post['reply_uid']), false, false);
                         }
                     }
                     if (!$res && !isset($post['compose_skip_sent']) || isset($post['compose_skip_sent']) && !$post['compose_skip_sent']) {
                         $sent_folder = $_SESSION['user_settings']['sent_folder'];
                         if (isset($_SESSION['sent_folder_override']) && isset($_SESSION['folders'][$_SESSION['sent_folder_override']])) {
                             $sent_folder = $_SESSION['sent_folder_override'];
                             unset($_SESSION['sent_folder_override']);
                         }
                         if (isset($sent_folder) && isset($_SESSION['folders'][$sent_folder])) {
                             $status = stream_imap_append($message, $post['compose_session'], $sent_folder);
                             if (!$status) {
                                 $this->errors[] = $user->str[539];
                             }
                         }
                     }
                     if (!$res && isset($_SESSION['user_settings']['draft_folder']) && isset($post['message_id']) && $post['message_id'] && isset($_SESSION['user_settings']['delete_draft']) && $_SESSION['user_settings']['delete_draft'] && $_SESSION['user_settings']['draft_folder']) {
                         $trash_folder = false;
                         if (isset($_SESSION['user_settings']['trash_folder']) && $_SESSION['user_settings']['trash_folder']) {
                             $trash_folder = $_SESSION['user_settings']['trash_folder'];
                         }
                         $select_res = $imap->select_mailbox($_SESSION['user_settings']['draft_folder'], false, false, true);
                         if ($select_res) {
                             $search_res = $imap->simple_search('header message-id', false, $post['message_id']);
                             if (isset($search_res[0])) {
                                 $this->perform_imap_action('DELETE', $_SESSION['user_settings']['draft_folder'], array($search_res[0]), $trash_folder, false);
                             }
                         }
                     }
                     do_work_hook('compose_after_send');
                 } else {
                     $this->errors[] = $res;
                     $this->form_vals = $post;
                 }
                 if (!$res) {
                     unset_attachments($post['compose_session']);
                 }
                 $smtp->disconnect();
             } else {
                 $this->form_vals = $post;
                 $this->errors[] = $user->str[356];
             }
         } else {
             $this->form_vals = $post;
             $this->errors[] = $user->str[357];
         }
     }
 }
Exemplo n.º 5
0
 function url_action_contacts($get)
 {
     global $user;
     global $imap;
     global $include_path;
     global $conf;
     global $fd;
     global $sticky_url;
     if ($user->logged_in) {
         do_work_hook('contacts_page_start');
         $user->page_data['contacts_link_class'] = 'current_page';
         $user->dsp_page = 'contacts';
         $user->page_title .= ' | ' . $user->str[8] . ' |';
         $user->page_data['show_card_detail'] = false;
         $page = 1;
         if (isset($get['contacts_page'])) {
             $page = (int) $get['contacts_page'];
             if (!$page) {
                 $page = 1;
             }
         }
         $user->page_data['contacts_page'] = $page;
         $keywords = false;
         $user->page_data['list_label'] = $user->str[157];
         if (isset($user->page_data['contact_search_keywords']) && $user->page_data['contact_search_keywords']) {
             $_SESSION['contact_search_keywords'] = $user->page_data['contact_search_keywords'];
             $keywords = $user->page_data['contact_search_keywords'];
             $user->page_data['list_label'] = $user->str[419];
         } elseif (isset($_SESSION['contact_search_keywords']) && $_SESSION['contact_search_keywords']) {
             $keywords = $_SESSION['contact_search_keywords'];
             $user->page_data['list_label'] = $user->str[419];
         }
         if (isset($user->page_data['contact_sort'])) {
             $_SESSION['contact_sort_order'] = $user->page_data['contact_sort'];
             require_once $include_path . 'lib' . $fd . 'vcard.php';
             $vcard = hm_new('vcard');
             $vcard->sort_fld = $user->page_data['contact_sort'];
             $vcard->search_terms = $keywords;
             $user->page_data['contact_sort_order'] = $vcard->sort_fld;
             $vcard->get_card_list(false, $page);
             $user->page_data['card_total'] = $vcard->card_total;
             $user->page_data['contact_list'] = $vcard->card_list;
         } else {
             if (isset($_SESSION['contact_sort_order'])) {
                 $sort = $_SESSION['contact_sort_order'];
             } else {
                 $sort = 'EMAIL';
             }
             $user->page_data['contact_sort_order'] = $sort;
             if (isset($_SESSION['import_card_detail']) && !empty($_SESSION['import_card_detail'])) {
                 require_once $include_path . 'lib' . $fd . 'vcard.php';
                 $vcard = hm_new('vcard');
                 $vcard->card = $_SESSION['import_card_detail'];
                 unset($_SESSION['import_card_detail']);
                 $vcard->sort_fld = $sort;
                 $vcard->search_terms = $keywords;
                 $vcard->get_card_list(false, $page);
                 $user->page_data['card_total'] = $vcard->card_total;
                 $user->page_data['import_vals'] = $vcard->card;
             }
             if (isset($user->page_data['import_card'])) {
                 $vcard = $user->page_data['import_card'];
                 $vcard->sort_fld = $sort;
                 $vcard->search_terms = $keywords;
                 $vcard->get_card_list(false, $page);
                 $user->page_data['card_total'] = $vcard->card_total;
                 $user->page_data['import_vals'] = $vcard->card;
             } else {
                 require_once $include_path . 'lib' . $fd . 'vcard.php';
                 $vcard = hm_new('vcard');
                 $vcard->sort_fld = $sort;
                 $vcard->search_terms = $keywords;
                 $vcard->get_card_list(false, $page);
                 $user->page_data['card_total'] = $vcard->card_total;
             }
             $user->page_data['contact_list'] = $vcard->card_list;
             if (isset($get['card_detail'])) {
                 $id = $get['card_detail'];
                 if (isset($vcard->card_list[$id])) {
                     $user->page_data['show_card_detail'] = true;
                     $user->page_data['card_id'] = $id;
                     $user->page_data['card_detail'] = $vcard->card_list[$id];
                 }
             } elseif (isset($get['edit_card'])) {
                 $id = $get['edit_card'];
                 if (isset($vcard->card_list[$id])) {
                     $user->page_data['card_id'] = $id;
                     $user->page_data['edit_vals'] = $vcard->card_list[$id];
                 }
             } elseif (isset($get['download_card'])) {
                 $id = $get['download_card'];
                 if ($id == 'all') {
                     $body = '';
                     $vcard->get_card_list();
                     foreach ($vcard->card_list as $i => $vals) {
                         list($nothing, $text) = $vcard->export_card($i);
                         $body .= "\r\n" . $text;
                     }
                     ob_end_clean();
                     header("Content-Type:text/x-vcard");
                     header('Content-Disposition: attachment; filename="' . str_replace('@', '_', $_SESSION['user_data']['username']) . '_contacts.vcf"');
                     header("Content-Length: " . strlen($body));
                     echo $body;
                     $imap->disconnect();
                     $user->clean_up();
                     exit;
                 } else {
                     if (isset($vcard->card_list[$id])) {
                         list($filename, $body) = $vcard->export_card($id);
                         ob_end_clean();
                         header("Content-Type:text/x-vcard");
                         header('Content-Disposition: attachment; filename="' . $filename . '"');
                         header("Content-Length: " . strlen($body));
                         echo $body;
                         $imap->disconnect();
                         $user->clean_up();
                         exit;
                     }
                 }
             }
         }
         $user->page_data['contact_search_keywords'] = $keywords;
         $user->page_data['top_link'] = '<a href="' . $sticky_url . '#top">' . $user->str[186] . '</a>';
         $user->page_data['folders'] = $_SESSION['folders'];
     }
 }
Exemplo n.º 6
0
function ajax_save_outgoing_message($subject, $body, $to, $cc, $from, $id, $reply_to, $refs, $priortiy, $mdn, $c_session, $content_type)
{
    global $user;
    global $hastymail_version;
    global $imap;
    global $conf;
    global $include_path;
    global $fd;
    global $message;
    if ($user->user_action->gpc) {
        $to = stripslashes($to);
        $cc = stripslashes($cc);
        $from = stripslashes($from);
        $body = stripslashes($body);
        $subject = stripslashes($subject);
    }
    $path = $conf['attachments_path'];
    if ($user->logged_in) {
        $select_res = false;
        $_SESSION['compose_sessions'][$c_session] = time();
        if (trim($body)) {
            if (isset($_SESSION['user_settings']['draft_folder'])) {
                $mailbox = $_SESSION['user_settings']['draft_folder'];
                $select_res = $imap->select_mailbox($mailbox, false, false, true);
            } else {
                $mailbox = 'INBOX';
            }
            require_once $include_path . 'lib' . $fd . 'smtp_class.php';
            $message = hm_new('mime', $c_session);
            if ($to) {
                $message->to = $to;
            }
            if ($cc) {
                $message->cc = $cc;
            }
            if ($refs) {
                $message->references = $refs;
            }
            if ($reply_to) {
                $message->in_reply_to = $reply_to;
            }
            if ($id) {
                $message->message_id = $id;
            }
            if (isset($_SESSION['user_settings']['profiles'][$from])) {
                $from_atts = $_SESSION['user_settings']['profiles'][$from];
                $message->from = '"' . $from_atts['profile_name'] . '" <' . $from_atts['profile_address'] . '> ';
                $message->from_address = $from_atts['profile_address'];
                if (isset($from_atts['profile_reply_to']) && $from_atts['profile_reply_to']) {
                    $message->reply_to = '<' . $from_atts['profile_address'] . '>';
                }
            }
            $existing_id = false;
            if ($select_res) {
                $search_res = $imap->simple_search('header message-id', false, $message->message_id);
                if (isset($search_res[0])) {
                    $existing_id = $search_res[0];
                }
            }
            if ($message->from_address) {
                $message->subject = decode_unicode_url($subject);
                $message->body = decode_unicode_url($body);
                if (!isset($_SESSION['user_settings']['compose_hide_mailer']) || !$_SESSION['user_settings']['compose_hide_mailer']) {
                    $message->set_header('x_Mailer', $hastymail_version);
                }
                if ($priortiy && $priortiy != 3) {
                    $message->set_header('x_Priority', $priortiy);
                }
                if ($mdn) {
                    $message->set_header('disposition_Notification_To', $message->from_address);
                }
                do_work_hook('message_save', array($message->body));
                $status = stream_imap_append($message, $c_session, $mailbox);
                if ($status && $existing_id) {
                    $imap->message_action(array($existing_id), 'DELETE');
                    $imap->message_action(array($existing_id), 'EXPUNGE');
                    $_SESSION['uid_cache_refresh'][$mailbox] = 1;
                    $_SESSION['header_cache_refresh'][$mailbox] = 1;
                }
            }
        }
    }
    if (isset($message->message_id)) {
        return $message->message_id;
    } else {
        return '';
    }
}
Exemplo n.º 7
0
 function form_action_update_settings($form, $post)
 {
     global $user;
     global $imap;
     global $conf;
     global $smtp_auth_mechs;
     global $date_formats;
     global $time_formats;
     global $hm_tags;
     global $start_pages;
     global $max_msg_per_page;
     global $langs;
     global $prev_next_actions;
     $folder_refresh = false;
     $font_families = array('monospace', 'serif', 'sans-serif', 'cursive', 'fantasy');
     if ($user->logged_in) {
         $settings = array();
         if (isset($conf['user_defaults'])) {
             $settings = $conf['user_defaults'];
         }
         if (isset($post['lang']) && isset($langs[$post['lang']])) {
             $settings['lang'] = $post['lang'];
         } else {
             $settings['lang'] = 'en_US';
         }
         if (isset($post['start_page']) && isset($start_pages[$post['start_page']])) {
             $settings['start_page'] = $post['start_page'];
         } else {
             $settings['start_page'] = 'mailbox';
         }
         if (isset($post['enable_delete_warning']) && $post['enable_delete_warning']) {
             $settings['enable_delete_warning'] = 1;
         } else {
             $settings['enable_delete_warning'] = 0;
         }
         if (isset($post['mailbox_controls_bottom']) && $post['mailbox_controls_bottom']) {
             $settings['mailbox_controls_bottom'] = 1;
         } else {
             $settings['mailbox_controls_bottom'] = 0;
         }
         if (isset($post['full_headers_default']) && $post['full_headers_default']) {
             $settings['full_headers_default'] = 1;
         } else {
             $settings['full_headers_default'] = 0;
         }
         if (isset($post['small_headers'])) {
             $settings['small_headers'] = $post['small_headers'];
         }
         if (isset($_SESSION['user_settings']['sort_by'])) {
             $settings['sort_by'] = $_SESSION['user_settings']['sort_by'];
         }
         if (isset($_SESSION['user_settings']['hidden_folders'])) {
             $settings['hidden_folders'] = $_SESSION['user_settings']['hidden_folders'];
         }
         if (isset($_SESSION['user_settings']['folder_check'])) {
             $settings['folder_check'] = $_SESSION['user_settings']['folder_check'];
         }
         if (isset($post['compose_text_format'])) {
             $settings['compose_text_format'] = $post['compose_text_format'];
         } else {
             $settings['compose_text_format'] = 0;
         }
         if (isset($post['compose_text_encoding'])) {
             $settings['compose_text_encoding'] = $post['compose_text_encoding'];
         } else {
             $settings['compose_text_encoding'] = 0;
         }
         if (isset($post['compose_window']) && $post['compose_window']) {
             $settings['compose_window'] = 1;
         } else {
             $settings['compose_window'] = 0;
         }
         if (isset($post['close_on_send']) && $post['close_on_send']) {
             $settings['close_on_send'] = 1;
         } else {
             $settings['close_on_send'] = 0;
         }
         if (isset($post['message_window']) && $post['message_window']) {
             $settings['message_window'] = 1;
         } else {
             $settings['message_window'] = 0;
         }
         if (isset($post['new_window_icon']) && $post['new_window_icon']) {
             $settings['new_window_icon'] = 1;
         } else {
             $settings['new_window_icon'] = 0;
         }
         if (isset($post['compose_hide_mailer']) && $post['compose_hide_mailer']) {
             $settings['compose_hide_mailer'] = 1;
         } else {
             $settings['compose_hide_mailer'] = 0;
         }
         if (isset($post['delete_draft']) && $post['delete_draft']) {
             $settings['delete_draft'] = 1;
         } else {
             $settings['delete_draft'] = 0;
         }
         if (isset($post['mailbox_update']) && $post['mailbox_update']) {
             $settings['mailbox_update'] = 1;
         } else {
             $settings['mailbox_update'] = 0;
         }
         if (isset($post['disable_checked_js']) && $post['disable_checked_js']) {
             $settings['disable_checked_js'] = 1;
         } else {
             $settings['disable_checked_js'] = 0;
         }
         if (isset($post['disable_list_icons']) && $post['disable_list_icons']) {
             $settings['disable_list_icons'] = 1;
         } else {
             $settings['disable_list_icons'] = 0;
         }
         if (isset($post['full_mailbox_option']) && $post['full_mailbox_option']) {
             $settings['full_mailbox_option'] = 1;
         } else {
             $settings['full_mailbox_option'] = 0;
         }
         if (isset($post['top_page_links']) && $post['top_page_links']) {
             $settings['top_page_links'] = 1;
         } else {
             $settings['top_page_links'] = 0;
         }
         if (isset($post['selective_expunge']) && $post['selective_expunge']) {
             $settings['selective_expunge'] = 1;
         } else {
             $settings['selective_expunge'] = 0;
         }
         if (isset($post['always_expunge']) && $post['always_expunge']) {
             $settings['always_expunge'] = 1;
         } else {
             $settings['always_expunge'] = 0;
         }
         if (isset($post['hide_deleted_messages']) && $post['hide_deleted_messages']) {
             $settings['hide_deleted_messages'] = 1;
         } else {
             $settings['hide_deleted_messages'] = 0;
         }
         if (isset($post['mailbox_freeze']) && $post['mailbox_freeze']) {
             $settings['mailbox_freeze'] = 1;
         } else {
             $settings['mailbox_freeze'] = 0;
             if (isset($_SESSION['frozen_folders'])) {
                 unset($_SESSION['frozen_folders']);
             }
         }
         if (isset($post['hide_folder_on_empty']) && $post['hide_folder_on_empty']) {
             $settings['hide_folder_on_empty'] = 1;
         } else {
             $settings['hide_folder_on_empty'] = 0;
         }
         if (isset($post['smtp_auth']) && in_array($post['smtp_auth'], $smtp_auth_mechs)) {
             $settings['smtp_auth'] = $post['smtp_auth'];
             if ($settings['smtp_auth'] != 'none') {
                 if (isset($post['smtp_user']) && trim($post['smtp_user']) && isset($post['smtp_pass']) && trim($post['smtp_pass'])) {
                     $settings['smtp_user'] = $post['smtp_user'];
                     $settings['smtp_pass'] = $post['smtp_pass'];
                 } else {
                     $this->errors[] = $user->str[374];
                     $settings['smtp_auth'] = 'none';
                 }
             }
         }
         $settings['font_family'] = 'monospace';
         if (in_array($post['font_family'], $font_families)) {
             $settings['font_family'] = $post['font_family'];
         }
         if (isset($conf['site_themes'][$post['theme']])) {
             $settings['theme'] = $post['theme'];
         } else {
             $settings['theme'] = 'default';
         }
         $settings['subscribed_only'] = 0;
         if (isset($post['subscribed_only'])) {
             $settings['subscribed_only'] = true;
         }
         $settings['remote_image'] = 0;
         if (isset($post['remote_image'])) {
             $settings['remote_image'] = true;
         }
         $settings['default_message_action'] = '';
         if (isset($prev_next_actions[$post['default_message_action']])) {
             $settings['default_message_action'] = $post['default_message_action'];
         }
         $settings['short_message_parts'] = 0;
         if (isset($post['short_message_parts'])) {
             $settings['short_message_parts'] = true;
         }
         $settings['html_first'] = 0;
         if (isset($post['html_first'])) {
             $settings['html_first'] = true;
         }
         $settings['hl_reply'] = 0;
         if (isset($post['hl_reply'])) {
             $settings['hl_reply'] = true;
         }
         $settings['text_email'] = 0;
         if (isset($post['text_email'])) {
             $settings['text_email'] = true;
         }
         $settings['text_links'] = 0;
         if (isset($post['text_links'])) {
             $settings['text_links'] = true;
         }
         $mailbox_per_page_count = (int) $post['mailbox_per_page_count'];
         if ($mailbox_per_page_count > $max_msg_per_page) {
             if (strstr($user->str[375], '%s')) {
                 $this->errors[] = sprintf($user->str[375], $max_msg_per_page);
             } else {
                 $this->errors[] = $user->str[375];
             }
             $mailbox_per_page_count = $max_msg_per_page;
         }
         $settings['mailbox_per_page_count'] = $mailbox_per_page_count;
         $settings['folder_style'] = $post['folder_style'];
         if (isset($post['timezone'])) {
             $settings['timezone'] = $post['timezone'];
         } else {
             $settings['timezone'] = false;
         }
         if (isset($post['trim_subject_fld']) && intval($post['trim_subject_fld'])) {
             $settings['trim_subject_fld'] = intval($post['trim_subject_fld']);
         } else {
             $settings['trim_subject_fld'] = 0;
         }
         if (isset($post['trim_from_fld']) && intval($post['trim_from_fld'])) {
             $settings['trim_from_fld'] = intval($post['trim_from_fld']);
         } else {
             $settings['trim_from_fld'] = 0;
         }
         $font_size = (int) $post['font_size'];
         if ($font_size >= 50 && $font_size <= 200) {
             $settings['font_size'] = $font_size;
         } else {
             $settings['font_size'] = 100;
         }
         $settings['image_thumbs'] = 0;
         if (isset($post['image_thumbs']) && $post['image_thumbs']) {
             $settings['image_thumbs'] = 1;
         }
         if (isset($post['display_mode']) && $post['display_mode'] == 2) {
             $settings['display_mode'] = 2;
             $hm_tags['complex'] = true;
             $hm_tags['simple'] = false;
         } else {
             $settings['display_mode'] = 1;
             $hm_tags['complex'] = false;
             $hm_tags['simple'] = true;
         }
         $settings['folder_detail'] = $post['folder_detail'];
         if (isset($post['show_folder_list']) && $post['show_folder_list']) {
             $settings['show_folder_list'] = 1;
         } else {
             if (isset($_SESSION['hide_folder_list'])) {
                 unset($_SESSION['hide_folder_list']);
             }
             $settings['show_folder_list'] = 0;
         }
         if (isset($post['disable_folder_icons']) && $post['disable_folder_icons']) {
             $settings['disable_folder_icons'] = 1;
         } else {
             $settings['disable_folder_icons'] = 0;
         }
         if (isset($post['auto_switch_simple_mode']) && $post['auto_switch_simple_mode']) {
             $settings['auto_switch_simple_mode'] = 1;
         } else {
             $settings['auto_switch_simple_mode'] = 0;
         }
         if (isset($post['expunge_on_exit']) && $post['expunge_on_exit']) {
             $settings['expunge_on_exit'] = 1;
         } else {
             $settings['expunge_on_exit'] = 0;
         }
         if (isset($post['time_format'])) {
             if (isset($time_formats[$post['time_format']])) {
                 $settings['time_format'] = $post['time_format'];
             } elseif ($post['time_format'] = 'none') {
                 $settings['time_format'] = '';
             }
         } else {
             $settings['time_format'] = 'h:i:s: A';
         }
         if (isset($post['date_format']) && isset($date_formats[$post['date_format']])) {
             $settings['date_format'] = $post['date_format'];
             if ($post['date_format'] == 'r') {
                 $settings['time_format'] = false;
             }
         } else {
             $settings['date_format'] = 'm/d/y';
         }
         if (isset($post['mailbox_date_format_2']) && isset($time_formats[$post['mailbox_date_format_2']])) {
             $settings['mailbox_date_format_2'] = $post['mailbox_date_format_2'];
         } else {
             $settings['mailbox_date_format_2'] = false;
         }
         if (isset($post['mailbox_date_format']) && (isset($date_formats[$post['mailbox_date_format']]) || $post['mailbox_date_format'] == 'h')) {
             $settings['mailbox_date_format'] = $post['mailbox_date_format'];
         } else {
             $settings['mailbox_date_format'] = 'h';
         }
         if ($settings['mailbox_date_format'] == 'h' || $settings['mailbox_date_format'] == 'r') {
             $settings['mailbox_date_format_2'] = false;
         }
         if (isset($post['sent_folder']) && $post['sent_folder']) {
             $settings['sent_folder'] = $post['sent_folder'];
             if (!isset($_SESSION['user_settings']['sent_folder']) || isset($_SESSION['user_settings']['sent_folder']) && $_SESSION['user_settings']['sent_folder'] != $settings['sent_folder']) {
                 $folder_refresh = true;
             }
         } elseif (isset($_SESSION['user_settings']['sent_folder'])) {
             $folder_refresh = true;
         }
         if (isset($post['draft_folder']) && $post['draft_folder']) {
             $settings['draft_folder'] = $post['draft_folder'];
             if (!isset($_SESSION['user_settings']['draft_folder']) || isset($_SESSION['user_settings']['draft_folder']) && $_SESSION['user_settings']['draft_folder'] != $settings['draft_folder']) {
                 $folder_refresh = true;
             }
         } elseif (isset($_SESSION['user_settings']['draft_folder'])) {
             $folder_refresh = true;
         }
         if (isset($post['trash_folder']) && $post['trash_folder']) {
             $settings['trash_folder'] = $post['trash_folder'];
             if (!isset($_SESSION['user_settings']['trash_folder']) || isset($_SESSION['user_settings']['trash_folder']) && $_SESSION['user_settings']['trash_folder'] != $settings['trash_folder']) {
                 $folder_refresh = true;
             }
         } elseif (isset($_SESSION['user_settings']['trash_folder'])) {
             $folder_refresh = true;
         }
         $settings['dropdown_ajax'] = 0;
         $settings['folder_list_ajax'] = 0;
         if (isset($post['ajax_update_interval'])) {
             $int = (int) $post['ajax_update_interval'];
             if ($int >= 30 && $int <= 1200) {
                 $settings['dropdown_ajax'] = 1;
                 $settings['ajax_update_interval'] = $int;
                 if ($settings['show_folder_list']) {
                     $settings['folder_list_ajax'] = 1;
                 }
             } else {
                 $settings['ajax_update_interval'] = 0;
             }
         }
         $settings['new_page_refresh'] = 0;
         if (isset($post['new_page_refresh'])) {
             $int = (int) $post['new_page_refresh'];
             if ($int >= 30 && $int <= 1200) {
                 $settings['new_page_refresh'] = $int;
             }
         }
         $settings['compose_autosave'] = 0;
         if (isset($post['compose_autosave'])) {
             $int = (int) $post['compose_autosave'];
             if ($int >= 60 && $int <= 1200) {
                 $settings['compose_autosave'] = $int;
             }
         }
         if (isset($_SESSION['user_settings']['folder_check'])) {
             $settings['folder_check'] = $_SESSION['user_settings']['folder_check'];
         }
         if (isset($_SESSION['user_settings']['profiles'])) {
             $settings['profiles'] = $_SESSION['user_settings']['profiles'];
         } else {
             $settings['profiles'] = array(array());
         }
         foreach ($_SESSION['user_settings'] as $i => $v) {
             if (!isset($form[$i]) && !isset($settings[$i])) {
                 $settings[$i] = $v;
             }
         }
         $_SESSION['user_settings'] = $settings;
         do_work_hook('update_settings');
         if (isset($_SESSION['plugin_settings'])) {
             foreach ($_SESSION['plugin_settings'] as $i => $v) {
                 $_SESSION['user_settings'][$i] = $v;
             }
             unset($_SESSION['plugin_settings']);
         }
         if ($folder_refresh) {
             $imap->get_folders(true);
         }
         $this->write_settings();
         foreach ($_SESSION['folders'] as $vals) {
             if (isset($_SESSION['header_cache'][$vals['name']])) {
                 $_SESSION['header_cache_refresh'][$vals['name']] = 1;
             }
             if (isset($_SESSION['uid_cache'][$vals['name']])) {
                 $_SESSION['uid_cache_refresh'][$vals['name']] = 1;
             }
         }
         $imap->get_unseen_status($_SESSION['user_settings']['folder_check']);
         $user->page_data['settings'] = $_SESSION['user_settings'];
         $user->set_timezone();
         $this->form_redirect = true;
     }
 }
Exemplo n.º 8
0
 function url_action_mailbox($get)
 {
     global $user;
     global $imap;
     global $sort_types;
     global $client_sort_types;
     global $sticky_url;
     global $sort_filters;
     global $show_all_max;
     if ($user->logged_in) {
         do_work_hook('mailbox_page_start');
         $user->page_data['labels'] = array($user->str[13], $user->str[56], $user->str[58], $user->str[57]);
         if (isset($_SESSION['just_logged_in']) && $_SESSION['just_logged_in']) {
             if (isset($_SESSION['user_settings']['folder_check'])) {
                 $imap->get_unseen_status($_SESSION['user_settings']['folder_check']);
             }
         }
         if ($user->dsp_page == 'search') {
             return $this->url_action_search($get);
         }
         $user->page_data['mailbox_link_class'] = 'current_page';
         if (isset($_SESSION['search_terms'][0]['words'])) {
             $user->page_data['mailbox_search_words'] = $_SESSION['search_terms'][0]['words'];
         } else {
             $user->page_data['mailbox_search_words'] = '';
         }
         if (isset($_SESSION['search_terms'][0]['fld'])) {
             $user->page_data['fld_id'] = $_SESSION['search_terms'][0]['fld'];
         } else {
             $user->page_data['fld_id'] = 0;
         }
         if (isset($_SESSION['search_terms'][0]['location'])) {
             $user->page_data['location_id'] = $_SESSION['search_terms'][0]['location'];
         } else {
             $user->page_data['location_id'] = 0;
         }
         if (isset($_SESSION['user_settings']['top_page_links']) && $_SESSION['user_settings']['top_page_links']) {
             $user->page_data['top_page_links'] = true;
         } else {
             $user->page_data['top_page_links'] = false;
         }
         $mailbox = 'INBOX';
         if (isset($get['mailbox'])) {
             if (isset($_SESSION['folders'][$get['mailbox']])) {
                 $mailbox = $get['mailbox'];
             } elseif ($get['mailbox'] != $_SESSION['folders']['INBOX']['name']) {
                 $this->errors[] = $user->str[11] . ': ' . $user->htmlsafe($get['mailbox']);
             }
         }
         $filter_by = 'ALL';
         if (isset($get['filter_by'])) {
             if (isset($sort_filters[$get['filter_by']])) {
                 $filter_by = $get['filter_by'];
             }
         } else {
             if (isset($_SESSION['user_settings']['hide_deleted_messages']) && $_SESSION['user_settings']['hide_deleted_messages']) {
                 $filter_by = 'UNDELETED';
             }
         }
         $user->page_data['filter_by'] = $filter_by;
         if (isset($_SESSION['user_settings']['sort_by'][$mailbox])) {
             $sort_by = $_SESSION['user_settings']['sort_by'][$mailbox];
         } else {
             $sort_by = 'ARRIVAL';
         }
         if (isset($_SESSION['session_sort'][$mailbox])) {
             $sort_by = $_SESSION['session_sort'][$mailbox];
         }
         if (isset($get['sort_by'])) {
             if (stristr($_SESSION['imap_capability'], 'SORT')) {
                 $types = $sort_types;
             } else {
                 $types = $client_sort_types;
             }
             if (isset($types[$get['sort_by']])) {
                 $sort_by = $get['sort_by'];
                 $_SESSION['session_sort'][$mailbox] = $sort_by;
             }
         }
         if (isset($_SESSION['user_settings']['sent_folder']) && $_SESSION['user_settings']['sent_folder'] == $mailbox) {
             $user->page_data['labels'][1] = $user->str[55];
         }
         $unseen_refresh = false;
         if (isset($get['track_mail'])) {
             $sticky_url = preg_replace("/\\&amp;track_mail=(1|0)/", '', $sticky_url);
             if ($get['track_mail']) {
                 if (isset($_SESSION['user_settings']['folder_check']) && is_array($_SESSION['user_settings']['folder_check'])) {
                     if (!in_array($mailbox, $_SESSION['user_settings']['folder_check'])) {
                         $folders = $_SESSION['user_settings']['folder_check'];
                         $folders[] = $mailbox;
                         usort($folders, 'new_folder_sort');
                         $_SESSION['user_settings']['folder_check'] = $folders;
                         $user->page_data['settings']['folder_check'] = $_SESSION['user_settings']['folder_check'];
                         $unseen_refresh = true;
                         $this->write_settings();
                     }
                 } else {
                     $_SESSION['user_settings']['folder_check'] = array($mailbox);
                     $user->page_data['settings']['folder_check'] = array($mailbox);
                     $user->page_data['settings']['folder_check'] = $_SESSION['user_settings']['folder_check'];
                     $this->write_settings();
                 }
             } else {
                 if (isset($_SESSION['user_settings']['folder_check']) && is_array($_SESSION['user_settings']['folder_check']) && in_array($mailbox, $_SESSION['user_settings']['folder_check'])) {
                     $new_folders = array();
                     foreach ($_SESSION['user_settings']['folder_check'] as $v) {
                         if ($v != $mailbox) {
                             $new_folders[] = $v;
                         }
                     }
                     $_SESSION['user_settings']['folder_check'] = $new_folders;
                     $user->page_data['settings']['folder_check'] = $new_folders;
                     $this->write_settings();
                 }
             }
         }
         $status = $imap->select_mailbox($mailbox, $sort_by, $unseen_refresh, false, $filter_by);
         do_work_hook('mailbox_page_selected');
         if ($status) {
             $page = 1;
             if (isset($get['mailbox_page'])) {
                 $page = (int) $get['mailbox_page'];
                 if (!$page) {
                     $page = 1;
                 }
             }
             if (isset($get['show_all_msg']) && $get['show_all_msg']) {
                 $page = 1;
                 $user->page_data['settings']['mailbox_per_page_count'] = $show_all_max;
                 if (count($_SESSION['uid_cache'][$mailbox]['uids']) > $show_all_max) {
                     $this->errors[] = 'Only displaying first ' . $show_all_max . ' messages out of ' . count($_SESSION['uid_cache'][$mailbox]['uids']);
                 }
                 $user->page_data['show_all_msg'] = 1;
             } else {
                 $user->page_data['show_all_msg'] = 0;
             }
             list($page, $uids) = $this->build_page_uids($mailbox, $page, $user->page_data['settings']['mailbox_per_page_count'], $_SESSION['uid_cache'][$mailbox]['uids']);
             $total = $_SESSION['uid_cache'][$mailbox]['total'];
             $unread = $_SESSION['folders'][$mailbox]['status']['unseen'];
             $user->page_data['mailbox_page'] = $page;
             $user->page_data['folder_unread'] = $unread;
             $user->page_data['mailbox_range'] = $user->page_data['settings']['mailbox_per_page_count'] * ($page - 1) + 1;
             if ($total < $user->page_data['mailbox_range'] - 1 + $user->page_data['settings']['mailbox_per_page_count']) {
                 $user->page_data['mailbox_range'] .= ' - ' . $total;
             } else {
                 $user->page_data['mailbox_range'] .= ' - ' . ($user->page_data['mailbox_range'] - 1 + $user->page_data['settings']['mailbox_per_page_count']);
             }
             if (!empty($uids)) {
                 /*if (!empty($_SESSION['uid_cache'][$mailbox]['thread_data'])) {
                       $total = count($_SESSION['uid_cache'][$mailbox]['threads']);
                       list($page, $uids) = $this->build_page_uids($mailbox, $page,
                       $user->page_data['settings']['mailbox_per_page_count'],
                       $_SESSION['uid_cache'][$mailbox]['threads']);
                   }*/
                 $user->page_data['header_list'] = $imap->get_mailbox_page($mailbox, $uids, $page);
                 $user->page_data['page_count'] = count($user->page_data['header_list']);
                 if (count($user->page_data['header_list']) > 14) {
                     $user->page_data['top_link'] = '<a href="' . $sticky_url . '#top">' . $user->str[186] . '</a>';
                 }
                 $user->page_data['mailbox_total'] = $_SESSION['folders'][$mailbox]['status']['messages'];
                 $user->page_data['thread_data'] = $_SESSION['uid_cache'][$mailbox]['thread_data'];
                 $user->page_data['page_links'] = build_page_links($page, $total, $user->page_data['settings']['mailbox_per_page_count'], '?page=mailbox&amp;sort_by=' . $sort_by . '&amp;filter_by=' . $filter_by . '&amp;mailbox=' . urlencode($mailbox));
             } else {
                 $user->page_data['header_list'] = array();
                 $user->page_data['page_links'] = '';
                 $user->page_data['mailbox_total'] = 0;
             }
             $user->page_data['sort_by'] = $sort_by;
             $user->page_data['mailbox'] = $mailbox;
             $user->page_data['url_mailbox'] = urlencode($mailbox);
             if ($mailbox == 'INBOX') {
                 $user->page_data['mailbox_dsp'] = $user->str[436];
             } else {
                 $user->page_data['mailbox_dsp'] = $user->htmlsafe($mailbox, 0, 0, 1);
             }
             $user->dsp_page = 'mailbox';
             if (isset($_SESSION['search_results'])) {
                 $user->page_data['search_results'] = $_SESSION['search_results'];
             }
             $user->page_data['folders'] = $_SESSION['folders'];
             $user->page_title .= ' | ' . $user->str[22] . ' |';
             if (isset($_SESSION['frozen_folders'][$mailbox])) {
                 $user->page_data['frozen_dsp'] = '<span id="frozen">(Mailbox Frozen)</span>';
             } else {
                 $user->page_data['frozen_dsp'] = '';
             }
         } else {
             $this->errors[] = $user->str[387] . ': ' . $user->htmlsafe($mailbox);
         }
     }
 }
Exemplo n.º 9
0
 function url_action_search($get)
 {
     global $user;
     global $imap;
     global $conf;
     global $sticky_url;
     if (!isset($conf['search_max'])) {
         $conf['search_max'] = 5;
     }
     if ($user->logged_in) {
         do_work_hook('search_page_start');
         if (isset($get['reset_search']) && $get['reset_search']) {
             $_SESSION['search_terms'] = array();
             $_SESSION['search_results'] = array();
             $_SESSION['search_max'] = 1;
             $_SESSION['search_total'] = 0;
         }
         if (isset($get['advanced_view']) && $get['advanced_view']) {
             $_SESSION['advanced_search'] = 1;
         }
         if (isset($get['simple_view']) && $get['simple_view']) {
             $_SESSION['advanced_search'] = 0;
         }
         $user->page_data['advanced_view'] = 0;
         if (isset($_SESSION['advanced_search']) && $_SESSION['advanced_search']) {
             $user->page_data['advanced_view'] = 1;
         }
         $user->page_data['search_flags'] = array(2 => $user->str[114], 3 => $user->str[115], 4 => $user->str[116], 5 => $user->str[117], 6 => $user->str[118], 7 => $user->str[119]);
         $user->page_data['search_start'] = 0;
         $user->page_data['search_end'] = 0;
         $user->page_data['mailbox_page'] = 1;
         $user->page_data['search_per_page'] = 1000;
         $user->page_data['search_flds'] = array(2 => $user->str[107], 3 => $user->str[108], 4 => $user->str[109], 5 => $user->str[110], 6 => $user->str[111]);
         $user->page_data['search_size_1'] = array(2 => $user->str[120], 3 => $user->str[121]);
         $user->page_data['search_date_1'] = array(1 => $user->str[431], 2 => $user->str[123], 3 => $user->str[124]);
         $user->page_data['search_size_3'] = array(1 => $user->str[125], 2 => $user->str[126], 3 => $user->str[127]);
         $user->page_data['search_date_2'] = array(1 => $user->str[131], 2 => $user->str[132], 3 => $user->str[133], 4 => $user->str[134], 5 => $user->str[135], 6 => $user->str[136], 7 => $user->str[137], 8 => $user->str[138], 9 => $user->str[139], 10 => $user->str[140], 11 => $user->str[141], 12 => $user->str[142]);
         $user->page_data['search_total'] = 0;
         $user->page_data['max_search'] = 1;
         if (isset($get['reset_results']) && $get['reset_results']) {
             $_SESSION['search_results'] = array();
             $_SESSION['search_total'] = 0;
         }
         if (isset($_SESSION['search_max'])) {
             $user->page_data['max_search'] = $_SESSION['search_max'];
         }
         if ($user->page_data['max_search'] > $conf['search_max']) {
             $this->errors[] = $user->str[386];
             $_SESSION['search_max'] = $conf['search_max'];
             $user->page_data['max_search'] = $conf['search_max'];
         }
         $user->page_data['search_results'] = array();
         $user->page_data['search_link_class'] = 'current_page';
         if (isset($_SESSION['search_total'])) {
             if ($_SESSION['search_total'] > 15) {
                 $user->page_data['top_link'] = '<br /><a href="' . $sticky_url . '#top">' . $user->str[186] . '</a>';
             }
             $user->page_data['search_total'] = $_SESSION['search_total'];
             $search_res = array();
             $ordered_res = array();
             if (isset($_SESSION['search_results'])) {
                 $per_page_count = $user->page_data['settings']['mailbox_per_page_count'];
                 $page = 1;
                 if (isset($get['mailbox_page'])) {
                     $page = (int) $get['mailbox_page'];
                     if (!$page) {
                         $page = 1;
                     }
                 }
                 if ($page > 1) {
                     $start = $page * $per_page_count + 1 - $per_page_count;
                     $end = $page * $per_page_count;
                 } else {
                     $start = 1;
                     $end = $per_page_count;
                 }
                 $user->page_data['search_start'] = $start;
                 $user->page_data['search_end'] = $end;
                 $user->page_data['mailbox_page'] = $page;
                 $user->page_data['search_per_page'] = $per_page_count;
                 foreach ($_SESSION['search_results'] as $mbx => $vals) {
                     $imap->select_mailbox($mbx, false);
                     $search_res[$mbx] = array('total' => count($vals), 'headers' => $this->sort_search_res($imap->get_mailbox_page($mbx, $vals, false)));
                     if (!empty($search_res[$mbx]['headers'])) {
                         foreach (array_reverse($search_res[$mbx]['headers']) as $atts) {
                             $ordered_res[$mbx][] = $atts['uid'];
                         }
                     }
                 }
                 $user->page_data['search_results'] = $search_res;
                 $_SESSION['search_results'] = $ordered_res;
             }
         }
         if (isset($_SESSION['search_terms'])) {
             $user->page_data['search_terms'] = $_SESSION['search_terms'];
         }
         $user->dsp_page = 'search';
         $user->page_title .= ' | ' . $user->str[9] . ' |';
         $user->page_data['folders'] = $_SESSION['folders'];
     }
 }
Exemplo n.º 10
0
 function check_session()
 {
     global $user;
     global $conf;
     global $imap;
     $imap_index = 0;
     if (isset($conf['imap_enable_proxyauth']) && $conf['imap_enable_proxyauth'] && isset($_SERVER[$conf['imap_enable_proxyauth']]) && isset($conf['imap_proxyauth_user']) && isset($_POST['login'])) {
         $plugins = get_plugins(true, true);
         do_work_hook('on_login', array(), $plugins);
         $this->login_attempt = true;
         if (isset($_POST['imap_server']) && $_POST['imap_server']) {
             $username = trim($_SERVER[$conf['imap_enable_proxyauth']]);
             $alt_servers = get_alt_servers($conf);
             if (isset($alt_servers[$_POST['imap_server']])) {
                 $imap_index = $_POST['imap_server'];
                 $vals = $alt_servers[$_POST['imap_server']];
                 foreach ($vals as $i => $v) {
                     $name = substr($i, 5);
                     $imap->{$name} = $v;
                 }
             }
         } else {
             if ($user->append_login_domain && !strstr($_SERVER[$conf['imap_enable_proxyauth']], '@')) {
                 if (isset($conf['percent_d_host']) && trim($conf['percent_d_host']) && strstr($user->append_login_domain, '%d')) {
                     $domain = $user->get_domain($conf['host_name'], $conf['percent_d_host']);
                     $user->append_login_domain = str_replace('%d', $domain, $user->append_login_domain);
                 }
                 $username = $_SERVER[$conf['imap_enable_proxyauth']] . '@' . $user->append_login_domain;
             } else {
                 $username = $_SERVER[$conf['imap_enable_proxyauth']];
             }
         }
         $pass = $conf['imap_proxyauth_pass'];
         if (isset($conf['trim_login_fields']) && $conf['trim_login_fields']) {
             $username = trim($username);
             $pass = trim($pass);
         }
         if ($this->do_auth($username, $pass, $conf['imap_proxyauth_user'])) {
             $this->start_session();
             $this->logged_in = true;
             $_SESSION['imap_index'] = $imap_index;
             $_SESSION['user_data'] = array('username' => $username);
             $this->just_logged_in = true;
         }
     } elseif (isset($_POST['user']) && isset($_POST['pass']) && isset($_POST['login'])) {
         $plugins = get_plugins(true, true);
         do_work_hook('on_login', array(), $plugins);
         $this->login_attempt = true;
         if (isset($_POST['imap_server']) && $_POST['imap_server']) {
             $username = trim($_POST['user']);
             $alt_servers = get_alt_servers($conf);
             if (isset($alt_servers[$_POST['imap_server']])) {
                 $imap_index = $_POST['imap_server'];
                 $vals = $alt_servers[$_POST['imap_server']];
                 foreach ($vals as $i => $v) {
                     $name = substr($i, 5);
                     $imap->{$name} = $v;
                 }
             }
         } else {
             if ($user->append_login_domain && !strstr($_POST['user'], '@')) {
                 if (isset($conf['percent_d_host']) && trim($conf['percent_d_host']) && strstr($user->append_login_domain, '%d')) {
                     $domain = $user->get_domain($conf['host_name'], $conf['percent_d_host']);
                     $user->append_login_domain = str_replace('%d', $domain, $user->append_login_domain);
                 }
                 $username = $_POST['user'] . '@' . $user->append_login_domain;
             } else {
                 $username = $_POST['user'];
             }
         }
         $pass = $_POST['pass'];
         if (isset($conf['trim_login_fields']) && $conf['trim_login_fields']) {
             $username = trim($username);
             $pass = trim($pass);
         }
         if ($this->do_auth($username, $pass, false)) {
             $this->start_session();
             $this->logged_in = true;
             $_SESSION['imap_index'] = $imap_index;
             $_SESSION['user_data'] = array('username' => $username, 'pass' => $user->string_crypt($pass));
             $this->just_logged_in = true;
         }
     } elseif (isset($_GET['page']) && $_GET['page'] == 'logout') {
         $this->logout = true;
         $this->continue_session();
     } elseif (!$this->login_attempt) {
         if ($user->use_cookies && isset($_COOKIE[$this->cookie_name])) {
             $this->continue_session();
         } elseif (!$user->use_cookies) {
             if (isset($_REQUEST['PHPSESSID'])) {
                 session_id($_REQUEST['PHPSESSID']);
                 $this->continue_session();
             }
         }
     }
     if (isset($_SESSION['imap_index'])) {
         if ($_SESSION['imap_index'] > 0) {
             $tmp_conf = $conf;
             foreach ($tmp_conf as $i => $v) {
                 if (preg_match('/alt_' . $_SESSION['imap_index'] . '/', $i)) {
                     $conf[substr($i, 6)] = $v;
                 }
             }
         }
     }
 }
Exemplo n.º 11
0
 function url_action_not_found($get)
 {
     global $user;
     $user->dsp_page = 'not_found';
     $user->page_title .= ' | Not Found |';
     $user->page_data['top_link'] = '';
     if ($user->logged_in) {
         do_work_hook('not_found_start');
         $user->page_data['folders'] = $_SESSION['folders'];
     }
 }
Exemplo n.º 12
0
 function get_quick_list($sort = 'sort_name', $page = 1, $source = 'local', $filter = false, $page_size = false, $filter_regex = false, $groups = true)
 {
     global $contacts_per_page;
     if (!$page_size) {
         $page_size = $contacts_per_page;
     }
     $_SESSION['contact_sources'] = array(array('title' => 'Personal Addressbook', 'source' => 'local'));
     do_work_hook('register_contacts_source');
     if (!$filter && isset($_SESSION['active_contact_source']) && $_SESSION['active_contact_source'] === $source && isset($_SESSION['contact_list']) && isset($_SESSION['contact_list_page']) && $_SESSION['contact_list_page'] == $page) {
         $res = $_SESSION['contact_list'];
     } else {
         $res = array();
         if (empty($this->card_list)) {
             $this->get_card_list();
         }
         foreach ($this->card_list as $id => $vals) {
             $email = array();
             $last_name = '';
             $name = '';
             foreach ($vals as $atts) {
                 if ($atts['name'] == 'EMAIL') {
                     $email[] = $atts['value'];
                 }
                 if ($atts['group'] == 'N' && $atts['name'] == 'FAMILY') {
                     $lastname = $atts['value'];
                 }
                 if ($atts['name'] == 'FN') {
                     $name = $atts['value'];
                 }
             }
             if (!empty($email)) {
                 foreach ($email as $v) {
                     $res[] = array('source' => 'local', 'email' => $v, 'last_name' => $last_name, 'name' => $name, 'id' => $id);
                 }
             }
         }
         if ($groups && isset($this->card_groups) && is_array($this->card_groups)) {
             foreach ($this->card_groups as $v) {
                 $res[] = array('source' => 'local', 'email' => '&lt;' . join('&gt;, &lt;', $this->get_group_email_list($v)) . '&gt;', 'name' => $v, 'id' => $v);
             }
         }
         $_SESSION['quick_list'] = array();
         if ($filter) {
             foreach ($res as $vals) {
                 if ($filter_regex) {
                     if (preg_match("/" . $filter . "/i", $vals['email']) || preg_match("/" . $filter . "/i", $vals['name'])) {
                         $_SESSION['quick_list'][] = $vals;
                     }
                 } else {
                     if (stristr($vals['email'], $filter) || stristr($vals['name'], $filter)) {
                         $_SESSION['quick_list'][] = $vals;
                     }
                 }
             }
         } else {
             $_SESSION['quick_list'] = $res;
         }
         if ($source !== 'local') {
             do_work_hook('compose_contact_list', array($filter, $filter_regex));
         }
         $res = $_SESSION['quick_list'];
         unset($_SESSION['quick_list']);
         if ($source) {
             $temp = array();
             foreach ($res as $vals) {
                 if ($vals['source'] == $source) {
                     $temp[] = $vals;
                 }
             }
             $res = $temp;
         }
         usort($res, array($this, $sort));
         $total = count($res);
         $_SESSION['contact_list_total'] = $total;
         if ($page > 1) {
             $res = array_slice($res, $page_size * ($page - 1), $page_size);
         } elseif ($page) {
             $res = array_slice($res, 0, $page_size);
         }
     }
     $_SESSION['contact_list'] = $res;
     $_SESSION['contact_list_page'] = $page;
     $_SESSION['active_contact_source'] = $source;
     if (!isset($total)) {
         $total = $_SESSION['contact_list_total'];
     }
     return array($res, $total);
 }
Exemplo n.º 13
0
 function url_action_message($get)
 {
     global $sort_types;
     global $client_sort_types;
     global $max_read_length;
     global $user;
     global $imap;
     global $include_path;
     global $message_part_types;
     global $override_missing_mime_header;
     global $add_contact_headers;
     global $conf;
     global $sort_filters;
     global $fd;
     global $sticky_url;
     $user->page_data['top_link'] = '<a href="' . $sticky_url . '#top">' . $user->str[186] . '</a>';
     if ($user->logged_in) {
         if (isset($_SESSION['iframe_content']) && $_SESSION['iframe_content'] && isset($get['inline_html']) && $get['inline_html']) {
             ob_clean();
             echo $_SESSION['iframe_content'];
             unset($_SESSION['iframe_content']);
             exit;
         }
         do_work_hook('message_page_start');
         $user->page_data['unseen_uids'] = 0;
         $user->page_data['show_previous_options'] = 0;
         $user->page_data['show_up_options'] = 0;
         $user->page_data['show_next_options'] = 0;
         $user->page_data['full_header'] = -1;
         $user->page_data['full_part_header'] = -1;
         $user->page_data['message_part_headers'] = array();
         $user->page_data['sort_filters'] = array('ALL' => 'All messages', 'UNSEEN' => 'Unread', 'SEEN' => 'Read', 'FLAGGED' => 'Flagged', 'UNFLAGGED' => 'Unflagged', 'ANSWERED' => 'Answered', 'UNANSWERED' => 'Unanswered', 'DELETED' => 'Deleted', 'UNDELETED' => 'Not Deleted');
         $user->page_data['message_link_class'] = 'current_page';
         $mailbox = false;
         if (isset($get['mailbox'])) {
             if (isset($_SESSION['folders'][$get['mailbox']])) {
                 $mailbox = $get['mailbox'];
             }
         }
         if (isset($get['full_part_header'])) {
             $user->page_data['full_part_header'] = intval($get['full_part_header']);
         }
         if (isset($get['full_header'])) {
             $user->page_data['full_header'] = intval($get['full_header']);
         }
         if (isset($get['find_response']) && isset($get['current_uid']) && isset($get['response_id'])) {
             $uid = false;
             if (isset($_SESSION['user_settings']['sent_folder'])) {
                 $select_res = $imap->select_mailbox($_SESSION['user_settings']['sent_folder'], false, false, true);
                 if ($select_res) {
                     $search_res = $imap->simple_search('header in-reply-to', false, $get['response_id']);
                     if (isset($search_res[0])) {
                         $get['uid'] = $search_res[0];
                         $uid = $get['uid'];
                         $mailbox = $_SESSION['user_settings']['sent_folder'];
                         $_GET['mailbox'] = $mailbox;
                         $this->errors[] = $user->str[388];
                     }
                 }
             }
             if (!$uid) {
                 $get['uid'] = $get['current_uid'];
                 $this->errors[] = $user->str[389];
             }
         }
         if ($mailbox && isset($get['uid'])) {
             if (isset($_SESSION['frozen_folders'][$mailbox])) {
                 $user->page_data['frozen_dsp'] = '<span id="frozen">(Mailbox Frozen)</span>';
             } else {
                 $user->page_data['frozen_dsp'] = '';
             }
             $id = (int) $get['uid'];
             if ($id) {
                 $sort_by = 'ARRIVAL';
                 if (isset($get['sort_by'])) {
                     if (stristr($_SESSION['imap_capability'], 'SORT')) {
                         $types = $sort_types;
                     } else {
                         $types = $client_sort_types;
                     }
                     if (isset($types[$get['sort_by']])) {
                         $sort_by = $get['sort_by'];
                     }
                 }
                 $filter_by = 'ALL';
                 if (isset($get['filter_by'])) {
                     if (isset($sort_filters[$get['filter_by']])) {
                         $filter_by = $get['filter_by'];
                     }
                 }
                 $user->page_data['filter_by'] = $filter_by;
                 $user->page_data['sort_by'] = $sort_by;
                 if ($imap->select_mailbox($mailbox, $sort_by, false, true, $filter_by)) {
                     do_work_hook('message_page_selected');
                     $user->page_data['mailbox'] = $mailbox;
                     if ($mailbox == 'INBOX') {
                         $user->page_data['mailbox_dsp'] = $user->str[436];
                     } else {
                         $user->page_data['mailbox_dsp'] = $user->htmlsafe($mailbox, 0, 0, 1);
                     }
                     $user->page_data['url_mailbox'] = urlencode($mailbox);
                     if ((!isset($get['show_all_mp']) || !$get['show_all_mp']) && isset($_SESSION['user_settings']['short_message_parts']) && $_SESSION['user_settings']['short_message_parts']) {
                         if (isset($_SESSION['user_settings']['html_first']) && $_SESSION['user_settings']['html_first']) {
                             $mfilter = 'html';
                         } else {
                             $mfilter = 'plain';
                         }
                     } else {
                         $mfilter = false;
                     }
                     if (!isset($get['show_all_mp']) || !$get['show_all_mp']) {
                         $user->page_data['show_all_mp'] = false;
                     } else {
                         $user->page_data['show_all_mp'] = true;
                     }
                     if ($mfilter) {
                         list($struct, $user->page_data['filtered_mp']) = $imap->get_message_structure($id, $mfilter);
                     } else {
                         $user->page_data['filtered_mp'] = 0;
                         $struct = $imap->get_message_structure($id);
                     }
                     $flat_list = $this->get_flat_part_list($struct);
                     $user->page_data['part_nav_list'] = $flat_list;
                     if (isset($get['message_part'])) {
                         $mpart = $get['message_part'];
                     } else {
                         $mpart = 0;
                     }
                     $sort_by = 'ARRIVAL';
                     if (!isset($get['show_image']) && !isset($get['download']) || isset($get['framed_part'])) {
                         $user->page_data['full_message_headers'] = $imap->get_message_headers($id, false);
                     }
                     if ($override_missing_mime_header) {
                         $struct = $this->override_missing_mime_header($struct, $user->page_data['full_message_headers']);
                     }
                     if (isset($_SESSION['user_settings']['html_first']) && $_SESSION['user_settings']['html_first']) {
                         list($message_data, $viewable) = $this->find_message_part($struct, $mpart, 'text', 'html');
                         if (empty($message_data) && !empty($viewable)) {
                             list($message_data, $viewable) = $this->find_message_part($struct, $viewable[0]);
                         }
                     } else {
                         list($message_data, $viewable) = $this->find_message_part($struct, $mpart, 'text', 'plain');
                         if (empty($message_data) && !empty($viewable)) {
                             list($message_data, $viewable) = $this->find_message_part($struct, $viewable[0]);
                         }
                     }
                     if (isset($get['raw_view']) && $get['raw_view']) {
                         $raw = 1;
                         $message_data['imap_id'] = 0;
                         $message_data['type'] = 'text';
                         $message_data['subtype'] = 'plain';
                     } else {
                         $raw = 0;
                     }
                     if (empty($message_data) && !empty($user->page_data['full_message_headers'])) {
                         $message_data['imap_id'] = 0;
                         $message_data['type'] = 'text';
                         $message_data['subtype'] = 'plain';
                         $user->page_data['broken_msg'] = true;
                     }
                     $user->page_data['raw_view'] = $raw;
                     $user->page_data['message_struct'] = $struct;
                     $user->page_data['message_uid'] = $id;
                     $user->page_data['message_part'] = $mpart;
                     $count = $_SESSION['uid_cache'][$mailbox]['total'];
                     $page = 1;
                     if (isset($get['mailbox_page'])) {
                         $page = (int) $get['mailbox_page'];
                         if (!$page) {
                             $page = 1;
                         }
                     }
                     $user->page_data['previous_uid'] = false;
                     $user->page_data['uid_index'] = false;
                     $user->page_data['next_uid'] = false;
                     for ($i = 0; $i < $count; $i++) {
                         if ($id == $_SESSION['uid_cache'][$mailbox]['uids'][$i]) {
                             $page = floor($i / $user->page_data['settings']['mailbox_per_page_count']) + 1;
                             $user->page_data['uid_index'] = $i;
                             if (isset($_SESSION['uid_cache'][$mailbox]['uids'][$i + 1])) {
                                 $user->page_data['next_uid'] = $_SESSION['uid_cache'][$mailbox]['uids'][$i + 1];
                                 $user->page_data['next_uid_page'] = floor(($i + 1) / $user->page_data['settings']['mailbox_per_page_count']) + 1;
                             }
                             if (isset($_SESSION['uid_cache'][$mailbox]['uids'][$i - 1])) {
                                 $user->page_data['previous_uid'] = $_SESSION['uid_cache'][$mailbox]['uids'][$i - 1];
                                 $user->page_data['prev_uid_page'] = floor(($i - 1) / $user->page_data['settings']['mailbox_per_page_count']) + 1;
                             }
                             break;
                         }
                     }
                     $user->page_data['show_small_headers'] = 0;
                     $user->page_data['show_full_headers'] = 0;
                     if (isset($get['full_headers']) && $get['full_headers']) {
                         $user->page_data['show_full_headers'] = 1;
                     } elseif (isset($get['small_headers']) && $get['small_headers']) {
                         $user->page_data['show_small_headers'] = 1;
                     }
                     if (!empty($message_data)) {
                         $user->page_data['message_part'] = $message_data['imap_id'];
                         $type = strtolower($message_data['type'] . '/' . $message_data['subtype']);
                         $user->page_data['charset'] = 'us-ascii';
                         if (isset($message_data['charset'])) {
                             $user->page_data['charset'] = strtolower($message_data['charset']);
                         }
                         $user->page_data['raw_message_type'] = $type;
                         if (isset($message_part_types[$type]) || isset($get['download'])) {
                             $user->page_data['message_type'] = false;
                             if (isset($message_part_types[$type])) {
                                 $user->page_data['message_type'] = $message_part_types[$type];
                             }
                             if (isset($get['show_image']) && strtolower($message_data['type'] == 'image')) {
                                 $data = $imap->get_message_part($id, $message_data['imap_id']);
                                 if (isset($message_data['encoding']) && strtolower($message_data['encoding']) == 'base64') {
                                     $data = base64_decode($data);
                                 } elseif (isset($message_data['encoding']) && strtolower($message_data['encoding']) == 'quoted-printable') {
                                     $data = quoted_printable_decode($data);
                                 }
                                 ob_end_clean();
                                 if ($data) {
                                     if (isset($get['thumbnail']) && $get['thumbnail'] && function_exists('imagecreatefromstring')) {
                                         $im = @imagecreatefromstring($data);
                                         $width = imagesx($im);
                                         $height = imagesy($im);
                                         $max_width = 80;
                                         $max_height = 60;
                                         if ($width > $max_width) {
                                             $new_width = $max_width;
                                             $new_height = $new_width * $height / $width;
                                             if ($new_height > $max_height) {
                                                 $new_height = $max_height;
                                                 $new_width = $new_height * $width / $height;
                                             }
                                         } elseif ($height > $max_height) {
                                             $new_height = $max_height;
                                             $new_width = $new_height * $width / $height;
                                         } else {
                                             $new_height = $height;
                                             $new_width = $width;
                                         }
                                         if (!$new_height || !$new_width) {
                                             $new_height = 50;
                                             $new_width = 50;
                                         }
                                         $im2 = @imagecreatetruecolor($new_width, $new_height);
                                         if ($im2 !== false && $im !== false) {
                                             imagecolortransparent($im2, imagecolorallocate($im2, 0, 0, 0));
                                             imagealphablending($im2, false);
                                             imagesavealpha($im2, true);
                                             imagecopyresampled($im2, $im, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
                                             imagepng($im2);
                                         }
                                         $imap->disconnect();
                                         $user->clean_up();
                                         exit;
                                     }
                                     $size = (int) $message_data['size'];
                                     header("Content-Type: " . $type);
                                     header("Content-Length: " . strlen($data));
                                     echo $data;
                                     $imap->disconnect();
                                     $user->clean_up();
                                     exit;
                                 }
                             } elseif (isset($get['framed_part'])) {
                                 if (isset($message_data['filename']) && $message_data['filename']) {
                                     $name = $message_data['filename'];
                                 } elseif (isset($message_data['name']) && $message_data['name']) {
                                     $name = $message_data['name'];
                                 } else {
                                     $name = 'message_' . $message_data['imap_id'];
                                 }
                                 $exten = get_mimetype_extension($type);
                                 if (strtolower(substr($name, -4)) != $exten) {
                                     $name .= $exten;
                                 }
                                 $encoding = false;
                                 if (isset($message_data['encoding']) && strtolower($message_data['encoding']) == 'base64') {
                                     $encoding = 'base64_decode';
                                 } elseif (isset($message_data['encoding']) && strtolower($message_data['encoding'] == 'quoted-printable')) {
                                     $encoding = 'quoted_decode';
                                 }
                                 $left_over = '';
                                 $read_size = 0;
                                 $lit_size = $imap->get_message_part_start($id, $message_data['imap_id']);
                                 header("Content-Type: {$type}");
                                 header('Content-Transfer-Encoding: binary');
                                 header('Accept-Ranges: bytes');
                                 header("Pragma: public");
                                 header("Expires: 0");
                                 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                                 ob_end_clean();
                                 while ($data = $imap->get_message_part_line()) {
                                     $read_size += strlen($data);
                                     if ($read_size > $lit_size) {
                                         $extra = $read_size - $lit_size;
                                         if (strlen($data) > $extra) {
                                             $data = substr($data, 0, strlen($data) - $extra);
                                         } else {
                                             $data = false;
                                         }
                                     }
                                     if ($data && $encoding == 'base64_decode') {
                                         $data = base64_decode($data);
                                     } elseif ($data && $encoding == 'quoted_decode') {
                                         $data = $user->user_action->quoted_decode($data);
                                     }
                                     if ($data) {
                                         echo $data;
                                         flush();
                                     }
                                     $data = false;
                                 }
                                 $imap->disconnect();
                                 $user->clean_up();
                                 exit;
                             } elseif (isset($get['download'])) {
                                 if (isset($message_data['filename']) && $message_data['filename']) {
                                     $name = $message_data['filename'];
                                 } elseif (isset($message_data['name']) && $message_data['name']) {
                                     $name = $message_data['name'];
                                 } else {
                                     $name = 'message_' . $message_data['imap_id'];
                                 }
                                 $exten = get_mimetype_extension($type);
                                 if (strtolower(substr($name, -4)) != $exten) {
                                     $name .= $exten;
                                 }
                                 $encoding = false;
                                 if (isset($message_data['encoding']) && strtolower($message_data['encoding']) == 'base64') {
                                     $encoding = 'base64_decode';
                                 } elseif (isset($message_data['encoding']) && strtolower($message_data['encoding'] == 'quoted-printable')) {
                                     $encoding = 'quoted_decode';
                                 }
                                 $left_over = '';
                                 $read_size = 0;
                                 $lit_size = $imap->get_message_part_start($id, $message_data['imap_id']);
                                 header("Content-Type: text");
                                 //$type");
                                 header('Content-Transfer-Encoding: binary');
                                 header('Accept-Ranges: bytes');
                                 if (isset($message_data['att_size']) && intval($message_data['att_size']) > 0) {
                                     header('Content-Length: ' . $message_data['att_size']);
                                 } elseif (!$encoding && intval($lit_size) > 0) {
                                     header('Content-Length: ' . $lit_size);
                                 }
                                 header("Pragma: public");
                                 header("Expires: 0");
                                 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                                 header('Content-Disposition: attachment; filename="' . $name . '"');
                                 ob_end_clean();
                                 while ($data = $imap->get_message_part_line()) {
                                     $read_size += strlen($data);
                                     if ($read_size > $lit_size) {
                                         $extra = $read_size - $lit_size;
                                         if (strlen($data) > $extra) {
                                             $data = substr($data, 0, strlen($data) - $extra);
                                         } else {
                                             $data = false;
                                         }
                                     }
                                     if ($data && $encoding == 'base64_decode') {
                                         $data = base64_decode($data);
                                     } elseif ($data && $encoding == 'quoted_decode') {
                                         $data = $user->user_action->quoted_decode($data);
                                     }
                                     if ($data) {
                                         echo $data;
                                     }
                                     $data = false;
                                 }
                                 $imap->disconnect();
                                 $user->clean_up();
                                 ob_flush();
                                 flush();
                                 exit;
                             } else {
                                 /*if (isset($_SESSION['header_cache'][$mailbox][$page][$id]['flags'])) {
                                       if (!stristr($_SESSION['header_cache'][$mailbox][$page][$id]['flags'], 'seen')) {
                                           if (isset($_SESSION['folders'][$mailbox]['status']['unseen']) && $_SESSION['folders'][$mailbox]['status']['unseen'] > 0) {
                                               $_SESSION['folders'][$mailbox]['status']['unseen'] -= 1;
                                               $user->page_data['folders'] = $_SESSION['folders'];
                                           }
                                       }
                                       if (!stristr($_SESSION['header_cache'][$mailbox][$page][$id]['flags'], 'Seen')) {
                                           $_SESSION['header_cache'][$mailbox][$page][$id]['flags'] .= ' \Seen';
                                           if (isset($_SESSION['total_unread']) && $_SESSION['total_unread'] > 0 &&
                                               isset($_SESSION['user_settings']['folder_check']) && is_array($_SESSION['user_settings']['folder_check']) &&
                                               in_array($mailbox, $_SESSION['user_settings']['folder_check'])) {
                                               $_SESSION['total_unread']--;
                                           }
                                       }
                                   }*/
                                 if (!isset($user->page_data['full_message_headers'])) {
                                     $user->page_data['full_message_headers'] = $imap->get_message_headers($id, false);
                                 }
                                 $user->page_data['message_headers'] = $this->prep_headers($user->page_data['full_message_headers']);
                                 if (!$user->page_data['charset']) {
                                     foreach ($user->page_data['message_headers'] as $vals) {
                                         if (strtolower($vals[0]) == 'content-type') {
                                             if (preg_match("/charset=([^\\s;]+)/", $vals[1], $matches)) {
                                                 $user->page_data['charset'] = trim(str_replace(array("'", '"'), '', $matches[1]));
                                             }
                                             break;
                                         }
                                     }
                                 }
                                 if (count($user->page_data['part_nav_list']) > 1) {
                                     $parent_id = 0;
                                     foreach ($flat_list as $vals) {
                                         if ($vals[0] == $message_data['imap_id'] && $vals[1]) {
                                             $parent_id = $vals[1];
                                             break;
                                         }
                                     }
                                     if ($parent_id && $parent_id != 1) {
                                         $user->page_data['message_part_headers'] = $this->prep_headers($imap->get_message_headers($id, $parent_id));
                                     }
                                 }
                                 if ($raw) {
                                     $user->page_data['message_data'] = $imap->get_message_part($id, false, $raw, $max_read_length);
                                     if (isset($user->page_data['message_part_headers'])) {
                                         unset($user->page_data['message_part_headers']);
                                     }
                                     $user->page_data['part_nav_list'] = array();
                                 } elseif ($message_part_types[$type] == 'text' || $message_part_types[$type] == 'html') {
                                     $user->page_data['message_data'] = $imap->get_message_part($id, $message_data['imap_id'], $raw, $max_read_length);
                                     if ($imap->max_read) {
                                         $this->errors[] = $user->str[390];
                                         $imap->max_read = false;
                                     }
                                     if ($message_part_types[$type] == 'html') {
                                         if (isset($get['show_external_images'])) {
                                             if ($get['show_external_images']) {
                                                 $user->page_data['show_external_images'] = true;
                                             } else {
                                                 $user->page_data['show_external_images'] = false;
                                             }
                                         }
                                     }
                                     if (!$raw) {
                                         if (isset($message_data['encoding']) && strtolower($message_data['encoding']) == 'base64') {
                                             $user->page_data['message_data'] = base64_decode($user->page_data['message_data']);
                                         } elseif (isset($message_data['encoding']) && strtolower($message_data['encoding'] == 'quoted-printable')) {
                                             $user->page_data['message_data'] = $user->user_action->quoted_decode($user->page_data['message_data']);
                                         }
                                     }
                                     if (isset($conf['html_message_iframe']) && $conf['html_message_iframe'] && $message_part_types[$type] == 'html') {
                                         if ($user->sub_class_names['url']) {
                                             $class_name = 'site_page_' . $user->sub_class_names['url'];
                                             $pd = hm_new($class_name);
                                         } else {
                                             $pd = hm_new('site_page');
                                         }
                                         $_SESSION['iframe_content'] = $pd->print_message_iframe_content();
                                     }
                                     if (strstr($type, 'x-vcard')) {
                                         require_once $include_path . 'lib' . $fd . 'vcard.php';
                                         $vcard = hm_new('vcard');
                                         $vcard->import_card(explode("\r\n", $user->page_data['message_data']));
                                         if (is_array($vcard->card) && !empty($vcard->card)) {
                                             $user->page_data['card_detail'] = $vcard->card;
                                             $_SESSION['import_card_detail'] = $vcard->card;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if (!isset($user->page_data['full_message_headers'])) {
                         $user->page_data['full_message_headers'] = $imap->get_message_headers($id, false);
                     }
                     if (!isset($user->page_data['charset'])) {
                         $user->page_data['charset'] = false;
                         if (isset($user->page_data['message_headers'])) {
                             foreach ($user->page_data['message_headers'] as $vals) {
                                 if (strtolower($vals[0]) == 'content-type') {
                                     if (preg_match("/charset=([^ ]+)/", $vals[1], $matches)) {
                                         $user->page_data['charset'] = trim(str_replace(array("'", '"'), '', $matches[1]));
                                     }
                                     break;
                                 }
                             }
                         }
                     }
                     $user->page_data['mailbox_page'] = $page;
                     $user->page_data['mailbox_total'] = $_SESSION['uid_cache'][$mailbox]['total'];
                     $user->page_data['page_links'] = build_page_links($page, $_SESSION['uid_cache'][$mailbox]['total'], $user->page_data['settings']['mailbox_per_page_count'], '?page=mailbox&amp;sort_by=' . $sort_by . '&amp;filter_by=' . $filter_by . '&amp;mailbox=' . urlencode($mailbox), $user->str[88]);
                     $user->dsp_page = 'message';
                     $_SESSION['last_message_read'][$mailbox] = $id;
                     if (isset($get['print_view']) && $get['print_view']) {
                         ob_clean();
                         if ($user->sub_class_names['url']) {
                             $class_name = 'site_page_' . $user->sub_class_names['url'];
                             $pd = hm_new($class_name);
                         } else {
                             $pd = hm_new('site_page');
                         }
                         echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                           <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
                             <head><title>Message Print View</title><base href="' . $pd->pd['base_href'] . '" /><title id="title">' . $pd->user->page_title . '</title>
                             <style type="text/css">table {padding:10px;margin-left:-10px;padding-bottom:20px;}
                             b{font-weight: normal;} table td {padding-left:10px;} table th {text-align:left;font-weight:normal;}
                             pre {white-space: pre-wrap; white-space: -moz-pre-wrap !important; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;}
                             </style></head>
                         <body style="background: none; background-image: none; background-color: #fff; color: #000; margin: 30px;">' . '<table>' . $pd->print_message_headers() . '</table>';
                         if (isset($pd->pd['message_part_headers'])) {
                             '<table>' . $pd->print_part_headers() . '</table>';
                         }
                         //$pd->pd['raw_view'] = true;
                         switch ($user->page_data['message_type']) {
                             case 'text':
                             case 'image':
                             case 'html':
                                 echo $pd->{'print_message_' . $user->page_data['message_type']}();
                                 break;
                             default:
                                 echo '<div style="text-align: center; margin-top: 100px;">Unsupported MIME type: ' . $user->htmlsafe($user->page_data['raw_message_type']) . '</div>';
                                 break;
                         }
                         echo '
                     </body>
                     </html>';
                         exit;
                     }
                     if (isset($get['show_up_options'])) {
                         $user->page_data['show_up_options'] = 1;
                     }
                     if (isset($get['show_next_options'])) {
                         $user->page_data['show_next_options'] = 1;
                     }
                     if (isset($get['show_previous_options'])) {
                         $user->page_data['show_previous_options'] = 1;
                     }
                     $new_contacts = array();
                     if (isset($user->page_data['full_message_headers'])) {
                         foreach ($user->page_data['full_message_headers'] as $vals) {
                             $i = $vals[0];
                             $v = $vals[1];
                             if (!in_array(strtolower($i), $add_contact_headers)) {
                                 continue;
                             }
                             if (strstr($v, ' ')) {
                                 $bits = explode(' ', trim($v));
                             } elseif (strstr($v, ',')) {
                                 $bits = explode(',', trim($v));
                             } else {
                                 $bits = array($v);
                             }
                             foreach ($bits as $val) {
                                 $val = rtrim(ltrim($val, '<,'), '>,');
                                 if ($this->match_email($val)) {
                                     $new_contacts[] = $val;
                                 }
                             }
                         }
                     }
                     $user->page_data['new_contacts'] = $new_contacts;
                     list($total_unread, $user->page_data['unseen_uids']) = $imap->get_mailbox_unseen($mailbox);
                     if ($total_unread) {
                         $user->page_data['unseen_uids'][] = $user->page_data['message_uid'];
                         $user->page_data['unseen_uids'] = $this->sort_uid_list($user->page_data['unseen_uids'], $mailbox);
                     }
                     if (isset($_SESSION['search_results'][$mailbox])) {
                         $user->page_data['search_results'] = $this->sort_uid_list($_SESSION['search_results'][$mailbox], $mailbox);
                     }
                     if (isset($_SESSION['uid_cache'][$mailbox]['thread_data'])) {
                         $user->page_data['thread_data'] = $_SESSION['uid_cache'][$mailbox]['thread_data'];
                     }
                     $user->page_data['folders'] = $_SESSION['folders'];
                     $user->page_title .= ' | Message |';
                 }
             }
         }
     }
 }
Exemplo n.º 14
0
   request we do not return from the handle_client_request call, it outputs
   the ajax response. */
if ($user->ajax_enabled && isset($_POST['rs'])) {
    require_once $include_path . 'lib' . $fd . 'ajax_functions.php';
    handle_client_request();
}
/* Counter for the new page, only reset on non-ajax requests */
$_SESSION['new_page_refresh_count'] = 0;
/* Clean up IMAP communication. At this point all the work that needs to be done
   for this request is complete. */
if ($imap->connected) {
    $imap->disconnect();
}
/* Do a handy work hook. This is a good way for plugins to get access to the completed
   data for a page request before the XHTML is built. */
do_work_hook('page_end');
/* Build the XHTML and sent it to the browser 
----------------------------------------------------------------*/
/* Setup template data. The code is broken out into multiple includes to keep
   the application memory footprint smaller. */
if ($user->sub_class_names['url']) {
    $class_name = 'site_page_' . $user->sub_class_names['url'];
    $pd = hm_new($class_name);
} else {
    $pd = hm_new('site_page');
}
/* Build the page XHTML. The resulting page is constructed but not sent to the browser yet */
build_page($pd);
/* Filter the output XHTML for the current display mode, and send it to the browser */
output_filtered_content($hm_tags);
/* IMAP debug. Outputs debug information below the page if the show_imap_debug setting