$message .= "<br>"; } rescue_item($euid, $mail_id); $rescued++; } $sth->free(); if ($rescued > 0) { $message .= sprintf($lang['text_attachments_rescued'], $rescued) . ".<br>"; } break; case "header": $rescued = 0; $select = "SELECT maia_mail.id, maia_mail.sender_email " . "FROM maia_mail, maia_mail_recipients " . "WHERE maia_mail.id = maia_mail_recipients.mail_id " . "AND maia_mail_recipients.type = 'B' " . "AND maia_mail_recipients.token = ? " . "AND SUBSTRING(maia_mail_recipients.token FROM 1 FOR 7) <> 'expired' " . "AND maia_mail_recipients.recipient_id = ?"; $sth = $dbh->query($select, array($token, $euid)); while ($row = $sth->fetchRow()) { $mail_id = $row["id"]; $sender = $row["sender_email"]; if (array_key_exists('wblist', $_GET)) { $message .= $lang[add_address_to_wb_list($euid, $sender, "W")]; $message .= "<br>"; } rescue_item($euid, $mail_id); $rescued++; } $sth->free(); if ($rescued > 0) { $message .= sprintf($lang['text_headers_rescued'], $rescued) . ".<br>"; } } $_SESSION["message"] = $message; header("Location: welcome.php");
function rescue_item($user_id, $mail_id, $resend = false) { global $dbh, $logger; $sth = $dbh->prepare("SELECT sender_email, contents, " . "envelope_to, maia_mail_recipients.type " . "FROM maia_mail, maia_mail_recipients " . "WHERE maia_mail.id = maia_mail_recipients.mail_id " . "AND maia_mail_recipients.recipient_id = ? " . "AND maia_mail_recipients.mail_id = ?"); $res = $sth->execute(array($user_id, $mail_id)); if (PEAR::isError($sth)) { die($sth->getMessage()); } if ($row = $res->fetchrow()) { $sender_email = $row["sender_email"]; $body = $row["contents"]; $type = $row["type"]; if (extension_loaded('mcrypt')) { if (text_is_encrypted($body)) { $key = get_encryption_key(); $body = decrypt_text($key, $body); } } if (is_a_domain_default_user($user_id)) { // System default user (@.) or domain-class user (e.g. @domain) $my_email_address = $row["envelope_to"]; } else { // Regular user (e.g. user@domain) $rlist = explode(" ", trim($row["envelope_to"])); $sth2 = $dbh->prepare("SELECT email FROM users " . "WHERE maia_user_id = ? " . "AND email = ?"); $my_email_address = ""; foreach ($rlist as $rmail) { $res2 = $sth2->execute(array($user_id, $rmail)); if (PEAR::isError($sth2)) { die($sth2->getMessage()); } if ($row2 = $res2->fetchrow()) { $my_email_address = $row2["email"]; break; } } $sth2->free(); } if (!empty($my_email_address)) { if ($resend || $type != 'P') { // don't send if it is a labeled fp $smtp_result = smtp_send($sender_email, $my_email_address, $body); } else { $smtp_result = "200 no delivery needed"; } if (($succeeded = strncmp($smtp_result, "2", 1) == 0) || $type == 'P') { if (!$resend) { if ($type == 'S' || $type == 'P') { record_mail_stats($user_id, $mail_id, "fp"); if (get_user_value($user_id, "auto_whitelist") == "Y") { add_address_to_wb_list($user_id, $sender_email, "W"); } } set_item_confirmations('G', $user_id, $mail_id); } } else { $logger->err("rescue attempt failed! " . $smtp_result); } } else { $smtp_result = $lang['text_rescue_error'] . "(EmptyAddress)"; // code really shouldn't be here. } } else { $smtp_result = $lang['text_rescue_error'] . "(MessageNotFound)"; // code really shouldn't be here. } $sth->free(); $logger->info($smtp_result); return $smtp_result; }
require_once "core.php"; require_once "authcheck.php"; require_once "display.php"; require_once "maia_db.php"; require_once "mailtools.php"; $display_language = get_display_language($euid); require_once "./locale/{$display_language}/display.php"; require_once "./locale/{$display_language}/db.php"; require_once "./locale/{$display_language}/wblist.php"; if ($_SERVER['REQUEST_METHOD'] == 'POST') { switch ($_REQUEST['action']) { case 'addallow': $result = add_address_to_wb_list($euid, $_REQUEST['newaddr'], 'W'); break; case 'addblock': $result = add_address_to_wb_list($euid, $_REQUEST['newaddr'], 'B'); break; case 'block': $result = set_wb_status($euid, $_REQUEST['id'], 'B'); $actiontext = $lang['text_allow_address']; break; case 'allow': $result = set_wb_status($euid, $_REQUEST['id'], 'W'); $actiontext = $lang['text_block_address']; break; case 'remove': $result = delete_wb_entry($euid, $_REQUEST['id']); $actiontext = $lang['text_remove_rule']; break; } if ($_REQUEST['ajax'] == 'true') {