예제 #1
0
파일: save.php 프로젝트: jackpf/ossim-arc
    exit;
}
if (!Ossec::is_editable($file)) {
    $data['status'] = 'error';
    $data['data'] = _('Error! File not editable');
    echo json_encode($data);
    exit;
}
$_SESSION['_current_file'] = $file;
$lk_name = $_SESSION['lk_name'];
$new_xml_data = html_entity_decode(base64_decode($new_xml_data), ENT_QUOTES, 'UTF-8');
$xml_obj = new Xml_parser($lk_name);
$xml_obj->load_string($new_xml_data);
if ($xml_obj->errors['status'] == FALSE) {
    $data['status'] = 'error';
    $data['data'] = "<div id='parse_errors'>\n                        <span style='font-weight: bold;'>" . _('Data in XML file with wrong format') . "&nbsp;<a onclick=\"\$('#msg_errors').toggle();\"> [" . _('View errors') . "]</a></span>\n                        <br/><div id='msg_errors'>" . implode('', $xml_obj->errors['msg']) . "</div>\n                   </div>";
} else {
    try {
        Ossec::set_rule_file($sensor_id, $file, $new_xml_data);
        $array_xml = $xml_obj->xml2array();
        $tree_json = Ossec_utilities::array2json($array_xml, $file);
        $_SESSION['_tree_json'] = $tree_json;
        $_SESSION['_tree'] = $array_xml;
        $data['data'] = _("{$file} updated successfully") . '###' . base64_encode($tree_json);
    } catch (Exception $e) {
        $data['status'] = 'error';
        $data['data'] = $e->getMessage();
    }
}
echo json_encode($data);
exit;
예제 #2
0
            }
        }
        break;
}
if ($data['status'] != 'error') {
    if ($ok === FALSE) {
        $data['status'] = 'error';
        $data['data'] = _('Error! XML file not updated (1)');
        echo json_encode($data);
    } else {
        $xml = new Xml_parser($lk_name);
        $output = $xml->array2xml($tree);
        $output = Ossec_utilities::formatOutput($output, $lk_name);
        $output = utf8_decode($output);
        try {
            Ossec::set_rule_file($sensor_id, $file, $output);
            $tree = Ossec::get_tree($sensor_id, $file);
            $tree_json = Ossec_utilities::array2json($tree, $file);
            $_SESSION['_tree_json'] = $tree_json;
            $_SESSION['_tree'] = $tree;
        } catch (Exception $e) {
            $data['status'] = 'error';
            $data['data'] = $e->getMessage();
        }
    }
}
if ($data['status'] == 'error') {
    //Restore copy
    @copy($path_tmp, $rule_file);
    $_SESSION['_tree'] = $tree_cp;
    $_SESSION['_tree_json'] = Ossec_utilities::array2json($tree_cp, $file);