echo "<p>\n\n#DNS zone file exports do not work - unable to create file in " . DNSEXPORTPATH . " - check permissions<br>\n"; } if (!is_writeable(DHCPEXPORTPATH)) { echo "<p>\n\n#DHCP exports do not work - unable to create file in " . DHCPEXPORTPATH . " - check permissions<br>\n"; } // not currently used #if (!is_writeable(VIEWEXPORTPATH)) { # echo "<p>\n\n#View exports do not work - unable to create file in ".VIEWEXPORTPATH." - check permissions<br>\n"; #} // cannot use is_executable() function here - only for php > 5.x if (NMAP != "") { if (!@file_exists(NMAP)) { // to stop fork errors on older php versions echo "<p>\n\n#Could not find NMAP as defined by path " . NMAP . " - check path<br>\n"; } else { if (!NmapScan("127.0.0.1/32")) { echo "<p>\n\n#Could not execute NMAP as defined by path " . NMAP . " - check path<br>\n"; } } } echo "\n"; // check some database drivers (not all are checked and may still give errors) // only check on unix systems - not sure if this works on windows? if (strncmp(PHP_OS, 'WIN', 3) != 0) { switch (DBF_TYPE) { case "mysql": case "mysqlt": case "maxsql": if (!extension_loaded("mysql")) { echo "<p>mysql driver not compiled into php - cannot complete install<br>"; echo "this is a php issue and has nothing to do with IPplan<br>";
$vars = $_SERVER["PHP_SELF"] . "?baseindex=" . $baseindex . "&block=" . floor($totcnt / MAXTABLESIZE) . "&showactive=" . $showactive . "&expr={$expr}&search=" . urlencode($search); insert($cblk, block(" | ")); insert($cblk, anchor($vars, $anc . inet_ntoa($row["ipaddr"]))); } } $totcnt++; } $ipscan = array(); if ($showactive and NMAP != "") { $nmapstart = inet_ntoa($baseaddr + $block * MAXTABLESIZE); if ($maxcnt > MAXTABLESIZE) { $nmapend = inet_ntoa($baseaddr + $block * MAXTABLESIZE + MAXTABLESIZE - 1); } else { $nmapend = inet_ntoa($baseaddr + $maxcnt - 1); } $ipscan = NmapScan(NmapRange($nmapstart, $nmapend)); // nmap had error due to safe mode? if ($ipscan === FALSE) { $showactive = 0; } } //capture data for the export view functionality $export = new exportForm(); $export->addRow(array("ip_addr", "user", "location", "description", "hostname", TELNO ? "telephone" : "mac_address", "last_polled", "last_modified", "changed_by")); $export->saveRow(); $pollcnt = array("d" => 0, "w" => 0, "m" => 0, "y" => 0); // note for translations to work here, the next field should have exactly 4x elements $pollflag = split(":", my_("D:W:M:Y")); $pollflag["d"] = $pollflag[0]; $pollflag["w"] = $pollflag[1]; $pollflag["m"] = $pollflag[2];
function do_poll($filename, $cust) { // If the -time parameter exists, get the start time global $timestamp, $starttime, $hostnames, $audit; if ($timestamp == TRUE) { $starttime = date("F j, Y, g:i:s a"); } $ds = open_dbf(); $handle = fopen($filename, "r"); while (!feof($handle)) { $buffer = chop(fgets($handle, 256)); // skip empty lines if (empty($buffer)) { continue; } // We break up the $both variable passed back which ends up with the $ret value // in $hosts1 and the $myhosts value in $names $hosts = NmapScan($buffer); // got an error? if (empty($hosts)) { continue; } // each nmap run is a transaction - problem with scan an entire transaction // is dumped if (DBF_TRANSACTIONS) { $ds->BeginTrans(); } // now loop through each address polled foreach ($hosts as $key => $hname) { $ipaddr = inet_aton($key); // find the subnet the address belongs to $result = $ds->Execute("SELECT baseindex\n FROM base\n WHERE {$ipaddr} BETWEEN baseaddr AND\n baseaddr+subnetsize-1 AND\n customer={$cust}"); // got a subnet, now try to update. if update fails, insert a new empty record if ($row = $result->FetchRow()) { $baseindex = $row["baseindex"]; if ($hostnames) { $result = $ds->Execute("UPDATE ipaddr\n SET lastpol=" . $ds->DBTimeStamp(time()) . ", hname=" . $ds->qstr($hname) . "\n WHERE baseindex={$baseindex} AND\n ipaddr={$ipaddr}"); } else { $result = $ds->Execute("UPDATE ipaddr\n SET lastpol=" . $ds->DBTimeStamp(time()) . "\n WHERE baseindex={$baseindex} AND\n ipaddr={$ipaddr}"); } if ($ds->Affected_Rows() == 0) { $ds->Execute("INSERT INTO ipaddr\n (userinf, location, telno, descrip, hname,\n baseindex, ipaddr, lastmod, lastpol, userid)\n VALUES\n (" . $ds->qstr("") . ",\n " . $ds->qstr("") . ",\n " . $ds->qstr("") . ",\n " . $ds->qstr("Unknown - added by IPplan command line poller") . ",\n " . $ds->qstr($hname) . ",\n {$baseindex}, \n {$ipaddr},\n " . $ds->DBTimeStamp(time()) . ",\n " . $ds->DBTimeStamp(time()) . ",\n " . $ds->qstr("POLLER") . ")"); if ($audit) { $ds->Execute("INSERT INTO auditlog\n (action, userid, dt)\n VALUES\n (" . $ds->qstr(sprintf("User POLLER added ip record %s customer %u index %u", $key, $cust, $baseindex)) . ",\n " . $ds->qstr("POLLER") . ",\n " . $ds->DBTimeStamp(time()) . ")"); } } } else { echo "No IPplan subnet found for address {$key}\n"; } } // end foreach if (DBF_TRANSACTIONS) { $ds->CommitTrans(); } } // end of while loop for each file line fclose($handle); close_dbf($ds); // If the -time parameter exists, timestamp it when done if ($timestamp == TRUE) { echo "Started: {$starttime}"; echo "\n"; $today = date("F j, Y, g:i:s a"); echo "Finished: {$today}"; echo "\n"; } }
' . $jsset . ' } ', array("language" => "JavaScript", "type" => "text/javascript"))); insert($w, $f = form(array("name" => "REQUESTIP", "method" => "get", "action" => $_SERVER["PHP_SELF"]))); insert($f, $con = container("fieldset", array("class" => "fieldset"))); insert($con, $legend = container("legend", array("class" => "legend"))); insert($legend, text(my_("Requested addresses"))); insert($con, selectbox($lst, array("name" => "request", "onChange" => "modifyipform()"))); } // ------------------- request ip address section ends here ------------------------ // ------------------- support functions block start here ------------------------ insert($w, textB(my_("IP Address to modify:") . " " . $iptemp)); // scan the new address to see if it is currently active if ($probe or $ipplanPoll) { if (NMAP != "") { $ipscan = NmapScan(NmapRange($iptemp, $iptemp)); if (!empty($ipscan)) { insert($w, text(my_(" (Address active on network) "), array("color" => "#FF0000"))); } } else { if (ScanHost($iptemp, 1)) { insert($w, text(my_(" (Address active on network) "), array("color" => "#FF0000"))); } } } insert($w, block(" | ")); insert($w, anchor("whois.php?lookup=" . $iptemp, my_("Whois"))); insert($w, block(" | ")); // dont bother checking for safe mode as error will be thrown in called scripts //if (!ini_get("safe_mode")) { insert($w, anchor("ping.php?lookup=" . $iptemp, my_("Ping")));