Example #1
0
 $directive_editor = new Directive_editor($engine_id);
 $filepath = $directive_editor->engine_path . "/" . $file;
 if (!file_exists($filepath)) {
     die(ossim_error(_("User Contributed file not found in") . " " . $directive_editor->engine_path . ". " . _("Please, create it first")));
 }
 // SAVE CURRENT
 if ($directive_id != "") {
     $directive_editor = new Directive_editor($engine_id);
     $filepath = $directive_editor->engine_path . "/" . $file;
     $dom = $directive_editor->get_xml($filepath, "DOMXML");
     $directive = $directive_editor->getDirectiveFromXML($dom, $directive_id);
     $node = $directive->directive;
     $node->setAttribute('name', $name);
     $node->setAttribute('priority', $prio);
     $directive_editor->save_xml($filepath, $dom, "DOMXML");
     $directive_editor->update_directive_pluginsid($directive_id, 2, $prio, $name);
     $directive_editor->update_directive_taxonomy($directive_id, $intent, $strategy, $method);
     $infolog = array($directive_id, 'updated');
     Log_action::log(86, $infolog);
 } else {
     if ($directive_editor->directive_exists($name, $filepath)) {
         die(ossim_error(_("This directive name already exists")));
     }
     // Get new ID
     $id = $directive_editor->new_directive_id($file);
     if ($id < 1) {
         echo ossim_error(_("Unable to create a new directive in ") . "<b>{$file}</b>");
     }
     // Create a Node (Do not create yet, at rule finish)
     // ...
 }
Example #2
0
    $attributes = array("name" => stripslashes(POST("name")), "plugin_id" => POST("plugin_id"), "type" => POST("type"), "plugin_sid" => POST("plugin_sid"), "product" => POST("product"), "category" => POST("category"), "subcategory" => POST("subcategory"), "entity" => POST("entity"), "from" => POST("from"), "port_from" => POST("port_from"), "to" => POST("to"), "port_to" => POST("port_to"), "from_rep" => POST("from_rep"), "to_rep" => POST("to_rep"), "from_rep_min_pri" => POST("from_rep_min_pri"), "to_rep_min_pri" => POST("to_rep_min_pri"), "from_rep_min_rel" => POST("from_rep_min_rel"), "to_rep_min_rel" => POST("to_rep_min_rel"), "protocol" => $protocol, "sensor" => POST("sensor"), "occurrence" => POST("occurrence"), "time_out" => POST("time_out"), "reliability" => POST("reliability"), "condition" => POST("condition"), "value" => POST("value"), "interval" => POST("interval"), "absolute" => POST("absolute"), "sticky" => POST("sticky"), "sticky_different" => POST("sticky_different"), "userdata1" => utf8_encode(stripslashes(POST("userdata1"))), "userdata2" => utf8_encode(stripslashes(POST("userdata2"))), "userdata3" => utf8_encode(stripslashes(POST("userdata3"))), "userdata4" => utf8_encode(stripslashes(POST("userdata4"))), "userdata5" => utf8_encode(stripslashes(POST("userdata5"))), "userdata6" => utf8_encode(stripslashes(POST("userdata6"))), "userdata7" => utf8_encode(stripslashes(POST("userdata7"))), "userdata8" => utf8_encode(stripslashes(POST("userdata8"))), "userdata9" => utf8_encode(stripslashes(POST("userdata9"))), "filename" => POST("filename"), "username" => utf8_encode(POST("username")), "password" => POST("password"));
    $rule = new Directive_rule(POST('id'), POST('level'), "", $attributes);
    $file = $directive_editor->engine_path . "/" . POST('xml_file');
    $directive_error = false;
    if (POST('from_directive') != "") {
        $dom = $directive_editor->get_xml($file, "DOMXML");
        $node = $dom->createElement('directive');
        $node->setAttribute('id', POST('directive_id'));
        $node->setAttribute('name', POST('directive_name'));
        $node->setAttribute('priority', POST('directive_prio'));
        $dom->appendChild($node);
        if (!$directive_editor->save_xml($file, $dom, "DOMXML", false)) {
            // DTD Validation = false
            $directive_error = true;
        } else {
            $directive_editor->update_directive_pluginsid(POST('directive_id'), 2, POST('directive_prio'), POST('directive_name'));
            $directive_editor->update_directive_taxonomy(POST('directive_id'), POST('directive_intent'), POST('directive_strategy'), POST('directive_method'));
        }
    }
    if (!$directive_error) {
        $directive_editor->insert($rule, POST("directive_id"), $file);
        ?>
        <script type="text/javascript">
            var params          = new Array();
            params['xml']       = "<?php 
        echo $xml_file;
        ?>
";
            params['directive'] = "<?php 
        echo POST('directive_id');
        ?>