$data['data'] = _('Your changes have been saved'); $validation_errors = validate_form_fields('POST', $validate); if (is_array($validation_errors) && !empty($validation_errors)) { //Formatted message $error_msg = '<div>' . _('The following errors occurred') . ":</div>\n <div style='padding: 5px;'>" . implode('<br/>', $validation_errors) . '</div>'; Util::response_bad_request($error_msg); } else { try { $db = new ossim_db(); $conn = $db->connect(); $asset_id = POST('asset_id'); $protocol = POST('s_protocol'); $protocol_name = Protocol::get_protocol_by_number($protocol); $port = POST('s_port'); $service = POST('s_name'); $ctx = Asset_host::get_ctx_by_id($conn, $asset_id); $n_ports = Port::get_list($conn, " AND port_number = {$port} and protocol_name = '{$protocol_name}'"); if (count($n_ports) == 0) { Port::insert($conn, $port, $protocol_name, $service, '', $ctx); } else { $data['status'] = 'warning'; $data['data'] = _('Warning! This port has already been added'); } $db->close(); } catch (Exception $e) { Util::response_bad_request(_('Error! Your changes could not be saved')); } } break; //Asset properties, MAC address, Software and Services //Asset properties, MAC address, Software and Services
* Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt * */ ini_set('include_path', '/usr/share/ossim/include'); require_once 'av_init.php'; $option = $argv[1]; $asset = $argv[2]; $result = ''; $db = new ossim_db(); $dbconn = $db->connect(); $_SESSION['_user'] = '******'; switch ($option) { case 'get_ctx': if (preg_match("/^([a-f\\d]{32})#\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\$/i", $asset, $found)) { // host_id#IP $result = Asset_host::get_ctx_by_id($dbconn, $found[1]); } else { 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)) { // net_id#CIDR $result = Asset_net::get_ctx_by_id($dbconn, $found[1]); } else { $filters = array('where' => 'hostname = "' . $asset . '" OR fqdns LIKE "%' . $asset . '%"'); $_hosts_data = Asset_host::get_basic_list($dbconn, $filters); $hosts_list = $_hosts_data[1]; $total = count($hosts_list); if ($total > 0) { $host_id = key($hosts_list); $result = $hosts_list[$host_id]['ctx']; } else { $result = ''; }