X-Git-Url: http://git.pjr.cc/?p=configmanager.git;a=blobdiff_plain;f=lib%2Fwww.php;h=91ce2c29c9aa80f667f90a942c7b922ed17d4179;hp=3b7c5061756903ca301da715954ea2b9a18819bc;hb=16e3be6e5ed75359a4271cc94f80ca656cefd4b2;hpb=c5565a4a43cec9436fc8b6c8ddec513619405bbd
diff --git a/lib/www.php b/lib/www.php
index 3b7c506..91ce2c2 100644
--- a/lib/www.php
+++ b/lib/www.php
@@ -4,8 +4,8 @@
// some global menu stuff
$MENUS["home"]["url"] = "?action=home";
$MENUS["home"]["name"] = "Home";
-$MENUS["hosts"]["url"] = "?action=hosts";
-$MENUS["hosts"]["name"] = "Hosts";
+//$MENUS["hosts"]["url"] = "?action=hosts";
+//$MENUS["hosts"]["name"] = "Hosts";
$MENUS["add"]["url"] = "?action=addhost";
$MENUS["add"]["name"] = "Add Host";
$MENUS["config"]["url"] = "?action=config";
@@ -188,10 +188,27 @@ function www_updateHost()
$hostname = $data[0]["hostname"];
$htype = $data[0]["hosttype"];
- $func = $HOST_TYPE["$htype"]["updateconfig"];
+ $func = $HOST_TYPE["$htype"]["getconfig"];
+ $logdets = unserialize(base64_decode($hconfig));
+
+ $conf = $func($hip, $logdets["username"], $logdets["password"], $logdets["enable"]);
+
+ // function db_getMaxValue($tablename, $column, $columnsel="", $wheresel="")
+ $oldconf_rid = db_getMaxValue("configs", "configs_id", "hostip", "$hip");
+ $oldconf_id = $oldconf_rid[0][0];
+ error_log("oldconf_id is $oldconf_id");
- error_log("calling $func with $hip, and $hconfig");
- $func("$hip", $hconfig);
+ // function db_selectData($tablename, $column="", $value="", $orderby = "")
+ $oldconf_r = db_selectData("configs", "configs_id", "$oldconf_id");
+ $oldconf = base64_decode($oldconf_r[0]["configdata"]);
+
+ if(md5($oldconf) != md5($conf)) {
+ echo "New config found, updating db
";
+ db_insertData("configs", "$hip", time(), base64_encode($conf));
+ echo "Config added
";
+ } else {
+ echo "New config and old config are the same, not updating
";
+ }
}
@@ -220,9 +237,6 @@ function www_deleteHost()
} else {
echo "Are you use you wish to delete the host, $hostname with IP address $hip? (and all associated config info)
";
echo "Yes";
- echo "
"; - print_r($data); - echo ""; } } @@ -249,12 +263,17 @@ function www_addhost() db_createTable("configs", "hostip", "configtime", "configdata"); ?> "; - $func(); - echo ""; - } else echo "would call $func for $htype but it doesnt exist\n"; - } -} + + $confdetails["username"] = $user; + $confdetails["password"] = $pass; + $confdetails["enable"] = $enable; + + $logdata = base64_encode(serialize($confdetails)); + + db_updateData("hosts", "hostconfig", "$logdata", "hostip", "$hip"); + //function db_updateData($tablename, $column, $newdata, $wherecol, $wheredata, $exact=true) + -function www_addHostStageThree() -{ - global $HOST_TYPE; - if(isset($_REQUEST["hosttype"])) { - $htype = $_REQUEST["hosttype"]; - $func = $HOST_TYPE["$htype"]["postfunction"]; - if(function_exists($func)) { - $func(); - } else echo "would call $func for $htype but it doesnt exist\n"; + echo "Host added successfully, running configuration test
$conf"; + + //db_createTable("configs", "hostip", "configtime", "configdata"); + db_insertData("configs", "$hip", time(), base64_encode($conf)); } - } + ?> \ No newline at end of file