/** * Adds sent_subfolders options in folder preferences */ function sent_subfolders_optpage_loadhook_folders_do() { global $data_dir, $username, $optpage_data, $imapServerAddress, $imapPort, $imap_stream_options, $show_contain_subfolders_option, $sent_folder; /* Get some imap data we need later. */ $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options); $boxes = sqimap_mailbox_list($imapConnection); sqimap_logout($imapConnection); /* Load the Sent Subfolder Options into an array. */ $optgrp = _("Sent Subfolders Options"); $optvals = array(); global $sent_subfolders_setting; $sent_subfolders_setting = getPref($data_dir, $username, 'sent_subfolders_setting', SMPREF_SENT_SUBFOLDERS_DISABLED); $optvals[] = array('name' => 'sent_subfolders_setting', 'caption' => _("Use Sent Subfolders"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => array(SMPREF_SENT_SUBFOLDERS_DISABLED => _("Disabled"), SMPREF_SENT_SUBFOLDERS_MONTHLY => _("Monthly"), SMPREF_SENT_SUBFOLDERS_QUARTERLY => _("Quarterly"), SMPREF_SENT_SUBFOLDERS_YEARLY => _("Yearly")), 'save' => 'save_option_sent_subfolders_setting'); $filtered_folders = array_filter($boxes, "filter_folders"); $sent_subfolders_base_values = array('whatever' => $filtered_folders); global $sent_subfolders_base; $sent_subfolders_base = getPref($data_dir, $username, 'sent_subfolders_base', $sent_folder); $optvals[] = array('name' => 'sent_subfolders_base', 'caption' => _("Base Sent Folder"), 'type' => SMOPT_TYPE_FLDRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => $sent_subfolders_base_values, 'folder_filter' => 'noinferiors', 'save' => 'save_option_sent_subfolders_base'); if ($show_contain_subfolders_option) { $optvals[] = array('name' => 'sent_subfolders_warning', 'caption' => _("Warning"), 'type' => SMOPT_TYPE_COMMENT, 'comment' => _("There are some restrictions in Sent Subfolder options.")); } /* Add our option data to the global array. */ $optpage_data['grps'][SMOPT_GRP_SENT_SUBFOLDERS] = $optgrp; $optpage_data['vals'][SMOPT_GRP_SENT_SUBFOLDERS] = $optvals; }
/** * Adds sent_subfolders options in folder preferences */ function sent_subfolders_optpage_loadhook_folders() { global $optpage_data, $imapServerAddress, $imapPort; sqgetGlobalVar('username', $username, SQ_SESSION); sqgetGlobalVar('key', $key, SQ_COOKIE); /* Get some imap data we need later. */ $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); $boxes = sqimap_mailbox_list($imapConnection); sqimap_logout($imapConnection); /* Load the Sent Subfolder Options into an array. */ $optgrp = _("Sent Subfolders Options"); $optvals = array(); $optvals[] = array('name' => 'sent_subfolders_setting', 'caption' => _("Use Sent Subfolders"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => array(SMPREF_SENT_SUBFOLDERS_DISABLED => _("Disabled"), SMPREF_SENT_SUBFOLDERS_MONTHLY => _("Monthly"), SMPREF_SENT_SUBFOLDERS_QUARTERLY => _("Quarterly"), SMPREF_SENT_SUBFOLDERS_YEARLY => _("Yearly")), 'save' => 'save_option_sent_subfolders_setting'); $filtered_folders = array_filter($boxes, "filter_folders"); $sent_subfolders_base_values = array('whatever' => $filtered_folders); $optvals[] = array('name' => 'sent_subfolders_base', 'caption' => _("Base Sent Folder"), 'type' => SMOPT_TYPE_FLDRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => $sent_subfolders_base_values); /* Add our option data to the global array. */ $optpage_data['grps'][SMOPT_GRP_SENT_SUBFOLDERS] = $optgrp; $optpage_data['vals'][SMOPT_GRP_SENT_SUBFOLDERS] = $optvals; }
case 'create': $td_str .= _("Created folder successfully!"); break; case 'rename': $td_str .= _("Renamed successfully!"); break; case 'subscribe-doesnotexist': $td_str .= _("Subscription Unsuccessful - Folder does not exist."); break; } $td_str .= '</b><br />'; echo html_tag('table', html_tag('tr', html_tag('td', $td_str . '<a href="../src/left_main.php" target="left">' . _("refresh folder list") . '</a>', 'center')), 'center', '', 'width="100%" cellpadding="4" cellspacing="0" border="0"'); } echo "\n<br />"; $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); $boxes = sqimap_mailbox_list($imapConnection, true); /** CREATING FOLDERS **/ echo html_tag('table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"') . html_tag('tr', html_tag('td', '<b>' . _("Create Folder") . '</b>', 'center', $color[9])) . html_tag('tr') . html_tag('td', '', 'center', $color[0]) . addForm('folders_create.php', 'POST', 'cf') . addInput('folder_name', '', 25) . "<br />\n" . _("as a subfolder of") . '<br />' . "<tt><select name=\"subfolder\">\n"; $show_selected = array(); $skip_folders = array(); $server_type = strtolower($imap_server_type); if ($server_type == 'courier') { array_push($skip_folders, 'inbox.trash'); if ($default_folder_prefix == 'INBOX.') { array_push($skip_folders, 'INBOX'); } } if ($default_sub_of_inbox == false) { echo '<option selected="selected" value="">[ ' . _("None") . " ]</option>\n"; } else { echo '<option value="">[ ' . _("None") . " ]</option>\n";
displayPageHeader($color, 'None'); plain_error_message(_("You have not selected a folder to delete. Please do so.") . '<br /><a href="../src/folders.php">' . _("Click here to go back") . '</a>.', $color); exit; } if (sqgetGlobalVar('backingout', $tmp, SQ_POST)) { $location = get_location(); header("Location: {$location}/folders.php"); exit; } if (!sqgetGlobalVar('confirmed', $tmp, SQ_POST)) { displayPageHeader($color, 'None'); echo '<br />' . html_tag('table', '', 'center', '', 'width="95%" border="0"') . html_tag('tr', html_tag('td', '<b>' . _("Delete Folder") . '</b>', 'center', $color[0])) . html_tag('tr') . html_tag('td', '', 'center', $color[4]) . sprintf(_("Are you sure you want to delete %s?"), str_replace(array(' ', '<', '>'), array(' ', '<', '>'), imap_utf7_decode_local($mailbox))) . addForm('folders_delete.php', 'post') . "<p>\n" . addHidden('mailbox', $mailbox) . addSubmit(_("Yes"), 'confirmed') . addSubmit(_("No"), 'backingout') . '</p></form><br /></td></tr></table>'; exit; } $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); $boxes = sqimap_mailbox_list($imap_stream); $numboxes = count($boxes); global $delete_folder; if (substr($mailbox, -1) == $delimiter) { $mailbox_no_dm = substr($mailbox, 0, strlen($mailbox) - 1); } else { $mailbox_no_dm = $mailbox; } /** lets see if we CAN move folders to the trash.. otherwise, ** just delete them **/ if (isset($delete_folder) && $delete_folder || eregi('^' . $trash_folder . '.+', $mailbox)) { $can_move_to_trash = FALSE; } else { for ($i = 0; $i < $numboxes; $i++) { if ($boxes[$i]['unformatted'] == $trash_folder) { $can_move_to_trash = !in_array('noinferiors', $boxes[$i]['flags']);
function newmail_plugin() { global $username, $key, $imapServerAddress, $imapPort, $newmail_media, $newmail_enable, $newmail_popup, $newmail_popup_height, $newmail_popup_width, $newmail_recent, $newmail_changetitle, $imapConnection; include_once SM_PATH . 'functions/display_messages.php'; if ($newmail_enable == 'on' || $newmail_popup == 'on' || $newmail_changetitle) { // open a connection on the imap port (143) $boxes = sqimap_mailbox_list($imapConnection); $delimeter = sqimap_get_delimiter($imapConnection); $status = 0; $totalNew = 0; for ($i = 0; $i < count($boxes); $i++) { $line = ''; $mailbox = $boxes[$i]['formatted']; if (!isset($boxes[$i]['unseen'])) { $boxes[$i]['unseen'] = ''; } if ($boxes[$i]['flags']) { $noselect = false; for ($h = 0; $h < count($boxes[$i]['flags']); $h++) { if (strtolower($boxes[$i]["flags"][$h]) == 'noselect') { $noselect = TRUE; } } if (!$noselect) { $status += CheckNewMailboxSound($imapConnection, $mailbox, $boxes[$i]['unformatted'], $delimeter, $boxes[$i]['unseen'], $totalNew); } } else { $status += CheckNewMailboxSound($imapConnection, $mailbox, $boxes[$i]['unformatted'], $delimeter, $boxes[$i]['unseen'], $totalNew); } } // sqimap_logout($imapConnection); // If we found unseen messages, then we // will play the sound as follows: if ($newmail_changetitle) { echo "<script language=\"javascript\" type=\"text/javascript\">\n" . "function ChangeTitleLoad() {\n"; if ($totalNew > 1 || $totalNew == 0) { echo 'window.parent.document.title = "' . sprintf(_("%s New Messages"), $totalNew) . "\";\n"; } else { echo 'window.parent.document.title = "' . sprintf(_("%s New Message"), $totalNew) . "\";\n"; } echo "if (BeforeChangeTitle != null)\n" . "BeforeChangeTitle();\n" . "}\n" . "BeforeChangeTitle = window.onload;\n" . "window.onload = ChangeTitleLoad;\n" . "</script>\n"; } if ($totalNew > 0 && $newmail_enable == 'on' && $newmail_media != '' && $newmail_media != '(none)') { $newmail_media = sqm_baseuri() . 'plugins/newmail/sounds/' . basename($newmail_media); echo '<embed src="' . htmlspecialchars($newmail_media) . "\" hidden=\"true\" autostart=\"true\" width=\"2\" height=\"2\">\n"; } if ($totalNew > 0 && $newmail_popup == 'on') { echo "<script language=\"JavaScript\">\n" . "<!--\n" . "function PopupScriptLoad() {\n" . 'window.open("' . sqm_baseuri() . 'plugins/newmail/newmail.php?numnew=' . $totalNew . '", "SMPopup",' . "\"width=" . (int) $newmail_popup_width . ",height=" . (int) $newmail_popup_height . ",scrollbars=no\");\n" . "if (BeforePopupScript != null)\n" . "BeforePopupScript();\n" . "}\n" . "BeforePopupScript = window.onload;\n" . "window.onload = PopupScriptLoad;\n" . "// End -->\n" . "</script>\n"; } } }
/** * This function builds an array with all the information about * the options available to the user, and returns it. The options * are grouped by the groups in which they are displayed. * For each option, the following information is stored: * - name: the internal (variable) name * - caption: the description of the option in the UI * - type: one of SMOPT_TYPE_* * - refresh: one of SMOPT_REFRESH_* * - size: one of SMOPT_SIZE_* * - save: the name of a function to call when saving this option * @return array all option information */ function load_optpage_data_folder() { global $username, $key, $imapServerAddress, $imapPort; global $folder_prefix, $default_folder_prefix, $show_prefix_option; /* Get some imap data we need later. */ $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); $boxes = sqimap_mailbox_list($imapConnection); /* Build a simple array into which we will build options. */ $optgrps = array(); $optvals = array(); /******************************************************/ /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */ /******************************************************/ /*** Load the General Options into the array ***/ $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options"); $optvals[SMOPT_GRP_SPCFOLDER] = array(); if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; } if ($show_prefix_option) { $optvals[SMOPT_GRP_SPCFOLDER][] = array('name' => 'folder_prefix', 'caption' => _("Folder Path"), 'type' => SMOPT_TYPE_STRING, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'size' => SMOPT_SIZE_LARGE); } $trash_folder_values = array(SMPREF_NONE => '[ ' . _("Do not use Trash") . ' ]', 'whatever' => $boxes); $optvals[SMOPT_GRP_SPCFOLDER][] = array('name' => 'trash_folder', 'caption' => _("Trash Folder"), 'type' => SMOPT_TYPE_FLDRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => $trash_folder_values, 'save' => 'save_option_trash_folder'); $draft_folder_values = array(SMPREF_NONE => '[ ' . _("Do not use Drafts") . ' ]', 'whatever' => $boxes); $optvals[SMOPT_GRP_SPCFOLDER][] = array('name' => 'draft_folder', 'caption' => _("Draft Folder"), 'type' => SMOPT_TYPE_FLDRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => $draft_folder_values, 'save' => 'save_option_draft_folder'); $sent_folder_values = array(SMPREF_NONE => '[ ' . _("Do not use Sent") . ' ]', 'whatever' => $boxes); $optvals[SMOPT_GRP_SPCFOLDER][] = array('name' => 'sent_folder', 'caption' => _("Sent Folder"), 'type' => SMOPT_TYPE_FLDRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => $sent_folder_values, 'save' => 'save_option_sent_folder'); /*** Load the General Options into the array ***/ $optgrps[SMOPT_GRP_FOLDERLIST] = _("Folder List Options"); $optvals[SMOPT_GRP_FOLDERLIST] = array(); $optvals[SMOPT_GRP_FOLDERLIST][] = array('name' => 'location_of_bar', 'caption' => _("Location of Folder List"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_ALL, 'posvals' => array(SMPREF_LOC_LEFT => _("Left"), SMPREF_LOC_RIGHT => _("Right"))); $left_size_values = array(); for ($lsv = 100; $lsv <= 300; $lsv += 10) { $left_size_values[$lsv] = "{$lsv} " . _("pixels"); } $optvals[SMOPT_GRP_FOLDERLIST][] = array('name' => 'left_size', 'caption' => _("Width of Folder List"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_ALL, 'posvals' => $left_size_values); $minute_str = _("Minutes"); $left_refresh_values = array(SMPREF_NONE => _("Never")); foreach (array(30, 60, 120, 180, 300, 600, 1200) as $lr_val) { if ($lr_val < 60) { $left_refresh_values[$lr_val] = "{$lr_val} " . _("Seconds"); } else { if ($lr_val == 60) { $left_refresh_values[$lr_val] = "1 " . _("Minute"); } else { $left_refresh_values[$lr_val] = $lr_val / 60 . " {$minute_str}"; } } } $optvals[SMOPT_GRP_FOLDERLIST][] = array('name' => 'left_refresh', 'caption' => _("Auto Refresh Folder List"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => $left_refresh_values); $optvals[SMOPT_GRP_FOLDERLIST][] = array('name' => 'unseen_notify', 'caption' => _("Enable Unread Message Notification"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => array(SMPREF_UNSEEN_NONE => _("No Notification"), SMPREF_UNSEEN_INBOX => _("Only INBOX"), SMPREF_UNSEEN_ALL => _("All Folders"))); $optvals[SMOPT_GRP_FOLDERLIST][] = array('name' => 'unseen_type', 'caption' => _("Unread Message Notification Type"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => array(SMPREF_UNSEEN_ONLY => _("Only Unseen"), SMPREF_UNSEEN_TOTAL => _("Unseen and Total"))); $optvals[SMOPT_GRP_FOLDERLIST][] = array('name' => 'collapse_folders', 'caption' => _("Enable Collapsable Folders"), 'type' => SMOPT_TYPE_BOOLEAN, 'refresh' => SMOPT_REFRESH_FOLDERLIST); $optvals[SMOPT_GRP_FOLDERLIST][] = array('name' => 'unseen_cum', 'caption' => _("Enable Cumulative Unread Message Notification"), 'type' => SMOPT_TYPE_BOOLEAN, 'refresh' => SMOPT_REFRESH_FOLDERLIST); $optvals[SMOPT_GRP_FOLDERLIST][] = array('name' => 'date_format', 'caption' => _("Show Clock on Folders Panel"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => array('0' => _("International date and time"), '1' => _("American date and time"), '2' => _("European date and time"), '3' => _("Show weekday and time"), '4' => _("Show time with seconds"), '5' => _("Show time"), '6' => _("No Clock"))); $optvals[SMOPT_GRP_FOLDERLIST][] = array('name' => 'hour_format', 'caption' => _("Hour Format"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"), SMPREF_TIME_24HR => _("24-hour clock"))); $optvals[SMOPT_GRP_FOLDERLIST][] = array('name' => 'search_memory', 'caption' => _("Memory Search"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_NONE, 'posvals' => array(0 => _("Disabled"), 1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8', 9 => '9')); /*** Load the General Options into the array ***/ $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options"); $optvals[SMOPT_GRP_FOLDERSELECT] = array(); $delim = sqimap_get_delimiter($imapConnection); $optvals[SMOPT_GRP_FOLDERSELECT][] = array('name' => 'mailbox_select_style', 'caption' => _("Selection List Style"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_NONE, 'posvals' => array(0 => _("Long:") . ' "' . _("Folder") . $delim . _("Subfolder") . '"', 1 => _("Indented:") . ' " ' . _("Subfolder") . '"', 2 => _("Delimited:") . ' ". ' . _("Subfolder") . '"'), 'htmlencoded' => true); /* Assemble all this together and return it as our result. */ $result = array('grps' => $optgrps, 'vals' => $optvals); sqimap_logout($imapConnection); return $result; }
echo '<small style="white-space: nowrap;">(<a href="../src/left_main.php" target="left">' . _("Check mail") . '</a>)</small></td></tr></table><br />'; /* Lastly, display the folder list. */ if ($collapse_folders) { /* If directed, collapse or uncollapse a folder. */ if (isset($fold)) { setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED); } else { if (isset($unfold)) { setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED); } } } sqgetGlobalVar('force_refresh', $force_refresh, SQ_GET); if (!isset($boxes)) { // auto_create_done $boxes = sqimap_mailbox_list($imapConnection, $force_refresh); } /* Prepare do do out collapsedness and visibility computation. */ $curbox = 0; $boxcount = count($boxes); /* Compute the collapsedness and visibility of each box. */ while ($curbox < $boxcount) { $boxes[$curbox]['visible'] = TRUE; compute_folder_children($curbox, $boxcount); } for ($i = 0; $i < count($boxes); $i++) { if ($boxes[$i]['visible']) { $mailbox = $boxes[$i]['formatted']; // remove folder_prefix using substr so folders aren't indented unnecessarily $mblevel = substr_count(substr($boxes[$i]['unformatted'], strlen($folder_prefix)), $delimiter) + 1; /* Create the prefix for the folder name and link. */
/** * Given a folder, moves it to trash (and all subfolders of it too). */ function folders_delete_do($imapConnection, $delimiter, $folder_name) { include SM_PATH . 'functions/tree.php'; $boxes = sqimap_mailbox_list($imapConnection); global $delete_folder, $imap_server_type, $trash_folder, $move_to_trash; if (substr($folder_name, -1) == $delimiter) { $folder_name_no_dm = substr($folder_name, 0, strlen($folder_name) - 1); } else { $folder_name_no_dm = $folder_name; } /** lets see if we CAN move folders to the trash.. otherwise, ** just delete them **/ if ($delete_folder || preg_match('/^' . preg_quote($trash_folder, '/') . '.+/i', $folder_name)) { $can_move_to_trash = FALSE; } else { /* Otherwise, check if trash folder exits and support sub-folders */ foreach ($boxes as $box) { if ($box['unformatted'] == $trash_folder) { $can_move_to_trash = !in_array('noinferiors', $box['flags']); } } } /** First create the top node in the tree **/ foreach ($boxes as $box) { if ($box['unformatted-dm'] == $folder_name && strlen($box['unformatted-dm']) == strlen($folder_name)) { $foldersTree[0]['value'] = $folder_name; $foldersTree[0]['doIHaveChildren'] = false; continue; } } /* Now create the nodes for subfolders of the parent folder You can tell that it is a subfolder by tacking the mailbox delimiter on the end of the $folder_name string, and compare to that. */ foreach ($boxes as $box) { if (substr($box['unformatted'], 0, strlen($folder_name_no_dm . $delimiter)) == $folder_name_no_dm . $delimiter) { addChildNodeToTree($box['unformatted'], $box['unformatted-dm'], $foldersTree); } } /** Lets start removing the folders and messages **/ if ($move_to_trash == true && $can_move_to_trash == true) { /** if they wish to move messages to the trash **/ walkTreeInPostOrderCreatingFoldersUnderTrash(0, $imapConnection, $foldersTree, $folder_name); walkTreeInPreOrderDeleteFolders(0, $imapConnection, $foldersTree); } else { /** if they do NOT wish to move messages to the trash (or cannot)**/ walkTreeInPreOrderDeleteFolders(0, $imapConnection, $foldersTree); } return; }
function printMessageInfo($imapConnection, $t, $not_last = true, $key, $mailbox, $start_msg, $where, $what) { global $checkall, $preselected, $color, $msgs, $msort, $td_str, $msg, $default_use_priority, $message_highlight_list, $index_order, $indent_array, $pos, $thread_sort_messages, $server_sort_order, $row_count, $allow_server_sort, $truncate_subject, $truncate_sender; $color_string = $color[4]; if ($GLOBALS['alt_index_colors']) { if (!isset($row_count)) { $row_count = 0; } $row_count++; if ($row_count % 2) { if (!isset($color[12])) { $color[12] = '#EAEAEA'; } $color_string = $color[12]; } } $msg = $msgs[$key]; if ($mailbox == 'None') { $boxes = sqimap_mailbox_list($imapConnection); $mailbox = $boxes[0]['unformatted']; unset($boxes); } $urlMailbox = urlencode($mailbox); if (handleAsSent($mailbox)) { $msg['FROM'] = $msg['TO']; } $msg['FROM'] = parseAddress($msg['FROM'], 1); /* * This is done in case you're looking into Sent folders, * because you can have multiple receivers. */ $senderNames = $msg['FROM']; $senderName = ''; $senderFrom = ''; if (sizeof($senderNames)) { foreach ($senderNames as $senderNames_part) { if ($senderName != '') { $senderName .= ', '; } if ($senderFrom != '') { $senderFrom .= ', '; } if ($senderNames_part[1]) { $senderName .= decodeHeader($senderNames_part[1]); } else { $senderName .= htmlspecialchars($senderNames_part[0]); } $senderFrom .= htmlspecialchars($senderNames_part[0]); } } $senderName = str_replace(' ', ' ', $senderName); echo html_tag('tr', '', '', '', 'valign="top"') . "\n"; if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true) { $flag = "<font color=\"{$color['2']}\">"; $flag_end = '</font>'; } else { $flag = ''; $flag_end = ''; } if (!isset($msg['FLAG_SEEN']) || $msg['FLAG_SEEN'] == false) { $bold = '<b>'; $bold_end = '</b>'; } else { $bold = ''; $bold_end = ''; } if (handleAsSent($mailbox)) { $italic = '<i>'; $italic_end = '</i>'; } else { $italic = ''; $italic_end = ''; } if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) { $fontstr = "<font color=\"{$color['9']}\">"; $fontstr_end = '</font>'; } else { $fontstr = ''; $fontstr_end = ''; } if ($where && $what) { $searchstr = '&where=' . $where . '&what=' . $what; } else { $searchstr = ''; } if (is_array($message_highlight_list) && count($message_highlight_list)) { $msg['TO'] = parseAddress($msg['TO']); $msg['CC'] = parseAddress($msg['CC']); foreach ($message_highlight_list as $message_highlight_list_part) { if (trim($message_highlight_list_part['value']) != '') { $high_val = strtolower($message_highlight_list_part['value']); $match_type = strtoupper($message_highlight_list_part['match_type']); if ($match_type == 'TO_CC') { $match = array('TO', 'CC'); } else { $match = array($match_type); } foreach ($match as $match_type) { switch ($match_type) { case 'TO': case 'CC': case 'FROM': foreach ($msg[$match_type] as $address) { $address[0] = decodeHeader($address[0], true, false); $address[1] = decodeHeader($address[1], true, false); if (strstr('^^' . strtolower($address[0]), $high_val) || strstr('^^' . strtolower($address[1]), $high_val)) { $hlt_color = $message_highlight_list_part['color']; break 4; } } break; default: $headertest = strtolower(decodeHeader($msg[$match_type], true, false)); if (strstr('^^' . $headertest, $high_val)) { $hlt_color = $message_highlight_list_part['color']; break 3; } break; } } } } } if (!isset($hlt_color)) { $hlt_color = $color_string; } if ($checkall == 1 || in_array($msg['ID'], $preselected)) { $checked = ' checked="checked"'; } else { $checked = ''; } $col = 0; $msg['SUBJECT'] = decodeHeader($msg['SUBJECT']); // $subject = processSubject($msg['SUBJECT'], $indent_array[$msg['ID']]); $subject = truncateWithEntities(str_replace(' ', ' ', $msg['SUBJECT']), $truncate_subject); if (sizeof($index_order)) { foreach ($index_order as $index_order_part) { switch ($index_order_part) { case 1: /* checkbox */ echo html_tag('td', "<input type=\"checkbox\" name=\"msg[{$t}]\" id=\"msg" . $msg['ID'] . "\" value=\"" . $msg['ID'] . "\"{$checked}>", 'center', $hlt_color); break; case 2: /* from */ $from_xtra = ''; $from_xtra = 'title="' . $senderFrom . '"'; echo html_tag('td', html_tag('label', $italic . $bold . $flag . $fontstr . truncateWithEntities($senderName, $truncate_sender) . $fontstr_end . $flag_end . $bold_end . $italic_end, '', '', 'for="msg' . $msg['ID'] . '"'), 'left', $hlt_color, $from_xtra); break; case 3: /* date */ $date_string = $msg['DATE_STRING'] . ''; if ($date_string == '') { $date_string = _("Unknown date"); } echo html_tag('td', $bold . $flag . $fontstr . $date_string . $fontstr_end . $flag_end . $bold_end, 'center', $hlt_color, 'nowrap'); break; case 4: /* subject */ $td_str = $bold; if ($thread_sort_messages == 1) { if (isset($indent_array[$msg['ID']])) { $td_str .= str_repeat(" ", $indent_array[$msg['ID']]); } } $td_str .= '<a href="read_body.php?mailbox=' . $urlMailbox . '&passed_id=' . $msg["ID"] . '&startMessage=' . $start_msg . $searchstr . '"'; $td_str .= ' ' . concat_hook_function('subject_link', array($start_msg, $searchstr)); if ($subject != $msg['SUBJECT']) { $title = get_html_translation_table(HTML_SPECIALCHARS); $title = array_flip($title); $title = strtr($msg['SUBJECT'], $title); $title = str_replace('"', "''", $title); $td_str .= " title=\"{$title}\""; } $td_str .= ">{$flag}{$subject}{$flag_end}</a>{$bold_end}"; echo html_tag('td', $td_str, 'left', $hlt_color); break; case 5: /* flags */ $stuff = false; $td_str = "<b><small>"; if (isset($msg['FLAG_ANSWERED']) && $msg['FLAG_ANSWERED'] == true) { $td_str .= _("A"); $stuff = true; } if ($msg['TYPE0'] == 'multipart' && $msg['TYPE1'] == 'mixed') { $td_str .= '+'; $stuff = true; } if ($default_use_priority) { if ($msg['PRIORITY'] == 1 || $msg['PRIORITY'] == 2) { $td_str .= "<font color=\"{$color['1']}\">!</font>"; $stuff = true; } if ($msg['PRIORITY'] == 5) { $td_str .= "<font color=\"{$color['8']}\">?</font>"; $stuff = true; } } if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'] == true) { $td_str .= "<font color=\"{$color['1']}\">D</font>"; $stuff = true; } if (!$stuff) { $td_str .= ' '; } do_hook("msg_envelope"); $td_str .= '</small></b>'; echo html_tag('td', $td_str, 'center', $hlt_color, 'nowrap'); break; case 6: /* size */ echo html_tag('td', $bold . $fontstr . show_readable_size($msg['SIZE']) . $fontstr_end . $bold_end, 'right', $hlt_color); break; } ++$col; } } if ($not_last) { echo '</tr>' . "\n" . '<tr><td colspan="' . $col . '" bgcolor="' . $color[0] . '" height="1"></td></tr>' . "\n"; } else { echo '</tr>' . "\n"; } }
/** * Checks if folder is noselect (can't store messages) * * Function does not check if folder subscribed. * @param stream $imap_stream imap connection resource * @param string $imap_folder imap folder name * @return boolean true, when folder has noselect flag. false in any other case. * @since 1.5.1 and 1.4.5 */ function mail_fetch_check_noselect($imap_stream, $imap_folder) { $boxes = sqimap_mailbox_list($imap_stream); foreach ($boxes as $box) { if ($box['unformatted'] == $imap_folder) { return (bool) check_is_noselect($box['raw']); } } return false; }
/** * Returns list of options (to be echoed into select statement * based on available mailboxes and separators * Caller should surround options with <select ...> </select> and * any formatting. * $imap_stream - $imapConnection to query for mailboxes * $show_selected - array containing list of mailboxes to pre-select (0 if none) * $folder_skip - array of folders to keep out of option list (compared in lower) * $boxes - list of already fetched boxes (for places like folder panel, where * you know these options will be shown 3 times in a row.. (most often unset). * $flag - flag to check for in mailbox flags, used to filter out mailboxes. * 'noselect' by default to remove unselectable mailboxes. * 'noinferiors' used to filter out folders that can not contain subfolders. * NULL to avoid flag check entirely. * $use_long_format - override folder display preference and always show full folder name. */ function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_skip = 0, $boxes = 0, $flag = 'noselect', $use_long_format = false) { global $username, $data_dir; $mbox_options = ''; if ($use_long_format) { $shorten_box_names = 0; } else { $shorten_box_names = getPref($data_dir, $username, 'mailbox_select_style', 1); } if ($boxes == 0) { $boxes = sqimap_mailbox_list($imap_stream); } foreach ($boxes as $boxes_part) { if ($flag == NULL || !in_array($flag, $boxes_part['flags'])) { $box = $boxes_part['unformatted']; if ($folder_skip != 0 && in_array($box, $folder_skip)) { continue; } $lowerbox = strtolower($box); // mailboxes are casesensitive => inbox.sent != inbox.Sent // nevermind, to many dependencies this should be fixed! if (strtolower($box) == 'inbox') { // inbox is special and not casesensitive $box2 = _("INBOX"); } else { switch ($shorten_box_names) { case 2: /* delimited, style = 2 */ $box2 = str_replace(' ', '. ', $boxes_part['formatted']); break; case 1: /* indent, style = 1 */ $box2 = $boxes_part['formatted']; break; default: /* default, long names, style = 0 */ $box2 = str_replace(' ', ' ', htmlspecialchars(imap_utf7_decode_local($boxes_part['unformatted-disp']))); break; } } $box2 = str_replace(array('<', '>'), array('<', '>'), $box2); if ($show_selected != 0 && in_array($lowerbox, $show_selected)) { $mbox_options .= '<option value="' . htmlspecialchars($box) . '" selected="selected">' . $box2 . '</option>' . "\n"; } else { $mbox_options .= '<option value="' . htmlspecialchars($box) . '">' . $box2 . '</option>' . "\n"; } } } return $mbox_options; }
function delete_move_next_moveForm($next) { global $color, $where, $what, $currentArrayIndex, $passed_id; global $urlMailbox, $sort, $startMessage, $delete_id, $move_id; global $imapConnection; ?> <tr> <form action="<?php echo "read_body.php"; ?> " method="get"> <td bgcolor="<?php echo $color[9]; ?> " width=100% align=center><small> <input type="hidden" name="passed_id" value="<?php echo $next; ?> "> <input type="hidden" name="mailbox" value="<?php echo $urlMailbox; ?> "> <input type="hidden" name="sort" value="<?php echo $sort; ?> "> <input type="hidden" name="startMessage" value="<?php echo $startMessage; ?> "> <input type="hidden" name="show_more" value="0"> <input type="hidden" name="move_id" value="<?php echo $passed_id; ?> "> Move to: <select name="targetMailbox"><?php $boxes = sqimap_mailbox_list($imapConnection); for ($i = 0; $i < count($boxes); $i++) { if (!in_array("noselect", $boxes[$i]['flags'])) { $box = $boxes[$i]["unformatted"]; $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']); echo " <option value=\"{$box}\">{$box2}\n"; } } ?> </select> <input type=submit value="Move"> </small> </td> </form> </tr> <?php }
function bayesspam_filters($imap_stream, $use_mailbox = 0) { $spam_stats = 0; $ham_stats = 0; $unsure_stats = 0; $total_messages = 0; $run_folders = array(); $boxes = sqimap_mailbox_list($imap_stream); foreach ($boxes as $box) { if ($GLOBALS['bayesspam_inboxonly'] != 1 || $GLOBALS['bayesspam_inboxonly'] == 1 && 'INBOX' == $box['unformatted-dm']) { if ($use_mailbox == 1 && $box['unformatted-dm'] == $GLOBALS['mailbox'] && !in_array($box['unformatted-dm'], $GLOBALS['bayesspam_ignore_folders']) || $use_mailbox == 0 && !in_array($box['unformatted-dm'], $GLOBALS['bayesspam_ignore_folders'])) { if ((array_search('noselect', $box['flags']) === FALSE || array_search('noselect', $box['flags']) === NULL) && $GLOBALS['sent_folder'] != $box['unformatted-dm'] && sqimap_unseen_messages($imap_stream, $box['unformatted-dm']) > 0) { $run_folders[] = $box['unformatted-dm']; } } } } foreach ($run_folders as $box) { $spam_messages = array(); $uncertain_messages = array(); $mbxresponse = sqimap_mailbox_select($imap_stream, $box); $messages = array(); $search = "SEARCH UNSEEN UNDELETED"; if (isset($_SESSION['bayesspam_last_filter'])) { $search .= " SINCE " . date('d-M-Y', $_SESSION['bayesspam_last_filter']); } $_SESSION['bayesspam_last_filter'] = time(); $read = sqimap_run_command($imap_stream, $search, TRUE, $response, $message, TRUE); if (isset($read[0])) { for ($i = 0, $iCnt = count($read); $i < $iCnt; ++$i) { if (preg_match("/^\\* SEARCH (.+)\$/", $read[$i], $regs)) { $messages = preg_split("/ /", trim($regs[1])); break; } } } foreach ($messages as $passed_id) { bayesspam_set_message_id($imap_stream, $passed_id); $bayesspam_check_messageid = bayesspam_check_messageid(); if ($GLOBALS['bayesspam_do_stats'] && $GLOBALS['bayesspam_do_user_stats']) { $bayesspam_old_message_score = bayesspam_get_old_message_score(); } $is_spam = bayesspam_get_probability($imap_stream, $passed_id, 1); if ($is_spam > 0.9) { $spam_messages[] = $passed_id; } elseif ($is_spam >= 0.1) { $uncertain_messages[] = $passed_id; } if ($GLOBALS['bayesspam_do_stats'] && $GLOBALS['bayesspam_do_user_stats'] && $bayesspam_old_message_score === FALSE) { if ($is_spam > 0.9) { $spam_stats++; $total_messages++; } if ($is_spam <= 0.9 && $is_spam >= 0.1) { $unsure_stats++; $total_messages++; } if ($is_spam < 0.1) { $ham_stats++; $total_messages++; } } } if ($spam_messages) { $message_str = sqimap_message_list_squisher($spam_messages); if ($GLOBALS['bayesspam_delete']) { sqimap_run_command($imap_stream, 'STORE ' . $message_str . ' +FLAGS (\\Deleted)', true, $response, $message, $GLOBALS['uid_support']); } elseif (sqimap_mailbox_exists($imap_stream, $GLOBALS['bayesspam_folder'])) { sqimap_run_command($imap_stream, 'COPY ' . $message_str . ' "' . $GLOBALS['bayesspam_folder'] . '"', true, $response, $message, $GLOBALS['uid_support']); sqimap_run_command($imap_stream, 'STORE ' . $message_str . ' +FLAGS (\\Deleted)', true, $response, $message, $GLOBALS['uid_support']); } sqimap_mailbox_expunge($imap_stream, $box); } if ($uncertain_messages && $GLOBALS['bayesspam_do_uncertain_filtering']) { $message_str = sqimap_message_list_squisher($uncertain_messages); if (sqimap_mailbox_exists($imap_stream, $GLOBALS['bayesspam_uncertain_folder'])) { sqimap_run_command($imap_stream, 'COPY ' . $message_str . ' "' . $GLOBALS['bayesspam_uncertain_folder'] . '"', true, $response, $message, $GLOBALS['uid_support']); sqimap_run_command($imap_stream, 'STORE ' . $message_str . ' +FLAGS (\\Deleted)', true, $response, $message, $GLOBALS['uid_support']); } sqimap_mailbox_expunge($imap_stream, $box); } } if ($GLOBALS['bayesspam_do_stats'] && $GLOBALS['bayesspam_do_user_stats'] && $total_messages) { $res = $GLOBALS['bayesdbhandle']->query('SELECT UserName FROM ' . $GLOBALS['bayesdbprefix'] . 'stats WHERE UserName=\'' . $GLOBALS['bayes_username'] . '\''); if (!DB::isError($res) && !($row = $res->fetchRow())) { $GLOBALS['bayesdbhandle']->query('INSERT INTO ' . $GLOBALS['bayesdbprefix'] . 'stats SET StatsStart=NOW(),UserName=\'' . $GLOBALS['bayes_username'] . '\',TotalMessages=' . $total_messages . ',HamMessages=' . $ham_stats . ',SpamMessages=' . $spam_stats . ',UnsureMessages=' . $unsure_stats . ($GLOBALS['bayesspam_do_timing'] ? ',TimedMessages=' . $GLOBALS['bayes_parsed_messages'] . ',TotalParseTime=' . $GLOBALS['bayes_parse_time'] : '')); } else { $GLOBALS['bayesdbhandle']->query('UPDATE ' . $GLOBALS['bayesdbprefix'] . 'stats SET TotalMessages=TotalMessages+' . $total_messages . ',HamMessages=HamMessages+' . $ham_stats . ',SpamMessages=SpamMessages+' . $spam_stats . ', UnsureMessages=UnsureMessages+' . $unsure_stats . ($GLOBALS['bayesspam_do_timing'] ? ',TimedMessages=TimedMessages+' . $GLOBALS['bayes_parsed_messages'] . ',TotalParseTime=TotalParseTime+' . $GLOBALS['bayes_parse_time'] : '') . ' WHERE UserName=\'' . $GLOBALS['bayes_username'] . '\''); } } }
function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_skip = 0, $boxes = 0) { global $username, $data_dir; $mbox_options = ''; $shorten_box_names = getPref($data_dir, $username, 'mailbox_select_style', SMPREF_OFF); if ($boxes == 0) { $boxes = sqimap_mailbox_list($imap_stream); } foreach ($boxes as $boxes_part) { if (!in_array('noselect', $boxes_part['flags'])) { $box = $boxes_part['unformatted']; $lowerbox = strtolower($box); if ($folder_skip != 0 && in_array($lowerbox, $folder_skip)) { continue; } if ($lowerbox == 'inbox') { $box2 = _("INBOX"); } else { if ($shorten_box_names == 2) { /* delimited, style = 2 */ $box2 = str_replace(' ', '. ', $boxes_part['formatted']); } else { if ($shorten_box_names == 1) { /* indent, style = 1 */ $box2 = $boxes_part['formatted']; } else { /* default, long names, style = 0 */ $box2 = str_replace(' ', ' ', imap_utf7_decode_local($boxes_part['unformatted-disp'])); } } } if ($show_selected != 0 && in_array($lowerbox, $show_selected)) { $mbox_options .= '<OPTION VALUE="' . $box . '" SELECTED>' . $box2 . '</OPTION>' . "\n"; } else { $mbox_options .= '<OPTION VALUE="' . $box . '">' . $box2 . '</OPTION>' . "\n"; } } } return $mbox_options; }
/** * Checks if folder is noinferiors (can't store other folders) * * Function does not check if folder subscribed. * @param stream $oImapStream imap connection resource * @param string $sImapFolder imap folder name * @param object $oBoxes mailboxes class object. * @return boolean true, when folder has noinferiors flag. false in any other case. * @since 1.5.1 */ function sqimap_mailbox_is_noinferiors($oImapStream, $sImapFolder, &$oBoxes) { // build mailbox object if it is not available if (!is_object($oBoxes)) { $oBoxes = sqimap_mailbox_list($oImapStream); } foreach ($oBoxes as $box) { if ($box['unformatted'] == $sImapFolder) { return (bool) check_is_noinferiors($box['raw']); } } return false; }