From 28961382f5b6b9d0b97408af8bcce52fe214db22 Mon Sep 17 00:00:00 2001 From: paulr Date: Tue, 9 Aug 2011 15:15:23 +1000 Subject: [PATCH] added alot of host gorup operations --- plugins/hosts.php | 130 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 109 insertions(+), 21 deletions(-) diff --git a/plugins/hosts.php b/plugins/hosts.php index 3634682..f2e8e44 100644 --- a/plugins/hosts.php +++ b/plugins/hosts.php @@ -35,6 +35,12 @@ class GLCASHosts { case "scanrange": GLCASpageBuilder($this, "scanIPRange"); return; + case "delgroup": + GLCASpageBuilder($this, "deleteGroup"); + return; + case "dooperation": + GLCASpageBuilder($this, "doOperation"); + return; } } @@ -43,6 +49,57 @@ class GLCASHosts { } + function doOperation($url) + { + $operation = $_REQUEST["operation"]; + $groupop = $_REQUEST["groupop"]; + $hosts = $this->config->getData("hosts"); + $groups = $this->config->getData("hostgroups"); + + // first check if nogroup is selected + if(isset($_REQUEST["nonegroup-selected"])) { + echo "nonegroup operation
"; + } + + foreach($hosts as $key=>$val) { + $hname = $val["category"]; + $hip = $val["name"]; + $hg = $val["val"]; + if(isset($_REQUEST["$hname-selecthost"])) { + echo "Select host, $hname true
"; + } + } + + foreach($groups as $key=>$val) { + $grpname = $val["category"]; + if(isset($_REQUEST["$grpname-selectgroup"])) { + echo "Select group, $grpname true
"; + } + } + + } + + function deleteGroup($url) + { + $grpname = $_REQUEST["grpname"]; + $this->config->delData("hostgroups", "$grpname"); + $hosts = $this->config->getData("hosts"); + foreach($hosts as $key=>$val) { + $hname = $val["category"]; + $hip = $val["name"]; + $hg = $val["val"]; + + if($hg == $grpname) { + $this->config->delData("hosts", "$hname", "$hip", "$hg"); + $this->config->addData("hosts", "$hname", "$hip", ""); + } + } + + global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL; + header("Location: $BASE_URL/hosts"); + + } + function scanIPRange($url) { $iprange = $_REQUEST["scanip"]; @@ -153,37 +210,68 @@ class GLCASHosts { $hosts = $this->config->getData("hosts"); $groups = $this->config->getData("hostgroups"); - echo "

Hosts

"; - if($hosts) { - echo ""; - foreach($hosts as $key => $val) { - $hname = $val["category"]; - $hip = $val["name"]; - $hg = $val["val"]; - if($hg == "") $hg = "-"; - echo ""; - } - echo "
HostIPHost GroupLast SeenControl
$hname$hip$hg...Delete
"; - } else { - echo "No hosts defined yet
"; + $gs = 0; + echo "

Hosts and Groups

"; + echo "
"; + echo "Selected hosts operation: "; + echo "Group "; + echo ""; + - // groups - echo "

Host Groups

"; + echo ""; + + $gs++; + // fist print ungrouped + echo ""; + echo ""; + if($groups) { - echo "
"; + echo "

Ungrouped Hosts


"; + echo ""; + foreach($hosts as $key => $val) { + $hname = $val["category"]; + $hip = $val["name"]; + $hg = $val["val"]; + if($hg == "") $hg = "-"; + if($hg=="-") echo ""; + } + echo "
HostIPHost GroupLast SeenControl
$hname$hip$hg...Delete
"; + echo "
"; foreach($groups as $key=>$val) { + $gs++; + echo ""; + echo "

Host Group: $grpname Delete


"; + echo "
Group Name
"; $grpname = $val["category"]; - echo "
$grpname
"; + foreach($hosts as $key => $val) { + $hname = $val["category"]; + $hip = $val["name"]; + $hg = $val["val"]; + if($hg == "") $hg = "-"; + if($hg==$grpname) echo ""; + } + echo "
HostIPHost GroupLast SeenControl
$hname$hip$hg...Delete
"; + echo ""; + if(($gs%4)==0) echo ""; } - echo ""; - } else { - echo "No host groups defined yet
"; } + + + echo ""; + echo "
"; + echo "
"; + echo "
"; // the add hosts dialog -- 1.7.0.4