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


PHP Host::in_host方法代码示例

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


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

示例1: import_assets_csv


//.........这里部分代码省略.........
        //IP
        if (!ossim_valid($param[0], OSS_IP_ADDR, 'illegal:' . _("IP"))) {
            $response['line_errors'][$cont][] = array("IP", ossim_get_error_clean());
            $response['status'] = false;
        }
        //Hostname
        if (empty($param[1])) {
            $param[1] = $param[0];
        } else {
            if (!ossim_valid($param[1], OSS_SCORE, OSS_ALPHA, OSS_PUNC, 'illegal:' . _("Hostname"))) {
                $response['line_errors'][$cont][] = array("Hostname", ossim_get_error_clean());
                $response['status'] = false;
                ossim_clean_error();
            }
        }
        //FQDNs
        if (!empty($param[2])) {
            $fqdns_list = explode(",", $param[2]);
            foreach ($fqdns_list as $k => $fqdn) {
                if (!ossim_valid(trim($fqdn), OSS_NULLABLE, OSS_ALPHA, OSS_PUNC, 'illegal:' . _("FQDN/Aliases"))) {
                    $response['line_errors'][$cont][] = array("FQDN/Aliases", ossim_get_error_clean());
                    $response['status'] = false;
                    ossim_clean_error();
                }
            }
        }
        //Description
        if (!ossim_valid($param[3], OSS_NULLABLE, OSS_SCORE, OSS_ALPHA, OSS_PUNC, OSS_AT, 'illegal:' . _("Description"))) {
            $response['line_errors'][$cont][] = array("Description", ossim_get_error_clean());
            $response['status'] = false;
            ossim_clean_error();
        }
        //Asset
        if ($param[4] == '') {
            $param[4] = 2;
        } else {
            if (!ossim_valid($param[4], OSS_NULLABLE, OSS_DIGIT, 'illegal:' . _("Asset value"))) {
                $response['line_errors'][$cont][] = array("Asset", ossim_get_error_clean());
                $response['status'] = false;
                ossim_clean_error();
            }
        }
        //NAT
        if (!ossim_valid($param[5], OSS_NULLABLE, OSS_IP_ADDR, 'illegal:' . _("NAT"))) {
            $response['line_errors'][$cont][] = array("NAT", ossim_get_error_clean());
            $response['status'] = false;
            ossim_clean_error();
        }
        //Sensors
        $sensors = array();
        if (!empty($param[6])) {
            $sensor_name = array();
            $list = explode(",", $param[6]);
            $sensors_list = array_intersect($list, $my_allowed_sensors);
            if (!empty($sensors_list)) {
                foreach ($sensors_list as $sensor) {
                    $sensors[] = Sensor::get_sensor_name($conn, $sensor);
                }
            } else {
                $response['line_errors'][$cont][] = array("Sensors", _("You need at least one allowed Sensor"));
                $response['status'] = false;
                ossim_clean_error();
            }
        } else {
            $response['line_errors'][$cont][] = array("Sensors", _("Column Sensors is empty"));
            $response['status'] = false;
            ossim_clean_error();
        }
        $list_os = array("Windows", "Linux", "FreeBSD", "NetBSD", "OpenBSD", "MacOS", "Solaris", "Cisco", "AIX", "HP-UX", "Tru64", "IRIX", "BSD/OS", "SunOS", "Plan9", "IPhone");
        //Operating System
        if (!empty($param[7]) && !in_array($param[7], $list_os)) {
            $param[7] = "Unknown";
        }
        if ($response['status'] == true) {
            //Parameters
            $ip = $param[0];
            $hostname = $param[1];
            $asset = $param[4];
            $threshold_c = 30;
            $threshold_a = 30;
            $rrd_profile = "";
            $alert = 0;
            $persistence = 0;
            $nat = $param[5];
            $descr = $param[3];
            $os = $param[7];
            $fqdns = $param[2];
            $latitude = '';
            $longitude = '';
            $icon = 0;
            if (!Host::in_host($conn, $ip)) {
                Host::insert($conn, $ip, $hostname, $asset, $threshold_c, $threshold_a, $rrd_profile, $alert, $persistence, $nat, $sensors, $descr, $os, $mac, $mac_vendor, $latitude, $longitude, $fqdns, $icon);
            } else {
                Host::update($conn, $ip, $hostname, $asset, $threshold_c, $threshold_a, $rrd_profile, $alert, $persistence, $nat, $sensors, $descr, $os, $mac, $mac_vendor, $latitude, $longitude, $fqdns, $icon);
            }
        }
    }
    $response['read_line'] = $cont;
    return $response;
}
开发者ID:jhbsz,项目名称:ossimTest,代码行数:101,代码来源:import_hosts.php

