if ($confirmed > 0) { $message .= sprintf($lang['text_ham_confirmed'], $confirmed) . ".<br>"; } } if ($_GET["report_spam"]) { # Spam $confirmed = 0; $select = "SELECT maia_mail.id " . "FROM maia_mail, maia_mail_recipients " . "WHERE maia_mail.id = maia_mail_recipients.mail_id " . "AND maia_mail.received_date <= ? " . "AND maia_mail_recipients.type IN ('S','P') " . "AND maia_mail_recipients.recipient_id = ?"; $sth = $dbh->query($select, array($cutoff_date, $euid)); while ($row = $sth->fetchRow()) { $mail_id = $row["id"]; confirm_spam($euid, $mail_id); $confirmed++; } $sth->free(); update_mail_stats($euid, "suspected_spam"); if ($confirmed > 0) { $message .= sprintf($lang['text_spam_confirmed'], $confirmed) . ".<br>"; } } if ($_GET["report_virus"]) { # Viruses $deleted = 0; $select = "SELECT maia_mail.id " . "FROM maia_mail, maia_mail_recipients " . "WHERE maia_mail.id = maia_mail_recipients.mail_id " . "AND maia_mail.received_date <= ? " . "AND maia_mail_recipients.type = 'V' " . "AND maia_mail_recipients.recipient_id = ?"; $sth = $dbh->query($select, array($cutoff_date, $euid)); while ($row = $sth->fetchRow()) { $mail_id = $row["id"]; delete_mail_reference($euid, $mail_id); $deleted++; } $sth->free();
update_mail_stats($row["id"], "suspected_ham"); update_mail_stats($row["id"], "suspected_spam"); } $sth->free(); $message = $lang['text_all_users_reset']; } elseif (isset($_POST["reset_viruses"])) { $update = "UPDATE maia_viruses SET count = 0"; $dbh->query($update); $message = $lang['text_all_viruses_reset']; } elseif (isset($_POST["reset_rules"])) { $update = "UPDATE maia_sa_rules SET rule_count = 0"; $dbh->query($update); $message = $lang['text_all_rules_reset']; } elseif (isset($_POST["reset_all"])) { $delete = "DELETE FROM maia_stats"; $dbh->query($delete); $select = "SELECT id FROM maia_users"; $sth = $dbh->query($select); while ($row = $sth->fetchrow()) { update_mail_stats($row["id"], "suspected_ham"); update_mail_stats($row["id"], "suspected_spam"); } $sth->free(); $update = "UPDATE maia_viruses SET count = 0"; $dbh->query($update); $update = "UPDATE maia_sa_rules SET rule_count = 0"; $dbh->query($update); $message = $lang['text_all_stats_reset']; } $smarty->assign('message', $message); $smarty->display('xadminstats.tpl');
function transfer_email_address_to_user($old_owner_id, $new_owner_id, $email) { global $dbh; // Link the e-mail address to the new owner $sth = $dbh->prepare("UPDATE users SET maia_user_id = ? WHERE email = ?"); $sth->execute(array($new_owner_id, $email)); if (PEAR::isError($sth)) { die($sth->getMessage()); } $sth->free(); // If the old owner has no other e-mail addresses, merge // the old owner's assets into the new owner's account // and delete the old owner. $sth = $dbh->prepare("SELECT id FROM users WHERE maia_user_id = ?"); $res = $sth->execute(array($old_owner_id)); if (!$res->fetchRow()) { transfer_mail_to_user($old_owner_id, $new_owner_id); transfer_wblist_to_user($old_owner_id, $new_owner_id); transfer_domain_admin_to_user($old_owner_id, $new_owner_id); transfer_stats_to_user($old_owner_id, $new_owner_id); update_mail_stats($new_owner_id, "suspected_ham"); update_mail_stats($new_owner_id, "suspected_spam"); delete_user($old_owner_id); } $sth->free(); }
function confirm_cache($euid) { $message = ""; $ham_list = array(); $spam_list = array(); $delete_list = array(); $resend_list = array(); global $_POST, $lang, $logger; if (isset($_POST['cache_item'])) { $items = $_POST['cache_item']; } else { $items = array(); } foreach ($items as $type => $mail_item) { foreach ($mail_item as $mail_id => $value) { if ($type == "generic") { $newtype = $_POST['submit']; } else { $newtype = $value; } // report item if ($newtype == "spam") { switch ($this->type) { case 'ham': // Mark the item as false negative. It will also be marked as confirmed. record_mail_stats($euid, $mail_id, "fn"); $this->reported++; break; default: $this->confirmed++; } array_push($spam_list, $mail_id); //send item } elseif ($newtype == "ham") { switch ($this->type) { case 'ham': array_push($ham_list, $mail_id); $this->confirmed++; break; default: $result = rescue_item($euid, $mail_id); // done individually because of mail delivery if (strncmp($result, "2", 1) == 0) { $this->rescued++; } else { $message .= $result . "\n"; } } //delete item. } elseif ($newtype == "delete") { array_push($delete_list, $mail_id); $this->deleted++; // resend the item and leave it in the cache } elseif ($newtype == "resend") { array_push($resend_list, $mail_id); $this->resent++; } } } if (count($ham_list) > 0) { confirm_ham($euid, $ham_list); } if (count($spam_list) > 0) { confirm_spam($euid, $spam_list); } if (count($delete_list) > 0) { delete_mail_reference($euid, $delete_list); } if (count($resend_list) > 0) { resend_message($euid, $resend_list); } update_mail_stats($euid, "suspected_ham"); if ($this->confirmed > 0) { switch ($this->type) { case "ham": $message .= sprintf($lang['text_ham_confirmed'], $this->confirmed) . ".<br>"; break; case "spam": $message .= sprintf($lang['text_spam_confirmed'], $this->confirmed) . ".<br>"; break; default: $message .= sprintf($lang['text_messages_confirmed'], $this->confirmed) . ".<br>"; } } if ($this->reported > 0) { $message .= sprintf($lang['text_spam_reported'], $this->reported) . ".<br>"; } if ($this->deleted > 0) { switch ($this->type) { case 'ham': $message .= sprintf($lang['text_ham_deleted'], $this->deleted) . ".<br>"; break; case 'spam': $message .= sprintf($lang['text_spam_deleted'], $this->deleted) . ".<br>"; break; case 'virus': $message .= sprintf($lang['text_viruses_deleted'], $this->deleted) . ".<br>"; break; case 'attachment': $message .= sprintf($lang['text_attachments_deleted'], $this->deleted) . ".<br>"; break; case 'header': $message .= sprintf($lang['text_headers_deleted'], $this->deleted) . ".<br>"; break; } } if ($this->rescued > 0) { switch ($this->type) { case 'spam': $message .= sprintf($lang['text_spam_rescued'], $this->rescued) . ".<br>"; break; case 'virus': $message .= sprintf($lang['text_viruses_rescued'], $this->rescued) . ".<br>"; break; case 'attachment': $message .= sprintf($lang['text_attachments_rescued'], $this->rescued) . ".<br>"; break; case 'header': $message .= sprintf($lang['text_headers_rescued'], $this->rescued) . ".<br>"; break; } } if ($this->resent > 0) { $message .= sprintf($lang['text_message_resent'], $this->resent) . ".<br>"; } return $message; }
function transfer_email_address_to_user($old_owner_id, $new_owner_id, $email) { global $dbh; // Link the e-mail address to the new owner $update = "UPDATE users SET maia_user_id = ? WHERE email = ?"; $dbh->query($update, array($new_owner_id, $email)); // If the old owner has no other e-mail addresses, merge // the old owner's assets into the new owner's account // and delete the old owner. $select = "SELECT id FROM users WHERE maia_user_id = ?"; $sth = $dbh->query($select, array($old_owner_id)); if (!$sth->fetchRow()) { transfer_mail_to_user($old_owner_id, $new_owner_id); transfer_wblist_to_user($old_owner_id, $new_owner_id); transfer_domain_admin_to_user($old_owner_id, $new_owner_id); transfer_stats_to_user($old_owner_id, $new_owner_id); update_mail_stats($new_owner_id, "suspected_ham"); update_mail_stats($new_owner_id, "suspected_spam"); delete_user($old_owner_id); } $sth->free(); }