当前位置: 首页>>代码示例>>PHP>>正文


PHP Asset_host::is_ip_in_cache_cidr方法代码示例

本文整理汇总了PHP中Asset_host::is_ip_in_cache_cidr方法的典型用法代码示例。如果您正苦于以下问题:PHP Asset_host::is_ip_in_cache_cidr方法的具体用法?PHP Asset_host::is_ip_in_cache_cidr怎么用?PHP Asset_host::is_ip_in_cache_cidr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Asset_host的用法示例。


在下文中一共展示了Asset_host::is_ip_in_cache_cidr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: preg_match

$selected = "";
// src_ips from acid_event
$where = Security_report::make_where($conn, $date_from, $date_to, $plugin_list, $dDB);
$ejoin = preg_match('/plist_[a-z]+/', $where) ? preg_replace('/.*(plist_[a-z]+)\\.id .*/', ',\\1', $where) : '';
$query = "SELECT DISTINCT ip_src AS ip FROM alienvault_siem.acid_event {$ejoin} WHERE 1=1 {$where}\n    UNION SELECT DISTINCT ip_dst as ip FROM alienvault_siem.acid_event {$ejoin} WHERE 1=1 {$where}";
$rs = $conn->Execute($query);
if (!$rs) {
    Av_exception::throw_error(Av_exception::DB_ERROR, $conn->ErrorMsg());
}
$already = array();
while (!$rs->EOF) {
    $ip = inet_ntop($rs->fields['ip']);
    if (!isset($already[$ip])) {
        //Session::hostAllowed($conn,$ip) => not necessary here?
        $already[$ip]++;
        if (!Asset_host::is_ip_in_cache_cidr($conn, $ip)) {
            // geoip
            $_country_aux = $geoloc->get_country_by_host($conn, $ip);
            $s_country = strtolower($_country_aux[0]);
            $s_country_name = $_country_aux[1];
            if ($s_country == '') {
                $ips[':Unknown']++;
            } else {
                $ips["{$s_country}:{$s_country_name}"]++;
            }
        }
    }
    $rs->MoveNext();
}
//
arsort($ips);
开发者ID:jackpf,项目名称:ossim-arc,代码行数:31,代码来源:Geographic.php

示例2: import_assets_from_csv