示例2: ossim_db

$db = new ossim_db();
$conn = $db->connect();
$asset = 2;
$conf = $GLOBALS["CONF"];
$threshold = $conf->get_conf("threshold");
$alert = 0;
$persistence = 0;
$nat = "";
$sensor_list = Sensor::get_all($conn, "ORDER BY name");
$nsens = count($sensor_list);
$sensors = array();
$num_sens = 0;
foreach ($sensor_list as $sensor) {
    $sensor_name = $sensor->get_name();
    $num_sens++;
    $sensors[] = $sensor_name;
}
$descr = "";
$os = "";
$mac = "";
$mac_vendor = "";
$latitude = 0;
$longitude = 0;
if (!Host::in_host($conn, $ip)) {
    Host::insert($conn, $ip, $ip, $asset, $threshold, $threshold, "", $alert, $persistence, $nat, $sensors, $descr, $os, $mac, $mac_vendor, $latitude, $longitude);
} else {
    echo _("Warning: the host inserted already exists, inventory insert skipped.");
    exit;
}
$db->close($conn);
echo _("Host ") . $host . _(" Successfully inserted into inventory with default values.");
开发者ID:jhbsz,项目名称:ossimTest,代码行数:31,代码来源:newhost_response.php

示例3: gettext

 </a> </td>
<?php 
}
?>

<td class="nobborder">|</td>
<td class="nobborder" nowrap> <a href="<?php 
echo Sensor::get_sensor_link($conn, $host) . "/{$host}.html";
?>
" target="report"> <?php 
echo gettext("Usage");
?>
 </a> </td>

<?php 
if (Host::in_host($conn, $host) || Net::isIpInAnyNet($conn, $host)) {
    $interface = Sensor::get_sensor_interface($conn, $host);
    ?>
<td class="nobborder">|</td>
<td class="nobborder" nowrap> <a href="<?php 
    echo Sensor::get_sensor_link($conn, $host) . "/plugins/rrdPlugin?action=list&key=interfaces/{$interface}/hosts/{$ip_slashed}&title=host%20{$host}";
    ?>
" target="report"> <?php 
    echo gettext("Anomalies");
    ?>
 </a> </td>

<?php 
}
$db->close($conn);
?>
开发者ID:jhbsz,项目名称:ossimTest,代码行数:31,代码来源:top.php

示例4: update_db

