]>
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) {
8 $util = Utils
::getInstance();
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($request, $ids) {
19 foreach ($ids as $id) {
20 $mail_id = urldecode($id);
21 $mail = unserialize($_SESSION['mailInfo']["$mail_id"]);
22 $secret_id = $mail->secret_id
;
23 $recipient = $mail->recipient
;
24 //echo "$mail_id $secret_id $recipient";
26 if ($request == 'release') {
27 $amavisserver = $CFG->amavisd_db_host
;
28 $policy_port = $CFG->amavis_policy_port
;
30 $fp = fsockopen($amavisserver, $policy_port, $errno, $errstr, 30);
32 error("$errstr ($errno)");
35 $out = "request=" . $request . "\r\n";
36 $out .= "mail_id=" . $mail_id . "\r\n";
37 $out .= "recipient=" . $recipient . "\r\n";
38 $out .= "secret_id=" . $secret_id . "\r\n\r\n";
40 $response = fread($fp, 8192);
42 $response = urldecode($response);
43 if (! preg_match("/^setreply=250\s+([\d\.]+)\s+(.*)/", $response, $matches)) {
44 error("Request to release failed [$out][$response]");
47 if ($matches[1] != '2.0.0') {
52 $query[] = "UPDATE msgrcpt SET rs = 'R' WHERE mail_id = '$mail_id'";
53 } else if ($request == 'delete') {
54 $query[] = "UPDATE msgrcpt SET rs = 'D' WHERE mail_id = '$mail_id'";
56 error("Unknown operation [$request]");
64 $util = Utils
::getInstance();
65 $loggedIn = $util->isLoggedIn();
66 $request = isset($_GET['op']) ?
$_GET['op'] : '';
67 if ($loggedIn && isset($_GET['id'])) {
68 $ids = explode(',', $_GET['id']);
69 $query = handleRequest($request, $ids);
71 $mail_id = urldecode($_GET['id']);
72 $mail = unserialize($_SESSION['mailInfo']["$mail_id"]);
73 $secret_id = $mail->secret_id;
74 $recipient = $mail->recipient;
77 if ($request == 'release') {
78 $amavisserver = $CFG->amavisd_db_host;
79 $policy_port = $CFG->amavis_policy_port;
81 $fp = fsockopen($amavisserver, $policy_port, $errno, $errstr, 30);
83 error("$errstr ($errno)");
86 $out = "request=" . $request . "\r\n";
87 $out .= "mail_id=" . $mail_id . "\r\n";
88 $out .= "recipient=" . $recipient . "\r\n";
89 $out .= "secret_id=" . $secret_id . "\r\n\r\n";
91 $response = fread($fp, 8192);
93 $response = urldecode($response);
94 if (! preg_match("/^setreply=250\s+([\d\.]+)\s+(.*)/", $response, $matches)) {
95 error("Request to release failed [$out][$response]");
98 if ($matches[1] != '2.0.0') {
103 $query[] = "UPDATE msgrcpt SET rs = 'R' WHERE mail_id = '$mail_id'";
104 } else if ($request == 'delete') {
105 $query[] = "UPDATE msgrcpt SET rs = 'D' WHERE mail_id = '$mail_id'";
107 error("Unknown operation [$request]");
112 $success = $DB->update($query);
114 error("Message not released, contact administrator [$query]");
117 header('Location: index.php');
118 } else if ($loggedIn && $request == 'purge') {
119 $marked = unserialize($_SESSION['marked']);
120 unset($_SESSION['marked']);
123 foreach ($marked as $mail_id) {
124 $query[] = "delete from msgs where mail_id = '$mail_id'";
125 $query[] = "delete from msgrcpt where mail_id = '$mail_id'";
126 $query[] = "delete from quarantine where mail_id = '$mail_id'";
127 $success = $DB->update($query);
132 if (count($error) > 0) {
133 $str = implode(', ', $error);
134 error("The following messages was not purged [$str], contact administrator");
137 header('Location: index.php');
138 } else if ($loggedIn) {
139 header('Location: index.php');
141 header('Location: auth.php');
This page took 0.173066 seconds and 6 git commands to generate.