X-Git-Url: http://git.pjr.cc/?p=configmanager.git;a=blobdiff_plain;f=lib%2Fwww.php;fp=lib%2Fwww.php;h=3b7c5061756903ca301da715954ea2b9a18819bc;hp=794279b539a9f2fa5bde9663d7f7b0faba4318d3;hb=779ccbdea52a495b9150c12c6d69af2aa370d8f1;hpb=843363a8f4dca2460800d5c3c72b559cce15c99f
diff --git a/lib/www.php b/lib/www.php
index 794279b..3b7c506 100644
--- a/lib/www.php
+++ b/lib/www.php
@@ -15,7 +15,11 @@ $FUNCTIONS["config"] = "www_configure";
$FUNCTIONS["addhost"] = "www_addhost";
$FUNCTIONS["addhostnext"] = "www_addHostStageTwo";
$FUNCTIONS["addhostthree"] = "www_addHostStageThree";
-
+$FUNCTIONS["delete"] = "www_deleteHost";
+$FUNCTIONS["update"] = "www_updateHost";
+$FUNCTIONS["detail"] = "www_hostDetail";
+$FUNCTIONS["getconfig"] = "www_getConfig";
+$FUNCTIONS["downloadconfig"] = "www_downloadConfig";
function www_header()
{
@@ -74,9 +78,120 @@ function www_body()
$db = db_getDB();
- // here we do the normal body, whatever that
+ // here we do the normal body
// we'll list the hosts, the size of the current config and
// the last time it was updated, plus the number of versions
+ $data = db_selectData("hosts");
+ if(!$data) {
+ echo "No hosts currently exist, add them from the right
";
+ } else {
+ echo "
Name | Address | Last Update | Schedule | Versions | Controls |
---|---|---|---|---|---|
$name | $addr | $lupdate | $sched | $vd | "; + echo "Delete Edit Update"; + echo " |
"; + echo $rdata; + echo ""; +} + +function www_downloadConfig() +{ + global $HOST_TYPE; + + $cid = $_REQUEST["cid"]; + $hip = $_REQUEST["hip"]; + $data = db_selectData("hosts", "hostip", "$hip"); + + $hostname = $data[0]["hostname"]; + $htype = $data[0]["hosttype"]; + + $func = $HOST_TYPE["$htype"]["getconfig"]; + + error_log("calling $func with $hip, and $cid"); + $rdata = $func("$hip", "$cid"); + + echo "Config:
"; + echo $rdata; + echo ""; +} + +function www_hostDetail() +{ + global $HOST_TYPE; + + //db_createTable("configs", "hostip", "configtime", "configdata"); + //db_createTable("hosts", "hostname", "hostip", "hosttype", "hostconfig", "lastupdate", "updateschedule"); + //function db_updateData($tablename, $column, $newdata, $wherecol, $wheredata, $exact=true) + $hip = $_REQUEST["hip"]; + $data = db_selectData("hosts", "hostip", "$hip"); + + $hconfig = $data[0]["hostconfig"]; + $hostname = $data[0]["hostname"]; + $htype = $data[0]["hosttype"]; + + $func = $HOST_TYPE["$htype"]["detail"]; + + error_log("calling $func with $hip, and $hconfig"); + $func("$hip"); +} + +function www_updateHost() +{ + global $HOST_TYPE; + + //db_createTable("configs", "hostip", "configtime", "configdata"); + //db_createTable("hosts", "hostname", "hostip", "hosttype", "hostconfig", "lastupdate", "updateschedule"); + //function db_updateData($tablename, $column, $newdata, $wherecol, $wheredata, $exact=true) + $hip = $_REQUEST["hip"]; + $data = db_selectData("hosts", "hostip", "$hip"); + + $hconfig = $data[0]["hostconfig"]; + $hostname = $data[0]["hostname"]; + $htype = $data[0]["hosttype"]; + + $func = $HOST_TYPE["$htype"]["updateconfig"]; + + error_log("calling $func with $hip, and $hconfig"); + $func("$hip", $hconfig); } @@ -91,15 +206,54 @@ function www_hostTypesDropDown() } } +function www_deleteHost() +{ + $hip = $_REQUEST["hip"]; + $data = db_selectData("hosts", "hostip", "$hip"); + + $hostname = $data[0]["hostname"]; + + if(isset($_REQUEST["confirmed"])) { + db_deleteData("hosts", "hostip", "$hip"); + db_deleteData("configs", "hostip", "$hip"); + echo "Done!"; + } else { + echo "Are you use you wish to delete the host, $hostname with IP address $hip? (and all associated config info)
"; + print_r($data); + echo ""; + } +} + +function www_updateSchedule() +{ +?> + + + + + + + + + + "; + + echo "