2014-12-16 16:39:00 +01:00
|
|
|
<?php
|
2021-03-15 13:31:24 +01:00
|
|
|
/**
|
|
|
|
* Tree view.
|
|
|
|
*
|
|
|
|
* @category Tree
|
|
|
|
* @package Pandora FMS
|
|
|
|
* @subpackage Community
|
|
|
|
* @version 1.0.0
|
|
|
|
* @license See below
|
|
|
|
*
|
|
|
|
* ______ ___ _______ _______ ________
|
2023-06-08 12:42:10 +02:00
|
|
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
|
|
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
2021-03-15 13:31:24 +01:00
|
|
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
|
|
|
*
|
|
|
|
* ============================================================================
|
2023-06-08 11:53:13 +02:00
|
|
|
* Copyright (c) 2005-2023 Pandora FMS
|
2023-06-08 13:19:01 +02:00
|
|
|
* Please see https://pandorafms.com/community/ for full contribution list
|
2021-03-15 13:31:24 +01:00
|
|
|
* 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.
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (is_ajax() === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
global $config;
|
|
|
|
|
2020-03-26 12:29:38 +01:00
|
|
|
// Login check.
|
|
|
|
check_login();
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
include_once $config['homedir'].'/include/class/Tree.class.php';
|
|
|
|
include_once $config['homedir'].'/include/class/TreeOS.class.php';
|
|
|
|
include_once $config['homedir'].'/include/class/TreeModuleGroup.class.php';
|
|
|
|
include_once $config['homedir'].'/include/class/TreeModule.class.php';
|
|
|
|
include_once $config['homedir'].'/include/class/TreeTag.class.php';
|
|
|
|
include_once $config['homedir'].'/include/class/TreeGroup.class.php';
|
2019-02-27 10:28:36 +01:00
|
|
|
include_once $config['homedir'].'/include/class/TreeService.class.php';
|
2019-01-30 16:18:44 +01:00
|
|
|
include_once $config['homedir'].'/include/class/TreeGroupEdition.class.php';
|
2021-09-28 13:44:12 +02:00
|
|
|
enterprise_include_once('include/class/TreeIPAMSupernet.class.php');
|
2019-01-30 16:18:44 +01:00
|
|
|
enterprise_include_once('include/class/TreePolicies.class.php');
|
|
|
|
enterprise_include_once('include/class/TreeGroupMeta.class.php');
|
|
|
|
include_once $config['homedir'].'/include/functions_reporting.php';
|
|
|
|
include_once $config['homedir'].'/include/functions_os.php';
|
|
|
|
|
|
|
|
$getChildren = (bool) get_parameter('getChildren', 0);
|
|
|
|
$getGroupStatus = (bool) get_parameter('getGroupStatus', 0);
|
|
|
|
$getDetail = (bool) get_parameter('getDetail');
|
|
|
|
|
2021-03-15 13:31:24 +01:00
|
|
|
if ($getChildren === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$type = get_parameter('type', 'group');
|
|
|
|
$rootType = get_parameter('rootType', '');
|
|
|
|
$id = get_parameter('id', -1);
|
|
|
|
$rootID = get_parameter('rootID', -1);
|
|
|
|
$serverID = get_parameter('serverID', false);
|
2020-07-01 20:50:07 +02:00
|
|
|
$metaID = (int) get_parameter('metaID', 0);
|
2019-01-30 16:18:44 +01:00
|
|
|
$childrenMethod = get_parameter('childrenMethod', 'on_demand');
|
|
|
|
|
|
|
|
$default_filters = [
|
|
|
|
'searchAgent' => '',
|
|
|
|
'statusAgent' => AGENT_STATUS_ALL,
|
|
|
|
'searchModule' => '',
|
2022-02-14 17:55:29 +01:00
|
|
|
'statusModule' => AGENT_MODULE_STATUS_ALL,
|
2019-01-30 16:18:44 +01:00
|
|
|
'groupID' => 0,
|
|
|
|
'tagID' => 0,
|
|
|
|
];
|
|
|
|
$filter = get_parameter('filter', $default_filters);
|
|
|
|
|
|
|
|
$agent_a = check_acl($config['id_user'], 0, 'AR');
|
|
|
|
$agent_w = check_acl($config['id_user'], 0, 'AW');
|
2021-03-15 13:31:24 +01:00
|
|
|
$access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR');
|
|
|
|
$switch_type = (empty($rootType) === false) ? $rootType : $type;
|
2019-01-30 16:18:44 +01:00
|
|
|
switch ($switch_type) {
|
|
|
|
case 'os':
|
2021-03-15 13:31:24 +01:00
|
|
|
$tree = new TreeOS(
|
|
|
|
$type,
|
|
|
|
$rootType,
|
|
|
|
$id,
|
|
|
|
$rootID,
|
|
|
|
$serverID,
|
|
|
|
$childrenMethod,
|
|
|
|
$access
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'module_group':
|
2021-03-15 13:31:24 +01:00
|
|
|
$tree = new TreeModuleGroup(
|
|
|
|
$type,
|
|
|
|
$rootType,
|
|
|
|
$id,
|
|
|
|
$rootID,
|
|
|
|
$serverID,
|
|
|
|
$childrenMethod,
|
|
|
|
$access
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'module':
|
2021-03-15 13:31:24 +01:00
|
|
|
$tree = new TreeModule(
|
|
|
|
$type,
|
|
|
|
$rootType,
|
|
|
|
$id,
|
|
|
|
$rootID,
|
|
|
|
$serverID,
|
|
|
|
$childrenMethod,
|
|
|
|
$access
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'tag':
|
2021-03-15 13:31:24 +01:00
|
|
|
$tree = new TreeTag(
|
|
|
|
$type,
|
|
|
|
$rootType,
|
|
|
|
$id,
|
|
|
|
$rootID,
|
|
|
|
$serverID,
|
|
|
|
$childrenMethod,
|
|
|
|
$access
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'group':
|
2021-03-15 13:31:24 +01:00
|
|
|
if (is_metaconsole() === true) {
|
|
|
|
if (class_exists('TreeGroupMeta') === false) {
|
2019-01-30 16:18:44 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-03-15 13:31:24 +01:00
|
|
|
$tree = new TreeGroupMeta(
|
|
|
|
$type,
|
|
|
|
$rootType,
|
|
|
|
$id,
|
|
|
|
$rootID,
|
|
|
|
$serverID,
|
|
|
|
$childrenMethod,
|
|
|
|
$access
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
} else {
|
2021-03-15 13:31:24 +01:00
|
|
|
$tree = new TreeGroup(
|
|
|
|
$type,
|
|
|
|
$rootType,
|
|
|
|
$id,
|
|
|
|
$rootID,
|
|
|
|
$serverID,
|
|
|
|
$childrenMethod,
|
|
|
|
$access
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'policies':
|
2021-03-15 13:31:24 +01:00
|
|
|
if (class_exists('TreePolicies') === false) {
|
2019-01-30 16:18:44 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-03-15 13:31:24 +01:00
|
|
|
$tree = new TreePolicies(
|
|
|
|
$type,
|
|
|
|
$rootType,
|
|
|
|
$id,
|
|
|
|
$rootID,
|
|
|
|
$serverID,
|
|
|
|
$childrenMethod,
|
|
|
|
$access
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'group_edition':
|
2021-03-15 13:31:24 +01:00
|
|
|
$tree = new TreeGroupEdition(
|
|
|
|
$type,
|
|
|
|
$rootType,
|
|
|
|
$id,
|
|
|
|
$rootID,
|
|
|
|
$serverID,
|
|
|
|
$childrenMethod,
|
|
|
|
$access
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
break;
|
|
|
|
|
2019-02-27 10:28:36 +01:00
|
|
|
case 'services':
|
2020-07-01 20:50:07 +02:00
|
|
|
$tree = new TreeService(
|
|
|
|
$type,
|
|
|
|
$rootType,
|
|
|
|
$id,
|
|
|
|
$rootID,
|
|
|
|
$serverID,
|
|
|
|
$childrenMethod,
|
|
|
|
$access,
|
|
|
|
$metaID
|
|
|
|
);
|
2019-02-27 10:28:36 +01:00
|
|
|
break;
|
|
|
|
|
2021-09-28 13:44:12 +02:00
|
|
|
case 'IPAM_supernets':
|
|
|
|
$tree = new TreeIPAMSupernet(
|
|
|
|
$type,
|
|
|
|
$rootType,
|
|
|
|
$id,
|
|
|
|
$rootID,
|
|
|
|
$serverID,
|
|
|
|
$childrenMethod,
|
|
|
|
$access
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
default:
|
2021-03-15 13:31:24 +01:00
|
|
|
// No error handler.
|
2019-01-30 16:18:44 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$tree->setFilter($filter);
|
|
|
|
ob_clean();
|
2019-02-27 10:28:36 +01:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
echo json_encode(['success' => 1, 'tree' => $tree->getArray()]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-15 13:31:24 +01:00
|
|
|
if ($getDetail === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
include_once $config['homedir'].'/include/functions_treeview.php';
|
|
|
|
|
|
|
|
$id = (int) get_parameter('id');
|
|
|
|
$type = (string) get_parameter('type');
|
|
|
|
|
|
|
|
$server = [];
|
2021-03-15 13:31:24 +01:00
|
|
|
if (is_metaconsole() === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$server_id = (int) get_parameter('serverID');
|
|
|
|
$server = metaconsole_get_servers($server_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
ob_clean();
|
|
|
|
|
2019-06-03 19:13:29 +02:00
|
|
|
echo '<style type="text/css">';
|
|
|
|
include_once __DIR__.'/../styles/progress.css';
|
|
|
|
echo '</style>';
|
|
|
|
|
2021-03-11 15:40:23 +01:00
|
|
|
echo '<div class="left_align backgrund_primary_important">';
|
2021-03-15 13:31:24 +01:00
|
|
|
if (empty($id) === false && empty($type) === false) {
|
2019-01-30 16:18:44 +01:00
|
|
|
switch ($type) {
|
|
|
|
case 'agent':
|
|
|
|
treeview_printTable($id, $server, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'module':
|
|
|
|
treeview_printModuleTable($id, $server, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'alert':
|
|
|
|
treeview_printAlertsTable($id, $server, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2021-03-15 13:31:24 +01:00
|
|
|
// Nothing.
|
2019-01-30 16:18:44 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '<br></div>';
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2014-12-16 16:39:00 +01:00
|
|
|
}
|