]> git.datanom.net - qtadmin.git/blob - index.php
Add multi action
[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><th></th>";
37 echo "</tr>";
38
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);
49 $checkbox = "<input name=\"action\" type=\"checkbox\" value=\"$url\" />";
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\">";
52 $action .= "<img class=\"nav-img\" src=\"pics/release.png\" alt=\"Release\" /></a>";
53 $action .= "&nbsp;<a title=\"Delete Mail\" href=\"quarantine.php?id=$url&op=delete\">";
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;
59 echo "<td>$received</td><td class=\"nav-action\">".
60 "$quaratinefor</td><td>$sender</td><td>$recipient</td>".
61 "<td>$subject</td><td class=\"nav-action\">$action</td><td>$checkbox</td></tr>";
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;
72 $prev = " <a title=\"Prev Page\" href=\"$self?page=$page&rowsperpage=$rowsPerPage\"
73 class='whitefooter'>[Prev]</a>";
74 $first = " <a title=\"First Page\" href=\"$self?page=1&rowsperpage=$rowsPerPage\"
75 class='whitefooter'>[First Page]</a> ";
76 } else {
77 $prev = '&nbsp;'; // we're on page one, don't print previous link
78 $first = '&nbsp;'; // nor the first page link
79 }
80
81 if ($pageNum < $maxPage) {
82 $page = $pageNum + 1;
83 $next = " <a title=\"Next Page\" href=\"$self?page=$page&rowsperpage=$rowsPerPage\"
84 class='whitefooter'>[Next]</a>";
85 $last = "<a title=\"Last Page\" href=\"$self?page=$maxPage&rowsperpage=$rowsPerPage\"
86 class='whitefooter'>[Last Page]</a> ";
87 } else {
88 $next = '&nbsp;'; // we're on the last page, don't print next link
89 $last = '&nbsp;'; // 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\'"/>';
95 echo "<p class=\"page-nav\">$first$prev Showing page $pageNum of
96 $maxPage pages $next$last</p>";
97
98 echo $util->getFooter();
99 } else {
100 header('Location: auth.php');
101 }
102 ?>
This page took 0.074166 seconds and 6 git commands to generate.