]>
git.datanom.net - qtadmin.git/blob - quarantine.php
2 /* vim: set ts=4 tw=0 sw=4 noet: */
3 require_once 'config.php';
4 require_once $CFG->root
. 'lib/db_factory.php';
5 require_once $CFG->root
. 'lib/utils.inc.php';
7 function error($error) {
9 $util->setHeading("Error");
10 echo $util->getHeader();
11 echo $util->getHeading();
12 echo "<p style=\"color: red;\">$error</p>";
13 echo '<a href="index.php">Return</a>';
14 echo $util->getFooter();
17 function handleRequest($util, $request, $ids) {
21 foreach ($ids as $id) {
22 $mail_id = urldecode($id);
23 $mail = unserialize($_SESSION['mailInfo']["$mail_id"]);
25 if (is_object($mail) && true == $util->authorized($mail->recipient
)) {
26 $secret_id = $mail->secret_id
;
27 $recipient = $mail->recipient
;
29 if ($request == 'release') {
30 $amavisserver = $CFG->amavisd_db_host
;
31 $policy_port = $CFG->amavis_policy_port
;
33 $fp = fsockopen($amavisserver, $policy_port, $errno, $errstr, 30);
35 error("$errstr ($errno)");
38 $out = "request=" . $request . "\r\n";
39 $out .= "mail_id=" . $mail_id . "\r\n";
40 $out .= "recipient=" . $recipient . "\r\n";
41 $out .= "secret_id=" . $secret_id . "\r\n\r\n";
43 $response = fread($fp, 8192);
45 $response = urldecode($response);
46 if (! preg_match("/^setreply=250\s+([\d\.]+)\s+(.*)/", $response, $matches)) {
47 error("Request to release failed [$out][$response]");
50 if ($matches[1] != '2.0.0') {
55 $query[] = "UPDATE msgrcpt SET rs = 'R' WHERE mail_id = '$mail_id'";
56 } else if ($request == 'delete') {
57 $query[] = "UPDATE msgrcpt SET rs = 'D' WHERE mail_id = '$mail_id'";
58 } else if ($request == 'block') {
60 error("Unknown operation [$request]");
70 $loggedIn = $util->isLoggedIn();
71 $request = isset($_GET['op']) ?
$_GET['op'] : '';
72 if ($loggedIn && isset($_GET['id'])) {
73 $ids = explode(',', $_GET['id']);
74 if ($request == 'block') {
77 $query = handleRequest($util, $request, $ids);
78 $success = $DB->update($query);
80 error("Message not released, contact administrator [$query]");
84 header('Location: index.php');
85 } else if ($loggedIn && $request == 'purge') {
86 $marked = unserialize($_SESSION['marked']);
87 unset($_SESSION['marked']);
90 foreach ($marked as $mail_id) {
91 $recipient = $DB->getRecipient($mail_id);
92 if ($recipient && true == $util->authorized($recipient)) {
93 $query[] = "delete from msgs where mail_id = '$mail_id'";
94 $query[] = "delete from msgrcpt where mail_id = '$mail_id'";
95 $query[] = "delete from quarantine where mail_id = '$mail_id'";
96 $success = $DB->update($query);
102 if (count($error) > 0) {
103 $str = implode(', ', $error);
104 error("The following messages was not purged [$str], contact administrator");
107 header('Location: index.php');
108 } else if ($loggedIn) {
109 header('Location: index.php');
111 header('Location: auth.php');
This page took 0.116842 seconds and 6 git commands to generate.