Example #1
0
//There are validation errors
if ($data['status'] == 'error') {
    $txt_error = '<div>' . _('We Found the following errors') . ":</div>\n\t\t\t\t  <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 {
    $db = new ossim_db();
    $conn = $db->connect();
    //Scan results
    $scan = new Scan();
    $scan_results = $scan->get_results();
    //Sensor context
    $ctx = $scan_results['sensor']['ctx'];
    session_write_close();
    $data = Scan::save_hosts_in_db($conn, $scan_results, $_POST);
    //Check general status
    if (count($data['general']['hosts_in_group']) == 0) {
        $data['general']['status'] = 'error';
        $data['general']['data'] = _('Error! Hosts no saved');
    } else {
        if (count($data['general']['hosts_in_group']) == $data['general']['total_hosts']) {
            $data['general']['status'] = 'success';
            $data['general']['data'] = _('Hosts saved successfully');
            foreach ($data['by_host'] as $h_key => $h_data) {
                if ($h_data['status'] == 'warning') {
                    $data['general']['status'] = 'warning';
                    $data['general']['data'] = _('Hosts saved with warnings');
                    break;
                }
            }