//.........这里部分代码省略.........
                    $summary['general']['statistics']['errors']++;
                    continue;
                }
            }
        }
        //Insert/Update host in database
        if (count($summary['by_hosts'][$num_line]['errors']) == 0) {
            try {
                $host = new Asset_host($conn, $host_id);
                if ($is_in_db == TRUE) {
                    $host->load_from_db($conn, $host_id);
                    $can_i_modify_ips = Asset_host::can_i_modify_ips($conn, $host_id);
                } else {
                    if ($can_i_create_assets == FALSE) {
                        $n_error_msg = _('Host') . ' ' . $name . ' ' . _("not allowed. You don't have permissions to import this host");
                        $summary['by_hosts'][$num_line]['errors']['Net'] = $n_error_msg;
                        $summary['general']['statistics']['errors']++;
                        continue;
                    }
                }
                //Check IPs
                if ($can_i_modify_ips == TRUE) {
                    $aux_ips = explode(',', $csv_ips);
                    foreach ($aux_ips as $ip) {
                        $host_ids = Asset_host::get_id_by_ips($conn, $ip, $ctx);
                        unset($host_ids[$host_id]);
                        if (!empty($host_ids)) {
                            $c_error_msg = _('IP') . ' ' . $csv_ips . ' ' . _("not allowed. IP {$ip} already exists for this entity");
                            $summary['by_hosts'][$num_line]['errors']['IP'] = $c_error_msg;
                            $summary['general']['statistics']['errors']++;
                            break;
                        } else {
                            $cnd_1 = Session::get_net_where() != '' && !Session::only_ff_net();
                            $cnd_2 = Asset_host::is_ip_in_cache_cidr($conn, $ip, $ctx, TRUE);
                            if ($cnd_1 && !$cnd_2) {
                                $c_error_msg = sprintf(_("Error! The IP %s is not allowed. Please check with your account admin for more information"), $csv_ips);
                                $summary['by_hosts'][$num_line]['errors']['IP'] = $c_error_msg;
                                $summary['general']['statistics']['errors']++;
                                break;
                            }
                        }
                    }
                } else {
                    $c_error_msg = _('Host') . ' ' . $name . ': ' . _("IP address not allowed. IP address cannot be modified");
                    $summary['by_hosts'][$num_line]['status'] = 'warning';
                    $summary['general']['warnings']['errors']++;
                    $summary['by_hosts'][$num_line]['warnings']['IP'] = $c_error_msg;
                }
                //Setting new values
                if (count($summary['by_hosts'][$num_line]['errors']) == 0) {
                    $host->set_ctx($ctx);
                    $host->set_name($name);
                    $host->set_descr($descr);
                    if ($is_in_db == FALSE) {
                        if ($can_i_modify_ips == TRUE) {
                            if (is_array($aux_ips) && !empty($aux_ips)) {
                                $ips = array();
                                foreach ($aux_ips as $ip) {
                                    $ips[$ip] = array('ip' => $ip, 'mac' => NULL);
                                }
                                $host->set_ips($ips);
                            }
                        }
                        $host->set_sensors($sensors);
                    }
                    if (!empty($fqdns)) {
开发者ID:jackpf,项目名称:ossim-arc,代码行数:67,代码来源:import_all_hosts.php

示例3: array

    // adding all not external lans
    $local_ips = array();
    $total_ips = 0;
    foreach ($_nets as $current_net) {
        $cirds = explode(",", $current_net['ips']);
        foreach ($cirds as $cidr) {
            if (!$current_net['external'] && preg_match("/(.*)\\.(.*)\\.(.*)\\.(.*)\\/(.*)/", $cidr, $fields)) {
                $local_ips[] = array(" ", "ip_" . $_GET["addhomeips"], "=", $fields[1], $fields[2], $fields[3], $fields[4], $cidr, " ", "OR", $fields[5]);
                $total_ips++;
            }
        }
    }
    // adding rest of hosts
    foreach ($hosts as $current_ip => $_hips) {
        foreach ($_hips as $ctx => $_hdata) {
            if ($_hdata["home"] && !Asset_host::is_ip_in_cache_cidr($conn, $current_ip, $ctx)) {
                $fields = explode(".", $current_ip);
                $local_ips[] = array(" ", "ip_" . $_GET["addhomeips"], "=", $fields[0], $fields[1], $fields[2], $fields[3], $current_ip, " ", "OR", "");
                $total_ips++;
            }
        }
    }
    if (count($local_ips) > 0) {
        $local_ips[count($local_ips) - 1][9] = " ";
        // delete last OR
        $_SESSION['ip_addr'] = $_GET['ip_addr'] = $local_ips;
        $_SESSION['ip_addr_cnt'] = $_GET['ip_addr_cnt'] = $total_ips;
    }
    $_SESSION["_hostgroup"] = "";
    //print_r($_SESSION["ip_addr"]);
} elseif ($_GET["addhomeips"] == "-1") {
开发者ID:AntBean,项目名称:alienvault-ossim,代码行数:31,代码来源:base_include.inc.php

示例4: _

     $image = @imagecreatefromstring($icon);
     if (!$image || imagesx($image) > 16 || imagesy($image) > 16) {
         $validation_errors['icon'] = _('Image format is not allowed. Allowed only 16x16 PNG images');
     }
 }
 //Validating IPs
 $aux_ips = explode(',', $ips_string);
 foreach ($aux_ips as $ip) {
     $host_ids = Asset_host::get_id_by_ips($conn, $ip, $ctx);
     unset($host_ids[$id]);
     if (!empty($host_ids)) {
         $validation_errors['ip'] = _('Error! IP not allowed.') . " IP {$ip} " . _('already exists for this entity');
         break;
     } else {
         $cnd_1 = Session::get_net_where() != '' && !Session::only_ff_net();
         $cnd_2 = Asset_host::is_ip_in_cache_cidr($conn, $ip, $ctx, TRUE);
         if ($cnd_1 && !$cnd_2) {
             $validation_errors['ip'] = _("Error! IP {$ip} not allowed.  Check your asset filter");
             break;
         }
     }
 }
 //Validating Sensors
 if (is_array($sensors) && !empty($sensors)) {
     foreach ($sensors as $sensor) {
         if (!Av_sensor::is_allowed($conn, $sensor)) {
             $validation_errors['sboxs[]'] = _('Error! Host could not be saved because there are unallowed sensors');
         }
     }
 } else {
     $validation_errors['sboxs[]'] = _("Error in the 'Sensors' field (missing required field)");
开发者ID:AntBean,项目名称:alienvault-ossim,代码行数:31,代码来源:save_host.php


注:本文中的Asset_host::is_ip_in_cache_cidr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。