]>
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]");
63 $util = Utils
::getInstance();
64 $loggedIn = $util->isLoggedIn();
65 $request = isset($_GET['op']) ?
$_GET['op'] : '';
66 if ($loggedIn && isset($_GET['id'])) {
67 $ids = explode(',', $_GET['id']);
68 $query = handleRequest($request, $ids);
70 /* $mail_id = urldecode($_GET['id']);
71 $mail = unserialize($_SESSION['mailInfo']["$mail_id"]);
72 $secret_id = $mail->secret_id;
73 $recipient = $mail->recipient;
76 if ($request == 'release') {
77 $amavisserver = $CFG->amavisd_db_host;
78 $policy_port = $CFG->amavis_policy_port;
80 $fp = fsockopen($amavisserver, $policy_port, $errno, $errstr, 30);
82 error("$errstr ($errno)");
85 $out = "request=" . $request . "\r\n";
86 $out .= "mail_id=" . $mail_id . "\r\n";
87 $out .= "recipient=" . $recipient . "\r\n";
88 $out .= "secret_id=" . $secret_id . "\r\n\r\n";
90 $response = fread($fp, 8192);
92 $response = urldecode($response);
93 if (! preg_match("/^setreply=250\s+([\d\.]+)\s+(.*)/", $response, $matches)) {
94 error("Request to release failed [$out][$response]");
97 if ($matches[1] != '2.0.0') {
102 $query[] = "UPDATE msgrcpt SET rs = 'R' WHERE mail_id = '$mail_id'";
103 } else if ($request == 'delete') {
104 $query[] = "UPDATE msgrcpt SET rs = 'D' WHERE mail_id = '$mail_id'";
106 error("Unknown operation [$request]");
109 $success = $DB->update($query);
111 error("Message not released, contact administrator [$query]");
114 header('Location: index.php');
115 } else if ($loggedIn && $request == 'purge') {
116 $marked = unserialize($_SESSION['marked']);
117 unset($_SESSION['marked']);
120 foreach ($marked as $mail_id) {
121 $query[] = "delete from msgs where mail_id = '$mail_id'";
122 $query[] = "delete from msgrcpt where mail_id = '$mail_id'";
123 $query[] = "delete from quarantine where mail_id = '$mail_id'";
124 $success = $DB->update($query);
129 if (count($error) > 0) {
130 $str = implode(', ', $error);
131 error("The following messages was not purged [$str], contact administrator");
134 header('Location: index.php');
135 } else if ($loggedIn) {
136 header('Location: index.php');
138 header('Location: auth.php');
This page took 0.183572 seconds and 6 git commands to generate.