]> git.datanom.net - qtadmin.git/commitdiff
More functions for wblist page
authorMichael Rasmussen <mir@datanom.net>
Thu, 25 Jun 2015 17:32:54 +0000 (19:32 +0200)
committerMichael Rasmussen <mir@datanom.net>
Thu, 25 Jun 2015 17:32:54 +0000 (19:32 +0200)
wblist.php

index 1f42f94f0f79450b0a2fb35e3565e30301391757..51cc681405473657cf95cfa455c84a6bed761b06 100644 (file)
@@ -3,68 +3,95 @@
     require_once 'config.php';
     require_once $CFG->root . 'lib/utils.inc.php';
 
-       function createHeader($data) {
-               $out = '<th>Id</th>';
-               foreach ($data as $head => $value) {
-                       $out .= "<th>$head</th>";
-               }
-               
-               return $out;
-       }
-       
-       function parseResponse($raw) {
-               if (count($raw) < 1) {
-                       return '';
-               }
-               $headers = createHeader($raw[0]);
-               $r = "<table><tr>$headers</tr>";
-               $i = 1;
-               foreach ($raw as $obj) {
-                       $r .= "<tr><td>$i</td>";
-                       foreach ($obj as $value) {
-                               $r .= "<td>$value</td>";
-                       }
-                       $r .= '</tr>';
-                       $i++;
-               }
-               $r .= '</table>';
-               
-               return $r;
-       }
+    function createHeader($data) {
+        $out = '<th>Id</th>';
+        foreach ($data as $head => $value) {
+            $out .= "<th>$head</th>";
+        }
+
+        return $out;
+    }
+
+    function parseResponse($raw) {
+        if (count($raw) < 1) {
+            return '';
+        }
+        $headers = createHeader($raw[0]);
+        $r = "<table><tr>$headers</tr>";
+        $i = 1;
+        foreach ($raw as $obj) {
+            $r .= "<tr><td>$i</td>";
+            foreach ($obj as $value) {
+                $r .= "<td>$value</td>";
+            }
+            $r .= '</tr>';
+            $i++;
+        }
+        $r .= '</table>';
+
+        return $r;
+    }
 
     $util = new Utils;
 
     if ($util->isLoggedIn()) {
-       $function = isset($_GET['p']) ? $_GET['p'] : null;
-       $subfunction = isset($_GET['s']) ? $_GET['s'] : null;
-       if (($function && $function == 'show' && !$subfunction) ||
-               ($function && $function == 'add' && $subfunction) ||
-               ($function && $function == 'del' && $subfunction)) {
-               header('Location: index.php');
-       } else if($function == 'show') {
-               if ($subfunction == 'all') {
-                       $list = $util->makeRestCall('/show');
-                       if ($list) {
-                               $out = parseResponse($list);
-                       } else {
-                               $out = '<p>Connection to REST service failed</p>';
-                       }
-               } else if ($subfunction == 'blacklist') {
-               } else if ($subfunction == 'whitelist') {
-               } else {
-                       header('Location: index.php');
-               }
-       } else if($function == 'add') {
-       } else if($function == 'del') {
-       } else {
-               header('Location: index.php');
-       }
+        $function = isset($_GET['p']) ? $_GET['p'] : null;
+        $subfunction = isset($_GET['s']) ? $_GET['s'] : null;
+        if (($function && $function == 'show' && !$subfunction) ||
+            ($function && $function == 'add' && $subfunction) ||
+            ($function && $function == 'del' && $subfunction)) {
+            header('Location: index.php');
+        } else if($function == 'show') {
+            if ($subfunction == 'all') {
+                if ($util->isAdmin()) {
+                    $method = '/show';
+                } else {
+                    $method = '/show/' . $util->getUser();
+                }
+                $list = $util->makeRestCall($method);
+                if ($list) {
+                    $out = parseResponse($list);
+                } else {
+                    $out = '<p>Connection to REST service failed</p>';
+                }
+            } else if ($subfunction == 'blacklist') {
+                if ($util->isAdmin()) {
+                    $method = '/show/blacklist';
+                } else {
+                    $method = '/show/blacklist' . $util->getUser();
+                }
+                $list = $util->makeRestCall($method);
+                if ($list) {
+                    $out = parseResponse($list);
+                } else {
+                    $out = '<p>Connection to REST service failed</p>';
+                }
+            } else if ($subfunction == 'whitelist') {
+                if ($util->isAdmin()) {
+                    $method = '/show/whitelist';
+                } else {
+                    $method = '/show/whitelist' . $util->getUser();
+                }
+                $list = $util->makeRestCall($method);
+                if ($list) {
+                    $out = parseResponse($list);
+                } else {
+                    $out = '<p>Connection to REST service failed</p>';
+                }
+            } else {
+                header('Location: index.php');
+            }
+        } else if($function == 'add') {
+        } else if($function == 'del') {
+        } else {
+            header('Location: index.php');
+        }
         $util->setHeading('WB List and Quarantine Administration');
         echo $util->getHeader();
         echo $util->getHeading();
-               echo $out;
+        echo $out;
         echo $util->getFooter();
     } else {
         header('Location: auth.php');
     }
-?>
\ No newline at end of file
+?>
This page took 0.043148 seconds and 5 git commands to generate.