if (ossim_error()) { echo ossim_error(_('Error! Host not found')); exit; } /**************************************************** ******************** Host data ********************* ****************************************************/ //Properties $p_obj = new Properties($conn); $properties = $p_obj->get_properties(); $host = new Asset_host($conn, $id); $host->load_from_db($conn); //CTX $ctx = $host->get_ctx(); //Host Ips $host_ips = $host->get_ips(); $ips = $host_ips->get_ips(); $ips = array_keys($ips); $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; } /**************************************************** ******************* Other data ********************* ****************************************************/ //Ports $ports = array(); $port_list = Port::get_list($conn); foreach ($port_list as $port) {
//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); } } catch (Exception $e) { $validation_errors['asset_id'] = $e->getMessage(); } if (empty($validation_errors)) { //Getting asset information $_ips = $asset->get_ips(); $ips = $_ips->get_ips(); //Checking HIDS Sensor $cnd_1 = Ossec_utilities::is_sensor_allowed($conn, $sensor_id) == FALSE; $asset_sensors = Asset_host_sensors::get_sensors_by_id($conn, $asset_id); $cnd_2 = empty($asset_sensors[$sensor_id]); if ($cnd_1 || $cnd_2) { $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)); } else { $system_ids = Av_center::get_system_id_by_component($conn, $sensor_id); $res = Av_center::get_system_info_by_id($conn, $system_ids['non-canonical']); if ($res['status'] == 'success') { //We use this function to calculate sensor name because in HA environments there are two systems for one Sensor ID if (empty($res['data']['ha_ip'])) { $sensor_name = $res['data']['name']; } else {
?> </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); $ips_obj = $host->get_ips(); $old_ips = $ips_obj->get_ips(); } else { $can_i_modify_ips = TRUE; $can_i_create_assets = Session::can_i_create_assets(); $old_ips = array(); } 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) { $mac = !empty($old_ips[$ip]['mac']) ? $old_ips[$ip]['mac'] : NULL; $ips[$ip] = array('ip' => $ip, 'mac' => $mac); }