Пример #1
0
function clean_from($string)
{
    global $user;
    $return = $string;
    if (!trim($string)) {
        return 'No From';
    } else {
        $string = str_replace(';', ',', $string);
        if (!strstr($string, ',')) {
            if (strstr($string, '<')) {
                $return = trim(str_replace('"', '', preg_replace("/\\<[^>]+\\>/", '', $string)));
            }
            if (!$return) {
                $return = $string;
            }
        } else {
            $parts = explode(',', $string);
            $res = array();
            foreach ($parts as $i => $part) {
                $res[] = clean_from($part);
            }
            if (count($res) > 0) {
                $return = join(', ', $res);
            }
        }
    }
    return str_replace(array('<', '>', '"'), '', $return);
}
Пример #2
0
 function print_mailbox_list_rows($cols, $rows, $onclick, $mailbox, $n = 1, $ignore_sent = false)
 {
     global $page_id;
     $data = '';
     $search_res = array();
     $date_format_2 = false;
     $c_start = '<complex-' . $page_id . '>';
     $c_end = '</complex-' . $page_id . '>';
     $td_end = $c_start . '</td>' . $c_end;
     $s_start = '<simple-' . $page_id . '>';
     $s_end = '</simple-' . $page_id . '>';
     if (isset($this->pd['settings']['mailbox_date_format'])) {
         $date_format = $this->pd['settings']['mailbox_date_format'];
         if ($date_format != 'r' && $date_format != 'h') {
             if (isset($this->pd['settings']['mailbox_date_format_2'])) {
                 $date_format_2 = $this->pd['settings']['mailbox_date_format_2'];
             }
         } elseif ($date_format == 'h') {
             $date_format = false;
         }
     } else {
         $date_format = false;
     }
     if (!$this->user->use_cookies) {
         $sid = '&amp;PHPSESSID=' . session_id();
     } else {
         $sid = '';
     }
     if ($this->dsp_page != 'search' && isset($this->pd['search_results'][$mailbox])) {
         $search_res = $this->pd['search_results'][$mailbox];
     }
     if (!isset($this->pd['mailbox_page'])) {
         $this->pd['mailbox_page'] = '';
     }
     if (!isset($this->pd['filter_by'])) {
         $this->pd['filter_by'] = '';
     }
     $list_count = count($rows);
     if (isset($_SESSION['toggle_uids'])) {
         $toggle_uids = $_SESSION['toggle_uids'];
     } else {
         $toggle_uids = array();
     }
     if (isset($_SESSION['toggle_all'])) {
         $toggle_all = $_SESSION['toggle_all'];
     } else {
         $toggle_all = false;
     }
     if (isset($_SESSION['toggle_boxes'])) {
         $toggle_boxes = $_SESSION['toggle_boxes'];
     } else {
         $toggle_boxes = array();
     }
     foreach ($rows as $vals) {
         if (isset($this->pd['settings']['hide_deleted_messages']) && $this->pd['settings']['hide_deleted_messages'] && stristr($vals['flags'], 'deleted')) {
             continue;
         }
         $vals['mailbox'] = $mailbox;
         $message_url = '?page=message' . $sid . '&amp;uid=' . $vals['uid'] . '&amp;mailbox_page=' . $this->pd['mailbox_page'] . '&amp;sort_by=' . $this->pd['sort_by'] . '&amp;filter_by=' . $this->pd['filter_by'] . '&amp;mailbox=' . urlencode($mailbox);
         $new_window = '';
         if ($onclick) {
             if (isset($this->pd['settings']['message_window']) && $this->pd['settings']['message_window']) {
                 $js = 'onclick="open_window(\'' . $message_url . '&amp;new_window=1&amp;parent_refresh=1' . $sid . '\', 1024, 900, ' . $vals['uid'] . ');
                    return false;" onmouseover="this.style.cursor=\'pointer\'"';
             } else {
                 $js = 'onclick="document.location.href=\'' . $message_url . '\';" onmouseover="this.style.cursor=\'pointer\'"';
             }
         } else {
             $js = false;
             if (isset($this->pd['settings']['message_window']) && $this->pd['settings']['message_window']) {
                 $new_window = 'onclick="open_window(\'' . $message_url . '&amp;new_window=1&amp;parent_refresh=1' . $sid . '\', 1024, 900, ' . $vals['uid'] . '); return false;"';
             }
         }
         if (!$ignore_sent && (isset($this->pd['settings']['sent_folder']) && $mailbox == $this->pd['settings']['sent_folder'] || isset($this->pd['settings']['draft_folder']) && $mailbox == $this->pd['settings']['draft_folder'])) {
             $from = clean_from($vals['to']);
             $full_from = $vals['to'];
         } else {
             $from = clean_from($vals['from']);
             $full_from = $vals['from'];
         }
         if (isset($this->pd['settings']['trim_subject_fld']) && $this->pd['settings']['trim_subject_fld']) {
             $subject_len = $this->pd['settings']['trim_subject_fld'];
         } else {
             $subject_len = 0;
         }
         if (isset($this->pd['settings']['trim_from_fld']) && $this->pd['settings']['trim_from_fld']) {
             $trim_len = $this->pd['settings']['trim_from_fld'];
         } else {
             $trim_len = 0;
         }
         $xtra_class = '';
         if (!empty($search_res) && in_array($vals['uid'], $search_res)) {
             $xtra_class = 'search_res ';
         }
         if (stristr($vals['flags'], 'seen')) {
             $class_prefix = 'mbx_';
         } else {
             $class_prefix = 'mbx_unseen_';
         }
         if ($n == $list_count) {
             $xtra_class .= ' last_row ';
         }
         if (!trim($vals['subject'])) {
             $vals['subject'] = $this->user->str[524];
         }
         $indicators = '&#160;&#160;';
         if (stristr($vals['content-type'], 'multipart') && !stristr($vals['content-type'], 'alternative')) {
             $indicators .= '<span class="multi_ind">+&#160;</span>';
         }
         if (stristr($vals['flags'], 'answered')) {
             $indicators .= '<span class="reply_ind">r&#160;&#160;</span>';
         }
         if (stristr($vals['flags'], 'flagged')) {
             $indicators .= '<span class="flag_ind">f&#160;&#160;</span>';
             $xtra_class .= ' flagged ';
         }
         if (trim($vals['x-priority']) == '1') {
             $indicators .= '<span class="important_ind">!&#160;&#160;</span>';
         }
         if (!empty($search_res) && in_array($vals['uid'], $search_res)) {
             $indicators .= '<span class="search_ind">*&#160;&#160;</span>';
         }
         if ($indicators) {
             $indicators = '<span class="' . $xtra_class . 'indicators">' . $indicators . '</span>';
         }
         $subj_post = '';
         $subj_pre = '';
         if (isset($this->pd['thread_data'][$vals['uid']])) {
             $ind = $this->pd['thread_data'][$vals['uid']]['level'] - 1;
             $subj_pre = str_repeat('&#160;', 5 * $ind);
             /*if (!$this->pd['thread_data'][$vals['uid']]['parent']) {
                   if (isset($this->pd['thread_data'][$vals['uid']]['reply_count'])) {
                       $subj_post .= ' <span class="reply_count">replies: <b>'.$this->pd['thread_data'][$vals['uid']]['reply_count'].'</b></span>';
                   }
                   else {
                       $subj_post .= ' <span class="reply_count">replies: 0</span>';
                   }
               }*/
         }
         if (stristr($vals['flags'], 'deleted')) {
             $subj_post .= '</div>';
             $subj_pre .= '<div class="deleted_message">';
         }
         $indicators_cell = '';
         $image_cell = '';
         $subject_cell = '';
         $from_cell = '';
         $date_cell = '';
         $size_cell = '';
         $checkbox_cell = '';
         $data .= $c_start . '<tr class="mbx_row">' . $c_end;
         $indicators_cell = $c_start . '<td ' . $js . ' class="' . $xtra_class . $class_prefix . 'indicators">';
         $indicators_cell .= $indicators . $c_end . $td_end;
         $checkbox_cell = $c_start . '<td class="' . $xtra_class . $class_prefix . 'checkbox">';
         $image_cell = $c_start . '<td class="' . $xtra_class . $class_prefix . 'image_cell">';
         if (!isset($this->pd['settings']['disable_list_icons']) || !$this->pd['settings']['disable_list_icons']) {
             $image_cell .= '<div></div>';
         }
         if (!isset($this->pd['settings']['message_window']) || !$this->pd['settings']['message_window']) {
             if (isset($this->pd['settings']['new_window_icon']) && $this->pd['settings']['new_window_icon']) {
                 $image_cell .= '<a href="' . $message_url . '" onclick="open_window(\'' . $message_url . '&amp;new_window=1&amp;parent_refresh=1\', 1024, 900, ' . $vals['uid'] . '); return false;" ' . 'title="' . $this->user->str[530] . '"><span class="new_window_icon"></span></a> ';
             }
         }
         $image_cell .= '</td>' . $c_end;
         if (isset($this->pd['last_message_read'][$mailbox]) && $this->pd['last_message_read'][$mailbox] == $vals['uid']) {
             $checkbox_cell .= '<span class="last_read">&gt;</span>';
         } else {
             $checkbox_cell .= '<span class="last_read_hidden">&gt;</span>';
         }
         $checkbox_cell .= $c_end . '<input type="hidden" id="mailboxes-' . $vals['uid'] . '" name="mailboxes[' . $vals['uid'] . ']" value="' . $this->user->htmlsafe($mailbox, false, false, true) . '" /><input type="checkbox" ';
         if ($toggle_all && !in_array($vals['uid'], $toggle_uids) && isset($toggle_boxes[$vals['uid']]) && $toggle_boxes[$vals['uid']] == $mailbox) {
             $checkbox_cell .= 'checked="checked" ';
         } elseif (isset($_GET['toggle_folder']) && $_GET['toggle_folder'] == $mailbox) {
             $checkbox_cell .= 'checked="checked" ';
         }
         $checkbox_cell .= 'id="message_' . $n . '" name="uids[]" value="' . $vals['uid'] . '" onclick="save_checked_state(' . $n . ');" /><input type="hidden" name="mailboxes[' . $vals['uid'] . ']" value="' . $this->user->htmlsafe($mailbox, false, false, true) . '" />' . $td_end;
         $subject_cell = $c_start . '<td class="' . $xtra_class . $class_prefix . 'subject">';
         $subject_cell .= '<div ' . $js . ' class="sub_div">' . $c_end . $subj_pre . '<a title="' . $this->user->htmlsafe($vals['subject'], $vals['charset'], true) . '" ' . $new_window . ' href="' . $message_url . '">' . trim_htmlstr($this->user->htmlsafe($vals['subject'], $vals['charset'], true), $subject_len) . '</a>' . $subj_post . $c_start . '</div>' . $c_end . $td_end . $s_start . '<br />' . $s_end;
         $plugin_cell = $c_start . '<td class="' . $xtra_class . $class_prefix . 'plugin_cell">' . $c_end . '<div>' . do_display_hook('msglist_after_subject', $vals) . '</div>' . $c_start . '</td>' . $c_end;
         $from_cell = $c_start . '<td ' . $js . ' class="' . $xtra_class . $class_prefix . 'from">' . $c_end . '<div title="' . $this->user->htmlsafe($full_from, $vals['charset'], true, false, false, false, true) . '" class="from_inner">' . trim_htmlstr($this->user->htmlsafe($from, $vals['charset'], true, false, false, false, true), $trim_len) . '</div>' . $td_end . $s_start . '<br />' . $s_end;
         $date_cell = $c_start . '<td ' . $js . ' class="' . $xtra_class . $class_prefix . 'date" >' . $c_end . print_time2($vals['date'], $date_format, $date_format_2) . $td_end . $s_start . '<br /><br />' . $s_end;
         $size_cell = $c_start . '<td ' . $js . ' class="' . $xtra_class . $class_prefix . 'size">' . format_size($vals['size'] / 1024) . '</td>' . $c_end;
         $folder_cell = $c_start . '<td ' . $js . ' class="' . $xtra_class . $class_prefix . 'folder">' . $this->user->htmlsafe($mailbox) . '</td>' . $c_end;
         foreach ($cols as $v) {
             if (isset(${$v})) {
                 $data .= ${$v};
             }
         }
         $data .= $c_start . '</tr>' . $c_end;
         $n++;
     }
     return $data;
 }