]>
git.datanom.net - qtadmin.git/blob - mail_report.php
2 /* vim: set ts=4 tw=0 sw=4 noet: */
3 require_once 'Mail/mimeDecode.php';
4 require_once 'config.php';
5 require_once $CFG->root
. 'lib/db_factory.php';
6 require_once $CFG->root
. 'lib/utils.inc.php';
9 $loggedIn = $util->isLoggedIn();
10 if ($loggedIn && isset($_GET['id'])) {
12 $mail = unserialize($_SESSION['mailInfo'][$id]);
14 if (! is_object($mail) ||
false == $util->authorized($mail->recipient
)) {
15 header('Location: qtadmin.php');
19 $util->setHeading('Spam Report');
20 echo $util->getHeader();
21 echo $util->getHeading();
23 $row = $DB->getMail($id);
24 $string = $row->mail_text
;
26 $params['include_bodies'] = false;
27 $params['decode_bodies'] = true;
28 $params['decode_headers'] = true;
29 $params['input'] = $string;
30 $params['crlf'] = "\r\n";
32 $structure = Mail_mimeDecode
::decode($params);
33 $headers = $structure->headers
;
35 foreach ($headers as $header => $value) {
36 if ($header == 'x-spam-status') {
37 if (preg_match('/^(.*),\s*score=([\d\.]+).*tests=\[(.*)\].*/',
39 $sa_tests = array('x-spam-status' => $matches[1],
40 'score' => $matches[2], 'tests' => $matches[3]);
42 } else if ($header == 'x-spam-flag') {
43 $value = str_replace("<", "<", $value);
44 $value = str_replace(">", ">", $value);
45 $rows['spam'] = "<tr><td class=\"label\">Spam</td><td class=\"value\">$value</td></tr>";
46 } else if ($header == 'x-spam-score') {
47 $value = str_replace("<", "<", $value);
48 $value = str_replace(">", ">", $value);
49 $rows['score'] = "<tr><td class=\"label\">Spam Score</td><td class=\"value\">$value</td></tr>";
50 } else if ($header == 'x-spam-level') {
51 $value = str_replace("<", "<", $value);
52 $value = str_replace(">", ">", $value);
53 $rows['level'] = "<tr><td class=\"label\">Spam Level</td><td class=\"value\">$value</td></tr>";
54 } else if ($header == 'date') {
55 $value = str_replace("<", "<", $value);
56 $value = str_replace(">", ">", $value);
57 $rows['date'] = "<tr><td class=\"label\">Date</td><td class=\"value\">$value</td></tr>";
58 } else if ($header == 'from') {
59 $value = str_replace("<", "<", $value);
60 $value = str_replace(">", ">", $value);
61 $rows['from'] = "<tr><td class=\"label\">From</td><td class=\"value\">$value</td></tr>";
62 } else if ($header == 'reply-to') {
63 $value = str_replace("<", "<", $value);
64 $value = str_replace(">", ">", $value);
65 $rows['reply-to'] = "<tr><td class=\"label\">Reply-to</td><td class=\"value\">$value</td></tr>";
66 } else if ($header == 'to') {
67 $value = str_replace("<", "<", $value);
68 $value = str_replace(">", ">", $value);
69 $rows['to'] = "<tr><td class=\"label\">To</td><td class=\"value\">$value</td></tr>";
70 } else if ($header == 'subject') {
71 $value = str_replace("<", "<", $value);
72 $value = str_replace(">", ">", $value);
73 $rows['subject'] = "<tr><td class=\"label\">Subject</td><td class=\"value\">$value</td></tr>";
74 } else if ($header == 'received') {
76 foreach ($value as $val) {
77 $val = str_replace("<", "<", $val);
78 $val = str_replace(">", ">", $val);
79 $headers .= ($headers == '') ?
"$val" : "<br/><br/>$val";
81 $rows['headers'] = "<tr><td class=\"label\">Headers</td><td class=\"value\">$headers</td></tr>";
86 $sa_tests['tests'] = str_replace(" ","",$sa_tests['tests']);
87 $sa_rules = explode(",",$sa_tests['tests']);
88 $sa_count = count($sa_rules);
89 for ($i = 0; $i < $sa_count; $i++
) {
90 $sa_rule = explode("=", $sa_rules[$i]);
91 $bayes[$i] = "<tr><td class=\"label\">$sa_rule[0]</td><td class=\"value\">$sa_rule[1]</td></tr>";
93 $bayes['total'] = "<tr><td class=\"label\">TOTAL</td><td class=\"value\">".$sa_tests['score']."</td></tr>";
95 $bayes['total'] = "<tr><td class=\"label\">TOTAL</td><td class=\"value\">-</td></tr>";
97 $plain = "?id=$id&format=plain";
98 $html = "?id=$id&format=html";
99 echo '<p class="ruler">Message ID : ' . $mail->mail_id
. '</p>';
100 echo '<table class="button-menu">';
101 echo '<tr class="button-row">';
102 echo '<td class="button"><input class="btn-input" type="button" value="Return"
103 onclick="javascript: history.back();"/></td>';
104 echo '<td class="button"><input class="btn-input" type="button" value="View HTML"
105 onclick="javascript: window.location.href=\'message_view.php'.$html.'\'"/></td>';
106 echo '<td class="button"><input class="btn-input" type="button" value="View Plain Text"
107 onclick="javascript: window.location.href=\'message_view.php'.$plain.'\'"/></td>';
108 echo '<td class="button"><input class="btn-input" type="button" value="View Full Headers"
109 onclick="javascript: window.location.href=\'show_headers.php?id='.$id.'\'"/></td>';
110 echo '</tr></table>';
112 if (isset($rows['spam']))
114 if (isset($rows['score']))
116 if (isset($rows['level']))
118 if (isset($rows['headers']))
119 echo $rows['headers'];
120 if (isset($rows['date']))
122 if (isset($rows['from']))
124 if (isset($rows['reply-to']))
125 echo $rows['reply-to'];
126 if (isset($rows['to']))
128 if (isset($rows['subject']))
129 echo $rows['subject'];
131 echo '<p class="ruler">Spamassassin Report</p>';
132 echo '<table><tr><th>Rule</th><th>Score</th></tr>';
133 foreach ($bayes as $key => $row) {
134 if ($key != 'total') {
138 echo $bayes['total'];
140 echo $util->getFooter();
141 } else if ($loggedIn) {
142 header('Location: qtadmin.php');
144 header('Location: auth.php');
This page took 0.119432 seconds and 6 git commands to generate.