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


PHP Asset_host::is_in_db方法代码示例

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


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

示例1: main_page


//.........这里部分代码省略.........
    } else {
        $sortdir = "ASC";
    }
    $arr = array("name" => "Name", "schedule_type" => "Schedule Type", "time" => "Time", "next_CHECK" => "Next Scan", "enabled" => "Status");
    // modified by hsh to return all scan schedules
    if (empty($arruser)) {
        $query = "SELECT t2.name as profile, t1.meth_TARGET, t1.id, t1.name, t1.schedule_type, t1.meth_VSET, t1.meth_TIMEOUT, t1.username, t1.enabled, t1.next_CHECK, t1.email\n              FROM vuln_job_schedule t1 LEFT JOIN vuln_nessus_settings t2 ON t1.meth_VSET=t2.id ";
    } else {
        $query = "SELECT t2.name as profile, t1.meth_TARGET, t1.id, t1.name, t1.schedule_type, t1.meth_VSET, t1.meth_TIMEOUT, t1.username, t1.enabled, t1.next_CHECK, t1.email\n              FROM vuln_job_schedule t1 LEFT JOIN vuln_nessus_settings t2 ON t1.meth_VSET=t2.id WHERE username in ({$user}) ";
    }
    $query .= $sql_order;
    $result = $dbconn->execute($query);
    if ($result->EOF) {
        echo "<tr><td class='empty_results' height='20' style='text-align:center;'>" . _("No Scheduled Jobs") . "</td></tr>";
    }
    if (!$result->EOF) {
        echo "<tr>";
        foreach ($arr as $order_by => $value) {
            echo "<th><a href=\"manage_jobs.php?sortby={$order_by}&sortdir={$sortdir}\">" . _($value) . "</a></th>";
        }
        if (Session::menu_perms("environment-menu", "EventsVulnerabilitiesScan")) {
            echo "<th>" . _("Action") . "</th></tr>";
        }
    }
    $colors = array("#FFFFFF", "#EEEEEE");
    $color = 0;
    while (!$result->EOF) {
        list($profile, $targets, $schedid, $schedname, $schedtype, $sid, $timeout, $user, $schedstatus, $nextscan, $servers) = $result->fields;
        $name = Av_sensor::get_name_by_id($dbconn, $servers);
        $servers = $name != '' ? $name : "unknown";
        $targets_to_resolve = explode("\n", $targets);
        $ttargets = array();
        foreach ($targets_to_resolve as $id_ip) {
            if (preg_match("/^([a-f\\d]{32})#\\d+\\.\\d+\\.\\d+\\.\\d+\\/\\d{1,2}/i", $id_ip, $found) && Asset_net::is_in_db($dbconn, $found[1])) {
                $ttargets[] = preg_replace("/^([a-f\\d]{32})#/i", "", $id_ip) . " (" . Asset_net::get_name_by_id($dbconn, $found[1]) . ")";
            } else {
                if (preg_match("/^([a-f\\d]{32})#\\d+\\.\\d+\\.\\d+\\.\\d+/i", $id_ip, $found) && Asset_host::is_in_db($dbconn, $found[1])) {
                    $ttargets[] = preg_replace("/^([a-f\\d]{32})#/i", "", $id_ip) . " (" . Asset_host::get_name_by_id($dbconn, $found[1]) . ")";
                } else {
                    $ttargets[] = preg_replace("/[a-f\\d]{32}/i", "", $id_ip);
                }
            }
        }
        $targets = implode("<BR/>", $ttargets);
        $tz = intval($tz);
        $nextscan = gmdate("Y-m-d H:i:s", Util::get_utc_unixtime($nextscan) + 3600 * $tz);
        preg_match("/\\d+\\-\\d+\\-\\d+\\s(\\d+:\\d+:\\d+)/", $nextscan, $found);
        $time = $found[1];
        switch ($schedtype) {
            case "N":
                $stt = _("Once (Now)");
                break;
            case "O":
                $stt = _("Once");
                break;
            case "D":
                $stt = _("Daily");
                break;
            case "W":
                $stt = _("Weekly");
                break;
            case "M":
                $stt = _("Monthly");
                break;
            case "Q":
                $stt = _("Quarterly");
开发者ID:AntBean,项目名称:alienvault-ossim,代码行数:67,代码来源:manage_jobs.php

示例2: get_targets

function get_targets($conn, $ip_list)
{
    $result = array();
    if (!empty($ip_list)) {
        if (is_array($ip_list) == FALSE) {
            $ip_list = explode("\n", trim($ip_list));
        }
        foreach ($ip_list as $asset) {
            $asset = trim($asset);
            if (preg_match('/^([a-f\\d]{32})#(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\/\\d{1,2})$/i', $asset, $found)) {
                $_asset_name = Asset_net::is_in_db($conn, $found[1]) ? Asset_net::get_name_by_id($conn, $found[1]) : $found[2];
                $result[$asset] = $_asset_name;
            } else {
                if (preg_match('/^([a-f\\d]{32})#(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})$/i', $asset, $found)) {
                    $_asset_name = Asset_host::is_in_db($conn, $found[1]) ? Asset_host::get_name_by_id($conn, $found[1]) : $found[2];
                    $result[$asset] = $_asset_name;
                } else {
                    if (preg_match('/^([a-f\\d]{32})#hostgroup$/i', $asset, $found)) {
                        $result[$asset] = Asset_group::get_name_by_id($conn, $found[1]);
                    } else {
                        if (preg_match('/^([a-f\\d]{32})#netgroup$/i', $asset, $found)) {
                            $result[$asset] = Net_group::get_name_by_id($conn, $found[1]);
                        } else {
                            $result[$asset] = $asset;
                        }
                    }
                }
            }
        }
    }
    return $result;
}
开发者ID:jackpf,项目名称:ossim-arc,代码行数:32,代码来源:new_scan.php

示例3: explode

$_POST = $_GET;
$agent_data = explode('###', base64_decode($_POST['agent_data']));
$_POST['agent_id'] = $agent_data[0];
$_POST['asset_id'] = $agent_data[1];
$sensor_id = POST('sensor_id');
$asset_id = POST('asset_id');
$agent_id = POST('agent_id');
$validate = array('sensor_id' => array('validation' => "OSS_HEX", 'e_message' => 'illegal:' . _('Sensor ID')), 'asset_id' => array('validation' => "OSS_HEX", 'e_message' => 'illegal:' . _('Asset ID')), 'agent_id' => array('validation' => 'OSS_DIGIT', 'e_message' => 'illegal:' . _('Agent ID')));
$validation_errors = validate_form_fields('POST', $validate);
//Database connection
$db = new ossim_db();
$conn = $db->connect();
if (empty($validation_errors)) {
    //Extra validations
    try {
        if (Asset_host::is_in_db($conn, $asset_id) == FALSE) {
            $e_msg = _('Unable to deploy HIDS agent. This asset no longer exists in the asset inventory. Please check with your system admin for more information');
            Av_exception::throw_error(Av_exception::USER_ERROR, $e_msg);
        }
        $asset = new Asset_host($conn, $asset_id);
        $asset->load_from_db($conn);
        //Check asset context
        $ext_ctxs = Session::get_external_ctxs($conn);
        $ctx = $asset->get_ctx();
        if (!empty($ext_ctxs[$ctx])) {
            $e_msg = _('Asset can only be deployed at this USM');
            //Server related to CTX
            $server_obj = Server::get_server_by_ctx($conn, $ctx);
            if ($server_obj) {
                $s_name = $server_obj->get_name();
                $s_ip = $server_obj->get_ip();
开发者ID:jackpf,项目名称:ossim-arc,代码行数:31,代码来源:a_deployment_form.php

示例4:

 $unresolved = !preg_match("/\\d+\\.\\d+\\.\\d+\\.\\d+/", $target) && $not_resolve ? true : false;
 if (preg_match("/([a-f\\d]+)#(.*)/i", $target, $found)) {
     $asset_id = $found[1];
     $ip_cidr = $found[2];
 } else {
     $asset_id = '';
     $ip_cidr = $target;
 }
 $net_id = $host_id = '';
 if (!empty($asset_id)) {
     if (preg_match("/\\//", $ip_cidr)) {
         if (Asset_net::is_in_db($conn, $asset_id) === TRUE) {
             $net_id = $asset_id;
         }
     } else {
         if (Asset_host::is_in_db($conn, $asset_id) === TRUE) {
             $host_id = $asset_id;
         }
     }
 }
 if (!empty($net_id)) {
     // Net with ID
     $total_host += Util::host_in_net($ip_cidr);
     $name = Asset_net::get_name_by_id($conn, $net_id);
     $perm = Session::netAllowed($conn, $net_id);
     if (count($sensors) == 0) {
         $sensors = array_keys(Asset_net_sensors::get_sensors_by_id($conn, $net_id));
     }
 } else {
     if (!empty($host_id)) {
         // Host with ID
开发者ID:AntBean,项目名称:alienvault-ossim,代码行数:31,代码来源:simulate.php

示例5: sprintf

 //Extra validations
 if (empty($validation_errors['sensor_id']) && !Ossec_utilities::is_sensor_allowed($conn, $sensor_id)) {
     $validation_errors['sensor_id'] = sprintf(_("Sensor %s not allowed. Please check with your account admin for more information"), Av_sensor::get_name_by_id($conn, $sensor_id));
 }
 if (is_array($validation_errors) && !empty($validation_errors)) {
     $db->close();
     echo "<div style='color:gray; margin:15px; text-align:center;'>" . _('Trend chart not available') . "</div>";
     exit;
 }
 $tz = Util::get_timezone();
 $timetz = gmdate("U") + 3600 * $tz;
 // time to generate dates with timezone correction
 //HIDS trend
 $data = array();
 if ($agent_status > 1) {
     if (Asset_host::is_in_db($conn, $asset_id)) {
         $data = Ossec_utilities::hids_trend_by_id($conn, $asset_id);
     } else {
         if ($ip_cidr == '127.0.0.1') {
             // Getting default sensor IP
             $sensor_ip = Av_sensor::get_ip_by_id($conn, $sensor_id);
             $ip_cidr = empty($sensor_ip) ? $ip_cidr : $sensor_ip;
         } else {
             try {
                 $agent = array('name' => $agent_name, 'ip_cidr' => $ip_cidr);
                 $ip_cidr = Ossec_agent::get_last_ip($sensor_id, $agent);
             } catch (Exception $e) {
             }
         }
         if (Asset_host_ips::valid_ip($ip_cidr)) {
             $data = Ossec_utilities::hids_trend_by_ip($conn, $ip_cidr);
开发者ID:jackpf,项目名称:ossim-arc,代码行数:31,代码来源:load_trend.php

示例6: array

             $ips[$hostip] = array('ip' => $hostip, 'mac' => NULL);
             $host->set_ips($ips);
             $host->set_sensors($sensors);
             $host->set_fqdns($aliases);
             $host->save_in_db($dbconn);
         } catch (Exception $e) {
             $result = 'Impossible to save the host';
         }
     } else {
         $result = 'The host already exists.';
     }
     break;
 case 'update_aliases':
     list($hostip, $ctx, $aliases) = explode('|', base64_decode($asset));
     $hostid = key(Asset_host::get_id_by_ips($dbconn, $hostip, $ctx));
     if (Asset_host::is_in_db($dbconn, $hostid)) {
         try {
             $asset = new Asset_host($dbconn, $hostid);
             $asset->load_from_db($dbconn);
             $asset->set_fqdns($aliases);
             $asset->save_in_db($dbconn);
             $result = 'Host aliases updated';
         } catch (Exception $e) {
             $result = 'Impossible to save the host aliases';
         }
     }
     break;
 case "get_host_id":
     list($hostip, $ctx) = explode('|', base64_decode($asset));
     $result = key(Asset_host::get_id_by_ips($dbconn, $hostip, $ctx));
     break;
开发者ID:AntBean,项目名称:alienvault-ossim,代码行数:31,代码来源:util.php

示例7: strtolower

     $entity_type = Session::get_entity_type($conn, $_ctx);
     $entity_type = strtolower($entity_type);
     //Sometimes CTX is an engine instead of context
     $_ctx = $entity_type == 'context' ? $_ctx : Session::get_default_ctx();
     if (Asset_host_ips::valid_ip($_ip) && valid_hex32($_ctx)) {
         $aux_ids = Asset_host::get_id_by_ips($conn, $_ip, $_ctx);
         $aux_id = key($aux_ids);
         if (Asset_host::is_in_db($conn, $aux_id)) {
             $id = $aux_id;
         }
     } else {
         unset($_ip);
         unset($_ctx);
     }
 }
 if (!empty($id) && Asset_host::is_in_db($conn, $id)) {
     ossim_valid($id, OSS_HEX, 'illegal:' . _('Asset ID'));
     if (ossim_error()) {
         echo ossim_error(_('Error! Asset not found'));
         exit;
     }
     $asset = new Asset_host($conn, $id);
     $asset->load_from_db($conn);
     $is_in_db = 1;
     $is_editable = Asset_host::can_i_modify_ips($conn, $id) ? 'yes' : 'no_ip';
 } else {
     //New asset or asset has been deleted but there are some instances in the system (SIEM, alarms, ...)
     $id = valid_hex32($id) ? $id : Util::uuid();
     $asset = new Asset_host($conn, $id);
     if (isset($_ip) && isset($_ctx)) {
         $asset->set_ctx($_ctx);
开发者ID:jackpf,项目名称:ossim-arc,代码行数:31,代码来源:asset_form.php

示例8: tab_discovery

function tab_discovery()
{
    global $component, $uroles, $editdata, $scheduler, $username, $useremail, $dbconn, $disp, $enScanRequestImmediate, $enScanRequestRecur, $timeout, $smethod, $SVRid, $sid, $ip_list, $ip_exceptions_list, $schedule_type, $ROYEAR, $ROday, $ROMONTH, $time_hour, $time_min, $dayofweek, $dayofmonth, $sname, $user, $entity, $hosts_alive, $scan_locally, $version, $nthweekday, $semail, $not_resolve, $time_interval, $ssh_credential, $smb_credential, $net_id;
    global $pluginOptions, $enComplianceChecks, $profileid;
    $conf = $GLOBALS["CONF"];
    $users = Session::get_users_to_assign($dbconn);
    $entities_to_assign = Session::get_entities_to_assign($dbconn);
    $pre_scan_locally_status = $conf->get_conf("nessus_pre_scan_locally");
    $user_selected = $user;
    $entity_selected = $entity;
    $SVRid_selected = $SVRid;
    $sid_selected = $sid != "" ? $sid : $editdata['meth_VSET'];
    $timeout_selected = $editdata["meth_TIMEOUT"];
    $ip_list_selected = str_replace("\\r\\n", "\n", str_replace(";;", "\n", $ip_list));
    if (count($ip_exceptions_list) > 0) {
        $ip_list_selected .= "\n" . implode("\n", $ip_exceptions_list);
    }
    $ROYEAR_selected = $ROYEAR;
    $ROday_selected = $ROday;
    $ROMONTH_selected = $ROMONTH;
    $time_hour_selected = $time_hour;
    $time_min_selected = $time_min;
    $dayofweek_selected = $dayofweek;
    $dayofmonth_selected = $dayofmonth;
    $sname_selected = $sname;
    if (preg_match("/^[a-f\\d]{32}\$/i", $net_id)) {
        // Autofill new scan job from deployment
        if (Asset_net::is_in_db($dbconn, $net_id)) {
            $sname_selected = Asset_net::get_name_by_id($dbconn, $net_id);
            $schedule_type = "M";
            $ip_list = array();
            $nips = explode(",", Asset_net::get_ips_by_id($dbconn, $net_id));
            foreach ($nips as $nip) {
                $ip_list[] = $net_id . "#" . trim($nip);
            }
        }
    }
    if ($schedule_type != "") {
        $editdata['schedule_type'] = $schedule_type;
    }
    $cquery_like = "";
    if ($component != "") {
        $cquery_like = " AND component='{$component}'";
    }
    $today = date("Ymd");
    $tyear = substr($today, 0, 4);
    $nyear = $tyear + 1;
    $tmonth = substr($today, 4, 2);
    $tday = substr($today, 6, 2);
    #SET VALUES UP IF EDIT SCHEDULER
    if (isset($editdata['notify'])) {
        $enotify = $editdata['notify'];
    } else {
        $enotify = "{$useremail}";
    }
    if (isset($editdata['time'])) {
        list($time_hour, $time_min, $time_sec) = split(':', $editdata['time']);
        $tz = Util::get_timezone();
        $time_hour = $time_hour + $tz;
    }
    $arrTypes = array("N", "O", "D", "W", "M", "NW");
    foreach ($arrTypes as $type) {
        $sTYPE[$type] = "";
    }
    $arrJobTypes = array("C", "M", "R", "S");
    foreach ($arrJobTypes as $type) {
        $sjTYPE[$type] = "";
    }
    if (isset($editdata['schedule_type'])) {
        $sTYPE[$editdata['schedule_type']] = "selected='selected'";
        if ($editdata['schedule_type'] == 'D') {
            $ni = 2;
        } elseif ($editdata['schedule_type'] == 'O') {
            $ni = 3;
        } elseif ($editdata['schedule_type'] == 'W') {
            $ni = 4;
        } elseif ($editdata['schedule_type'] == 'NW') {
            $ni = 6;
        } else {
            $ni = 5;
        }
        $show = "<br><script language=javascript>showLayer('idSched', {$ni});</script>";
    } else {
        if ($enScanRequestImmediate) {
            $sTYPE['N'] = "selected='selected'";
            $show = "<br><script language=javascript>showLayer('idSched', 1);</script>";
        } else {
            $sTYPE['O'] = "selected='selected'";
            $show = "<br><script language=javascript>showLayer('idSched', 3);</script>";
        }
    }
    if ($schedule_type != "") {
        if ($schedule_type == "N") {
            $show .= "<br><script language=javascript>showLayer('idSched', 1);</script>";
        }
        if ($schedule_type == "O") {
            $show .= "<br><script language=javascript>showLayer('idSched', 3);</script>";
        }
        if ($schedule_type == "D") {
            $show .= "<br><script language=javascript>showLayer('idSched', 2);</script>";
//.........这里部分代码省略.........
开发者ID:AntBean,项目名称:alienvault-ossim,代码行数:101,代码来源:sched.php

示例9: ossim_db

</title>
    	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    	<meta http-equiv="Pragma" content="no-cache">
    	<link type="text/css" rel="stylesheet" href="../style/av_common.css?t=<?php 
echo Util::get_css_id();
?>
"/>
    </head>
    
    <body>
    <?php 
if ($data['status'] != 'error') {
    try {
        $db = new ossim_db();
        $conn = $db->connect();
        $is_in_db = Asset_host::is_in_db($conn, $id);
        $host = new Asset_host($conn, $id);
        if ($is_in_db == TRUE) {
            $can_i_modify_ips = Asset_host::can_i_modify_ips($conn, $id);
            $can_i_create_assets = TRUE;
            $host->load_from_db($conn, $id);
        } else {
            $can_i_modify_ips = TRUE;
            $can_i_create_assets = Session::can_i_create_assets();
        }
        if ($can_i_create_assets == TRUE) {
            $host->set_ctx($ctx);
            $host->set_name($name);
            if ($can_i_modify_ips == TRUE) {
                if (is_array($aux_ips) && !empty($aux_ips)) {
                    foreach ($aux_ips as $ip) {
开发者ID:AntBean,项目名称:alienvault-ossim,代码行数:31,代码来源:save_host.php


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