case "scanrange":
GLCASpageBuilder($this, "scanIPRange");
return;
+ case "delgroup":
+ GLCASpageBuilder($this, "deleteGroup");
+ return;
+ case "dooperation":
+ GLCASpageBuilder($this, "doOperation");
+ return;
}
}
}
+ 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<br>";
+ }
+
+ foreach($hosts as $key=>$val) {
+ $hname = $val["category"];
+ $hip = $val["name"];
+ $hg = $val["val"];
+ if(isset($_REQUEST["$hname-selecthost"])) {
+ echo "Select host, $hname true<br>";
+ }
+ }
+
+ foreach($groups as $key=>$val) {
+ $grpname = $val["category"];
+ if(isset($_REQUEST["$grpname-selectgroup"])) {
+ echo "Select group, $grpname true<br>";
+ }
+ }
+
+ }
+
+ 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"];
$hosts = $this->config->getData("hosts");
$groups = $this->config->getData("hostgroups");
- echo "<h2>Hosts</h2>";
- if($hosts) {
- echo "<table border=\"1\"><tr><th>Host</th><th>IP</th><th>Host Group</th><th>Last Seen</th><th>Control</th></tr>";
- foreach($hosts as $key => $val) {
- $hname = $val["category"];
- $hip = $val["name"];
- $hg = $val["val"];
- if($hg == "") $hg = "-";
- echo "<tr><td>$hname</td><td>$hip</td><td>$hg</td><td>...</td><td><a href=\"?action=deletehost&hostname=$hname\">Delete</a></tr>";
- }
- echo "</table>";
- } else {
- echo "No hosts defined yet<br>";
+ $gs = 0;
+ echo "<h2>Hosts and Groups</h2>";
+ echo "<form method=\"post\"action=\"?action=dooperation\">";
+ echo "Selected hosts operation: <select name=\"operation\">";
+ echo "<option value=\"move\">Move To</option>";
+ echo "<option value=\"move\">Delete</option>";
+ echo "</select>";
+ echo "Group <select name=\"groupop\">";
+ foreach($groups as $key => $val) {
+ $grpname = $val["category"];
+ echo "<option value=\"$grpname\">$grpname</option>";
}
- echo "<hr>";
+ echo "</select>";
+ echo "<input type=\"submit\" name=\"Go\" value=\"Go\">";
+
- // groups
- echo "<h2>Host Groups</h2>";
+ echo "<table border=\"1\">";
+
+ $gs++;
+ // fist print ungrouped
+ echo "<tr valign=\"top\">";
+ echo "<td>";
+ echo "<h3>Ungrouped Hosts</h3><br>";
+ echo "<table border=\"1\"><tr><th><input type=\"checkbox\" name=\"nonegroup-selected\"></th><th>Host</th><th>IP</th><th>Host Group</th><th>Last Seen</th><th>Control</th></tr>";
+ foreach($hosts as $key => $val) {
+ $hname = $val["category"];
+ $hip = $val["name"];
+ $hg = $val["val"];
+ if($hg == "") $hg = "-";
+ if($hg=="-") echo "<tr><td><input type=\"checkbox\" name=\"$hname-selecthost\"></td><td>$hname</td><td>$hip</td><td>$hg</td><td>...</td><td><a href=\"?action=deletehost&hostname=$hname\">Delete</a></tr>";
+ }
+ echo "</table>";
+ echo "</td>";
+
if($groups) {
- echo "<table border=\"1\"><tr><th>Group Name</th></tr>";
foreach($groups as $key=>$val) {
+ $gs++;
+ echo "<td>";
$grpname = $val["category"];
- echo "<tr><td>$grpname</td></tr>";
+ echo "<h3>Host Group: $grpname <a href=\"?action=delgroup&grpname=$grpname\">Delete</a></h3><br>";
+ echo "<table border=\"1\"><tr><th><input type=\"checkbox\" name=\"$grpname-selectgroup\"></th><th>Host</th><th>IP</th><th>Host Group</th><th>Last Seen</th><th>Control</th></tr>";
+ foreach($hosts as $key => $val) {
+ $hname = $val["category"];
+ $hip = $val["name"];
+ $hg = $val["val"];
+ if($hg == "") $hg = "-";
+ if($hg==$grpname) echo "<tr><td><input type=\"checkbox\" name=\"$hname-selecthost\"></td><td>$hname</td><td>$hip</td><td>$hg</td><td>...</td><td><a href=\"?action=deletehost&hostname=$hname\">Delete</a></tr>";
+ }
+ echo "</table>";
+ echo "</td>";
+ if(($gs%4)==0) echo "</tr><tr>";
}
- echo "</table>";
- } else {
- echo "No host groups defined yet<br>";
}
+
+
+ echo "</tr></table>";
+ echo "</form>";
+
echo "<hr>";
+
echo "<table><tr valign=\"top\"><td>";
// the add hosts dialog