$scantype = gettext("None"); if ($scan_list = Host_scan::get_list($conn, "WHERE host_ip = inet_aton('{$ip}')")) { $scantype = ""; foreach ($scan_list as $scan) { $id = $scan->get_plugin_id(); $plugin_name = ""; if ($plugin_list = Plugin::get_list($conn, "WHERE id = {$id}")) { $plugin_name .= $plugin_list[0]->get_name(); $scantype .= ucfirst($plugin_name) . "<br>"; } else { $scantype .= "{$id}<BR>"; } } } $xml .= "<cell><![CDATA[" . $scantype . "]]></cell>"; if ($os_data = Host_os::get_ip_data($conn, $host->get_ip())) { $os = $os_data["os"]; $host_os = $os . " " . Host_os::get_os_pixmap_nodb($os); } else { $host_os = ""; } $xml .= "<cell><![CDATA[" . $host_os . "]]></cell>"; $xml .= "</row>\n"; } $xml .= "</rows>\n"; echo $xml; $db->close($conn); ?>
function query_inventory($value) { require_once 'ossim_db.inc'; // Database Object $db = new ossim_db(); $conn = $db->connect(); $date_from = $_SESSION['inventory_search']['date_from'] != "" ? $_SESSION['inventory_search']['date_from'] : "1700-01-01"; $date_to = $_SESSION['inventory_search']['date_to'] != "" ? $_SESSION['inventory_search']['date_to'] : "3000-01-01"; $value = str_replace("/", "\\/", $value); $error = ""; $matches = array(); $ips = array(); // OS $allips = array(); $sql = "SELECT DISTINCT ip FROM host_os"; if (!($rs =& $conn->Execute($sql))) { $error = _("Error in Query: {$sql}"); } else { while (!$rs->EOF) { $allips[] = $rs->fields['ip']; $rs->MoveNext(); } } foreach ($allips as $ip) { /* $anom0os = $anom1os = ""; $sql2 = "SELECT os FROM host_os WHERE os LIKE '%$value%' AND ip=$ip AND anom=0 AND date >= '$date_from' AND date <= '$date_to' ORDER BY date DESC LIMIT 1"; if (!$rs = & $conn->Execute($sql2, $params)) { $error = _("Error in Query: $sql2"); } else { while (!$rs->EOF) { $anom0os = $rs->fields['os']; $rs->MoveNext(); } } $sql2 = "SELECT os FROM host_os WHERE os LIKE '%$value%' AND ip=$ip AND anom=1 AND date >= '$date_from' AND date <= '$date_to' ORDER BY date DESC LIMIT 1"; if (!$rs = & $conn->Execute($sql2, $params)) { $error = _("Error in Query: $sql2"); } else { while (!$rs->EOF) { $anom1os = $rs->fields['os']; $rs->MoveNext(); } } if ($anom0os != "") $matches[$anom0os][] = long2ip($ip); // Add IP to list elseif ($anom1os != "") $matches[$anom1os][] = long2ip($ip); */ $ret = Host_os::get_ip_data($conn, long2ip($ip)); $matches[$ret['os']][] = long2ip($ip); } // Services $allips = array(); $sql = "SELECT DISTINCT ip FROM host_services"; if (!($rs =& $conn->Execute($sql))) { $error = _("Error in Query: {$sql}"); } else { while (!$rs->EOF) { $allips[] = $rs->fields['ip']; $rs->MoveNext(); } } foreach ($allips as $ip) { $anom0serv = $anom1serv = ""; $sql2 = "SELECT service FROM host_services WHERE service LIKE '%{$value}%' AND ip={$ip} AND anom=0 AND date >= '{$date_from}' AND date <= '{$date_to}' ORDER BY date DESC LIMIT 1"; if (!($rs =& $conn->Execute($sql2, $params))) { $error = _("Error in Query: {$sql2}"); } else { while (!$rs->EOF) { $anom0serv = $rs->fields['service']; $rs->MoveNext(); } //if ($ip == 3232235781) return array(1,"matches IP $anom0serv"); } $sql2 = "SELECT service FROM host_services WHERE service LIKE '%{$value}%' AND ip={$ip} AND anom=1 ORDER BY date AND date >= '{$date_from}' AND date <= '{$date_to}' DESC LIMIT 1"; if (!($rs =& $conn->Execute($sql2, $params))) { $error = _("Error in Query: {$sql2}"); } else { while (!$rs->EOF) { $anom1serv = $rs->fields['service']; $rs->MoveNext(); } } if ($anom0serv != "") { $matches[$anom0serv][] = long2ip($ip); } elseif ($anom1serv != "") { $matches[$anom1serv][] = long2ip($ip); } } foreach ($matches as $os_service => $ips_arr) { //echo "found $os_service<br>"; //return array(1,"matches ".implode(",",array_keys($matches))); if (preg_match("/{$value}/i", $os_service)) { $ips = $ips_arr; } } if ($error != "") { return array(1, $error); } else { return array(0, $ips); } }
?> </td> </tr> <?php } ?> <tr> <th>Ip</th> <td><b><?php echo $host; ?> </b></td> </tr> <?php if ($os = Host_os::get_ip_data($conn, $host)) { ?> <tr> <th> <?php echo gettext("Operating System"); ?> </th> <td> <?php echo $os["os"]; echo Host_os::get_os_pixmap($conn, $host); ?> </td> </tr> <?php }