]>
Commit | Line | Data |
---|---|---|
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 | ||
3a5824c1 MR |
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 | } | |
6cba8db7 MR |
19 | if (! is_object($raw[0])) { |
20 | return "<p>{$raw[0]}</p>"; | |
21 | } | |
3a5824c1 MR |
22 | $headers = createHeader($raw[0]); |
23 | $r = "<table><tr>$headers</tr>"; | |
24 | $i = 1; | |
25 | foreach ($raw as $obj) { | |
26 | $r .= "<tr><td>$i</td>"; | |
27 | foreach ($obj as $value) { | |
28 | $r .= "<td>$value</td>"; | |
29 | } | |
30 | $r .= '</tr>'; | |
31 | $i++; | |
32 | } | |
33 | $r .= '</table>'; | |
34 | ||
35 | return $r; | |
36 | } | |
70c7fd57 | 37 | |
df10d813 MR |
38 | $util = new Utils; |
39 | ||
40 | if ($util->isLoggedIn()) { | |
3a5824c1 MR |
41 | $function = isset($_GET['p']) ? $_GET['p'] : null; |
42 | $subfunction = isset($_GET['s']) ? $_GET['s'] : null; | |
43 | if (($function && $function == 'show' && !$subfunction) || | |
44 | ($function && $function == 'add' && $subfunction) || | |
45 | ($function && $function == 'del' && $subfunction)) { | |
46 | header('Location: index.php'); | |
47 | } else if($function == 'show') { | |
48 | if ($subfunction == 'all') { | |
49 | if ($util->isAdmin()) { | |
50 | $method = '/show'; | |
51 | } else { | |
52 | $method = '/show/' . $util->getUser(); | |
53 | } | |
54 | $list = $util->makeRestCall($method); | |
55 | if ($list) { | |
56 | $out = parseResponse($list); | |
57 | } else { | |
58 | $out = '<p>Connection to REST service failed</p>'; | |
59 | } | |
60 | } else if ($subfunction == 'blacklist') { | |
61 | if ($util->isAdmin()) { | |
62 | $method = '/show/blacklist'; | |
63 | } else { | |
64 | $method = '/show/blacklist' . $util->getUser(); | |
65 | } | |
66 | $list = $util->makeRestCall($method); | |
67 | if ($list) { | |
68 | $out = parseResponse($list); | |
69 | } else { | |
70 | $out = '<p>Connection to REST service failed</p>'; | |
71 | } | |
72 | } else if ($subfunction == 'whitelist') { | |
73 | if ($util->isAdmin()) { | |
74 | $method = '/show/whitelist'; | |
75 | } else { | |
76 | $method = '/show/whitelist' . $util->getUser(); | |
77 | } | |
78 | $list = $util->makeRestCall($method); | |
79 | if ($list) { | |
80 | $out = parseResponse($list); | |
81 | } else { | |
82 | $out = '<p>Connection to REST service failed</p>'; | |
83 | } | |
84 | } else { | |
85 | header('Location: index.php'); | |
86 | } | |
87 | } else if($function == 'add') { | |
88 | } else if($function == 'del') { | |
89 | } else { | |
90 | header('Location: index.php'); | |
91 | } | |
df10d813 MR |
92 | $util->setHeading('WB List and Quarantine Administration'); |
93 | echo $util->getHeader(); | |
94 | echo $util->getHeading(); | |
3a5824c1 | 95 | echo $out; |
df10d813 MR |
96 | echo $util->getFooter(); |
97 | } else { | |
98 | header('Location: auth.php'); | |
99 | } | |
3a5824c1 | 100 | ?> |