本文整理汇总了PHP中sqimap_mailbox_select函数的典型用法代码示例。如果您正苦于以下问题:PHP sqimap_mailbox_select函数的具体用法?PHP sqimap_mailbox_select怎么用?PHP sqimap_mailbox_select使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqimap_mailbox_select函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sqgetGlobalVar
/** GET/POST VARS */
sqgetGlobalVar('passed_ent_id', $passed_ent_id);
sqgetGlobalVar('mailbox', $mailbox);
if (sqgetGlobalVar('passed_id', $temp)) {
$passed_id = (int) $temp;
}
if (sqgetGlobalVar('sort', $temp)) {
$sort = (int) $temp;
}
if (sqgetGlobalVar('startMessage', $temp)) {
$startMessage = (int) $temp;
}
/* end of get globals */
global $uid_support, $sqimap_capabilities;
$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
$mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
/**
* $message contains all information about the message
* including header and body
*/
$uidvalidity = $mbx_response['UIDVALIDITY'];
if (!isset($messages[$uidvalidity])) {
$messages[$uidvalidity] = array();
}
if (!isset($messages[$uidvalidity][$passed_id]) || !$uid_support) {
$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
$FirstTimeSee = !$message->is_seen;
$message->is_seen = true;
$messages[$uidvalidity][$passed_id] = $message;
} else {
// $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
示例2: deliverMessage
//.........这里部分代码省略.........
$rfc822_header->encoding = '8bit';
}
if ($default_charset) {
$content_type->properties['charset'] = $default_charset;
}
}
$rfc822_header->content_type = $content_type;
$composeMessage->rfc822_header = $rfc822_header;
/* Here you can modify the message structure just before we hand
it over to deliver */
$hookReturn = do_hook('compose_send', $composeMessage);
/* Get any changes made by plugins to $composeMessage. */
if (is_object($hookReturn[1])) {
$composeMessage = $hookReturn[1];
}
if (!$useSendmail && !$draft) {
require_once SM_PATH . 'class/deliver/Deliver_SMTP.class.php';
$deliver = new Deliver_SMTP();
global $smtpServerAddress, $smtpPort, $pop_before_smtp, $smtp_auth_mech;
$authPop = isset($pop_before_smtp) && $pop_before_smtp ? true : false;
get_smtp_user($user, $pass);
$stream = $deliver->initStream($composeMessage, $domain, 0, $smtpServerAddress, $smtpPort, $user, $pass, $authPop);
} elseif (!$draft) {
require_once SM_PATH . 'class/deliver/Deliver_SendMail.class.php';
global $sendmail_path;
$deliver = new Deliver_SendMail();
$stream = $deliver->initStream($composeMessage, $sendmail_path);
} elseif ($draft) {
global $draft_folder;
require_once SM_PATH . 'class/deliver/Deliver_IMAP.class.php';
$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
if (sqimap_mailbox_exists($imap_stream, $draft_folder)) {
require_once SM_PATH . 'class/deliver/Deliver_IMAP.class.php';
$imap_deliver = new Deliver_IMAP();
$length = $imap_deliver->mail($composeMessage);
sqimap_append($imap_stream, $draft_folder, $length);
$imap_deliver->mail($composeMessage, $imap_stream);
sqimap_append_done($imap_stream, $draft_folder);
sqimap_logout($imap_stream);
unset($imap_deliver);
return $length;
} else {
$msg = '<br />' . sprintf(_("Error: Draft folder %s does not exist."), $draft_folder);
plain_error_message($msg, $color);
return false;
}
}
$succes = false;
if ($stream) {
$length = $deliver->mail($composeMessage, $stream);
$succes = $deliver->finalizeStream($stream);
}
if (!$succes) {
$msg = $deliver->dlv_msg . '<br />' . _("Server replied: ") . $deliver->dlv_ret_nr . ' ' . $deliver->dlv_server_msg;
plain_error_message($msg, $color);
} else {
unset($deliver);
$move_to_sent = getPref($data_dir, $username, 'move_to_sent');
$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
/* Move to sent code */
if (isset($default_move_to_sent) && $default_move_to_sent != 0) {
$svr_allow_sent = true;
} else {
$svr_allow_sent = false;
}
if (isset($sent_folder) && ($sent_folder != '' || $sent_folder != 'none') && sqimap_mailbox_exists($imap_stream, $sent_folder)) {
$fld_sent = true;
} else {
$fld_sent = false;
}
if (isset($move_to_sent) && $move_to_sent != 0 || !isset($move_to_sent)) {
$lcl_allow_sent = true;
} else {
$lcl_allow_sent = false;
}
if ($fld_sent && $svr_allow_sent && !$lcl_allow_sent || $fld_sent && $lcl_allow_sent) {
global $passed_id, $mailbox, $action;
if ($action == 'reply' || $action == 'reply_all') {
$save_reply_with_orig = getPref($data_dir, $username, 'save_reply_with_orig');
if ($save_reply_with_orig) {
$sent_folder = $mailbox;
}
}
sqimap_append($imap_stream, $sent_folder, $length);
require_once SM_PATH . 'class/deliver/Deliver_IMAP.class.php';
$imap_deliver = new Deliver_IMAP();
$imap_deliver->mail($composeMessage, $imap_stream);
sqimap_append_done($imap_stream, $sent_folder);
unset($imap_deliver);
}
global $passed_id, $mailbox, $action;
ClearAttachments($composeMessage);
if ($action == 'reply' || $action == 'reply_all') {
sqimap_mailbox_select($imap_stream, $mailbox);
sqimap_messages_flag($imap_stream, $passed_id, $passed_id, 'Answered', false);
}
sqimap_logout($imap_stream);
}
return $succes;
}
示例3: sqgetGlobalVar
sqgetGlobalVar('passed_id', $passed_id, SQ_GET);
if (!sqgetGlobalVar('startMessage', $startMessage, SQ_GET)) {
$startMessage = 1;
}
if (!sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET)) {
$passed_ent_id = 0;
}
sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION);
if (!sqgetGlobalVar('composesession', $composesession, SQ_SESSION)) {
$composesession = 0;
sqsession_register($composesession, 'composesession');
}
/* END GLOBALS */
displayPageHeader($color, $mailbox);
$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
sqimap_mailbox_select($imap_stream, $mailbox);
if ($spamcop_method == 'quick_email' || $spamcop_method == 'thorough_email') {
// Use email-based reporting -- save as an attachment
$session = "{$composesession}" + 1;
$composesession = $session;
sqsession_register($composesession, 'composesession');
if (!isset($compose_messages)) {
$compose_messages = array();
}
if (!isset($compose_messages[$session]) || $compose_messages[$session] == NULL) {
$composeMessage = new Message();
$rfc822_header = new Rfc822Header();
$composeMessage->rfc822_header = $rfc822_header;
$composeMessage->reply_rfc822_header = '';
$compose_messages[$session] = $composeMessage;
sqsession_register($compose_messages, 'compose_messages');
示例4: showMessagesForMailbox
function showMessagesForMailbox($imapConnection, $in_box, $ok_box, $er_box, $domain, $skannauskansio)
{
// Valitaan inboxi
$mbxresponse = sqimap_mailbox_select($imapConnection, $in_box);
// haetaan inboxin kaikki viestit
$query = "SEARCH UID 1:*";
$read_list = sqimap_run_command_list($imapConnection, $query, true, $response, $message, '');
// Otetaan messageid:t
if (preg_match("/\\* SEARCH ([0-9 ]*)/", $read_list[0][0], $matches)) {
$messaget = explode(" ", trim($matches[1]));
} else {
$messaget = array();
}
$messu_seqid_corr = 0;
foreach ($messaget as $messu_seqid) {
// Oliks tää ok maili
$is_ok = FALSE;
$messu_seqid = $messu_seqid - $messu_seqid_corr;
// Haetaan viestin UID
$query = "FETCH {$messu_seqid} (UID)";
$fetch_uid = sqimap_run_command_list($imapConnection, $query, true, $response, $message, '');
if (isset($fetch_uid[0][0]) and preg_match("/\\(UID ([0-9]*)\\)/", $fetch_uid[0][0], $matches)) {
$uid = $matches[1];
} else {
continue;
}
// Haetaan viestin From
$query = "UID FETCH {$uid} (BODY[HEADER.FIELDS (From)])";
$fetch_from = sqimap_run_command_list($imapConnection, $query, true, $response, $message, '');
// Onko lähettäjän domaini ok?
$okdomain = FALSE;
if (empty($domain)) {
$okdomain = TRUE;
} elseif (is_array($domain) and count($domain) > 0) {
foreach ($domain as $d_d) {
if (preg_match("/[a-z\\.]*?@{$d_d}/i", $fetch_from[0][1])) {
$okdomain = TRUE;
break;
}
}
if (!$okdomain) {
echo "Laskuja hyväksytään vain ";
foreach ($domain as $d_d) {
echo $d_d . " ";
}
echo "domainista, " . $fetch_from[0][1] . "\n";
}
} elseif (!is_array($domain) and $domain != '') {
if (preg_match("/[a-z\\.]*?@{$domain}/i", $fetch_from[0][1])) {
$okdomain = TRUE;
} else {
echo "Laskuja hyväksytään vain {$domain} domainista, " . $fetch_from[0][1] . "\n";
}
}
if ($okdomain) {
// Haetaan viestin BODYSTRUCTURE
$query = "UID FETCH {$uid} (BODYSTRUCTURE)";
$fetch_message = sqimap_run_command_list($imapConnection, $query, true, $response, $message, '');
preg_match("/BODYSTRUCTURE \\((.*)\\)/", $fetch_message[0][0], $matches);
$bodyt = explode(")(", $matches[1]);
for ($bodyind = 1; $bodyind <= count($bodyt); $bodyind++) {
// Haetaan viestin BODY, tai siis osa siitä
$query = "UID FETCH {$uid} (BODY[{$bodyind}])";
$fetch_body_part = sqimap_run_command_list($imapConnection, $query, true, $response, $message, '');
if (preg_match("/\\(BODY\\[{$bodyind}\\] NIL\\)/", $fetch_body_part[0][0])) {
break;
}
// Fetchataan filename
if (preg_match("/\\(\"(FILE)?NAME\" \"(.*?)\"\\)/", $bodyt[$bodyind - 1], $matches)) {
// Ok maili
$is_ok = TRUE;
$path_parts = pathinfo($matches[2]);
$name = strtoupper($path_parts['filename']);
$ext = strtoupper($path_parts['extension']);
// Hyväksytyt filet
if (strtoupper($ext) != "JPG" and strtoupper($ext) != "JPEG" and strtoupper($ext) != "PNG" and strtoupper($ext) != "GIF" and strtoupper($ext) != "PDF") {
echo "Ainoastaan .jpg .gif .png .pdf tiedostot sallittuja!\n";
continue;
}
// Kirjoitetaan liitetiedosto levylle
$attachmentbody = "";
for ($line = 1; $line < count($fetch_body_part[0]) - 1; $line++) {
$attachmentbody .= trim($fetch_body_part[0][$line]);
}
$attachmentbody = base64_decode($attachmentbody);
// Katotaan, ettei samalla nimellä oo jo laskua jonossa
if (file_exists($skannauskansio . "/" . $matches[2])) {
$kala = 1;
$filename = $matches[2];
while (file_exists($skannauskansio . "/" . $filename)) {
$filename = $kala . "_" . $matches[2];
$kala++;
}
$matches[2] = $filename;
}
file_put_contents($skannauskansio . "/" . $matches[2], $attachmentbody);
}
}
}
$movebox = $is_ok ? $ok_box : $er_box;
//.........这里部分代码省略.........
示例5: sqgetGlobalVar
require '../include/init.php';
/** SquirrelMail required files. */
require_once SM_PATH . 'functions/imap.php';
require_once SM_PATH . 'functions/mime.php';
require_once SM_PATH . 'functions/date.php';
/** Get globals */
sqgetGlobalVar('messages', $messages, SQ_SESSION);
sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
sqgetGlobalVar('ent_id', $ent_id, SQ_GET);
sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET);
sqgetGlobalVar('passed_id', $passed_id, SQ_GET, NULL, SQ_TYPE_BIGINT);
// TODO: add required var checks here.
global $imap_stream_options;
// in case not defined in config
$imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
$mbx_response = sqimap_mailbox_select($imap_stream, $mailbox);
$message =& $messages[$mbx_response['UIDVALIDITY']][$passed_id];
if (!is_object($message)) {
$message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
}
$message_ent = $message->getEntity($ent_id);
if ($passed_ent_id) {
$message = $message->getEntity($passed_ent_id);
}
$header = $message_ent->header;
$type0 = $header->type0;
$type1 = $header->type1;
$charset = $header->getParameter('charset');
$encoding = strtolower($header->encoding);
$body = mime_fetch_body($imap_stream, $passed_id, $ent_id);
$body = decodeBody($body, $encoding);
示例6: spam_filters
/**
* FIXME: Undocumented function
* @access private
*/
function spam_filters($imap_stream)
{
global $data_dir, $username, $uid_support;
global $SpamFilters_YourHop;
global $SpamFilters_DNScache;
global $SpamFilters_SharedCache;
global $SpamFilters_BulkQuery;
$filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan');
$filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder');
$filters = load_spam_filters();
if ($SpamFilters_SharedCache) {
filters_LoadCache();
}
$run = false;
foreach ($filters as $Key => $Value) {
if ($Value['enabled']) {
$run = true;
break;
}
}
// short-circuit
if (!$run) {
return;
}
sqimap_mailbox_select($imap_stream, 'INBOX');
$search_array = array();
if ($filters_spam_scan == 'new') {
$read = sqimap_run_command($imap_stream, 'SEARCH UNSEEN', true, $response, $message, $uid_support);
if (isset($read[0])) {
for ($i = 0, $iCnt = count($read); $i < $iCnt; ++$i) {
if (preg_match("/^\\* SEARCH (.+)\$/", $read[$i], $regs)) {
$search_array = explode(' ', trim($regs[1]));
break;
}
}
}
}
if ($filters_spam_scan == 'new' && count($search_array)) {
$msg_str = sqimap_message_list_squisher($search_array);
$imap_query = 'FETCH ' . $msg_str . ' (FLAGS BODY.PEEK[HEADER.FIELDS (RECEIVED)])';
} else {
if ($filters_spam_scan != 'new') {
$imap_query = 'FETCH 1:* (FLAGS BODY.PEEK[HEADER.FIELDS (RECEIVED)])';
} else {
return;
}
}
$read = sqimap_run_command_list($imap_stream, $imap_query, true, $response, $message, $uid_support);
if (isset($response) && $response != 'OK') {
return;
}
$messages = parseFetch($read);
$bulkquery = strlen($SpamFilters_BulkQuery) > 0 ? true : false;
$aSpamIds = array();
foreach ($messages as $id => $message) {
if (isset($message['UID'])) {
$MsgNum = $message['UID'];
} else {
$MsgNum = $id;
}
if (isset($message['received'])) {
foreach ($message['received'] as $received) {
if (is_int(strpos($received, $SpamFilters_YourHop))) {
if (preg_match('/([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})/', $received, $matches)) {
$IsSpam = false;
if (filters_spam_check_site($matches[1], $matches[2], $matches[3], $matches[4], $filters)) {
$aSpamIds[] = $MsgNum;
$IsSpam = true;
}
if ($bulkquery) {
array_shift($matches);
$IP = explode('.', $matches);
foreach ($filters as $key => $value) {
if ($filters[$key]['enabled'] && $filters[$key]['dns']) {
if (strlen($SpamFilters_DNScache[$IP . '.' . $filters[$key]['dns']]) == 0) {
$IPs[$IP] = true;
break;
}
}
}
}
if ($SpamFilters_YourHop == ' ' || $IsSpam) {
break;
}
}
}
}
}
}
if (count($aSpamIds) && sqimap_mailbox_exists($imap_stream, $filters_spam_folder)) {
sqimap_msgs_list_move($imap_stream, $aSpamIds, $filters_spam_folder);
sqimap_mailbox_expunge($imap_stream, 'INBOX', true, $aSpamIds);
}
if ($bulkquery && count($IPs)) {
filters_bulkquery($filters, $IPs);
}
//.........这里部分代码省略.........
示例7: sqgetGlobalVar
require_once SM_PATH . 'include/validate.php';
require_once SM_PATH . 'functions/date.php';
require_once SM_PATH . 'functions/page_header.php';
require_once SM_PATH . 'functions/mime.php';
require_once SM_PATH . 'include/load_prefs.php';
/* globals */
sqgetGlobalVar('username', $username, SQ_SESSION);
sqgetGlobalVar('key', $key, SQ_COOKIE);
sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
sqgetGlobalVar('passed_id', $passed_id, SQ_GET);
sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
sqgetGlobalVar('ent_id', $ent_id, SQ_GET);
sqgetGlobalVar('startMessage', $startMessage, SQ_GET);
/* end globals */
$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
sqimap_mailbox_select($imapConnection, $mailbox);
displayPageHeader($color, 'None');
echo '<br /><table width="100%" border="0" cellspacing="0" cellpadding="2" ' . 'align="center">' . "\n" . '<tr><td bgcolor="' . $color[0] . '">' . '<b><center>' . _("Viewing a Business Card") . " - ";
$msg_url = 'read_body.php?mailbox=' . urlencode($mailbox) . '&startMessage=' . urlencode($startMessage) . '&passed_id=' . urlencode($passed_id);
$msg_url = set_url_var($msg_url, 'ent_id', 0);
echo '<a href="' . $msg_url . '">' . _("View message") . '</a>';
echo '</center></b></td></tr>';
$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
$entity_vcard = getEntity($message, $ent_id);
$vcard = mime_fetch_body($imapConnection, $passed_id, $ent_id);
$vcard = decodeBody($vcard, $entity_vcard->header->encoding);
$vcard = explode("\n", $vcard);
foreach ($vcard as $l) {
$k = substr($l, 0, strpos($l, ':'));
$v = substr($l, strpos($l, ':') + 1);
$attributes = explode(';', $k);
示例8: newMail
function newMail($mailbox = '', $passed_id = '', $passed_ent_id = '', $action = '', $session = '')
{
global $editor_size, $default_use_priority, $body, $idents, $use_signature, $data_dir, $username, $key, $imapServerAddress, $imapPort, $imap_stream_options, $composeMessage, $body_quote, $request_mdn, $request_dr, $mdn_user_support, $languages, $squirrelmail_language, $default_charset, $do_not_reply_to_self;
/*
* Set $default_charset to correspond with the user's selection
* of language interface. $default_charset global is not correct,
* if message is composed in new window.
*/
set_my_charset();
$send_to = $send_to_cc = $send_to_bcc = $subject = $identity = '';
$mailprio = 3;
if ($passed_id) {
$imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
sqimap_mailbox_select($imapConnection, $mailbox);
$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
$body = '';
if ($passed_ent_id) {
/* redefine the messsage in case of message/rfc822 */
$message = $message->getEntity($passed_ent_id);
/* message is an entity which contains the envelope and type0=message
* and type1=rfc822. The actual entities are childs from
* $message->entities[0]. That's where the encoding and is located
*/
$entities = $message->entities[0]->findDisplayEntity(array(), $alt_order = array('text/plain'));
if (!count($entities)) {
$entities = $message->entities[0]->findDisplayEntity(array(), $alt_order = array('text/plain', 'text/html'));
}
$orig_header = $message->rfc822_header;
/* here is the envelope located */
/* redefine the message for picking up the attachments */
$message = $message->entities[0];
} else {
$entities = $message->findDisplayEntity(array(), $alt_order = array('text/plain'));
if (!count($entities)) {
$entities = $message->findDisplayEntity(array(), $alt_order = array('text/plain', 'text/html'));
}
$orig_header = $message->rfc822_header;
}
$type0 = $message->type0;
$type1 = $message->type1;
foreach ($entities as $ent) {
$msg = $message->getEntity($ent);
$type0 = $msg->type0;
$type1 = $msg->type1;
$unencoded_bodypart = mime_fetch_body($imapConnection, $passed_id, $ent);
$body_part_entity = $message->getEntity($ent);
$bodypart = decodeBody($unencoded_bodypart, $body_part_entity->header->encoding);
if ($type1 == 'html') {
$bodypart = str_replace("\n", ' ', $bodypart);
$bodypart = preg_replace(array('/<\\/?p>/i', '/<div><\\/div>/i', '/<br\\s*(\\/)*>/i', '/<\\/?div>/i'), "\n", $bodypart);
$bodypart = str_replace(array(' ', '>', '<'), array(' ', '>', '<'), $bodypart);
$bodypart = strip_tags($bodypart);
}
if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode')) {
if (mb_detect_encoding($bodypart) != 'ASCII') {
$bodypart = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode', $bodypart);
}
}
// charset encoding in compose form stuff
if (isset($body_part_entity->header->parameters['charset'])) {
$actual = $body_part_entity->header->parameters['charset'];
} else {
$actual = 'us-ascii';
}
if ($actual && is_conversion_safe($actual) && $actual != $default_charset) {
$bodypart = charset_convert($actual, $bodypart, $default_charset, false);
}
// end of charset encoding in compose
$body .= $bodypart;
}
if ($default_use_priority) {
$mailprio = substr($orig_header->priority, 0, 1);
if (!$mailprio) {
$mailprio = 3;
}
} else {
$mailprio = '';
}
$from_o = $orig_header->from;
if (is_array($from_o)) {
if (isset($from_o[0])) {
$from_o = $from_o[0];
}
}
if (is_object($from_o)) {
$orig_from = $from_o->getAddress();
} else {
$orig_from = '';
}
$identities = array();
if (count($idents) > 1) {
foreach ($idents as $nr => $data) {
$enc_from_name = '"' . $data['full_name'] . '" <' . $data['email_address'] . '>';
$identities[] = $enc_from_name;
}
$identity_match = $orig_header->findAddress($identities);
if ($identity_match !== FALSE) {
$identity = $identity_match;
}
}
//.........这里部分代码省略.........
示例9: bayesspam_filters
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'] . '\'');
}
}
}
示例10: walkTreeInPostOrderCreatingFoldersUnderTrash
function walkTreeInPostOrderCreatingFoldersUnderTrash($index, $imap_stream, $tree, $topFolderName)
{
global $trash_folder, $delimiter;
$position = strrpos($topFolderName, $delimiter) + 1;
$subFolderName = substr($tree[$index]['value'], $position);
if ($tree[$index]['doIHaveChildren']) {
sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, "");
$mbx_response = sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
$messageCount = $mbx_response['EXISTS'];
if ($messageCount > 0) {
sqimap_messages_copy($imap_stream, 1, '*', $trash_folder . $delimiter . $subFolderName);
}
for ($j = 0; $j < count($tree[$index]['subNodes']); $j++) {
walkTreeInPostOrderCreatingFoldersUnderTrash($tree[$index]['subNodes'][$j], $imap_stream, $tree, $topFolderName);
}
} else {
sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, '');
$mbx_response = sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
$messageCount = $mbx_response['EXISTS'];
if ($messageCount > 0) {
sqimap_messages_copy($imap_stream, 1, '*', $trash_folder . $delimiter . $subFolderName);
}
}
}
示例11: mail
/**
* function mail - send the message parts to the SMTP stream
*
* @param Message $message Message object to send
* NOTE that this is passed by
* reference and will be modified
* upon return with updated
* fields such as Message ID, References,
* In-Reply-To and Date headers.
* @param resource $stream Handle to the outgoing stream
* (when FALSE, nothing will be
* written to the stream; this can
* be used to determine the actual
* number of bytes that will be
* written to the stream)
* @param string $reply_id Identifies message being replied to
* (OPTIONAL; caller should ONLY specify
* a value for this when the message
* being sent is a reply)
* @param string $reply_ent_id Identifies message being replied to
* in the case it was an embedded/attached
* message inside another (OPTIONAL; caller
* should ONLY specify a value for this
* when the message being sent is a reply)
* @param resource $imap_stream If there is an open IMAP stream in
* the caller's context, it should be
* passed in here. This is OPTIONAL,
* as one will be created if not given,
* but as some IMAP servers may baulk
* at opening more than one connection
* at a time, the caller should always
* abide if possible. Currently, this
* stream is only used when $reply_id
* is also non-zero, but that is subject
* to change.
* @param mixed $extra Any implementation-specific variables
* can be passed in here and used in
* an overloaded version of this method
* if needed.
*
* @return integer The number of bytes written (or that would have been
* written) to the output stream.
*
*/
function mail(&$message, $stream = false, $reply_id = 0, $reply_ent_id = 0, $imap_stream = NULL, $extra = NULL)
{
$rfc822_header =& $message->rfc822_header;
if (count($message->entities)) {
$boundary = $this->mimeBoundary();
$rfc822_header->content_type->properties['boundary'] = '"' . $boundary . '"';
} else {
$boundary = '';
}
$raw_length = 0;
// calculate reply header if needed
//
if ($reply_id) {
global $imapConnection, $username, $key, $imapServerAddress, $imapPort, $mailbox;
// try our best to use an existing IMAP handle
//
$close_imap_stream = FALSE;
if (is_resource($imap_stream)) {
$my_imap_stream = $imap_stream;
} else {
if (is_resource($imapConnection)) {
$my_imap_stream = $imapConnection;
} else {
$close_imap_stream = TRUE;
$my_imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
}
}
sqimap_mailbox_select($my_imap_stream, $mailbox);
$reply_message = sqimap_get_message($my_imap_stream, $reply_id, $mailbox);
if ($close_imap_stream) {
sqimap_logout($my_imap_stream);
}
if ($reply_ent_id) {
/* redefine the messsage in case of message/rfc822 */
$reply_message = $message->getEntity($reply_ent_id);
/* message is an entity which contains the envelope and type0=message
* and type1=rfc822. The actual entities are childs from
* $reply_message->entities[0]. That's where the encoding and is located
*/
$orig_header = $reply_message->rfc822_header;
/* here is the envelope located */
} else {
$orig_header = $reply_message->rfc822_header;
}
$message->reply_rfc822_header = $orig_header;
}
$reply_rfc822_header = isset($message->reply_rfc822_header) ? $message->reply_rfc822_header : '';
$header = $this->prepareRFC822_Header($rfc822_header, $reply_rfc822_header, $raw_length);
$this->send_mail($message, $header, $boundary, $stream, $raw_length, $extra);
return $raw_length;
}
示例12: spam_filters
/**
* FIXME: Undocumented function
* @access private
*/
function spam_filters($imap_stream)
{
global $data_dir, $username, $uid_support;
global $SpamFilters_YourHop;
global $SpamFilters_DNScache;
global $SpamFilters_SharedCache;
global $SpamFilters_BulkQuery;
$filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan');
$filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder');
$filters = load_spam_filters();
if ($SpamFilters_SharedCache) {
filters_LoadCache();
}
$run = 0;
foreach ($filters as $Key => $Value) {
if ($Value['enabled']) {
$run++;
}
}
// short-circuit
if ($run == 0) {
return;
}
sqimap_mailbox_select($imap_stream, 'INBOX');
// Ask for a big list of all "Received" headers in the inbox with
// flags for each message. Kinda big.
if ($filters_spam_scan != 'new') {
$read = sqimap_run_command($imap_stream, 'FETCH 1:* (FLAGS BODY.PEEK[HEADER.FIELDS ' . '(RECEIVED)])', true, $response, $message, $uid_support);
} else {
$read = sqimap_run_command($imap_stream, 'SEARCH UNSEEN', true, $response, $message, $uid_support);
if ($response != 'OK' || trim($read[0]) == '* SEARCH') {
$read = sqimap_run_command($imap_stream, 'FETCH 1:* (FLAGS BODY.PEEK[HEADER.FIELDS ' . '(RECEIVED)])', true, $response, $message, $uid_support);
} else {
if (isset($read[0])) {
if (preg_match("/^\\* SEARCH (.+)\$/", $read[0], $regs)) {
$search_array = preg_split("/ /", trim($regs[1]));
}
}
$msgs_str = sqimap_message_list_squisher($search_array);
$imap_query = 'FETCH ' . $msgs_str;
$imap_query .= ' (FLAGS BODY.PEEK[HEADER.FIELDS ';
$imap_query .= '(RECEIVED)])';
$read = sqimap_run_command($imap_stream, $imap_query, true, $response, $message, $uid_support);
}
}
if (isset($response) && $response != 'OK') {
return;
}
if (strlen($SpamFilters_BulkQuery) > 0) {
filters_bulkquery($filters_spam_scan, $filters, $read);
}
$i = 0;
while ($i < count($read)) {
// EIMS will give funky results
$Chunks = explode(' ', $read[$i]);
if ($Chunks[0] != '*') {
$i++;
continue;
}
$MsgNum = $Chunks[1];
$IPs = array();
$i++;
$IsSpam = 0;
// Look through all of the Received headers for IP addresses
// Stop when I get ")" on a line
// Stop if I get "*" on a line (don't advance)
// and above all, stop if $i is bigger than the total # of lines
while ($i < count($read) && ($read[$i][0] != ')' && $read[$i][0] != '*' && $read[$i][0] != "\n") && !$IsSpam) {
// Check to see if this line is the right "Received from" line
// to check
if (is_int(strpos($read[$i], $SpamFilters_YourHop))) {
// short-circuit and skip work if we don't scan this one
$read[$i] = ereg_replace('[^0-9\\.]', ' ', $read[$i]);
$elements = explode(' ', $read[$i]);
foreach ($elements as $value) {
if ($value != '' && ereg('[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}', $value, $regs)) {
$Chunks = explode('.', $value);
if (filters_spam_check_site($Chunks[0], $Chunks[1], $Chunks[2], $Chunks[3], $filters)) {
$IsSpam++;
break;
// no sense in checking more IPs
}
// If we've checked one IP and YourHop is
// just a space
if ($SpamFilters_YourHop == ' ') {
break;
// don't check any more
}
}
}
}
$i++;
}
// Lookie! It's spam! Yum!
if ($IsSpam) {
if (sqimap_mailbox_exists($imap_stream, $filters_spam_folder)) {
//.........这里部分代码省略.........
示例13: spamcop_while_sending
function spamcop_while_sending()
{
global $mailbox, $spamcop_delete, $auto_expunge, $username, $key, $imapServerAddress, $imapPort;
// load sqgetGlobalVar()
include_once SM_PATH . 'functions/global.php';
// check if compose.php is called by spamcop plugin
if (sqgetGlobalVar('spamcop_is_composing', $spamcop_is_composing)) {
if ($spamcop_delete) {
$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
sqimap_mailbox_select($imapConnection, $mailbox);
sqimap_msgs_list_delete($imapConnection, $mailbox, $spamcop_is_composing);
if ($auto_expunge) {
sqimap_mailbox_expunge($imapConnection, $mailbox, true);
}
}
// change default email composition setting. Plugin always operates in right frame.
// make sure that compose.php redirects to right page. Temporally override.
global $compose_new_win;
$compose_new_win = false;
}
}
示例14: start_filters
/**
* Starts the filtering process
* @param array $hook_args (since 1.5.2) do hook arguments. Is used to check
* hook name, array key = 0.
* @access private
*/
function start_filters($hook_args)
{
global $imapServerAddress, $imapPort, $imap_stream_options, $imap_stream, $imapConnection, $UseSeparateImapConnection, $AllowSpamFilters, $filter_inbox_count, $username;
// if there were filtering errors previously during
// this login session, we won't try again
//
// (errors that this plugin was able to catch or a "NO"
// response/failure from IMAP found in the current session,
// which could have resulted from an attempted filter copy
// (over quota), in which case execution halts before this
// plugin can catch the problem -- note, however, that any
// other IMAP "NO" failure (caused by unrelated actions) at
// any time during the current session will cause this plugin
// to effectively shut down)
//
sqgetGlobalVar('filters_error', $filters_error, SQ_SESSION, FALSE);
sqgetGlobalVar('IMAP_FATAL_ERROR_TYPE', $imap_fatal_error, SQ_SESSION, '');
if ($filters_error || $imap_fatal_error == 'NO') {
return;
}
/**
* check hook that calls filtering. If filters are called by right_main_after_header,
* do filtering only when we are in INBOX folder.
*/
if ($hook_args[0] == 'right_main_after_header' && (sqgetGlobalVar('mailbox', $mailbox, SQ_FORM) && $mailbox != 'INBOX')) {
return;
}
$filters = load_filters();
// No point running spam filters if there aren't any to run //
if ($AllowSpamFilters) {
$spamfilters = load_spam_filters();
$AllowSpamFilters = false;
foreach ($spamfilters as $value) {
if ($value['enabled'] == SMPREF_ON) {
$AllowSpamFilters = true;
break;
}
}
}
// No user filters, and no spam filters, no need to continue //
if (!$AllowSpamFilters && empty($filters)) {
return;
}
// Detect if we have already connected to IMAP or not.
// Also check if we are forced to use a separate IMAP connection
if (!isset($imap_stream) && !isset($imapConnection) || $UseSeparateImapConnection) {
$stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 10, $imap_stream_options);
$previously_connected = false;
} else {
if (isset($imapConnection)) {
$stream = $imapConnection;
$previously_connected = true;
} else {
$previously_connected = true;
$stream = $imap_stream;
}
}
if (!isset($filter_inbox_count)) {
$aStatus = sqimap_status_messages($stream, 'INBOX', array('MESSAGES'));
if (!empty($aStatus['MESSAGES'])) {
$filter_inbox_count = $aStatus['MESSAGES'];
} else {
$filter_inbox_count = 0;
}
}
if ($filter_inbox_count > 0) {
sqimap_mailbox_select($stream, 'INBOX');
// Filter spam from inbox before we sort them into folders
if ($AllowSpamFilters) {
spam_filters($stream);
}
// Sort into folders
user_filters($stream);
}
if (!$previously_connected) {
sqimap_logout($stream);
}
}
示例15: showMessagesForMailbox
function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs, $start_msg, $sort, $color, $show_num, $use_cache, $mode = '')
{
global $msgs, $msort, $auto_expunge, $thread_sort_messages, $allow_server_sort, $server_sort_order;
/*
* For some reason, on PHP 4.3+, this being unset, and set in the session causes havoc
* so setting it to an empty array beforehand seems to clean up the issue, and stopping the
* "Your script possibly relies on a session side-effect which existed until PHP 4.2.3" error
*/
if (!isset($msort)) {
$msort = array();
}
if (!isset($msgs)) {
$msgs = array();
}
//$start = microtime();
/* If autoexpunge is turned on, then do it now. */
$mbxresponse = sqimap_mailbox_select($imapConnection, $mailbox);
$srt = $sort;
/* If autoexpunge is turned on, then do it now. */
if ($auto_expunge == true) {
$exp_cnt = sqimap_mailbox_expunge($imapConnection, $mailbox, false, '');
$mbxresponse['EXISTS'] = $mbxresponse['EXISTS'] - $exp_cnt;
$num_msgs = $mbxresponse['EXISTS'];
}
if ($mbxresponse['EXISTS'] > 0) {
/* if $start_msg is lower than $num_msgs, we probably deleted all messages
* in the last page. We need to re-adjust the start_msg
*/
if ($start_msg > $num_msgs) {
$start_msg -= $show_num;
if ($start_msg < 1) {
$start_msg = 1;
}
}
/* This code and the next if() block check for
* server-side sorting methods. The $id array is
* formatted and $sort is set to 6 to disable
* SM internal sorting
*/
if ($thread_sort_messages == 1) {
$mode = 'thread';
} elseif ($allow_server_sort == 1) {
$mode = 'serversort';
} else {
$mode = '';
}
if ($use_cache) {
sqgetGlobalVar('msgs', $msgs, SQ_SESSION);
sqgetGlobalVar('msort', $msort, SQ_SESSION);
} else {
sqsession_unregister('msort');
sqsession_unregister('msgs');
}
switch ($mode) {
case 'thread':
$id = get_thread_sort($imapConnection);
$msgs = getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
if ($msgs === false) {
echo '<b><small><center><font color="red">' . _("Thread sorting is not supported by your IMAP server.") . '<br />' . _("Please contact your system administrator and report this error.") . '</font></center></small></b>';
$thread_sort_messages = 0;
$msort = $msgs = array();
} else {
$msort = $msgs;
$sort = 6;
}
break;
case 'serversort':
$id = sqimap_get_sort_order($imapConnection, $sort, $mbxresponse);
$msgs = getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
if ($msgs === false) {
echo '<b><small><center><font color="red">' . _("Server-side sorting is not supported by your IMAP server.") . '<br />' . _("Please contact your system administrator and report this error.") . '</font></center></small></b>';
$sort = $server_sort_order;
$allow_server_sort = FALSE;
$msort = $msgs = array();
$id = array();
} else {
$msort = $msgs;
$sort = 6;
}
break;
default:
if (!$use_cache) {
$msgs = getSelfSortMessages($imapConnection, $start_msg, $show_num, $num_msgs, $sort, $mbxresponse);
$msort = calc_msort($msgs, $sort);
}
/* !use cache */
break;
}
// switch
sqsession_register($msort, 'msort');
sqsession_register($msgs, 'msgs');
}
/* if exists > 0 */
$res = getEndMessage($start_msg, $show_num, $num_msgs);
$start_msg = $res[0];
$end_msg = $res[1];
if ($num_msgs > 0) {
$paginator_str = get_paginator_str($mailbox, $start_msg, $end_msg, $num_msgs, $show_num, $sort);
} else {
$paginator_str = '';
//.........这里部分代码省略.........