} else { if (!empty($nodes) && is_array($nodes)) { $ok = @eval("\$tree{$branch}=\$nodes;"); } } 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
* * You should have received a copy of the GNU General Public License * along with this package; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301 USA * * * On Debian GNU/Linux systems, the complete text of the GNU General * Public License can be found in `/usr/share/common-licenses/GPL-2'. * * Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt * */ require_once dirname(__FILE__) . '/../../conf/config.inc'; Session::logcheck('environment-menu', 'EventsHidsConfig'); //Get XML node $lk_value = POST('lk_value'); $lk_name = $_SESSION['lk_name']; $tree_lr = $_SESSION['_tree']; $child = Ossec::get_child($tree_lr, $lk_name, $lk_value); $rule = array('@attributes' => array($lk_name => '1'), '0' => array('rule' => $child['tree'])); if (!empty($child)) { $xml_obj = new Xml_parser($lk_name); $output = $xml_obj->array2xml($rule); $data['status'] = 'success'; $data['data'] = Ossec_utilities::formatOutput($output, $lk_name); } else { $data['status'] = 'error'; $data['data'] = _('Error! Information not available'); } echo json_encode($data);