3 $WEB_ROOT_FS = realpath(dirname(__FILE__));
4 $BASE_URL = dirname($_SERVER["PHP_SELF"]);
6 global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL;
8 // add libglcas as if it were a path in ../libglcas
9 if(file_exists("../libglcas")) {
10 $path = realpath($WEB_ROOT_FS."/../");
11 error_log("added glcas path as $path");
12 set_include_path(get_include_path().PATH_SEPARATOR.$path);
15 // include the based library
16 require_once("libglcas/lib.php");
24 // TODO: do this better
25 $configpath = glcas_getWebConfigPath();
26 $glconfig = new GLCASConfig();
27 $glconfig->loadConfig($configpath);
36 $hostgroup = $argv[2];
41 echo "range makes no sense\n";
46 $ips_v = explode(".", $range);
48 $ips = $ips_v[0].".".$ips_v[1].".".$ips_v[2];
50 for($i = 1; $i < 255; $i++) {
53 echo "Scanning $ips_me<br>";
54 error_log("Scanning $ips_me<br>");
56 $hostname = gethostbyaddr($ips_me);
57 if($hostname != $ips_me) {
58 echo "Found host on $ips_me as $hostname<br>";
59 error_log("Found host on $ips_me as $hostname");
61 $hosts = $glconfig->getData("hosts");
63 foreach($hosts as $key => $val) {
64 if($val["category"] == $hostname && $val["name"] == $ips_me) {
65 echo "Host in db already<br>";
71 if(!$exists) $glconfig->addData("hosts", "$hostname", "$ips_me", "$hostgroup");