]>
Commit | Line | Data |
---|---|---|
1 | <?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'; | |
6 | ||
7 | $util = new Utils; | |
8 | unset($_SESSION['mailInfo']); | |
9 | ||
10 | if ($util->isLoggedIn()) { | |
11 | if (isset($_GET['rowsperpage'])) { | |
12 | $rowsPerPage = $_GET['rowsperpage']; | |
13 | } else { | |
14 | $rowsPerPage = 20; | |
15 | } | |
16 | ||
17 | $pageNum = 1; | |
18 | if (isset($_GET['page'])) { | |
19 | $pageNum = $_GET['page']; | |
20 | } | |
21 | ||
22 | $offset = ($pageNum - 1) * $rowsPerPage; | |
23 | ||
24 | $util->setHeading('Quarantine Administration'); | |
25 | echo $util->getHeader(); | |
26 | echo $util->getHeading(); | |
27 | ||
28 | echo "Rows per page <input type=\"text\" value=\"$rowsPerPage\" id=\"rows\" | |
29 | size=\"2\"/><input type=\"button\" onclick=\"javascript: updateRowsPerPage()\" | |
30 | value=\"Change\"/><span class=\"user\">{$util->getUser()} | |
31 | <a title=\"Logout\" href=\"auth.php?op=logout\">Logout</a></span>"; | |
32 | $which = ($util->isAdmin() == true) ? 'all' : $util->getUser(); | |
33 | $rows = $DB->getQMails($offset, $rowsPerPage, $which); | |
34 | $numrows = $DB->numRows(); | |
35 | echo "<span class=\"total-rows\">$numrows quarantined mail(s)</span>"; | |
36 | echo "<table><tr>"; | |
37 | echo "<th>Received</th><th>Cause</th>"; | |
38 | echo "<th>Sender</th><th>Recipient</th><th>Subject</th><th>Action</th>"; | |
39 | echo "<th><input name=\"multiselect\" type=\"checkbox\" "; | |
40 | echo "onchange=\"javascript: updateAction(this)\" /></th>"; | |
41 | echo "</tr>"; | |
42 | ||
43 | $mailInfo = array(); | |
44 | $i = 0; | |
45 | foreach ($rows as $row) { | |
46 | if ($i % 2) | |
47 | echo '<tr class="bg_odd">'; | |
48 | else | |
49 | echo '<tr class="bg_even">'; | |
50 | $id = $row->mail_id; | |
51 | $mailInfo[$id] = serialize($row); | |
52 | $url = urlencode($id); | |
53 | $checkbox = "<input name=\"action\" type=\"checkbox\" value=\"$url\" />"; | |
54 | $recipient = "<a title=\"Show Report\" href=\"mail_report.php?id=$url\">{$row->recipient}</a>"; | |
55 | $action = "<a title=\"Release Mail\" href=\"quarantine.php?id=$url&op=release\">"; | |
56 | $action .= "<img class=\"nav-img\" src=\"pics/release.png\" alt=\"Release\" /></a>"; | |
57 | $action .= " <a title=\"Delete Mail\" href=\"quarantine.php?id=$url&op=delete\">"; | |
58 | $action .= "<img class=\"nav-img\" src=\"pics/delete.png\" alt=\"Delete\" /></a>"; | |
59 | $action .= " <a title=\"Block Sender\" href=\"quarantine.php?id=$url&op=block\">"; | |
60 | $action .= "<img class=\"nav-img\" src=\"pics/spam.png\" alt=\"Block Sender\" /></a>"; | |
61 | $sender = $row->sender; | |
62 | $received = strftime("%c", $row->time_iso); | |
63 | $quaratinefor = $util->convertContent($row->quaratinefor); | |
64 | $subject = $row->subject; | |
65 | echo "<td>$received</td><td class=\"nav-action\">". | |
66 | "$quaratinefor</td><td>$sender</td><td>$recipient</td>". | |
67 | "<td>$subject</td><td class=\"nav-action\">$action</td><td class=\"nav-action\">$checkbox</td></tr>"; | |
68 | $i++; | |
69 | } | |
70 | $_SESSION['mailInfo'] = $mailInfo; | |
71 | echo "</table>"; | |
72 | ||
73 | $maxPage = ceil($numrows/$rowsPerPage); | |
74 | $self = $_SERVER['PHP_SELF']; | |
75 | ||
76 | if ($pageNum > 1) { | |
77 | $page = $pageNum - 1; | |
78 | $prev = " <a title=\"Prev Page\" href=\"$self?page=$page&rowsperpage=$rowsPerPage\" | |
79 | class='whitefooter'><img class=\"nav-img\" src=\"pics/go-previous-symbolic.svg\" alt=\"Previous\" /></a> "; | |
80 | $first = " <a title=\"First Page\" href=\"$self?page=1&rowsperpage=$rowsPerPage\" | |
81 | class='whitefooter'><img class=\"nav-img\" src=\"pics/go-first-symbolic.svg\" alt=\"First\" /></a> "; | |
82 | } else { | |
83 | $prev = ' '; // we're on page one, don't print previous link | |
84 | $first = ' '; // nor the first page link | |
85 | } | |
86 | ||
87 | if ($pageNum < $maxPage) { | |
88 | $page = $pageNum + 1; | |
89 | $next = " <a title=\"Next Page\" href=\"$self?page=$page&rowsperpage=$rowsPerPage\" | |
90 | class='whitefooter'><img class=\"nav-img\" src=\"pics/go-next-symbolic.svg\" alt=\"Next\" /></a> "; | |
91 | $last = " <a title=\"Last Page\" href=\"$self?page=$maxPage&rowsperpage=$rowsPerPage\" | |
92 | class='whitefooter'><img class=\"nav-img\" src=\"pics/go-last-symbolic.svg\" alt=\"Last\" /></a> "; | |
93 | } else { | |
94 | $next = ' '; // we're on the last page, don't print next link | |
95 | $last = ' '; // nor the last page link | |
96 | } | |
97 | $marked = $DB->getMarked($which); | |
98 | $_SESSION['marked'] = serialize($marked); | |
99 | echo '<input class="mail-purge" type="button" value="Purge Mails ('. | |
100 | count($marked).')" onclick="javascript: location.href=\'quarantine.php?op=purge\'"/>'; | |
101 | echo '<input class="mail-purge" type="button" value="Release checked" | |
102 | onclick="javascript: checkAction(\'release\');"/>'; | |
103 | echo '<input class="mail-purge" type="button" value="Delete checked" | |
104 | onclick="javascript: checkAction(\'delete\');"/>'; | |
105 | echo '<input class="mail-purge" type="button" value="Block checked" | |
106 | onclick="javascript: checkAction(\'block\');"/>'; | |
107 | echo "<p class=\"page-nav\">$first$prev Showing page $pageNum of | |
108 | $maxPage pages $next$last</p>"; | |
109 | ||
110 | echo $util->getFooter(); | |
111 | } else { | |
112 | header('Location: auth.php'); | |
113 | } | |
114 | ?> |