]> git.datanom.net - qtadmin.git/blame - wblist.php
First upload of wblist page
[qtadmin.git] / wblist.php
CommitLineData
df10d813
MR
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
70c7fd57 6 function createHeader($data) {
c1e881bf 7 $out = '<th>Id</th>';
70c7fd57 8 foreach ($data as $head => $value) {
156ce57f 9 $out .= "<th>$head</th>";
70c7fd57
MR
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>";
c1e881bf 21 $i = 1;
70c7fd57 22 foreach ($raw as $obj) {
c1e881bf 23 $r .= "<tr><td>$i</td>";
70c7fd57
MR
24 foreach ($obj as $value) {
25 $r .= "<td>$value</td>";
26 }
27 $r .= '</tr>';
c6e15571 28 $i++;
70c7fd57
MR
29 }
30 $r .= '</table>';
31
32 return $r;
33 }
34
df10d813
MR
35 $util = new Utils;
36
37 if ($util->isLoggedIn()) {
ccbb5c4b
MR
38 $function = isset($_GET['p']) ? $_GET['p'] : null;
39 $subfunction = isset($_GET['s']) ? $_GET['s'] : null;
40 if (($function && $function == 'show' && !$subfunction) ||
41 ($function && $function == 'add' && $subfunction) ||
02c51774 42 ($function && $function == 'del' && $subfunction)) {
ccbb5c4b
MR
43 header('Location: index.php');
44 } else if($function == 'show') {
45 if ($subfunction == 'all') {
46 $list = $util->makeRestCall('/show');
47 if ($list) {
70c7fd57 48 $out = parseResponse($list);
ccbb5c4b
MR
49 } else {
50 $out = '<p>Connection to REST service failed</p>';
51 }
52 } else if ($subfunction == 'blacklist') {
53 } else if ($subfunction == 'whitelist') {
54 } else {
55 header('Location: index.php');
56 }
57 } else if($function == 'add') {
58 } else if($function == 'del') {
59 } else {
60 header('Location: index.php');
61 }
df10d813
MR
62 $util->setHeading('WB List and Quarantine Administration');
63 echo $util->getHeader();
64 echo $util->getHeading();
df10d813
MR
65 echo $out;
66 echo $util->getFooter();
67 } else {
68 header('Location: auth.php');
69 }
70?>
This page took 0.060519 seconds and 5 git commands to generate.