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