2019-01-30 16:18:44 +01:00
< ? php
2021-04-29 13:28:03 +02:00
/**
* MIB Uploader view
*
* @ category Monitoring
* @ package Pandora FMS
* @ subpackage Community
* @ version 1.0 . 0
* @ license See below
*
* ______ ___ _______ _______ ________
* | __ \ .-----.--.--.--| |.-----.----.-----. | ___ | | | __ |
* | __ /| _ | | _ || _ | _ | _ | | ___ | | __ |
* | ___ | | ___ . _ | __ | __ | _____ || _____ | __ | | ___ . _ | | ___ | | __ | _ | __ | _______ |
*
* ============================================================================
* Copyright ( c ) 2005 - 2021 Artica Soluciones Tecnologicas
* Please see http :// pandorafms . org for full contribution list
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
* ============================================================================
*/
2013-02-07 19:21:59 +01:00
2021-04-29 13:28:03 +02:00
// Begin.
2013-02-07 19:21:59 +01:00
global $config ;
2019-01-30 16:18:44 +01:00
check_login ();
2013-02-07 19:21:59 +01:00
2019-01-30 16:18:44 +01:00
if ( ! check_acl ( $config [ 'id_user' ], 0 , 'PM' )) {
2022-02-01 13:39:18 +01:00
db_pandora_audit (
AUDIT_LOG_ACL_VIOLATION ,
'Trying to access MIB uploader'
);
2019-01-30 16:18:44 +01:00
include 'general/noaccess.php' ;
return ;
2013-02-07 19:21:59 +01:00
}
2019-01-30 16:18:44 +01:00
require_once 'include/functions_filemanager.php' ;
2013-02-07 19:21:59 +01:00
2021-04-29 13:28:03 +02:00
// Header.
ui_print_standard_header (
__ ( 'MIB uploader' ),
'images/op_snmp.png' ,
false ,
'' ,
false ,
[],
[
[
'link' => '' ,
'label' => __ ( 'Monitoring' ),
],
[
'link' => '' ,
'label' => __ ( 'SMNP' ),
],
]
);
2013-02-07 19:21:59 +01:00
if ( isset ( $config [ 'filemanager' ][ 'message' ])) {
2019-01-30 16:18:44 +01:00
echo $config [ 'filemanager' ][ 'message' ];
$config [ 'filemanager' ][ 'message' ] = null ;
2013-02-07 19:21:59 +01:00
}
2021-08-26 11:15:02 +02:00
$directory = ( string ) get_parameter ( 'directory' );
2019-01-30 16:18:44 +01:00
$directory = str_replace ( '\\' , '/' , $directory );
2013-02-07 19:21:59 +01:00
2021-08-26 11:15:02 +02:00
// Add custom directories here.
$fallback_directory = SNMP_DIR_MIBS ;
2013-02-07 19:21:59 +01:00
2021-08-26 11:15:02 +02:00
if ( empty ( $directory ) === true ) {
2019-01-30 16:18:44 +01:00
$directory = $fallback_directory ;
2021-08-26 11:15:02 +02:00
} else {
$directory = str_replace ( '\\' , '/' , $directory );
$directory = filemanager_safe_directory ( $directory , $fallback_directory );
2019-01-30 16:18:44 +01:00
}
2013-02-07 19:21:59 +01:00
2019-01-30 16:18:44 +01:00
$real_directory = realpath ( $config [ 'homedir' ] . '/' . $directory );
ui_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.' ));
2020-11-03 15:58:53 +01:00
$upload_file_or_zip = ( bool ) get_parameter ( 'upload_file_or_zip' );
$create_text_file = ( bool ) get_parameter ( 'create_text_file' );
$default_real_directory = realpath ( $config [ 'homedir' ] . '/' . $fallback_directory );
2021-08-26 11:15:02 +02:00
if ( $upload_file_or_zip === true ) {
2021-09-03 13:30:15 +02:00
upload_file ( $upload_file_or_zip , $default_real_directory , $real_directory );
2020-11-03 15:58:53 +01:00
}
2021-08-26 11:15:02 +02:00
if ( $create_text_file === true ) {
2021-09-03 13:30:15 +02:00
create_text_file ( $default_real_directory , $real_directory );
2020-11-03 15:58:53 +01:00
}
2019-01-30 16:18:44 +01:00
filemanager_file_explorer (
$real_directory ,
$directory ,
'index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_mib_uploader' ,
SNMP_DIR_MIBS ,
false ,
false ,
'' ,
false ,
'' ,
2022-03-09 17:27:08 +01:00
false ,
[ 'all' => true ]
2019-01-30 16:18:44 +01:00
);