]> git.datanom.net - qtadmin.git/blobdiff - mail_report.php
First upload of wblist page
[qtadmin.git] / mail_report.php
index e40f2292cc98a69c5bc37da36884a85193c7fab5..3607ba2e1c8772ae34353e1b298b821fef2e81c8 100644 (file)
 <?php
 /* vim: set ts=4 tw=0 sw=4 noet: */
 <?php
 /* vim: set ts=4 tw=0 sw=4 noet: */
-       require_once 'Mail/mimeDecode.php';
-       require_once 'config.php';
-       require_once $CFG->root . 'lib/db_factory.php';
-       require_once $CFG->root . 'lib/utils.inc.php';
+    require_once 'Mail/mimeDecode.php';
+    require_once 'config.php';
+    require_once $CFG->root . 'lib/db_factory.php';
+    require_once $CFG->root . 'lib/utils.inc.php';
 
 
-       $util = Utils::getInstance();
-       $loggedIn = $util->isLoggedIn();
-       if ($loggedIn && isset($_GET['id'])) {
-               $util->setHeading('Spam Report');
-               echo $util->getHeader();
-               echo $util->getHeading();
+    $util = new Utils;
+    $loggedIn = $util->isLoggedIn();
+    if ($loggedIn && isset($_GET['id'])) {
+        $id = $_GET['id'];
+        $mail = unserialize($_SESSION['mailInfo'][$id]);
 
 
-               $id = $_GET['id'];
-               $mail = unserialize($_SESSION['mailInfo'][$id]);
+        if (! is_object($mail) || false == $util->authorized($mail->recipient)) {
+            header('Location: qtadmin.php');
+            exit;
+        }
 
 
-               $row = $DB->getMail($id);
-               $string = $row->mail_text;
-               $sa_tests = null;
-               $params['include_bodies'] = false;
-               $params['decode_bodies']  = true;
-               $params['decode_headers'] = true;
-               $params['input']          = $string;
-               $params['crlf']           = "\r\n";
-               
-               $structure = Mail_mimeDecode::decode($params);
-               $headers = $structure->headers;
-               $rows = array();
-               foreach ($headers as $header => $value) {
-                       if ($header == 'x-spam-status') {
-                               if (preg_match('/^(.*),\s*score=([\d\.]+).*tests=\[(.*)\].*/',
-                                       $value, $matches)) {
-                                       $sa_tests = array('x-spam-status' => $matches[1],
-                                               'score' => $matches[2], 'tests' => $matches[3]);
-                               }
-                       } else if ($header == 'x-spam-flag') {
+        $util->setHeading('Spam Report');
+        echo $util->getHeader();
+        echo $util->getHeading();
+
+        $row = $DB->getMail($id);
+        $string = $row->mail_text;
+        $sa_tests = null;
+        $params['include_bodies'] = false;
+        $params['decode_bodies']  = true;
+        $params['decode_headers'] = true;
+        $params['input']          = $string;
+        $params['crlf']           = "\r\n";
+
+        $structure = Mail_mimeDecode::decode($params);
+        $headers = $structure->headers;
+        $rows = array();
+        foreach ($headers as $header => $value) {
+            if ($header == 'x-spam-status') {
+                if (preg_match('/^(.*),\s*score=([\d\.]+).*tests=\[(.*)\].*/',
+                    $value, $matches)) {
+                        $sa_tests = array('x-spam-status' => $matches[1],
+                        'score' => $matches[2], 'tests' => $matches[3]);
+                }
+            } else if ($header == 'x-spam-flag') {
                 $value = str_replace("<", "&lt;", $value);
                 $value = str_replace("<", "&lt;", $value);
-                               $value = str_replace(">", "&gt;", $value);
-                $rows['spam'] = "<tr><td class=\"label\">Spam</td><td class=\"value\">$value</td></tr>"; 
+                $value = str_replace(">", "&gt;", $value);
+                $rows['spam'] = "<tr><td class=\"label\">Spam</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'x-spam-score') {
                 $value = str_replace("<", "&lt;", $value);
             } else if ($header == 'x-spam-score') {
                 $value = str_replace("<", "&lt;", $value);
-                               $value = str_replace(">", "&gt;", $value);
+                $value = str_replace(">", "&gt;", $value);
                 $rows['score'] = "<tr><td class=\"label\">Spam Score</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'x-spam-level') {
                 $value = str_replace("<", "&lt;", $value);
                 $rows['score'] = "<tr><td class=\"label\">Spam Score</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'x-spam-level') {
                 $value = str_replace("<", "&lt;", $value);
-                               $value = str_replace(">", "&gt;", $value);
+                $value = str_replace(">", "&gt;", $value);
                 $rows['level'] = "<tr><td class=\"label\">Spam Level</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'date') {
                 $value = str_replace("<", "&lt;", $value);
                 $rows['level'] = "<tr><td class=\"label\">Spam Level</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'date') {
                 $value = str_replace("<", "&lt;", $value);
-                               $value = str_replace(">", "&gt;", $value);
+                $value = str_replace(">", "&gt;", $value);
                 $rows['date'] = "<tr><td class=\"label\">Date</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'from') {
                 $value = str_replace("<", "&lt;", $value);
                 $rows['date'] = "<tr><td class=\"label\">Date</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'from') {
                 $value = str_replace("<", "&lt;", $value);
-                               $value = str_replace(">", "&gt;", $value);
+                $value = str_replace(">", "&gt;", $value);
                 $rows['from'] = "<tr><td class=\"label\">From</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'reply-to') {
                 $value = str_replace("<", "&lt;", $value);
                 $rows['from'] = "<tr><td class=\"label\">From</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'reply-to') {
                 $value = str_replace("<", "&lt;", $value);
-                               $value = str_replace(">", "&gt;", $value);
+                $value = str_replace(">", "&gt;", $value);
                 $rows['reply-to'] = "<tr><td class=\"label\">Reply-to</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'to') {
                 $value = str_replace("<", "&lt;", $value);
                 $rows['reply-to'] = "<tr><td class=\"label\">Reply-to</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'to') {
                 $value = str_replace("<", "&lt;", $value);
-                               $value = str_replace(">", "&gt;", $value);
+                $value = str_replace(">", "&gt;", $value);
                 $rows['to'] = "<tr><td class=\"label\">To</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'subject') {
                 $value = str_replace("<", "&lt;", $value);
                 $rows['to'] = "<tr><td class=\"label\">To</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'subject') {
                 $value = str_replace("<", "&lt;", $value);
-                               $value = str_replace(">", "&gt;", $value);
+                $value = str_replace(">", "&gt;", $value);
                 $rows['subject'] = "<tr><td class=\"label\">Subject</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'received') {
                 $rows['subject'] = "<tr><td class=\"label\">Subject</td><td class=\"value\">$value</td></tr>";
             } else if ($header == 'received') {
-                               $headers = '';
-                               foreach ($value as $val) {
+                $headers = '';
+                foreach ($value as $val) {
                     $val = str_replace("<", "&lt;", $val);
                     $val = str_replace("<", "&lt;", $val);
-                                       $val = str_replace(">", "&gt;", $val);
+                    $val = str_replace(">", "&gt;", $val);
                     $headers .= ($headers == '') ? "$val" : "<br/><br/>$val";
                 }
                 $rows['headers'] = "<tr><td class=\"label\">Headers</td><td class=\"value\">$headers</td></tr>";
                     $headers .= ($headers == '') ? "$val" : "<br/><br/>$val";
                 }
                 $rows['headers'] = "<tr><td class=\"label\">Headers</td><td class=\"value\">$headers</td></tr>";
-                       }
-               }
-               $bayes = array();
-               if ($sa_tests) {
-                       $sa_tests['tests'] = str_replace(" ","",$sa_tests['tests']);
-                       $sa_rules = explode(",",$sa_tests['tests']);
-                       $sa_count = count($sa_rules);
-                       for ($i = 0; $i < $sa_count; $i++) {
-                               $sa_rule = explode("=", $sa_rules[$i]);
-                               $bayes[$i] = "<tr><td class=\"label\">$sa_rule[0]</td><td class=\"value\">$sa_rule[1]</td></tr>";
-                       }
-                       $bayes['total'] = "<tr><td class=\"label\">TOTAL</td><td class=\"value\">".$sa_tests['score']."</td></tr>";
-               } else {
-                       $bayes['total'] = "<tr><td class=\"label\">TOTAL</td><td class=\"value\">-</td></tr>";
-               }
-               $plain = "?id=$id&format=plain";
-               $html = "?id=$id&format=html";
-               echo '<p class="ruler">Message ID : ' . $mail->mail_id . '</p>';
-               echo '<table class="button-menu">';
-               echo '<tr class="button-row">';
-               echo '<td class="button"><input class="btn-input" type="button" value="Return" 
-                         onclick="javascript: history.back();"/></td>';
-               echo '<td class="button"><input class="btn-input" type="button" value="View HTML"
-                        onclick="javascript: window.location.href=\'message_view.php'.$html.'\'"/></td>';
-               echo '<td class="button"><input class="btn-input" type="button" value="View Plain Text" 
-                        onclick="javascript: window.location.href=\'message_view.php'.$plain.'\'"/></td>';
-               echo '<td class="button"><input class="btn-input" type="button" value="View Full Headers"
-                        onclick="javascript: window.location.href=\'show_headers.php?id='.$id.'\'"/></td>';
-               echo '</tr></table>';
-               echo '<table>';
-               if (isset($rows['spam']))
-                       echo $rows['spam'];
-               if (isset($rows['score']))
-                       echo $rows['score'];
-               if (isset($rows['level']))
-                       echo $rows['level'];
-               if (isset($rows['headers']))
-                       echo $rows['headers'];
-               if (isset($rows['date']))
-                       echo $rows['date'];
-               if (isset($rows['from']))
-                       echo $rows['from'];
-               if (isset($rows['reply-to']))
-                       echo $rows['reply-to'];
-               if (isset($rows['to']))
-                       echo $rows['to'];
-               if (isset($rows['subject']))
-                       echo $rows['subject'];
-               echo '</table>';
-               echo '<p class="ruler">Spamassassin Report</p>';
-               echo '<table><tr><th>Rule</th><th>Score</th></tr>';
-               foreach ($bayes as $key => $row) {
-                       if ($key != 'total') {
-                               echo $row;
-                       }
-               }
-               echo $bayes['total'];
-               echo '</table>';
-               echo $util->getFooter();
-       } else if ($loggedIn) {
-               header('Location: index.php');
-       } else {
-               header('Location: auth.php');
-       }
+            }
+        }
+        $bayes = array();
+        if ($sa_tests) {
+            $sa_tests['tests'] = str_replace(" ","",$sa_tests['tests']);
+            $sa_rules = explode(",",$sa_tests['tests']);
+            $sa_count = count($sa_rules);
+            for ($i = 0; $i < $sa_count; $i++) {
+                $sa_rule = explode("=", $sa_rules[$i]);
+                $bayes[$i] = "<tr><td class=\"label\">$sa_rule[0]</td><td class=\"value\">$sa_rule[1]</td></tr>";
+            }
+            $bayes['total'] = "<tr><td class=\"label\">TOTAL</td><td class=\"value\">".$sa_tests['score']."</td></tr>";
+        } else {
+            $bayes['total'] = "<tr><td class=\"label\">TOTAL</td><td class=\"value\">-</td></tr>";
+        }
+        $plain = "?id=$id&amp;format=plain";
+        $html = "?id=$id&amp;format=html";
+        echo '<p class="ruler">Message ID : ' . $mail->mail_id . '</p>';
+        echo '<table class="button-menu">';
+        echo '<tr class="button-row">';
+        echo '<td class="button"><input class="btn-input" type="button" value="Return"
+              onclick="javascript: history.back();"/></td>';
+        echo '<td class="button"><input class="btn-input" type="button" value="View HTML"
+             onclick="javascript: window.location.href=\'message_view.php'.$html.'\'"/></td>';
+        echo '<td class="button"><input class="btn-input" type="button" value="View Plain Text"
+             onclick="javascript: window.location.href=\'message_view.php'.$plain.'\'"/></td>';
+        echo '<td class="button"><input class="btn-input" type="button" value="View Full Headers"
+             onclick="javascript: window.location.href=\'show_headers.php?id='.$id.'\'"/></td>';
+        echo '</tr></table>';
+        echo '<table>';
+        if (isset($rows['spam']))
+            echo $rows['spam'];
+        if (isset($rows['score']))
+            echo $rows['score'];
+        if (isset($rows['level']))
+            echo $rows['level'];
+        if (isset($rows['headers']))
+            echo $rows['headers'];
+        if (isset($rows['date']))
+            echo $rows['date'];
+        if (isset($rows['from']))
+            echo $rows['from'];
+        if (isset($rows['reply-to']))
+            echo $rows['reply-to'];
+        if (isset($rows['to']))
+            echo $rows['to'];
+        if (isset($rows['subject']))
+            echo $rows['subject'];
+        echo '</table>';
+        echo '<p class="ruler">Spamassassin Report</p>';
+        echo '<table><tr><th>Rule</th><th>Score</th></tr>';
+        foreach ($bayes as $key => $row) {
+            if ($key != 'total') {
+                echo $row;
+            }
+        }
+        echo $bayes['total'];
+        echo '</table>';
+        echo $util->getFooter();
+    } else if ($loggedIn) {
+        header('Location: qtadmin.php');
+    } else {
+        header('Location: auth.php');
+    }
 
 ?>
 
 ?>
This page took 0.058435 seconds and 5 git commands to generate.