Ejemplo n.º 1
0
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) {
        $config_nt = array('content' => $e->getMessage(), 'options' => array('type' => 'nf_error', 'cancel_button' => false), 'style' => 'width: 80%; margin: 20px auto; text-align:center;');
        $nt = new Notification('nt_1', $config_nt);