2019-02-12 14:39:01 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
global $config;
|
|
|
|
|
2019-02-14 10:30:01 +01:00
|
|
|
check_login();
|
|
|
|
|
|
|
|
if (! check_acl($config['id_user'], 0, 'AW')) {
|
|
|
|
db_pandora_audit(
|
|
|
|
'ACL Violation',
|
|
|
|
'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-15 14:02:32 +01:00
|
|
|
ui_print_page_header(__('Discover'), '', false, '', true);
|
2019-02-12 14:39:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Undocumented function
|
|
|
|
*
|
|
|
|
* @param [type] $str
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
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-12 14:39:01 +01:00
|
|
|
default:
|
|
|
|
// Ignore.
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
$config['homedir'].'/enterprise/godmode/wizards/*.class.php'
|
|
|
|
);
|
|
|
|
if ($ent_classes === false) {
|
|
|
|
$ent_classes = [];
|
|
|
|
}
|
|
|
|
$classes = array_merge($classes, $ent_classes);
|
|
|
|
}
|
|
|
|
|
2019-02-12 14:39:01 +01:00
|
|
|
foreach ($classes as $classpath) {
|
|
|
|
include_once $classpath;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$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) {
|
|
|
|
$wiz = new $classname_selected($page);
|
2019-02-15 13:08:44 +01:00
|
|
|
$result = $wiz->run();
|
2019-02-15 13:57:33 +01:00
|
|
|
if (is_array($result) === true) {
|
|
|
|
if ($result['result'] === 0) {
|
|
|
|
// Success.
|
|
|
|
ui_print_success_message($result['msg']);
|
|
|
|
// TODO: Show task progress before redirect to main discovery menu.
|
|
|
|
} else {
|
|
|
|
// Failed.
|
|
|
|
ui_print_error_message($result['msg']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$classname_selected = null;
|
|
|
|
}
|
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) {
|
|
|
|
$classname = basename($classpath, '.class.php');
|
|
|
|
$obj = new $classname();
|
2019-02-18 10:24:19 +01:00
|
|
|
$wiz_data[] = $obj->load();
|
2019-02-12 14:39:01 +01:00
|
|
|
}
|
|
|
|
|
2019-02-18 10:24:19 +01:00
|
|
|
Wizard::printBigButtonsList($wiz_data);
|
2019-02-12 14:39:01 +01:00
|
|
|
}
|