2014-12-16 16:39:00 +01:00
|
|
|
<?php
|
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
|
|
|
// Copyright (c) 2005-2012 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 Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation; 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.
|
|
|
|
|
2014-12-18 09:55:54 +01:00
|
|
|
// Only accesible by ajax
|
|
|
|
if (is_ajax ()) {
|
|
|
|
global $config;
|
2014-12-18 14:22:10 +01:00
|
|
|
|
2017-11-21 16:59:49 +01:00
|
|
|
enterprise_include_once("include/functions_dashboard.php");
|
|
|
|
|
|
|
|
$public_hash = get_parameter('hash', 0);
|
|
|
|
|
|
|
|
// Try to authenticate by hash on public dashboards
|
2017-11-23 18:38:22 +01:00
|
|
|
if ($public_hash == 0) {
|
2017-11-21 16:59:49 +01:00
|
|
|
// Login check
|
|
|
|
check_login();
|
|
|
|
} else {
|
|
|
|
$validate_hash = enterprise_hook(
|
|
|
|
'dasboard_validate_public_hash',
|
|
|
|
array($public_hash, 'tree_view')
|
|
|
|
);
|
|
|
|
if ($validate_hash === false || $validate_hash === ENTERPRISE_NOT_HOOK) {
|
|
|
|
db_pandora_audit("Invalid public hash", "Trying to access report builder");
|
|
|
|
require ("general/noaccess.php");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
2014-12-16 16:39:00 +01:00
|
|
|
|
2014-12-18 14:22:10 +01:00
|
|
|
require_once($config['homedir'] . "/include/class/Tree.class.php");
|
2015-01-05 13:23:11 +01:00
|
|
|
enterprise_include_once("include/class/Tree.class.php");
|
2014-12-18 14:22:10 +01:00
|
|
|
require_once($config['homedir'] . "/include/functions_reporting.php");
|
2014-12-19 18:39:18 +01:00
|
|
|
require_once($config['homedir'] . "/include/functions_os.php");
|
2014-12-18 14:22:10 +01:00
|
|
|
|
2015-01-19 14:56:42 +01:00
|
|
|
$getChildren = (bool) get_parameter('getChildren', 0);
|
|
|
|
$getGroupStatus = (bool) get_parameter('getGroupStatus', 0);
|
2015-01-29 20:53:00 +01:00
|
|
|
$getDetail = (bool) get_parameter('getDetail');
|
2014-12-18 14:22:10 +01:00
|
|
|
|
2014-12-18 09:55:54 +01:00
|
|
|
if ($getChildren) {
|
|
|
|
$type = get_parameter('type', 'group');
|
2015-01-21 17:37:51 +01:00
|
|
|
$rootType = get_parameter('rootType', '');
|
|
|
|
$id = get_parameter('id', -1);
|
|
|
|
$rootID = get_parameter('rootID', -1);
|
2015-01-30 15:32:39 +01:00
|
|
|
$serverID = get_parameter('serverID', false);
|
2014-12-18 14:22:10 +01:00
|
|
|
$childrenMethod = get_parameter('childrenMethod', 'on_demand');
|
2017-11-21 16:59:49 +01:00
|
|
|
$hash = get_parameter('hash', false);
|
|
|
|
if ($hash !== false) {
|
|
|
|
enterprise_hook('dasboard_validate_public_hash', array($hash, 'tree_view'));
|
|
|
|
}
|
2015-01-22 16:55:31 +01:00
|
|
|
|
|
|
|
$default_filters = array(
|
|
|
|
'searchAgent' => '',
|
|
|
|
'statusAgent' => AGENT_STATUS_ALL,
|
|
|
|
'searchModule' => '',
|
|
|
|
'statusModule' => -1,
|
2015-03-09 19:29:45 +01:00
|
|
|
'groupID' => 0,
|
|
|
|
'tagID' => 0,
|
2015-01-22 16:55:31 +01:00
|
|
|
);
|
|
|
|
$filter = get_parameter('filter', $default_filters);
|
2014-12-18 09:55:54 +01:00
|
|
|
|
2016-09-08 16:06:12 +02:00
|
|
|
$agent_a = check_acl ($config['id_user'], 0, "AR");
|
|
|
|
$agent_w = check_acl ($config['id_user'], 0, "AW");
|
|
|
|
$access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR');
|
2015-01-05 13:23:11 +01:00
|
|
|
if (class_exists('TreeEnterprise')) {
|
2016-09-08 16:06:12 +02:00
|
|
|
$tree = new TreeEnterprise($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
2015-01-05 13:23:11 +01:00
|
|
|
}
|
|
|
|
else {
|
2016-09-08 16:06:12 +02:00
|
|
|
$tree = new Tree($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
2015-01-05 13:23:11 +01:00
|
|
|
}
|
|
|
|
|
2015-01-22 16:55:31 +01:00
|
|
|
$tree->setFilter($filter);
|
2015-07-06 18:26:13 +02:00
|
|
|
ob_clean();
|
2014-12-18 09:55:54 +01:00
|
|
|
echo json_encode(array('success' => 1, 'tree' => $tree->getArray()));
|
|
|
|
return;
|
|
|
|
}
|
2014-12-18 14:22:10 +01:00
|
|
|
|
2015-01-29 20:53:00 +01:00
|
|
|
if ($getDetail) {
|
2014-12-18 16:23:39 +01:00
|
|
|
require_once($config['homedir']."/include/functions_treeview.php");
|
|
|
|
|
|
|
|
$id = (int) get_parameter('id');
|
|
|
|
$type = (string) get_parameter('type');
|
|
|
|
|
|
|
|
$server = array();
|
2015-09-07 11:49:13 +02:00
|
|
|
if (is_metaconsole()) {
|
2015-01-29 20:53:00 +01:00
|
|
|
$server_id = (int) get_parameter('serverID');
|
|
|
|
$server = metaconsole_get_servers($server_id);
|
2014-12-18 16:23:39 +01:00
|
|
|
}
|
|
|
|
|
2015-01-29 20:53:00 +01:00
|
|
|
ob_clean();
|
|
|
|
|
2015-09-07 11:49:13 +02:00
|
|
|
echo '<div class="left_align">';
|
2015-01-29 20:53:00 +01:00
|
|
|
if (!empty($id) && !empty($type)) {
|
|
|
|
switch ($type) {
|
|
|
|
case 'agent':
|
2015-09-07 11:49:13 +02:00
|
|
|
treeview_printTable($id, $server, true);
|
2015-01-29 20:53:00 +01:00
|
|
|
break;
|
|
|
|
case 'module':
|
2015-09-07 11:49:13 +02:00
|
|
|
treeview_printModuleTable($id, $server, true);
|
2015-01-29 20:53:00 +01:00
|
|
|
break;
|
|
|
|
case 'alert':
|
2015-09-07 11:49:13 +02:00
|
|
|
treeview_printAlertsTable($id, $server, true);
|
2015-01-29 20:53:00 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Nothing
|
|
|
|
break;
|
|
|
|
}
|
2014-12-18 16:23:39 +01:00
|
|
|
}
|
2015-09-07 11:49:13 +02:00
|
|
|
echo '<br></div>';
|
2017-01-13 10:46:09 +01:00
|
|
|
|
2014-12-18 16:23:39 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-16 16:39:00 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
?>
|