コード例 #1
0
ファイル: real_time.php プロジェクト: jackpf/ossim-arc
 $hosts = array();
 try {
     $_hosts_data = Asset_host::get_basic_list($conn);
     $hosts = $_hosts_data[1];
 } catch (Exception $e) {
     $hosts = array();
 }
 foreach ($hosts as $host) {
     $_ip = $host['ips'];
     $_hostname = $host['name'];
     if (Session::hostAllowed($conn, $_ip)) {
         //Load available hosts (Autocompleted)
         if ($_hostname != $_ip) {
             $h_list .= '{ txt:"' . $_hostname . ' [Host:' . $_ip . ']", id: "' . Asset_host_ips::ip2ulong($_ip) . '" },';
         } else {
             $h_list .= '{ txt:"' . $_ip . '", id: "' . Asset_host_ips::ip2ulong($_ip) . '" },';
         }
     }
 }
 // Protocol list
 if ($protocol_list = Protocol::get_list()) {
     echo "var protocols = new Array(" . count($protocol_list) . ")\n";
     foreach ($protocol_list as $proto) {
         //$_SESSION[$id] = $plugin->get_name();
         echo "protocols['proto_" . $proto['id'] . "'] = '" . $proto['name'] . "'\n";
         //Load available protocols (Autocompleted)
         $p_list .= '{ txt: "Protocol:' . $proto['name'] . '", id: "' . $proto['id'] . '" },';
     }
 }
 //Port list (Autocompleted)
 if ($port_list = Port::get_list($conn, " AND protocol_name='tcp'")) {
コード例 #2
0
ファイル: check_agent_ip.php プロジェクト: jackpf/ossim-arc
if ($ip_cidr != 'any' && $ip_cidr != '0.0.0.0/0') {
    if (Asset_host_ips::valid_ip($ip_cidr)) {
        //Agent IP/CIDR is an IP address
        $asset_ips = Asset_host_ips::get_ips_to_string($conn, $asset_id);
        if (preg_match('/' . $ip_cidr . '/', $asset_ips) == FALSE) {
            $warning_msg = _('The asset IP and IP/CIDR do not match');
        }
    } else {
        //Agent IP/CIDR is an CIDR
        $ip_range = CIDR::expand_cidr($ip_cidr, 'SHORT', 'LONG');
        $asset_ips_obj = new Asset_host_ips($asset_id);
        $asset_ips_obj->load_from_db($conn);
        $asset_ips = $asset_ips_obj->get_ips();
        $valid_ip_range = FALSE;
        foreach ($asset_ips as $a_data) {
            $ip = Asset_host_ips::ip2ulong($a_data['ip']);
            if ($ip >= $ip_range[0] && $ip <= $ip_range[1]) {
                $valid_ip_range = TRUE;
                break;
            }
        }
        if ($valid_ip_range == FALSE) {
            $warning_msg = _('The selected asset IP is out of the IP/CIDR range');
        }
    }
}
$db->close();
$data['status'] = 'success';
$data['data'] = $warning_msg;
echo json_encode($data);
exit;