function update_db($global_info, $scan)
{
    $db = new ossim_db();
    $conn = $db->connect();
    $array_os = array("win" => "1", "linux" => "2", "cisco" => "3", "freebsd" => "5", "netbsd" => "6", "openbsd" => "7", "hp-ux" => "8", "solaris" => "9", "macos" => "10", "plan9" => "11", "sco" => "12", "aix" => "13", "unix" => "14");
    $ips = $global_info["ips"];
    $sensors = $global_info["sboxs"];
    $nagios = $global_info['nagios'];
    // load protocol ids
    $protocol_ids = array();
    if ($protocol_list = Protocol::get_list($conn)) {
        foreach ($protocol_list as $protocol_data) {
            $protocol_ids[$protocol_data->get_name()] = $protocol_data->get_id();
        }
    }
    for ($i = 0; $i < $ips; $i++) {
        $ip = $global_info["ip_{$i}"];
        if (!empty($ip)) {
            $hosts[] = $ip;
            //gethostbyaddr($ip);
            $os = $scan[$ip]["os"];
            $os_id = 0;
            foreach ($array_os as $k => $v) {
                if (preg_match("/{$k}/i", $os)) {
                    $os_id = $v;
                    break;
                }
            }
            if (Host::in_host($conn, $ip)) {
                echo "* " . gettext("Updating") . " {$ip}..<br/>";
                Host::update($conn, $ip, gethostbyaddr($ip), $global_info["asset"], $global_info["threshold_c"], $global_info["threshold_a"], $global_info["rrd_profile"], 0, 0, $global_info["nat"], $sensors, $global_info["descr"], $scan["{$ip}"]["os"], $scan["{$ip}"]["mac"], $scan["{$ip}"]["mac_vendor"]);
                Host_scan::delete($conn, $ip, 3001);
                //if (isset($global_info["nessus"])) { Host_scan::insert($conn, $ip, 3001, 0); }
            } else {
                echo "<span style='color='blue'>\n";
                echo "* " . gettext("Inserting") . " {$ip}..<br/>\n";
                echo "</span>\n";
                Host::insert($conn, $ip, gethostbyaddr($ip), $global_info["asset"], $global_info["threshold_c"], $global_info["threshold_a"], $global_info["rrd_profile"], 0, 0, $global_info["nat"], $sensors, $global_info["descr"], $scan[$ip]["os"], $scan[$ip]["mac"], $scan[$ip]["mac_vendor"]);
                // if (isset($global_info["nessus"])) { Host_scan::insert($conn, $ip, 3001, 0); }
            }
            if ($os_id != 0) {
                Host_plugin_sid::delete($conn, $ip, 5001);
                Host_plugin_sid::insert($conn, $ip, 5001, $os_id);
            }
            if (!empty($nagios)) {
                if (!Host_scan::in_host_scan($conn, $ip, 2007)) {
                    Host_scan::insert($conn, $ip, 2007, "", $ip, $sensors, "");
                }
            } else {
                if (Host_scan::in_host_scan($conn, $ip, 2007)) {
                    Host_scan::delete($conn, $ip, 2007);
                }
            }
            /* Services */
            Host_plugin_sid::delete($conn, $ip, 5002);
            foreach ($scan[$ip]["services"] as $port_proto => $service) {
                $service["proto"] = $protocol_ids[strtolower(trim($service["proto"]))];
                Host_services::insert($conn, $ip, $service["port"], strftime("%Y-%m-%d %H:%M:%S"), $_SERVER["SERVER_ADDR"], $service["proto"], $service["service"], $service["service"], $service["version"], 1);
                Host_plugin_sid::insert($conn, $ip, 5002, $service["port"]);
            }
            flush();
        }
    }
    // Insert group name
    $groupname = $global_info["groupname"];
    if (!empty($groupname) && !empty($hosts)) {
        $exists_hosts = count(Host_group::get_list($conn, " AND g.name='{$groupname}'")) > 0;
        if ($exists_hosts) {
            echo "<br/>" . _("The group name already exists") . "<br/>";
        } else {
            Host_group::insert($conn, $groupname, $global_info["threshold_c"], $global_info["threshold_a"], $global_info["rrd_profile"], $sensors, $hosts, $global_info["descr"]);
        }
        //if (isset($global_info["nessus"])) { Host_group_scan::insert($conn, $groupname, 3001, 0); }
        if (!empty($nagios)) {
            Host_group_scan::insert($conn, $groupname, 2007, 0);
        }
    }
    $db->close($conn);
}
开发者ID:jhbsz,项目名称:ossimTest,代码行数:79,代码来源:scan_db.php


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