--- /dev/null
+<?php
+
+$WEB_ROOT_FS = realpath(dirname(__FILE__));
+$BASE_URL = dirname($_SERVER["PHP_SELF"]);
+
+global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL;
+
+// add libglcas as if it were a path in ../libglcas
+if(file_exists("../libglcas")) {
+ $path = realpath($WEB_ROOT_FS."/../");
+ error_log("added glcas path as $path");
+ set_include_path(get_include_path().PATH_SEPARATOR.$path);
+}
+
+// include the based library
+require_once("libglcas/lib.php");
+
+// load plugins
+glcas_pluginLoader();
+
+// find our config
+$configpath = "";
+
+// TODO: do this better
+$configpath = glcas_getWebConfigPath();
+$glconfig = new GLCASConfig();
+$glconfig->loadConfig($configpath);
+
+
+$range = "";
+if(isset($argv[1])) {
+ $range = $argv[1];
+}
+
+if(isset($argv[2])) {
+ $hostgroup = $argv[2];
+}
+
+
+if($range == "") {
+ echo "range makes no sense\n";
+ exit(0);
+}
+
+
+$ips_v = explode(".", $range);
+
+$ips = $ips_v[0].".".$ips_v[1].".".$ips_v[2];
+
+for($i = 1; $i < 255; $i++) {
+ $hostname = "";
+ $ips_me = "$ips.$i";
+ echo "Scanning $ips_me<br>";
+ error_log("Scanning $ips_me<br>");
+ flush();
+ $hostname = gethostbyaddr($ips_me);
+ if($hostname != $ips_me) {
+ echo "Found host on $ips_me as $hostname<br>";
+ error_log("Found host on $ips_me as $hostname");
+ flush();
+ $hosts = $glconfig->getData("hosts");
+ $exists = false;
+ foreach($hosts as $key => $val) {
+ if($val["category"] == $hostname && $val["name"] == $ips_me) {
+ echo "Host in db already<br>";
+ $exists = true;
+ flush();
+ }
+
+ }
+ if(!$exists) $glconfig->addData("hosts", "$hostname", "$ips_me", "$hostgroup");
+
+
+ }
+}
+echo "Finished";
+
+?>
\ No newline at end of file