$conn = $db->connect(); if (!Ossec_utilities::is_sensor_allowed($conn, $sensor_id)) { $data['status'] = 'error'; $data['data'] = _('Error! Sensor not allowed'); } $db->close(); } } if ($data['status'] == 'error') { $data['status'] = 'error'; $data['data'] = _('We found the followings errors:') . "<div style='padding-left: 15px; text-align:left;'>" . $data['data'] . '</div>'; echo json_encode($data); exit; } //Level key $lk_name = Ossec::get_key_name($file); //Rule file $rule_file = Ossec_utilities::get_real_path($sensor_id, Ossec::RULES_PATH . '/' . $file); if (!Ossec::is_editable($file)) { $data['status'] = 'error'; $data['data'] = _('XML file can not be edited'); echo json_encode($data); exit; } $file_tmp = uniqid($file) . '_tmp.xml'; $path_tmp = "/tmp/tmp_" . $file_tmp; if (copy($rule_file, $path_tmp) == FALSE) { $data['status'] = 'error'; $data['data'] = _('Failure to create temporary copy from XML file'); echo json_encode($data); exit;
ossim_valid($file, OSS_ALPHA, OSS_SCORE, OSS_DOT, 'illegal:' . _('File')); if (!ossim_error()) { $db = new ossim_db(); $conn = $db->connect(); if (!Ossec_utilities::is_sensor_allowed($conn, $sensor_id)) { ossim_set_error(_('Error! Sensor not allowed')); } $db->close(); } if (ossim_error()) { $data['status'] = 'error'; $data['data'] = _('We found the followings errors:') . "<div style='padding-left: 15px; text-align:left;'>" . ossim_get_error_clean() . '</div>'; echo json_encode($data); exit; } //Set current file $_SESSION['_current_file'] = $file; $_SESSION['lk_name'] = Ossec::get_key_name($file); try { $tree = Ossec::get_tree($sensor_id, $file); $tree_json = Ossec_utilities::array2json($tree, $file); $_SESSION['_tree_json'] = $tree_json; $_SESSION['_tree'] = $tree; $data['status'] = 'success'; $data['data'] = _('Click on a branch to display a node') . '###' . base64_encode($tree_json); } catch (Exception $e) { $data['status'] = 'error'; $data['data'] = $e->getMessage(); } echo json_encode($data); exit;