Пример #1
0
<body>
    <?php 
if (POST('insert')) {
    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', 'newsensorform.php');
        exit;
    }
    $db = new ossim_db();
    $conn = $db->connect();
    $new_id = Util::uuid();
    try {
        $new = new Av_Sensor($new_id);
        $new->set_properties(array('version' => '', 'has_nagios' => 0, 'has_ntop' => 1, 'has_vuln_scanner' => 1, 'has_kismet' => 0));
        $new->set_name($sname);
        $new->set_ip($ip);
        $new->set_priority($priority);
        $new->set_port($port);
        $new->set_tzone($tzone);
        $new->set_descr($descr);
        foreach ($entities as $ctx) {
            $new->add_new_ctx($ctx, $ctx);
        }
        $new->save_in_db($conn);
        if ($location != '') {
            Locations::insert_related_sensor($conn, $location, $new_id);
        }
    } catch (Exception $e) {
Пример #2
0
 $newcontext = POST('newcontext') != '' ? POST('newcontext') : $sname;
 if (POST('isolated') == 1 && $newcontext != '') {
     // Isolated sensor. Creating a new context first
     $new_context_uuid = Session::clone_default_ctx($conn, $newcontext);
     $entities = array($new_context_uuid);
     // Refresh current permissions
     $_SESSION['_user_vision'] = Acl::get_user_vision($conn);
 } elseif (POST('isolated') == 0 && preg_match("/[a-f\\d]{32}/i", POST('neighborsensor'))) {
     // Use selected sensor context
     $entities = array_keys(Av_sensor::get_ctx_by_id($conn, POST('neighborsensor')));
 }
 try {
     $old = new Av_Sensor($sensor_id);
     $old->load_from_db($conn);
     $cproperties = $old->get_properties();
     $new = new Av_Sensor($sensor_id);
     $new->set_properties($cproperties);
     $new->set_name($sname);
     $new->set_ip($ip);
     $new->set_priority($priority);
     $new->set_port($port);
     $new->set_tzone($tzone);
     $new->set_descr($descr);
     $new->set_rpass($rpass);
     foreach ($entities as $ctx) {
         $new->add_new_ctx($ctx, $ctx);
     }
     // try to attach a component
     // Only when modifying a remote sensor
     if ($cproperties['version'] != '' && !empty($_POST['rpass'])) {
         $new->set_component($conn);