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