]> git.datanom.net - qtadmin.git/blobdiff - quarantine.php
add more debug info
[qtadmin.git] / quarantine.php
index 7bda56d66d090903397e7a6e5f0fe0d3e60f9f28..b6703d866c802ba867f55631ee32a9a8af82ae56 100644 (file)
@@ -25,6 +25,7 @@
             if (is_object($mail) && true == $util->authorized($mail->recipient)) {
                 $secret_id = $mail->secret_id;
                 $recipient = $mail->recipient;
+                $sender    = $mail->sender;
 
                 if ($request == 'release') {
                     $amavisserver = $CFG->amavisd_db_host;
@@ -55,6 +56,8 @@
                     $query[] = "UPDATE msgrcpt SET rs = 'R' WHERE mail_id = '$mail_id'";
                 } else if ($request == 'delete') {
                     $query[] = "UPDATE msgrcpt SET rs = 'D' WHERE mail_id = '$mail_id'";
+                } else if ($request == 'block') {
+                    $query[] = $sender;
                 } else {
                     error("Unknown operation [$request]");
                     exit;
     $request = isset($_GET['op']) ? $_GET['op'] : '';
     if ($loggedIn && isset($_GET['id'])) {
         $ids = explode(',', $_GET['id']);
-        $query = handleRequest($util, $request, $ids);
-        $success = $DB->update($query);
+        if ($request == 'block') {
+            // /add/(whitelist|blacklist)/(.+)
+            $query = handleRequest($util, $request, $ids);
+            $data = json_encode($query);
+            if ($util->isAdmin()) {
+                $method = '/add/blacklist';
+            } else {
+                $method = '/add/blacklist/' . $util->getUser();
+            }
+            $success = $util->makeRestCall($method, $data);
+        } else {
+            $query = handleRequest($util, $request, $ids);
+            $success = $DB->update($query);
+        }
         if (! $success) {
-            error("Message not released, contact administrator [$query]");
+            if ($request == 'block') {
+                error("Could not blacklist sender");
+            } else {
+                error("Message not released, contact administrator [$query]");
+            }
             exit;
         }
-        header('Location: index.php');
+        header('Location: qtadmin.php');
     } else if ($loggedIn && $request == 'purge') {
         $marked = unserialize($_SESSION['marked']);
         unset($_SESSION['marked']);
         $query = array();
         $error = array();
         foreach ($marked as $mail_id) {
-            $mail = $DB->getMail($mail_id);
-            if (is_object($mail) && true == $util->authorized($mail->recipient)) {
+            $recipient = $DB->getRecipient($mail_id);
+            if ($recipient && true == $util->authorized($recipient)) {
                 $query[] = "delete from msgs where mail_id = '$mail_id'";
                 $query[] = "delete from msgrcpt where mail_id = '$mail_id'";
                 $query[] = "delete from quarantine where mail_id = '$mail_id'";
             error("The following messages was not purged [$str], contact administrator");
             exit;
         }
-        header('Location: index.php');
+        header('Location: qtadmin.php');
     } else if ($loggedIn) {
-        header('Location: index.php');
+        header('Location: qtadmin.php');
     } else {
         header('Location: auth.php');
     }
This page took 0.030944 seconds and 5 git commands to generate.