root . 'lib/utils.inc.php'; function createHeader($data) { $out = 'Id'; foreach ($data as $head => $value) { $out .= "$head"; } return $out; } function parseResponse($raw) { if (count($raw) < 1) { return ''; } if (! is_object($raw[0])) { return "

{$raw[0]}

"; } $headers = createHeader($raw[0]); $r = "$headers"; $i = 1; foreach ($raw as $obj) { $r .= ""; foreach ($obj as $value) { $r .= ""; } $r .= ''; $i++; } $r .= '
$i$value
'; 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') { if ($util->isAdmin()) { $method = '/show'; } else { $method = '/show/' . $util->getUser(); } $list = $util->makeRestCall($method); if ($list) { $out = parseResponse($list); } else { $out = '

Connection to REST service failed

'; } } 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 = '

Connection to REST service failed

'; } } 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 = '

Connection to REST service failed

'; } } 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 $util->getFooter(); } else { header('Location: auth.php'); } ?>