//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 case 'new_property': case 'new_software': case 'new_service':
<body> <?php if ($data['status'] == 'error') { $txt_error = "<div>" . _("The following errors occurred") . ":</div>\n\t\t\t\t\t <div style='padding: 2px 10px 5px 10px;'>" . implode("<br/>", $validation_errors) . "</div>"; $config_nt = array('content' => $txt_error, 'options' => array('type' => 'nf_error', 'cancel_button' => false), 'style' => 'width: 80%; margin: 20px auto; text-align: left;'); $nt = new Notification('nt_1', $config_nt); $nt->show(); Util::make_form("POST", "newportform.php"); exit; } $db = new ossim_db(); $conn = $db->connect(); if (POST('insert')) { Port::insert($conn, $port, $protocol, $service, $descr, $ctx); Util::memcacheFlush(); } $db->close(); ?> <script type='text/javascript'> if (!parent.is_lightbox_loaded(window.name)) { document.location.href="port.php?msg=updated"; } </script> </body> </html>
} else { $date = strftime("%Y-%m-%d %H:%M:%S"); if ($nservice != '') { $serviceName = $nservice; } else { if ($ports[$port_number . " - " . $protocol_name] != "") { $serviceName = $ports[$port_number . " - " . $protocol_name]; } else { $serviceName = 'unknown'; } } // Insert new port $chport = array(); $chport = Port::get_list($conn, "where port_number = {$port_number} and protocol_name = '{$protocol_name}'"); if (count($chport) == 0) { Port::insert($conn, $port_number, $protocol_name, $serviceName, ""); } $protocol = $protocol_ids[$protocol_name]; Host_services::insert($conn, $ip, $port_number, $date, $_SERVER["SERVER_ADDR"], $protocol, $serviceName, "unknown", "unknown", 1, $newport_nagios); // origin = 0 (pads), origin = 1 (nmap) } } if ($error_message != null) { $style = "style='display: block;'"; $error_message = "<div style='padding-left: 15px;'>{$error_message}</div>"; ossim_clean_error(); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head>