$enable = POST('task_enable') >= 1 ? 1 : 0; ossim_valid($id, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _('Task ID')); if (ossim_error()) { $data['status'] = 'error'; $data['data']['id'] = ossim_get_error_clean(); } if ($data['status'] == 'error') { $txt_error = '<div>' . _('We Found the following errors') . ":</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", "index.php"); exit; } else { if (POST('mode') == 'insert') { $id = Inventory::insert($conn, $sensor_id, $name, $s_type_ids[$s_type], $period, $params, $enable, $nets); Web_indicator::set_on('Reload_tasks'); ?> <script type="text/javascript">document.location.href = "index.php?s_type=<?php echo $s_type; ?> &msg=saved"</script> <?php exit; } elseif (POST('mode') == 'update') { Inventory::modify($conn, $id, $sensor_id, $name, $s_type_ids[$s_type], $period, $params, $enable, $nets); Web_indicator::set_on('Reload_tasks'); ?> <script type="text/javascript">document.location.href = "index.php?s_type=<?php echo $s_type; ?>
function schedule_scan($conn, $wizard, $data) { $step = intval($wizard->get_step_data('scan_step')); $nets = $wizard->get_step_data('scan_nets'); if ($step != 3 || count($nets) < 1) { $response['error'] = TRUE; $response['msg'] = _('Asset Scan not valid to schedule'); return $response; } $sched = $data['sch_opt']; ossim_valid($sched, OSS_DIGIT, 'illegal:' . _("Schedule Option")); if (ossim_error()) { $response['error'] = TRUE; $response['msg'] = ossim_get_error(); ossim_clean_error(); $wizard->set_step_data('scan_nets', -1); return $response; } if ($sched == 1) { $period = 86400; } elseif ($sched == 2) { $period = 604800; } else { $period = 2419200; } $sensor_id = Av_sensor::get_default_sensor($conn); $name = _('Default_wizard_scan'); $type = 5; $targets = array(); foreach ($nets as $cidrs) { $cidrs = explode(' ', $cidrs); foreach ($cidrs as $cidr) { $targets[$cidr] = $cidr; } } $targets = implode(' ', $targets); $params = $targets . '#-T3 -A -sS -F'; Inventory::insert($conn, $sensor_id, $name, $type, $period, $params, $targets); $response['error'] = FALSE; $response['data'] = array(); return $response; }
ossim_valid($timing_template, OSS_TIMING_TEMPLATE, 'illegal:' . _('Timing template')); ossim_valid($custom_ports, OSS_DIGIT, OSS_SPACE, OSS_SCORE, OSS_NULLABLE, 'illegal:' . _('Custom Ports')); ossim_valid($rdns, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _('Reverse DNS resolution option')); ossim_valid($autodetect, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _('Autodetect services and OS option')); if (is_array($nmap_options) && count($nmap_options) > 0) { $task_params = $task_params . '#' . implode(' ', $nmap_options); } // ELSE: Text } else { if ($task_type == 4) { ossim_valid($task_params, OSS_ALPHA, ';', ':', '\\.', '\\*', 'illegal:' . _('Task Params')); } else { ossim_valid($task_params, OSS_NULLABLE, 'illegal:' . _('Task Params')); } } if (ossim_error() || !Inventory::insert($conn, $sensor_id, $task_name, $task_type, $task_period, $task_params, $task_nets)) { $config_nt['options']['type'] = 'nf_error'; $config_nt['content'] = _('Error! Inventory task could not be inserted. Some of mandatory fields are not correct'); } else { $config_nt['options']['type'] = 'nf_success'; $config_nt['content'] = _('Inventory task inserted successfully'); } } else { $config_nt['options']['type'] = 'nf_error'; $config_nt['content'] = _("Error: Cannot insert a new inventory task. Some of mandatory fields are not correct"); } } elseif ($submit == _('Delete Task')) { if (!Inventory::delete($conn, $task_id)) { $config_nt['options']['type'] = 'nf_error'; $config_nt['content'] = _('Error! Inventory task could not be deleted'); } else {
if ($matches[1] != '' && preg_match('/^\\*+$/', $matches[1]) && $_SESSION['wmi_pass'] != '') { $params = preg_replace('/wmipass:(.*)/', '', $params); $params = $params . 'wmipass:'******'wmi_pass']; } break; default: $targets = NULL; $params = NULL; } $db = new ossim_db(); $conn = $db->connect(); try { if ($task_id != '') { Inventory::modify($conn, $task_id, $sensor_id, $name, $scan_types[$s_type], $frequency, $params, $targets); } else { $task_id = Inventory::insert($conn, $sensor_id, $name, $scan_types[$s_type], $frequency, $params, $targets); } } catch (Exception $e) { $data['status'] = 'error'; $data['data'] = array('php_exception' => $e->getMessage()); } $db->close(); } if ($data['status'] == 'error') { $txt_error = '<div>' . _('The following errors occurred') . ":</div>\n <div style='padding: 10px;'>" . implode('<br/>', $data['data']) . '</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(); } else { ?> <script type='text/javascript'>