<?php
$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"]["getconfig"] = "nsos_getConfigFromDB";
+$HOST_TYPE["screenos"]["needsenable"] = false;
-function nsos_formFunction()
+
+function nsos_getConfigFromDB($hip, $cid)
{
- ?>
-Name <input type="text" name="username"><br>
-Password <input type="password" name="password"><br>
-Method <select name="methodtype"><option value="ssh">SSH</option><option value="telnet">Telnet</option></select>
- <?php
+ $data = db_selectData("configs", "configs_id", "$cid");
+
+ return base64_decode($data[0]["configdata"]);
}
-function nsos_postFunction()
+function nsos_updateConfig($hip, $hostconfig)
{
- echo "i am post function, your awesome<br>";
- echo "<pre>";
- print_r($_REQUEST);
- echo "</pre>";
}
-function nsos_getConfig($istest)
+function nsos_getConfig($host, $username, $password, $enable)
{
- genericssh_ssh($host, $username, $password, "cli show configuration");
+ return genericssh_ssh($host, $username, $password, "cli show configuration");
+}
+
+// remembver this:
+// pscp -scp -pw 'password' -l admin so-f2:ns_sys_config
+function screenosisgay($host, $username, $password, $command)
+{
+ $connector = ssh2_connect("$host");
+ error_log("attempting connect to $host with $username");
+ if($connector) {
+ error_log("connector true");
+ } else {
+ error_log("connector false");
+ }
+ ssh2_auth_password($connector, "$username", "$password");
+ $stream = ssh2_shell($connector, 'ansi');
+ fwrite($stream, PHP_EOL);
+ fwrite($stream, "set console page 0".PHP_EOL);
+ fwrite($stream, "get config".PHP_EOL);
+ fwrite($stream, PHP_EOL);
+ sleep(1);
+ stream_set_blocking($stream, true);
+ //fwrite($stream, "exit".PHP_EOL);
+ //fwrite($stream, "n".PHP_EOL);
+
+
+ $config = "";
+ $initline = "";
+ $haveinit = false;
+ while($buf = fgets($stream, 4096)) {
+ flush();
+ echo "got buf\n\"$buf\"\n";
+ $initline = $buf;
+ $config .= $buf;
+ }
+ fclose($stream);
+
+ return $config;
}
+
+
+
?>
\ No newline at end of file