ossim_valid($file, OSS_ALPHA, OSS_DOT, OSS_SCORE, 'illegal:' . _("XML File")); ossim_valid($engine_id, OSS_HEX, OSS_SCORE, 'illegal:' . _("Engine ID")); ossim_valid($rule, OSS_DIGIT, '\\-', OSS_NULLABLE, 'illegal:' . _("Rule ID")); ossim_valid($mode, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _("Mode")); if (ossim_error()) { die(ossim_error()); } $directive_editor = new Directive_editor($engine_id); $filepath = file_exists($directive_editor->engine_path . "/" . $file) ? $directive_editor->engine_path . "/" . $file : $directive_editor->main_path . "/" . $file; if (preg_match("/^\\d+-\\d+-\\d+\$/", $rule)) { if (GET('mode') == "delete") { $dom = $directive_editor->get_xml($filepath, "DOMXML"); $direct = $directive_editor->getDirectiveFromXML($dom, $directive_id); $tab_rules = $direct->rules; $directive_editor->delrule($rule, &$tab_rules); if (!$directive_editor->save_xml($filepath, $dom, "DOMXML")) { echo "<!-- ERRORDELETE -->"; } } elseif (GET('mode') == "copy") { $dom = $directive_editor->get_xml($filepath, "DOMXML"); $direct = $directive_editor->getDirectiveFromXML($dom, $directive_id); $tab_rules = $direct->rules; list($id_dir, $id_rule, $id_father) = explode("-", $rule); $old_rule = $tab_rules[$id_rule]; $new_rule = $old_rule->rule->cloneNode(true); // deep = true $new_rule->setAttribute("name", "Copy of " . $new_rule->getAttribute("name")); // Can not copy the root rule at same level => copy as a child (Button disabled for the moment) $parent = $old_rule->rule->parentNode; $parent->appendChild($new_rule); $directive_editor->save_xml($filepath, $dom, "DOMXML");
if ($error) { die(ossim_error(implode('<br>', $error_msg))); } $directive_editor = new Directive_editor($engine_id); $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; ?>