本文整理汇总了PHP中Asset_host::get_list方法的典型用法代码示例。如果您正苦于以下问题:PHP Asset_host::get_list方法的具体用法?PHP Asset_host::get_list怎么用?PHP Asset_host::get_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset_host
的用法示例。
在下文中一共展示了Asset_host::get_list方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_time_limit
if (isset($_GET['get_data'])) {
//Setting up a high time limit.
set_time_limit(360);
$db = new ossim_db();
$conn = $db->connect();
//Setting up the file name with the hosts info
$file = uniqid('/tmp/export_all_host_' . date('Ymd_H-i-s') . '_');
$_SESSION['_csv_file_hosts'] = $file;
session_write_close();
$csv = array();
//Export a filtered list
$filters = array();
$session = session_id();
$tables = ', user_component_filter hc';
$filters = array('where' => "hc.asset_id=host.id AND hc.asset_type='asset' AND hc.session_id = '{$session}'", 'order_by' => 'host.hostname ASC');
$_host_list = Asset_host::get_list($conn, $tables, $filters);
foreach ($_host_list[0] as $host) {
$id = $host['id'];
//Description
$descr = $host['descr'];
$descr = mb_convert_encoding($descr, 'UTF-8', 'HTML-ENTITIES');
//Operating System
$os = Asset_host_properties::get_property_from_db($conn, $host['id'], 3);
$os = array_pop($os);
//Latitude/Longitude
$latitude = empty($host['location']['lat']) ? '' : $host['location']['lat'];
$longitude = empty($host['location']['lon']) ? '' : $host['location']['lon'];
//Devices
$str_devices = '';
$devices = Asset_host_devices::get_devices_to_string($conn, $id);
if (!empty($devices)) {
示例2: ossim_db
$db = new ossim_db();
$conn = $db->connect();
$filters = array('limit' => "{$from}, {$maxrows}", 'order_by' => "{$order} {$torder}");
if ($search_str != '') {
$filters['where'] = 'hostname LIKE "%' . $search_str . '%"';
}
// Get object from session
$asset_object = unserialize($_SESSION['asset_detail'][$group_id]);
if (!is_object($asset_object)) {
throw new Exception(_('Error retrieving the asset data from memory'));
}
// Get the hosts from another groups
if ($asset_type == 'othergroups') {
$where = " id NOT IN (SELECT host_id FROM host_group_reference WHERE host_group_id = UNHEX('" . $group_id . "')) ";
$filters['where'] = !empty($filters['where']) ? $where . ' AND ' . $filters['where'] : $where;
list($host_list, $total) = Asset_host::get_list($conn, '', $filters, $cache);
} else {
list($host_list, $total) = $asset_object->get_hosts($conn, $filters, FALSE);
}
// DATA
$data = array();
foreach ($host_list as $host_id => $host_data) {
$devices = Asset_host_devices::get_devices_to_string($conn, $host_id);
// Asset Group details format
if ($asset_type == 'group') {
try {
$asset_object->can_i_edit($conn);
$asset_object->can_delete_host($conn);
$delete_link = '<a href="javascript:;" onclick="del_asset_from_group(\'' . $host_id . '\');return false">';
$delete_link .= '<img class="delete_small tipinfo" txt="' . _('Remove this asset from group') . '" src="/ossim/pixmaps/delete.png" border="0"/>';
$delete_link .= '</a>';
示例3: calc_devices_total
function calc_devices_total($conn)
{
try {
$filter = array();
//Limit one bcz we only want the count
$filter['limit'] = '1';
//Retrieving the total number of hosts from the system.
list($hosts, $total) = Asset_host::get_list($conn, '', $filter);
} catch (Exception $e) {
$total = 0;
}
return intval($total);
}
示例4: array
$maxrows = $maxrows > 50 ? 50 : $maxrows;
$torder = $torder == 1 ? 'ASC' : 'DESC';
$to = $maxrows;
$user = Session::get_session_user();
//Get list params
$filters = array();
$tables = '';
$filters['order_by'] = $order . ' ' . $torder;
$filters['limit'] = $from . ', ' . $to;
$filters['where'] = '';
if (!$all_list) {
$tables = ', user_host_filter hf';
$filters['where'] = "hf.asset_id=host.id AND hf.login='{$user}'";
}
try {
list($assets, $total) = Asset_host::get_list($conn, $tables, $filters);
} catch (Exception $e) {
$response = array();
$response['sEcho'] = $sec;
$response['iTotalRecords'] = 0;
$response['iTotalDisplayRecords'] = 0;
$response['aaData'] = array();
$response['iDisplayStart'] = 0;
echo json_encode($response);
die;
}
$detail = '<img class="detail_img" src="' . AV_PIXMAPS_DIR . '/show_details.png"/>';
$results = array();
foreach ($assets as $_id => $asset_data) {
// Alarms
$alarms = Asset_host::has_alarms($conn, $_id);
示例5: _
exit;
}
//Performimg action
if (is_array($validation_errors) && !empty($validation_errors)) {
$error_msg = '<div style="padding-left:5px">' . _('The following errors occurred') . ":</div>\n <div style='padding: 5px 5px 5px 15px;'>" . implode('<br/>', $validation_errors) . '</div>';
$db->close();
Util::response_bad_request($error_msg);
}
try {
$data['status'] = 'success';
$data['data'] = _('Your request has been processed');
//Getting assets with Windows OS
$tables = ', host_properties hp, user_component_filter f';
$filters = array('where' => 'hp.host_id=host.id AND hp.property_ref=3 AND (hp.value LIKE "windows%" OR hp.value LIKE "microsoft%")
AND f.asset_id = host.id AND f.asset_type="asset" AND f.session_id = "' . session_id() . '"');
list($assets_w_os, $total_windows) = Asset_host::get_list($conn, $tables, $filters, FALSE);
$total_deployed = 0;
$deployment_stats = array();
if ($total_windows > 0) {
//HIDS sensors
$s_data = Ossec_utilities::get_sensors($conn);
$hids_sensors = $s_data['sensors'];
foreach ($assets_w_os as $asset_id => $a_data) {
$deployment_stats[$asset_id] = array('status' => 'success', 'data' => '');
//Getting HIDS sensor and Windows IP
$sensor_id = NULL;
$hids_agents = Asset_host::get_related_hids_agents($conn, $asset_id);
$aux_ip_address = explode(',', $a_data['ips']);
$aux_ip_address = array_flip($aux_ip_address);
$default_ip_address = array_pop(array_keys($aux_ip_address));
if (is_array($hids_agents) && !empty($hids_agents)) {
示例6: Exception
/************************************************************************************************/
/*** This file is includen in step_loader.php hence the wizard object is defined in $wizard ***/
/*** database connection is stored in $conn ***/
/************************************************************************************************/
/************************************************************************************************/
if (!$wizard instanceof Welcome_wizard) {
throw new Exception('There was an unexpected error');
}
$tables = ', host_properties hp';
$filters_w['where'] = " hp.host_id=host.id AND hp.property_ref=3 AND hp.value LIKE '%\"windows%'";
$filters_w['limit'] = '1';
$filter_l = $filters_w;
$filters_l['where'] = " hp.host_id=host.id AND hp.property_ref=3 AND hp.value LIKE '%\"linux%'";
try {
list($asset_w, $total_w) = Asset_host::get_list($conn, $tables, $filters_w, TRUE);
list($asset_l, $total_l) = Asset_host::get_list($conn, $tables, $filters_l, TRUE);
} catch (Exception $e) {
die($e->getMessage());
}
$step = intval($wizard->get_step_data('deploy_step'));
$deploy_tabs = array();
if ($total_w > 0) {
$deploy_tabs['windows'] = _('Windows') . ' (' . $total_w . ')';
}
if ($total_l > 0) {
$deploy_tabs['linux'] = _('UNIX / LINUX') . ' (' . $total_l . ')';
}
$flag_empty = $total_l + $total_w > 0 ? FALSE : TRUE;
$button_class = 'disabled';
$first_tab = key($deploy_tabs);
?>
示例7: Exception
/************************************************************************************************/
/************************************************************************************************/
/*** This file is includen in step_loader.php hence the wizard object is defined in $wizard ***/
/*** database connection is stored in $conn ***/
/************************************************************************************************/
/************************************************************************************************/
if (!$wizard instanceof Welcome_wizard) {
throw new Exception("There was an error, the Welcome_wizard object doesn't exist");
}
$system_list = Av_center::get_avc_list($conn);
$admin_ip = @$system_list['data'][strtolower(Util::get_system_uuid())]['admin_ip'];
$table = ', host_types ht, host_ip hip';
$f = array();
$f['where'] = " host.id=ht.host_id AND ht.type=4 AND hip.host_id=host.id AND hip.ip!=inet6_aton('{$admin_ip}')";
try {
list($hosts, $total) = Asset_host::get_list($conn, $table, $f, FALSE);
$active_plugins = Plugin::get_plugins_by_assets();
} catch (Exception $e) {
$total = 0;
Av_exception::write_log(Av_exception::USER_ERROR, $e->getMessage());
}
if ($total > 0) {
try {
$vendors = Software::get_hardware_vendors();
} catch (Exception $e) {
$vendors = array();
Av_exception::write_log(Av_exception::USER_ERROR, $e->getMessage());
}
$device_list = array();
foreach ($hosts as $asset_id => $host) {
$plugin_list = array();
示例8: draw_html_content
function draw_html_content($conn, $ri_data, $edit_mode = FALSE)
{
$ri_html = '';
if ($ri_data['type'] == 'indicator') {
//Allowed host types
$host_types = array('host', 'server', 'sensor');
//Getting indicator values
if (preg_match("/view\\.php\\?map\\=([a-fA-F0-9]*)/", $ri_data['url'], $found)) {
// Linked to another map: loop by this map indicators
list($r_value, $v_value, $a_value, $ri_data['asset_id'], $related_sensor, , $ips, $in_assets) = get_map_values($conn, $found[1], $ri_data['asset_id'], $ri_data['asset_type'], $host_types);
} else {
// Asset Values
list(, $related_sensor, , $ips, $in_assets) = get_assets($conn, $ri_data['asset_id'], $ri_data['asset_type'], $host_types);
list($r_value, $v_value, $a_value) = get_values($conn, $host_types, $ri_data['asset_type'], $ri_data['asset_id'], FALSE);
}
// Getting indacator links
if ($edit_mode == TRUE) {
$linked_url = "javascript:void(0);";
$r_url = "javascript:void(0);";
$v_url = "javascript:void(0);";
$a_url = "javascript:void(0);";
} else {
// Risk link
$alarm_query = '';
if ($ri_data['asset_type'] == 'host') {
$alarm_query .= "&host_id=" . $ri_data['asset_id'];
} elseif ($ri_data['asset_type'] == 'net') {
$alarm_query .= "&net_id=" . $ri_data['asset_id'];
} elseif ($ri_data['asset_type'] == 'sensor') {
$alarm_query .= "&sensor_query=" . $ri_data['asset_id'];
} elseif ($ri_data['asset_type'] == 'host_group' || $ri_data['asset_type'] == 'hostgroup') {
$alarm_query .= "&asset_group=" . $ri_data['asset_id'];
}
$r_url = Menu::get_menu_url("/ossim/alarm/alarm_console.php?hide_closed=1" . $alarm_query, 'analysis', 'alarms', 'alarms');
// Vulnerability link
if ($ri_data['asset_type'] == 'host_group' || $ri_data['asset_type'] == 'hostgroup') {
$v_data = '';
if (valid_hex32($ri_data['asset_id'])) {
$_group_object = Asset_group::get_object($conn, $ri_data['asset_id']);
if ($_group_object != NULL) {
$_assets_aux = $_group_object->get_hosts($conn, '', array(), TRUE);
foreach ($_assets_aux[0] as $_host_data) {
if ($v_data != '') {
$v_data .= ',';
}
$v_data .= $_host_data[2];
// IP
}
}
}
} else {
$v_data = $ips;
}
$v_url = Menu::get_menu_url("/ossim/vulnmeter/index.php?value={$v_data}&type=hn", 'environment', 'vulnerabilities', 'overview');
// Availability link
if (!empty($related_sensor)) {
$conf = $GLOBALS['CONF'];
$conf = !$conf ? new Ossim_conf() : $conf;
$nagios_link = $conf->get_conf('nagios_link');
$scheme = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
$path = !empty($nagios_link) ? $nagios_link : '/nagios3/';
$port = !empty($_SERVER['SERVER_PORT']) ? ':' . $_SERVER['SERVER_PORT'] : "";
$nagios_url = $scheme . $related_sensor . $port . $path;
if ($ri_data['asset_type'] == 'host') {
$hostname = Asset_host::get_name_by_id($conn, $ri_data['asset_id']);
if (preg_match('/\\,/', $ips)) {
$hostname .= '_' . preg_replace('/\\,.*/', '', $ips);
}
$a_url = Menu::get_menu_url("/ossim/nagios/index.php?sensor={$related_sensor}&nagios_link=" . urlencode($nagios_url . "cgi-bin/status.cgi?host=" . $hostname), 'environment', 'availability');
} else {
$a_url = Menu::get_menu_url("/ossim/nagios/index.php?sensor={$related_sensor}&nagios_link=" . urlencode($nagios_url . "cgi-bin/status.cgi?hostgroup=all"), 'environment', 'availability');
}
} else {
$a_url = 'javascript:void(0);';
}
//Report link or map link
if ($ri_data['url'] == 'REPORT') {
$linked_url = "javascript:void(0);";
if ($ri_data['asset_type'] == 'sensor') {
try {
//Special case 1: Sensors don't have detail view
$sensor_ip = Av_sensor::get_ip_by_id($conn, $ri_data['asset_id']);
if (Asset_host_ips::valid_ip($sensor_ip)) {
$filters = array('where' => "host.id = hi.host_id AND hi.ip = INET6_ATON('{$sensor_ip}')\n AND hi.host_id = hs.host_id AND hs.sensor_id = UNHEX('" . $ri_data['asset_id'] . "')");
list($hosts, $total) = Asset_host::get_list($conn, ', host_sensor_reference hs, host_ip hi', $filters);
if ($total == 1) {
$ri_data['asset_id'] = key($hosts);
$linked_url = Menu::get_menu_url("/ossim/av_asset/common/views/detail.php?asset_id=" . $ri_data['asset_id'], 'environment', 'assets', 'assets');
} elseif ($total > 1) {
$linked_url = Menu::get_menu_url("/ossim/av_asset/asset/index.php?filter_id=11&filter_value={$sensor_ip}", 'environment', 'assets', 'assets');
}
}
} catch (Exception $e) {
}
} elseif ($ri_data['asset_type'] == 'net_group' || $ri_data['asset_type'] == 'netgroup') {
//Special case 2: Net groups don't have detail view
$_sm_option = 'assets';
$_h_option = 'network_groups';
$linked_url = Menu::get_menu_url("/ossim/netgroup/netgroup_form.php?id=" . $ri_data['asset_id'], 'environment', $_sm_option, $_h_option);
} else {
//.........这里部分代码省略.........
示例9: ossim_error
echo ossim_error(_('Error! Net not found'));
exit;
}
//Export hosts from net
if (isset($_GET['get_data'])) {
//Setting up a high time limit.
set_time_limit(360);
$db = new ossim_db();
$conn = $db->connect();
//Setting up the file name with the hosts info
$file = uniqid("/tmp/export_hosts_from_net_{$net_id}" . date('Ymd_H-i-s') . '_');
$_SESSION["_csv_file_hosts_from_net_{$net_id}"] = $file;
session_write_close();
$csv = array();
$filters = array('where' => "host_net_reference.net_id = UNHEX('{$net_id}') AND host.id = host_net_reference.host_id");
$_host_list = Asset_host::get_list($conn, ', host_net_reference', $filters);
foreach ($_host_list[0] as $host) {
$id = $host['id'];
//Description
$descr = $host['descr'];
//Operating System
$os = Asset_host_properties::get_property_from_db($conn, $host['id'], 3);
$os = array_pop($os);
//Latitude/Longitude
$latitude = empty($host['location']['lat']) ? '' : $host['location']['lat'];
$longitude = empty($host['location']['lon']) ? '' : $host['location']['lon'];
//Devices
$str_devices = '';
$devices = Asset_host_devices::get_devices_to_string($conn, $id);
if (!empty($devices)) {
$str_devices = str_replace('<br/>', ',', $devices);