本文整理汇总了PHP中Asset_host::load_from_db方法的典型用法代码示例。如果您正苦于以下问题:PHP Asset_host::load_from_db方法的具体用法?PHP Asset_host::load_from_db怎么用?PHP Asset_host::load_from_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset_host
的用法示例。
在下文中一共展示了Asset_host::load_from_db方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: POST
$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();
$server = $s_name . ' (' . $s_ip . ')';
$e_msg = sprintf(_("Unable to deploy agent to assets on a child server. Please login to %s to deploy the HIDS agents"), $server);
}
Av_exception::throw_error(Av_exception::USER_ERROR, $e_msg);
}
示例2: import_assets_from_csv
//.........这里部分代码省略.........
if (!ossim_valid($fqdns, OSS_FQDNS, OSS_NULLABLE, 'illegal:' . _('FQDN/Aliases'))) {
$summary['by_hosts'][$num_line]['errors']['FQDN/Aliases'] = ossim_get_error_clean();
$summary['general']['statistics']['errors']++;
continue;
}
//Asset
if (!ossim_valid($asset_value, OSS_DIGIT, 'illegal:' . _('Asset value'))) {
$summary['by_hosts'][$num_line]['errors']['Asset value'] = ossim_get_error_clean();
$summary['general']['statistics']['errors']++;
continue;
}
//Latitude
if (!empty($latitude)) {
if (!ossim_valid(trim($latitude), OSS_NULLABLE, OSS_DIGIT, OSS_DOT, '\\-', 'illegal:' . _('Latitude'))) {
$summary['by_hosts'][$num_line]['errors']['Latitude'] = ossim_get_error_clean();
$summary['general']['statistics']['errors']++;
continue;
}
}
//Longitude
if (!empty($longitude)) {
if (!ossim_valid(trim($longitude), OSS_NULLABLE, OSS_DIGIT, OSS_DOT, '\\-', 'illegal:' . _('Longitude'))) {
$summary['by_hosts'][$num_line]['errors']['Longitude'] = ossim_get_error_clean();
$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 {
示例3: catch
$host->save_in_db($dbconn);
$result = 'Host ID: ' . $hostid;
} catch (Exception $e) {
$result = 'Impossible to save the host';
}
} else {
$result = 'The host already exists. Host ID: ' . $hostid;
}
break;
case 'update_aliases':
list($hostip, $ctx, $aliases) = explode('|', base64_decode($data_1));
$hostid = key(Asset_host::get_id_by_ips($dbconn, $hostip, $ctx));
if (Asset_host::is_in_db($dbconn, $hostid)) {
try {
$h_object = new Asset_host($dbconn, $hostid);
$h_object->load_from_db($dbconn);
$h_object->set_fqdns($aliases);
$h_object->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($data_1));
$result = key(Asset_host::get_id_by_ips($dbconn, $hostip, $ctx));
break;
default:
$db->close();
die("The option isn't correct\n");
示例4: GET
require_once 'av_init.php';
Session::logcheck('environment-menu', 'PolicyHosts');
$id = GET('id');
ossim_valid($id, OSS_HEX, 'illegal:' . _('Host ID'));
if (ossim_error()) {
echo ossim_error(_('Error! Host not found'));
exit;
}
/****************************************************
******************** Host data *********************
****************************************************/
//Database connection
$db = new ossim_db();
$conn = $db->connect();
$host = new Asset_host($conn, $id);
$host->load_from_db($conn);
//CTX
$ctx = $host->get_ctx();
$is_nagios_enabled = $host->is_nagios_enabled($conn);
$is_ext_ctx = FALSE;
$ext_ctxs = Session::get_external_ctxs($conn);
if (!empty($ext_ctxs[$ctx])) {
$is_ext_ctx = TRUE;
}
//Closing database connection
$db->close();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title><?php
示例5: foreach
?>
"/>
</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) {
$ips[$ip] = array('ip' => $ip, 'mac' => NULL);
}
$host->set_ips($ips);
}
}