Esempio n. 1
0
     if (!Inventory::delete($conn, $task_id)) {
         $config_nt['options']['type'] = 'nf_error';
         $config_nt['content'] = _('Error! Inventory task could not be deleted');
     } else {
         $config_nt['options']['type'] = 'nf_success';
         $config_nt['content'] = _('Inventory task deleted successfully');
     }
 } elseif ($submit == _('Save Task')) {
     if (is_array($nmap_options) && count($nmap_options) > 0) {
         $task_params = $task_params . '#' . implode(' ', $nmap_options);
     }
     // Clean $task_params for OCS tasks
     if ($task_type == 3) {
         $task_params = '';
     }
     if (!Inventory::modify($conn, $task_id, $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 updated');
     } else {
         $config_nt['options']['type'] = 'nf_success';
         $config_nt['content'] = _('Inventory task updated successfully');
     }
 } elseif ($submit == _('Enable / Disable')) {
     if (!Inventory::toggle_scan($conn, $task_id)) {
         $config_nt['options']['type'] = 'nf_error';
         $config_nt['content'] = _('Error! Inventory task could not be updated');
     } else {
         $config_nt['options']['type'] = 'nf_success';
         $config_nt['content'] = _('Inventory task updated successfully');
     }
 }
Esempio n. 2
0
            $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;
                ?>
&msg=saved"</script>
			<?php 
                exit;
            }
        }
    }
}
//Get Data
$id = intval(GET('id'));
$s_type = GET('s_type');
Esempio n. 3
0
        case 'wmi':
            preg_match('/wmipass:(.*)/', $params, $matches);
            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 {