Example #1
0
function insert($id)
{
    $XML_FILE = $_SESSION['XML_FILE'];
    $rule = unserialize($_SESSION['rule']);
    $directive = unserialize($_SESSION['directive']);
    $tab_rules = $directive->rules;
    unset($_SESSION['rule']);
    list($id_dir, $id_rule, $id_father) = explode("-", $id);
    init_file($XML_FILE);
    if (!($dom = domxml_open_file($XML_FILE, DOMXML_LOAD_SUBSTITUTE_ENTITIES))) {
        echo "Error while parsing the document\n";
        exit;
    }
    $directive = getDirectiveFromXML($dom, $id_dir);
    if ($id_father != 0) {
        $tab_rules[$id_father]->nb_child = $tab_rules[$id_father]->nb_child + 1;
    }
    if ($id == $tab_rules[$id_rule]->id || $id_rule > count($tab_rules)) {
        $tab_rules[$id_rule] = $rule;
    } else {
        for ($i = count($tab_rules); $i >= $id_rule; $i--) {
            list($id_dir, $id_rule2, $id_father2) = explode("-", $tab_rules[$i]->id);
            $new_id_rule = $i + 1;
            if ($id_father2 >= $id_rule) {
                $new_id_father = $id_father2 + 1;
            } else {
                $new_id_father = $idfather2;
            }
            $newid = $id_dir . "-" . $new_id_rule . "-" . $new_id_father;
            $tab_rules[$i]->id = $newid;
            $tab_rules[$i + 1] = $tab_rules[$i];
        }
        $tab_rules[$id_rule] = $rule;
    }
    $direct = $directive->directive;
    $rules = $direct->child_nodes();
    foreach ($rules as $rule) {
        $direct->remove_child($rule);
    }
    do_directive($directive, &$tab_rules, $dom);
    $dom->dump_file($XML_FILE);
    release_file($XML_FILE);
    $newlevel = $tab_rules[$id_rule]->level;
    echo "<html><body onload=\"window.open('../viewer/index.php?directive=" . $directive->id . "&level={$newlevel}','right')\"></body></html>";
}
Example #2
0
?>
 </h1> -->
<?php 
if ($directive_id == '') {
    $XML_FILE = '/etc/ossim/server/directives.xml';
    //unset($_SESSION['XML_FILE']);
} elseif ($directive_xml != "") {
    $XML_FILE = '/etc/ossim/server/' . $directive_xml;
    //unset($_SESSION['XML_FILE']);
} elseif ($_SESSION['XML_FILE'] != "") {
    $XML_FILE = $_SESSION['XML_FILE'];
} else {
    $XML_FILE = get_directive_file($directive_id);
}
if ($XML_FILE != '/etc/ossim/server/directives.xml') {
    init_file($XML_FILE);
}
//$_SESSION['XML_FILE']=$XML_FILE;
/* create dom object from a XML file */
if (!($dom = domxml_open_file($XML_FILE, DOMXML_LOAD_SUBSTITUTE_ENTITIES))) {
    echo "<center><span style='color:red'>";
    if ($XML_FILE != "") {
        echo _("Error while parsing the document\nMake sure that") . " {$XML_FILE} " . _("begins with xml tag!\n");
    } else {
        echo _("The directive doesn't exist");
    }
    echo "</span></center>";
    exit;
}
if ($directive_xml != "") {
    $_SESSION['XML_FILE'] = $XML_FILE;
Example #3
0
function is_free($directive_id, $XML_FILE = "")
{
    if ($XML_FILE == "") {
        $XML_FILE = get_directive_file($directive_id);
    }
    //if (!file_exists($XML_FILE)) return "false";
    init_file($XML_FILE);
    $dom = domxml_open_file($XML_FILE, DOMXML_LOAD_SUBSTITUTE_ENTITIES);
    $count = 1;
    $free = "true";
    foreach ($dom->get_elements_by_tagname('directive') as $directive) {
        $id = $directive->get_attribute('id');
        $name = $directive->get_attribute('name');
        $count++;
        if (strcmp($id, $directive_id) == 0) {
            $free = "false";
        }
    }
    release_file($XML_FILE);
    return $free;
}
Example #4
0
function open_file($file)
{
    init_file($file);
    if (!($dom = domxml_open_file($file, DOMXML_LOAD_SUBSTITUTE_ENTITIES))) {
        echo _("Error while parsing the document") . "\n";
        exit;
    }
    return $dom;
}