2019-02-12 14:39:01 +01:00
|
|
|
<?php
|
|
|
|
|
2020-03-30 12:51:52 +02:00
|
|
|
enterprise_include_once('include/functions_license.php');
|
|
|
|
|
2019-02-12 14:39:01 +01:00
|
|
|
global $config;
|
|
|
|
|
2019-02-14 10:30:01 +01:00
|
|
|
check_login();
|
|
|
|
|
2019-10-09 15:45:02 +02:00
|
|
|
if (! check_acl($config['id_user'], 0, 'AR')
|
|
|
|
&& ! check_acl($config['id_user'], 0, 'AW')
|
|
|
|
&& ! check_acl($config['id_user'], 0, 'AM')
|
|
|
|
&& ! check_acl($config['id_user'], 0, 'RR')
|
|
|
|
&& ! check_acl($config['id_user'], 0, 'RW')
|
|
|
|
&& ! check_acl($config['id_user'], 0, 'RM')
|
|
|
|
&& ! check_acl($config['id_user'], 0, 'PM')
|
|
|
|
) {
|
2019-02-14 10:30:01 +01:00
|
|
|
db_pandora_audit(
|
2022-01-20 10:55:23 +01:00
|
|
|
AUDIT_LOG_ACL_VIOLATION,
|
2019-02-14 10:30:01 +01:00
|
|
|
'Trying to access Server Management'
|
|
|
|
);
|
|
|
|
include 'general/noaccess.php';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2019-02-15 10:00:23 +01:00
|
|
|
ui_require_css_file('discovery');
|
|
|
|
|
2019-02-12 14:39:01 +01:00
|
|
|
|
|
|
|
/**
|
2019-02-21 11:19:38 +01:00
|
|
|
* Mask class names.
|
2019-02-12 14:39:01 +01:00
|
|
|
*
|
2019-02-21 11:19:38 +01:00
|
|
|
* @param string $str Wiz parameter.
|
|
|
|
*
|
|
|
|
* @return string Classname.
|
2019-02-12 14:39:01 +01:00
|
|
|
*/
|
|
|
|
function get_wiz_class($str)
|
|
|
|
{
|
|
|
|
switch ($str) {
|
|
|
|
case 'hd':
|
|
|
|
return 'HostDevices';
|
|
|
|
|
2019-02-15 13:47:11 +01:00
|
|
|
case 'cloud':
|
|
|
|
return 'Cloud';
|
|
|
|
|
2019-02-15 18:05:59 +01:00
|
|
|
case 'tasklist':
|
|
|
|
return 'DiscoveryTaskList';
|
|
|
|
|
2019-02-19 14:36:16 +01:00
|
|
|
case 'app':
|
|
|
|
return 'Applications';
|
|
|
|
|
2019-02-21 11:19:38 +01:00
|
|
|
case 'ctask':
|
|
|
|
return 'ConsoleTasks';
|
|
|
|
|
2020-03-16 23:52:20 +01:00
|
|
|
case 'deploymentCenter':
|
|
|
|
return 'DeploymentCenter';
|
|
|
|
|
2019-02-12 14:39:01 +01:00
|
|
|
default:
|
2019-07-11 13:25:29 +02:00
|
|
|
// Main, show header.
|
|
|
|
ui_print_page_header(
|
|
|
|
__('Discovery'),
|
|
|
|
'',
|
|
|
|
false,
|
2020-05-29 11:37:06 +02:00
|
|
|
'',
|
2019-07-11 13:25:29 +02:00
|
|
|
true,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
GENERIC_SIZE_TEXT,
|
|
|
|
''
|
|
|
|
);
|
2019-02-12 14:39:01 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-21 11:19:38 +01:00
|
|
|
/**
|
|
|
|
* Aux. function to compare classpath names.
|
|
|
|
*
|
|
|
|
* @param string $a Classpath A.
|
|
|
|
* @param string $b Classpath B.
|
|
|
|
*
|
|
|
|
* @return string Matching one.
|
|
|
|
*/
|
|
|
|
function cl_load_cmp($a, $b)
|
|
|
|
{
|
|
|
|
$str_a = basename($a, '.class.php');
|
|
|
|
$str_b = basename($b, '.class.php');
|
|
|
|
if ($str_a == $str_b) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($str_a < $str_b) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-15 18:05:59 +01:00
|
|
|
/*
|
|
|
|
* CLASS LOADER.
|
|
|
|
*/
|
|
|
|
|
2019-02-12 14:39:01 +01:00
|
|
|
// Dynamic class loader.
|
|
|
|
$classes = glob($config['homedir'].'/godmode/wizards/*.class.php');
|
2019-02-18 14:30:03 +01:00
|
|
|
if (enterprise_installed()) {
|
|
|
|
$ent_classes = glob(
|
2019-07-17 20:37:13 +02:00
|
|
|
$config['homedir'].'/'.ENTERPRISE_DIR.'/godmode/wizards/*.class.php'
|
2019-02-18 14:30:03 +01:00
|
|
|
);
|
|
|
|
if ($ent_classes === false) {
|
|
|
|
$ent_classes = [];
|
|
|
|
}
|
2019-02-20 16:54:52 +01:00
|
|
|
|
2019-02-18 14:30:03 +01:00
|
|
|
$classes = array_merge($classes, $ent_classes);
|
|
|
|
}
|
|
|
|
|
2019-02-12 14:39:01 +01:00
|
|
|
foreach ($classes as $classpath) {
|
|
|
|
include_once $classpath;
|
|
|
|
}
|
|
|
|
|
2019-02-21 11:19:38 +01:00
|
|
|
// Sort output.
|
|
|
|
uasort($classes, 'cl_load_cmp');
|
|
|
|
|
|
|
|
// Check user action.
|
2019-02-12 14:39:01 +01:00
|
|
|
$wiz_in_use = get_parameter('wiz', null);
|
|
|
|
$page = get_parameter('page', 0);
|
|
|
|
|
|
|
|
$classname_selected = get_wiz_class($wiz_in_use);
|
|
|
|
|
|
|
|
// Else: class not found pseudo exception.
|
|
|
|
if ($classname_selected !== null) {
|
2020-03-16 23:52:20 +01:00
|
|
|
$wiz = new $classname_selected((int) $page);
|
|
|
|
|
|
|
|
// AJAX controller.
|
|
|
|
if (is_ajax()) {
|
|
|
|
$method = get_parameter('method');
|
|
|
|
|
|
|
|
if (method_exists($wiz, $method) === true) {
|
|
|
|
$wiz->{$method}();
|
|
|
|
} else {
|
|
|
|
$wiz->error('Method not found. ['.$method.']');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stop any execution.
|
|
|
|
exit;
|
|
|
|
} else {
|
|
|
|
$result = $wiz->run();
|
|
|
|
if (is_array($result) === true) {
|
|
|
|
// Redirect control and messages to DiscoveryTasklist.
|
|
|
|
$classname_selected = 'DiscoveryTaskList';
|
|
|
|
$wiz = new $classname_selected($page);
|
|
|
|
$result = $wiz->run($result['msg'], $result['result']);
|
|
|
|
}
|
2019-02-15 13:57:33 +01:00
|
|
|
}
|
2019-02-12 14:39:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($classname_selected === null) {
|
|
|
|
// Load classes and print selector.
|
2019-02-18 10:24:19 +01:00
|
|
|
$wiz_data = [];
|
2019-02-12 14:39:01 +01:00
|
|
|
foreach ($classes as $classpath) {
|
2022-07-11 16:42:20 +02:00
|
|
|
if (is_reporting_console_node() === true) {
|
2022-07-08 13:40:20 +02:00
|
|
|
if ($classpath !== '/var/www/html/pandora_console/godmode/wizards/DiscoveryTaskList.class.php') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-12 14:39:01 +01:00
|
|
|
$classname = basename($classpath, '.class.php');
|
|
|
|
$obj = new $classname();
|
2019-02-21 11:19:38 +01:00
|
|
|
|
2019-10-09 15:45:02 +02:00
|
|
|
$button = $obj->load();
|
|
|
|
|
|
|
|
if ($button === false) {
|
|
|
|
// No acess, skip.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-02-21 11:19:38 +01:00
|
|
|
// DiscoveryTaskList must be first button.
|
|
|
|
if ($classname == 'DiscoveryTaskList') {
|
2019-10-09 15:45:02 +02:00
|
|
|
array_unshift($wiz_data, $button);
|
2019-02-21 11:19:38 +01:00
|
|
|
} else {
|
2019-10-09 15:45:02 +02:00
|
|
|
$wiz_data[] = $button;
|
2019-02-21 11:19:38 +01:00
|
|
|
}
|
2019-02-12 14:39:01 +01:00
|
|
|
}
|
|
|
|
|
2019-07-17 20:37:13 +02:00
|
|
|
// Show hints if there is no task.
|
2019-04-10 17:30:35 +02:00
|
|
|
if (get_parameter('discovery_hint', 0)) {
|
|
|
|
ui_require_css_file('discovery-hint');
|
2019-04-10 17:51:50 +02:00
|
|
|
ui_print_info_message(__('You must create a task first'));
|
2019-04-10 17:30:35 +02:00
|
|
|
}
|
|
|
|
|
2019-02-18 10:24:19 +01:00
|
|
|
Wizard::printBigButtonsList($wiz_data);
|
2019-02-12 14:39:01 +01:00
|
|
|
}
|