]>
Commit | Line | Data |
---|---|---|
6df4b805 MR |
1 | <?php |
2 | /* vim: set ts=4 tw=0 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 | |
b95d1cdb MR |
7 | $util = Utils::getInstance(); |
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 | ||
28 | echo "<span class=\"user\">{$util->getUser()} | |
bb06f172 | 29 | <a title=\"Logout\" href=\"auth.php?op=logout\">Logout</a></span>"; |
b95d1cdb MR |
30 | $which = ($util->isAdmin() == true) ? 'all' : $util->getUser(); |
31 | $rows = $DB->getQMails($offset, $rowsPerPage, $which); | |
32 | $numrows = $DB->numRows(); | |
33 | echo "<span class=\"total-rows\">$numrows quarantined mail(s)</span>"; | |
34 | echo "<table><tr>"; | |
6df4b805 | 35 | echo "<table><tr><th>Received</th><th>Cause</th>"; |
5c7b972e | 36 | echo "<th>Sender</th><th>Recipient</th><th>Subject</th><th>Action</th><th></th>"; |
b95d1cdb | 37 | echo "</tr>"; |
6df4b805 | 38 | |
b95d1cdb MR |
39 | $mailInfo = array(); |
40 | $i = 0; | |
41 | foreach ($rows as $row) { | |
42 | if ($i % 2) | |
43 | echo '<tr class="bg_odd">'; | |
44 | else | |
45 | echo '<tr class="bg_even">'; | |
46 | $id = $row->mail_id; | |
47 | $mailInfo[$id] = serialize($row); | |
48 | $url = urlencode($id); | |
5c7b972e | 49 | $checkbox = "<input name=\"action\" type=\"checkbox\" value=\"$url\" />"; |
bb06f172 MR |
50 | $recipient = "<a title=\"Show Report\" href=\"mail_report.php?id=$url\">{$row->recipient}</a>"; |
51 | $action = "<a title=\"Release Mail\" href=\"quarantine.php?id=$url&op=release\">"; | |
b95d1cdb | 52 | $action .= "<img class=\"nav-img\" src=\"pics/release.png\" alt=\"Release\" /></a>"; |
bb06f172 | 53 | $action .= " <a title=\"Delete Mail\" href=\"quarantine.php?id=$url&op=delete\">"; |
b95d1cdb MR |
54 | $action .= "<img class=\"nav-img\" src=\"pics/delete.png\" alt=\"Delete\" /></a>"; |
55 | $sender = $row->sender; | |
56 | $received = strftime("%c", $row->time_iso); | |
57 | $quaratinefor = $util->convertContent($row->quaratinefor); | |
58 | $subject = $row->subject; | |
6df4b805 MR |
59 | echo "<td>$received</td><td class=\"nav-action\">". |
60 | "$quaratinefor</td><td>$sender</td><td>$recipient</td>". | |
5c7b972e | 61 | "<td>$subject</td><td class=\"nav-action\">$action</td><td>$checkbox</td></tr>"; |
b95d1cdb MR |
62 | $i++; |
63 | } | |
64 | $_SESSION['mailInfo'] = $mailInfo; | |
65 | echo "</table>"; | |
66 | ||
67 | $maxPage = ceil($numrows/$rowsPerPage); | |
68 | $self = $_SERVER['PHP_SELF']; | |
69 | ||
70 | if ($pageNum > 1) { | |
71 | $page = $pageNum - 1; | |
bb06f172 | 72 | $prev = " <a title=\"Prev Page\" href=\"$self?page=$page&rowsperpage=$rowsPerPage\" |
b95d1cdb | 73 | class='whitefooter'>[Prev]</a>"; |
bb06f172 | 74 | $first = " <a title=\"First Page\" href=\"$self?page=1&rowsperpage=$rowsPerPage\" |
b95d1cdb MR |
75 | class='whitefooter'>[First Page]</a> "; |
76 | } else { | |
77 | $prev = ' '; // we're on page one, don't print previous link | |
78 | $first = ' '; // nor the first page link | |
79 | } | |
6df4b805 | 80 | |
b95d1cdb MR |
81 | if ($pageNum < $maxPage) { |
82 | $page = $pageNum + 1; | |
bb06f172 | 83 | $next = " <a title=\"Next Page\" href=\"$self?page=$page&rowsperpage=$rowsPerPage\" |
b95d1cdb | 84 | class='whitefooter'>[Next]</a>"; |
bb06f172 | 85 | $last = "<a title=\"Last Page\" href=\"$self?page=$maxPage&rowsperpage=$rowsPerPage\" |
b95d1cdb MR |
86 | class='whitefooter'>[Last Page]</a> "; |
87 | } else { | |
88 | $next = ' '; // we're on the last page, don't print next link | |
89 | $last = ' '; // nor the last page link | |
90 | } | |
91 | $marked = $DB->getMarked($which); | |
92 | $_SESSION['marked'] = serialize($marked); | |
93 | echo '<input class="mail-purge" type="button" value="Purge Mails ('. | |
94 | count($marked).')" onclick="javascript: location.href=\'quarantine.php?op=purge\'"/>'; | |
537a267d MR |
95 | echo '<input class="mail-purge" type="button" value="Release checked Mails." |
96 | onclick="javascript: checkAction();"/>'; | |
b95d1cdb MR |
97 | echo "<p class=\"page-nav\">$first$prev Showing page $pageNum of |
98 | $maxPage pages $next$last</p>"; | |
6df4b805 | 99 | |
b95d1cdb MR |
100 | echo $util->getFooter(); |
101 | } else { | |
102 | header('Location: auth.php'); | |
103 | } | |
6df4b805 | 104 | ?> |