X-Git-Url: http://git.pjr.cc/?p=configmanager.git;a=blobdiff_plain;f=lib%2Fscreenos.plugin.php;fp=lib%2Fscreenos.plugin.php;h=30da6078c5aba68162b8fd76de9f5034d1fe7168;hp=7b1f2db1269b88ac8679008d5bcacbbdaa2b094b;hb=779ccbdea52a495b9150c12c6d69af2aa370d8f1;hpb=843363a8f4dca2460800d5c3c72b559cce15c99f diff --git a/lib/screenos.plugin.php b/lib/screenos.plugin.php index 7b1f2db..30da607 100644 --- a/lib/screenos.plugin.php +++ b/lib/screenos.plugin.php @@ -2,10 +2,15 @@ $HOST_TYPE["screenos"]["name"] = "Netscreen Screen OS"; $HOST_TYPE["screenos"]["configform"] = "nsos_formFunction"; $HOST_TYPE["screenos"]["postfunction"] = "nsos_postFunction"; +$HOST_TYPE["screenos"]["updateconfig"] = "nsos_updateConfig"; +$HOST_TYPE["screenos"]["detail"] = "nsos_detail"; +$HOST_TYPE["screenos"]["getconfig"] = "nsos_getConfigFromDB"; function nsos_formFunction() { ?> +Note: If your router/firewall/device uses a one-time password, leave these blank and manually update from the +home page Name Password Method SSHTelnet @@ -14,14 +19,116 @@ Method SSH"; + if($_REQUEST["password"] != "" && $_REQUEST["username"] != "") { + + $hip = $_REQUEST["hostip"]; + $user = $_REQUEST["username"]; + $pass = $_REQUEST["password"]; + $config = nsos_getConfig($hip, $user, $pass); + $hconfig["username"] = $user; + $hconfig["password"] = $pass; + $lastupdate = time(); + $upsched = $_REQUEST["upsched"]; + db_updateData("hosts", "hostconfig", base64_encode(serialize($hconfig)), "hostip", "$hip"); + db_updateData("hosts", "lastupdate", "$lastupdate", "hostip", "$hip"); + db_updateData("hosts", "updateschedule", "$upsched", "hostip", "$hip"); + db_insertData("configs", "$hip", "$lastupdate", base64_encode($config)); + //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) + + echo "if the below is accurate, this has worked"; + + echo "Attempting first config grab, i see"; + echo ""; + echo $config; + echo ""; + } else { + echo "No username and password set, you can update manually from the home page\n"; + $hconfig["username"] = ""; + $hconfig["password"] = ""; + db_updateData("hosts", "hostconfig", base64_encode(serialize($hconfig)), "hostip", "$hip"); + } + + echo ""; print_r($_REQUEST); echo ""; } -function nsos_getConfig($istest) + +function nsos_getConfigFromDB($hip, $cid) +{ + $data = db_selectData("configs", "configs_id", "$cid"); + + return base64_decode($data[0]["configdata"]); +} + +function nsos_detail($hip) +{ + $data = db_selectData("configs", "hostip", "$hip", "configtime desc"); + + echo ""; + echo "Config DataCompare"; + foreach($data as $dstruct) { + //echo ""; + //print_r($dstruct); + //echo ""; + $dold = round((time()-$dstruct["configtime"])/86400); + + $lupdate = strftime("%T %e %b %G", $dstruct["configtime"])." ($dold days old)"; + $cid = $dstruct["configs_id"]; + echo "$lupdate Get DownloadTick"; + } + echo ""; + +} + +function nsos_updateConfig($hip, $hostconfig) +{ + $hconf = unserialize(base64_decode($hostconfig)); + if($hconf["username"] == "" && !isset($_REQUEST["username"])) { + echo "No username/password data"; +?> + +Name +Password + + +"; + return 0; + } + + //error_log("getting config with ".$hconf["username"]." and ".$conf["password"]); + echo "Got config, saving it to db"; + $lastupdate = time(); + db_updateData("hosts", "lastupdate", "$lastupdate", "hostip", "$hip"); + db_insertData("configs", "$hip", "$lastupdate", base64_encode($config)); + + echo "Config is:"; + echo $config; + echo ""; +} + +function nsos_getConfig($host, $username, $password) { - genericssh_ssh($host, $username, $password, "cli show configuration"); + return genericssh_ssh($host, $username, $password, "cli show configuration"); } ?> \ No newline at end of file
"; + echo $config; + echo "
"; print_r($_REQUEST); echo "
"; + //print_r($dstruct); + //echo "