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