2013-02-07 19:21:59 +01:00
|
|
|
<?php
|
2019-03-04 15:33:36 +01:00
|
|
|
/**
|
|
|
|
* Extension to manage a list of gateways and the node address where they should
|
|
|
|
* point to.
|
|
|
|
*
|
|
|
|
* @category Extensions
|
|
|
|
* @package Pandora FMS
|
|
|
|
* @subpackage Community
|
|
|
|
* @version 1.0.0
|
|
|
|
* @license See below
|
|
|
|
*
|
|
|
|
* ______ ___ _______ _______ ________
|
|
|
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
|
|
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
|
|
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
* Copyright (c) 2005-2019 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
|
|
|
|
|
|
|
global $config;
|
2019-01-30 16:18:44 +01:00
|
|
|
require_once $config['homedir'].'/include/functions_snmp_browser.php';
|
|
|
|
ui_require_javascript_file('pandora_snmp_browser');
|
2013-02-07 19:21:59 +01:00
|
|
|
|
2019-03-04 15:33:36 +01:00
|
|
|
// AJAX call.
|
2013-02-07 19:21:59 +01:00
|
|
|
if (is_ajax()) {
|
2019-03-04 15:33:36 +01:00
|
|
|
// Read the action to perform.
|
2019-01-30 16:18:44 +01:00
|
|
|
$action = (string) get_parameter('action', '');
|
|
|
|
$target_ip = (string) get_parameter('target_ip', '');
|
|
|
|
$community = (string) get_parameter('community', '');
|
|
|
|
$snmp_version = (string) get_parameter('snmp_browser_version', '');
|
|
|
|
$server_to_exec = (int) get_parameter('server_to_exec', 0);
|
|
|
|
$snmp3_auth_user = io_safe_output(get_parameter('snmp3_browser_auth_user'));
|
|
|
|
$snmp3_security_level = get_parameter('snmp3_browser_security_level');
|
|
|
|
$snmp3_auth_method = get_parameter('snmp3_browser_auth_method');
|
|
|
|
$snmp3_auth_pass = io_safe_output(get_parameter('snmp3_browser_auth_pass'));
|
|
|
|
$snmp3_privacy_method = get_parameter('snmp3_browser_privacy_method');
|
2019-03-04 15:33:36 +01:00
|
|
|
$snmp3_privacy_pass = io_safe_output(
|
|
|
|
get_parameter('snmp3_browser_privacy_pass')
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2019-03-04 15:33:36 +01:00
|
|
|
// SNMP browser.
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($action == 'snmptree') {
|
|
|
|
$starting_oid = (string) get_parameter('starting_oid', '.');
|
|
|
|
|
|
|
|
$snmp_tree = snmp_browser_get_tree(
|
|
|
|
$target_ip,
|
|
|
|
$community,
|
|
|
|
$starting_oid,
|
|
|
|
$snmp_version,
|
|
|
|
$snmp3_auth_user,
|
|
|
|
$snmp3_security_level,
|
|
|
|
$snmp3_auth_method,
|
|
|
|
$snmp3_auth_pass,
|
|
|
|
$snmp3_privacy_method,
|
|
|
|
$snmp3_privacy_pass,
|
|
|
|
$server_to_exec
|
|
|
|
);
|
|
|
|
if (! is_array($snmp_tree)) {
|
|
|
|
echo $snmp_tree;
|
|
|
|
} else {
|
|
|
|
snmp_browser_print_tree($snmp_tree);
|
|
|
|
echo html_print_submit_button(
|
|
|
|
__('Create network components'),
|
|
|
|
'create_network_component',
|
|
|
|
false,
|
|
|
|
[
|
|
|
|
'style' => 'display: none; position: absolute; bottom: 0px; right: 35px;',
|
|
|
|
'class' => 'sub add',
|
|
|
|
],
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
echo '<div id="dialog_error" style="display: none" title="Network components">';
|
|
|
|
echo '<div>';
|
|
|
|
echo "<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='images/icono_error_mr.png'></div>";
|
|
|
|
echo "<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>ERROR</strong></h3>";
|
|
|
|
echo "<p style='font-family:Verdana; font-size:12pt;margin-bottom: 0px'>".__('Error creating the following modules:').'</p>';
|
|
|
|
echo "<p id='error_text' style='font-family:Verdana; font-size:12pt;'></p>";
|
|
|
|
echo '</div>';
|
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
|
|
|
|
echo '<div id="dialog_success" style="display: none" title="Network components">';
|
|
|
|
echo '<div>';
|
|
|
|
echo "<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='images/icono_exito_mr.png'></div>";
|
|
|
|
echo "<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>SUCCESS</strong></h3>";
|
|
|
|
echo "<p style='font-family:Verdana; font-size:12pt;'>".__('Modules successfully created').'</p>';
|
|
|
|
echo '</div>';
|
|
|
|
echo '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2019-03-04 15:33:36 +01:00
|
|
|
} else if ($action == 'snmpget') {
|
|
|
|
// SNMP get.
|
2019-01-30 16:18:44 +01:00
|
|
|
$target_oid = htmlspecialchars_decode(get_parameter('oid', ''));
|
|
|
|
$custom_action = get_parameter('custom_action', '');
|
|
|
|
if ($custom_action != '') {
|
|
|
|
$custom_action = urldecode(base64_decode($custom_action));
|
|
|
|
}
|
|
|
|
|
|
|
|
$oid = snmp_browser_get_oid(
|
|
|
|
$target_ip,
|
|
|
|
$community,
|
|
|
|
$target_oid,
|
|
|
|
$snmp_version,
|
|
|
|
$snmp3_auth_user,
|
|
|
|
$snmp3_security_level,
|
|
|
|
$snmp3_auth_method,
|
|
|
|
$snmp3_auth_pass,
|
|
|
|
$snmp3_privacy_method,
|
2019-03-04 15:33:36 +01:00
|
|
|
$snmp3_privacy_pass,
|
|
|
|
$server_to_exec
|
2019-01-30 16:18:44 +01:00
|
|
|
);
|
2019-03-04 15:33:36 +01:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
snmp_browser_print_oid(
|
|
|
|
$oid,
|
|
|
|
$custom_action,
|
|
|
|
false,
|
|
|
|
$community,
|
|
|
|
$snmp_version
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2013-02-07 19:21:59 +01:00
|
|
|
}
|
|
|
|
|
2019-03-04 15:33:36 +01:00
|
|
|
// Check login and ACLs.
|
2019-01-30 16:18:44 +01:00
|
|
|
check_login();
|
|
|
|
if (! check_acl($config['id_user'], 0, 'AR')) {
|
|
|
|
db_pandora_audit(
|
|
|
|
'ACL Violation',
|
|
|
|
'Trying to access SNMP Console'
|
|
|
|
);
|
|
|
|
include 'general/noaccess.php';
|
|
|
|
exit;
|
2013-02-07 19:21:59 +01:00
|
|
|
}
|
|
|
|
|
2019-03-04 15:33:36 +01:00
|
|
|
// Header.
|
2019-01-30 16:18:44 +01:00
|
|
|
$url = 'index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_browser&pure='.$config['pure'];
|
|
|
|
if ($config['pure']) {
|
2019-03-04 15:33:36 +01:00
|
|
|
// Windowed.
|
|
|
|
$link['text'] = '<a target="_top" href="'.$url.'&pure=0&refr=30">';
|
|
|
|
$link['text'] .= html_print_image(
|
|
|
|
'images/normal_screen.png',
|
|
|
|
true,
|
|
|
|
['title' => __('Normal screen')]
|
|
|
|
);
|
|
|
|
$link['text'] .= '</a>';
|
2019-01-30 16:18:44 +01:00
|
|
|
} else {
|
2019-03-04 15:33:36 +01:00
|
|
|
// Fullscreen.
|
|
|
|
$link['text'] = '<a target="_top" href="'.$url.'&pure=1&refr=0">';
|
|
|
|
$link['text'] .= html_print_image(
|
|
|
|
'images/full_screen.png',
|
|
|
|
true,
|
|
|
|
['title' => __('Full screen')]
|
|
|
|
);
|
|
|
|
$link['text'] .= '</a>';
|
2013-04-23 13:02:18 +02:00
|
|
|
}
|
2013-02-07 19:21:59 +01:00
|
|
|
|
2019-03-04 15:33:36 +01:00
|
|
|
ui_print_page_header(
|
|
|
|
__('SNMP Browser'),
|
|
|
|
'images/op_snmp.png',
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
[$link]
|
|
|
|
);
|
2013-02-07 19:21:59 +01:00
|
|
|
|
2019-03-04 15:33:36 +01:00
|
|
|
// SNMP tree container.
|
2019-01-30 16:18:44 +01:00
|
|
|
snmp_browser_print_container();
|