exit; } //Perform 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 changes have been saved'); switch ($action) { case 'select_os': //Select Operating System if ($os_windows == 1) { Asset_host_properties::delete_property_from_db($conn, $asset_id, 3); Asset_host_properties::save_property_in_db($conn, $asset_id, 3, 'Microsoft Windows', 1); } else { $data['status'] = 'warning'; $data['data'] = _("Unable to deploy HIDS agent. Automatic deployment is only available for Windows operating systems. Please go to <a href='javascript:parent.GB_close({\"action\": \"go_to_hids\"});' class='bold_yellow'>HIDS page</a> for more options"); } break; case 'deploy_agent': //Deploy HIDS Agent $db = new Ossim_db(); $conn = $db->connect(); $d_data = array('asset_id' => $asset_id, 'w_ip' => $ip_address, 'w_user' => $user, 'w_password' => $pass, 'w_domain' => $domain); $hids_agents = Asset_host::get_related_hids_agents($conn, $asset_id, $sensor_id); $num_agents = count($hids_agents); if ($num_agents >= 1) { if ($num_agents == 1) {
function change_htype($conn, $data) { $uuid = $data['id']; list($os, $dtype) = explode("_", $data['type']); // Type ossim_valid($uuid, OSS_HEX, 'illegal:' . _("ID")); ossim_valid($os, OSS_NULLABLE, OSS_ALPHA, 'illegal:' . _("OS")); ossim_valid($dtype, OSS_NULLABLE, OSS_ALPHA, 'illegal:' . _("Device Type")); check_ossim_error(); if (empty($dtype) && empty($os)) { Asset_host_devices::delete_all_from_db($conn, $uuid); Asset_host_properties::delete_property_from_db($conn, $uuid, 3, '', TRUE); } else { // Device Type if ($dtype == 'networkdevice') { Asset_host_devices::save_device_in_db($conn, $uuid, 4); //Adding the device type Asset_host_properties::delete_property_from_db($conn, $uuid, 3, '', TRUE); //Removing the previous OS } elseif ($os == 'windows' || $os == 'linux') { Asset_host_devices::delete_device_from_db($conn, $uuid, 4); //Removing device type Asset_host_properties::delete_property_from_db($conn, $uuid, 3); //Removing previous OS Asset_host_properties::save_property_in_db($conn, $uuid, 3, ucfirst($os), 1, TRUE); //Adding the new OS } } $response['error'] = FALSE; $response['data'] = array(); return $response; }