$output = formatOutput($output, $_level_key_name); $output = utf8_decode($output); if (@file_put_contents($path, $output, LOCK_EX) === false) { echo "2###" . _("Failure to update XML File") . " (3)"; $error = true; } else { $res = getTree($file); if (!is_array($res)) { echo $res; $error = true; } else { $tree = $res; $tree_json = array2json($tree, $path); $_SESSION['_tree_json'] = $tree_json; $_SESSION['_tree'] = $tree; $result = test_conf(); if ($result !== true) { $error = true; echo "3###" . $result; } } } } if ($error == true) { @unlink($path); @copy($path_tmp, $path); $_SESSION['_tree'] = $tree_cp; $_SESSION['_tree_json'] = array2json($tree_cp, $path); } else { echo "1###" . _("XML file update successfully") . "###" . base64_encode($tree_json); }
function getTree($file) { include_once 'classes/Xml_parser.inc'; include 'conf/_conf.php'; $_SESSION["_current_file"] = $file; $filename = $rules_file . $file; if (file_exists($filename)) { $file_xml = @file_get_contents($filename, false); $_level_key_name = set_key_name($_level_key_name, $file_xml); $_SESSION['_level_key_name'] = $_level_key_name; if ($file_xml == false) { return "2###" . _("Failure to read XML file"); } else { $result = test_conf(); if ($result !== true) { return "3###<div class='errors_ossec'>{$result}</div>"; } $xml_obj = new xml($_level_key_name); $xml_obj->load_file($filename); return $xml_obj->xml2array(); } } else { return "2###" . _("XML file not found"); } }