]> git.datanom.net - qtadmin.git/blob - wblist.php
0486db7c5b50fd850c4d3124bce82c2f987fd7d5
[qtadmin.git] / wblist.php
1 <?php
2 /* vim: set ts=4 tw=0 sw=4 noet: */
3 require_once 'config.php';
4 require_once $CFG->root . 'lib/utils.inc.php';
5
6 function createHeader($data) {
7 $out = '<th>Id</th>';
8 foreach ($data as $head => $value) {
9 $out .= "<th>$head</th>";
10 }
11
12 return $out;
13 }
14
15 function parseResponse($raw) {
16 if (count($raw) < 1) {
17 return '';
18 }
19 $headers = createHeader($raw[0]);
20 $r = "<table><tr>$headers</tr>";
21 $i = 1;
22 foreach ($raw as $obj) {
23 $r .= "<tr><td>$i</td>";
24 foreach ($obj as $value) {
25 $r .= "<td>$value</td>";
26 }
27 $r .= '</tr>';
28 }
29 $r .= '</table>';
30
31 return $r;
32 }
33
34 $util = new Utils;
35
36 if ($util->isLoggedIn()) {
37 $function = isset($_GET['p']) ? $_GET['p'] : null;
38 $subfunction = isset($_GET['s']) ? $_GET['s'] : null;
39 if (($function && $function == 'show' && !$subfunction) ||
40 ($function && $function == 'add' && $subfunction) ||
41 ($function && $function == 'del' && $subfunction)) {
42 header('Location: index.php');
43 } else if($function == 'show') {
44 if ($subfunction == 'all') {
45 $list = $util->makeRestCall('/show');
46 if ($list) {
47 $out = parseResponse($list);
48 } else {
49 $out = '<p>Connection to REST service failed</p>';
50 }
51 } else if ($subfunction == 'blacklist') {
52 } else if ($subfunction == 'whitelist') {
53 } else {
54 header('Location: index.php');
55 }
56 } else if($function == 'add') {
57 } else if($function == 'del') {
58 } else {
59 header('Location: index.php');
60 }
61 $util->setHeading('WB List and Quarantine Administration');
62 echo $util->getHeader();
63 echo $util->getHeading();
64 echo $out;
65 echo $util->getFooter();
66 } else {
67 header('Location: auth.php');
68 }
69 ?>
This page took 0.062074 seconds and 4 git commands to generate.