]>
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) {
21 foreach ($ids as $id) {
22 $mail_id = urldecode($id);
23 $mail = unserialize($_SESSION['mailInfo']["$mail_id"]);
24 $secret_id = $mail->secret_id
;
25 $recipient = $mail->recipient
;
26 //echo "$mail_id $secret_id $recipient";
28 if ($request == 'release') {
29 $amavisserver = $CFG->amavisd_db_host
;
30 $policy_port = $CFG->amavis_policy_port
;
32 $fp = fsockopen($amavisserver, $policy_port, $errno, $errstr, 30);
34 error("$errstr ($errno)");
37 $out = "request=" . $request . "\r\n";
38 $out .= "mail_id=" . $mail_id . "\r\n";
39 $out .= "recipient=" . $recipient . "\r\n";
40 $out .= "secret_id=" . $secret_id . "\r\n\r\n";
42 $response = fread($fp, 8192);
44 $response = urldecode($response);
45 if (! preg_match("/^setreply=250\s+([\d\.]+)\s+(.*)/", $response, $matches)) {
46 error("Request to release failed [$out][$response]");
49 if ($matches[1] != '2.0.0') {
54 $query[] = "UPDATE msgrcpt SET rs = 'R' WHERE mail_id = '$mail_id'";
55 } else if ($request == 'delete') {
56 $query[] = "UPDATE msgrcpt SET rs = 'D' WHERE mail_id = '$mail_id'";
58 error("Unknown operation [$request]");
66 $util = Utils
::getInstance();
67 $loggedIn = $util->isLoggedIn();
68 $request = isset($_GET['op']) ?
$_GET['op'] : '';
69 if ($loggedIn && isset($_GET['id'])) {
70 $ids = explode(',', $_GET['id']);
71 $query = handleRequest($request, $ids);
73 $mail_id = urldecode($_GET['id']);
74 $mail = unserialize($_SESSION['mailInfo']["$mail_id"]);
75 $secret_id = $mail->secret_id;
76 $recipient = $mail->recipient;
79 if ($request == 'release') {
80 $amavisserver = $CFG->amavisd_db_host;
81 $policy_port = $CFG->amavis_policy_port;
83 $fp = fsockopen($amavisserver, $policy_port, $errno, $errstr, 30);
85 error("$errstr ($errno)");
88 $out = "request=" . $request . "\r\n";
89 $out .= "mail_id=" . $mail_id . "\r\n";
90 $out .= "recipient=" . $recipient . "\r\n";
91 $out .= "secret_id=" . $secret_id . "\r\n\r\n";
93 $response = fread($fp, 8192);
95 $response = urldecode($response);
96 if (! preg_match("/^setreply=250\s+([\d\.]+)\s+(.*)/", $response, $matches)) {
97 error("Request to release failed [$out][$response]");
100 if ($matches[1] != '2.0.0') {
105 $query[] = "UPDATE msgrcpt SET rs = 'R' WHERE mail_id = '$mail_id'";
106 } else if ($request == 'delete') {
107 $query[] = "UPDATE msgrcpt SET rs = 'D' WHERE mail_id = '$mail_id'";
109 error("Unknown operation [$request]");
114 $success = $DB->update($query);
116 error("Message not released, contact administrator [$query]");
119 header('Location: index.php');
120 } else if ($loggedIn && $request == 'purge') {
121 $marked = unserialize($_SESSION['marked']);
122 unset($_SESSION['marked']);
125 foreach ($marked as $mail_id) {
126 $query[] = "delete from msgs where mail_id = '$mail_id'";
127 $query[] = "delete from msgrcpt where mail_id = '$mail_id'";
128 $query[] = "delete from quarantine where mail_id = '$mail_id'";
129 $success = $DB->update($query);
134 if (count($error) > 0) {
135 $str = implode(', ', $error);
136 error("The following messages was not purged [$str], contact administrator");
139 header('Location: index.php');
140 } else if ($loggedIn) {
141 header('Location: index.php');
143 header('Location: auth.php');
This page took 0.164805 seconds and 6 git commands to generate.