2 $HOST_TYPE["screenos"]["name"] = "Netscreen Screen OS";
3 $HOST_TYPE["screenos"]["configform"] = "nsos_formFunction";
4 $HOST_TYPE["screenos"]["postfunction"] = "nsos_postFunction";
5 $HOST_TYPE["screenos"]["updateconfig"] = "nsos_updateConfig";
6 $HOST_TYPE["screenos"]["detail"] = "nsos_detail";
7 $HOST_TYPE["screenos"]["getconfig"] = "nsos_getConfigFromDB";
9 function nsos_formFunction()
12 Note: If your router/firewall/device uses a one-time password, leave these blank and manually update from the
14 Name <input type="text" name="username"><br>
15 Password <input type="password" name="password"><br>
16 Method <select name="methodtype"><option value="ssh">SSH</option><option value="telnet">Telnet</option></select>
20 function nsos_postFunction()
22 if($_REQUEST["password"] != "" && $_REQUEST["username"] != "") {
24 $hip = $_REQUEST["hostip"];
25 $user = $_REQUEST["username"];
26 $pass = $_REQUEST["password"];
27 $config = nsos_getConfig($hip, $user, $pass);
28 $hconfig["username"] = $user;
29 $hconfig["password"] = $pass;
31 $upsched = $_REQUEST["upsched"];
32 db_updateData("hosts", "hostconfig", base64_encode(serialize($hconfig)), "hostip", "$hip");
33 db_updateData("hosts", "lastupdate", "$lastupdate", "hostip", "$hip");
34 db_updateData("hosts", "updateschedule", "$upsched", "hostip", "$hip");
35 db_insertData("configs", "$hip", "$lastupdate", base64_encode($config));
36 //db_createTable("configs", "hostip", "configtime", "configdata");
37 //db_createTable("hosts", "hostname", "hostip", "hosttype", "hostconfig", "lastupdate", "updateschedule");
38 //function db_updateData($tablename, $column, $newdata, $wherecol, $wheredata, $exact=true)
40 echo "if the below is accurate, this has worked<br>";
42 echo "Attempting first config grab, i see<br>";
47 echo "No username and password set, you can update manually from the home page\n";
48 $hconfig["username"] = "";
49 $hconfig["password"] = "";
50 db_updateData("hosts", "hostconfig", base64_encode(serialize($hconfig)), "hostip", "$hip");
60 function nsos_getConfigFromDB($hip, $cid)
62 $data = db_selectData("configs", "configs_id", "$cid");
64 return base64_decode($data[0]["configdata"]);
67 function nsos_detail($hip)
69 $data = db_selectData("configs", "hostip", "$hip", "configtime desc");
71 echo "<table border=\"1\">";
72 echo "<tr><th>Config Data</th><th>Compare</th></tr>";
73 foreach($data as $dstruct) {
77 $dold = round((time()-$dstruct["configtime"])/86400);
79 $lupdate = strftime("%T %e %b %G", $dstruct["configtime"])." ($dold days old)";
80 $cid = $dstruct["configs_id"];
81 echo "<tr><td>$lupdate <a href=\"?action=getconfig&cid=$cid&hip=$hip\">Get</a> <a href=\"?action=downloadconfig&cid=$cid&hip=$hip\">Download</a></td><td>Tick</td></tr>";
87 function nsos_updateConfig($hip, $hostconfig)
89 $hconf = unserialize(base64_decode($hostconfig));
90 if($hconf["username"] == "" && !isset($_REQUEST["username"])) {
91 echo "No username/password data<br>";
93 <form method="post" action="?action=update&hip=<?php echo $hip ?>">
94 Name <input type="text" name="username"><br>
95 Password <input type="password" name="password"><br>
96 <input type="submit" name="Go" value="Go"><br>
102 if(isset($_REQUEST["username"])) {
103 $hconf["username"] = $_REQUEST["username"];
104 $hconf["password"] = $_REQUEST["password"];
107 $lastconfig_n_d = db_getMaxValue("configs", "configs_id", "hostip", $hip);
108 $lastconfig_n = $lastconfig_n_d[0][0];
109 $lastconfig_d = db_selectData("configs", "configs_id", "$lastconfig_n");
110 $lastconfig = base64_decode($lastconfig_d[0]["configdata"]);
112 $config = nsos_getConfig($hip, $hconf["username"], $hconf["password"]);
114 if(md5($config) == md5($lastconfig)) {
115 echo "Retrieved config is same as previous one, ignoring<br>";
119 //error_log("getting config with ".$hconf["username"]." and ".$conf["password"]);
120 echo "Got config, saving it to db<br>";
121 $lastupdate = time();
122 db_updateData("hosts", "lastupdate", "$lastupdate", "hostip", "$hip");
123 db_insertData("configs", "$hip", "$lastupdate", base64_encode($config));
125 echo "Config is:<br><pre>";
130 function nsos_getConfig($host, $username, $password)
132 return genericssh_ssh($host, $username, $password, "cli show configuration");