1<?php 2 3// Pandora FMS - http://pandorafms.com 4// ================================================== 5// Copyright (c) 2013 Artica Soluciones Tecnologicas 6// Please see http://pandorafms.org for full contribution list 7 8// This program is free software; you can redistribute it and/or 9// modify it under the terms of the GNU General Public License 10// as published by the Free Software Foundation for version 2. 11// This program is distributed in the hope that it will be useful, 12// but WITHOUT ANY WARRANTY; without even the implied warranty of 13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14// GNU General Public License for more details. 15 16// Load global vars 17global $config; 18 19check_login (); 20 21if (! check_acl ($config['id_user'], 0, "PM")) { 22 db_pandora_audit("ACL Violation", "Trying to access MIB uploader"); 23 require ("general/noaccess.php"); 24 return; 25} 26 27require_once ("include/functions_filemanager.php"); 28 29// Header 30ui_print_page_header (__('MIB uploader'), "images/op_snmp.png", false, "", false); 31 32if (isset($config['filemanager']['message'])) { 33 echo $config['filemanager']['message']; 34 $config['filemanager']['message'] = null; 35} 36 37$directory = (string) get_parameter ('directory', SNMP_DIR_MIBS); 38$directory = str_replace("\\", "/", $directory); 39 40/* Add custom directories here */ 41$fallback_directory = "attachment/mibs"; 42 43// A miminal security check to avoid directory traversal 44if (preg_match ("/\.\./", $directory)) 45 $directory = $fallback_directory; 46if (preg_match ("/^\//", $directory)) 47 $directory = $fallback_directory; 48if (preg_match ("/^manager/", $directory)) 49 $directory = $fallback_directory; 50 51$banned_directories['include'] = true; 52$banned_directories['godmode'] = true; 53$banned_directories['operation'] = true; 54$banned_directories['reporting'] = true; 55$banned_directories['general'] = true; 56$banned_directories[ENTERPRISE_DIR] = true; 57 58if (isset ($banned_directories[$directory])) 59 $directory = $fallback_directory; 60 61// Current directory 62$available_directories[$directory] = $directory; 63 64$real_directory = realpath ($config['homedir'] . '/' . $directory); 65 66ui_print_info_message(__("MIB files will be installed on the system. Please note that a MIB may depend on other MIB. To customize trap definitions use the SNMP trap editor.")); 67 68//echo '<h4>' . __('Index of %s', $directory) . '</h4>'; 69 70$homedir_filemanager = isset ($config['homedir_filemanager']) ? $config['homedir_filemanager'] : false; 71 72filemanager_file_explorer($real_directory, 73 $directory, 74 'index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_mib_uploader', 75 SNMP_DIR_MIBS, 76 false, 77 false, 78 '', 79 false, 80 '', 81 $homedir_filemanager); 82?> 83