]> git.datanom.net - qtadmin.git/blobdiff - quarantine.php
Enhance security
[qtadmin.git] / quarantine.php
index 031a416d69e4796411db8fd511b0509b37524e1b..14e07e7a4f1883b29b2b27c30f81b5bdfdb45593 100644 (file)
         foreach ($ids as $id) {
             $mail_id = urldecode($id);
             $mail = unserialize($_SESSION['mailInfo']["$mail_id"]);
-            $secret_id = $mail->secret_id;
-            $recipient = $mail->recipient;
 
-            if ($request == 'release') {
-                $amavisserver = $CFG->amavisd_db_host;
-                $policy_port = $CFG->amavis_policy_port;
+            if (true == $util->authorized($mail->recipient)) {
+                $secret_id = $mail->secret_id;
+                $recipient = $mail->recipient;
 
-                $fp = fsockopen($amavisserver, $policy_port, $errno, $errstr, 30);
-                if (!$fp) {
-                    error("$errstr ($errno)");
-                    exit;
-                }
-                $out = "request=" . $request . "\r\n";
-                $out .= "mail_id=" . $mail_id . "\r\n";
-                $out .= "recipient=" . $recipient . "\r\n";
-                $out .= "secret_id=" . $secret_id . "\r\n\r\n";
-                fwrite($fp, $out);
-                $response = fread($fp, 8192);
-                fclose($fp);
-                $response = urldecode($response);
-                if (! preg_match("/^setreply=250\s+([\d\.]+)\s+(.*)/", $response, $matches)) {
-                    error("Request to release failed [$out][$response]");
-                    exit;
-                }
-                if ($matches[1] != '2.0.0') {
-                    error($matches[2]);
+                if ($request == 'release') {
+                    $amavisserver = $CFG->amavisd_db_host;
+                    $policy_port = $CFG->amavis_policy_port;
+
+                    $fp = fsockopen($amavisserver, $policy_port, $errno, $errstr, 30);
+                    if (!$fp) {
+                        error("$errstr ($errno)");
+                        exit;
+                    }
+                    $out = "request=" . $request . "\r\n";
+                    $out .= "mail_id=" . $mail_id . "\r\n";
+                    $out .= "recipient=" . $recipient . "\r\n";
+                    $out .= "secret_id=" . $secret_id . "\r\n\r\n";
+                    fwrite($fp, $out);
+                    $response = fread($fp, 8192);
+                    fclose($fp);
+                    $response = urldecode($response);
+                    if (! preg_match("/^setreply=250\s+([\d\.]+)\s+(.*)/", $response, $matches)) {
+                        error("Request to release failed [$out][$response]");
+                        exit;
+                    }
+                    if ($matches[1] != '2.0.0') {
+                        error($matches[2]);
+                        exit;
+                    }
+
+                    $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 {
+                    error("Unknown operation [$request]");
                     exit;
                 }
-
-                $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 {
-                error("Unknown operation [$request]");
-                exit;
             }
         }
 
         $query = array();
         $error = array();
         foreach ($marked as $mail_id) {
-            $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'";
-            $success = $DB->update($query);
-            if (! $success) {
-                $error[] = $mail_id;
+            $mail = $DB->getMail($mail_id);
+            if (true == $util->authorized($mail->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'";
+                $success = $DB->update($query);
+                if (! $success) {
+                    $error[] = $mail_id;
+                }
             }
         }
         if (count($error) > 0) {
This page took 0.048992 seconds and 5 git commands to generate.