mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
WIP: H&D
Former-commit-id: 7e74f1330b7e5cfdab3757ec62523942a1b4fe9f
This commit is contained in:
parent
070db506b8
commit
8acb658266
@ -52,7 +52,6 @@ if ($classname_selected !== null) {
|
|||||||
$wiz = new $classname_selected($page);
|
$wiz = new $classname_selected($page);
|
||||||
$wiz->run();
|
$wiz->run();
|
||||||
// TODO: Here we'll controlle if return is a valid recon task id.
|
// TODO: Here we'll controlle if return is a valid recon task id.
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($classname_selected === null) {
|
if ($classname_selected === null) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/Wizard.main.php';
|
require_once __DIR__.'/Wizard.main.php';
|
||||||
|
require_once $config['homedir'].'/include/functions_users.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented class
|
* Undocumented class
|
||||||
@ -104,6 +105,10 @@ class HostDevices extends Wizard
|
|||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Load styles.
|
||||||
|
parent::run();
|
||||||
|
|
||||||
$mode = get_parameter('mode', null);
|
$mode = get_parameter('mode', null);
|
||||||
|
|
||||||
if ($mode === null) {
|
if ($mode === null) {
|
||||||
@ -197,6 +202,18 @@ class HostDevices extends Wizard
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves and validates information given by user in NetScan wizard.
|
||||||
|
*
|
||||||
|
* @return boolean Data OK or not.
|
||||||
|
*/
|
||||||
|
public function parseNetScan()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
@ -217,34 +234,165 @@ class HostDevices extends Wizard
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
include_once $config['homedir'].'/include/functions_users.php';
|
|
||||||
|
|
||||||
$user_groups = users_get_groups(false, 'AW', true, false, null, 'id_grupo');
|
$user_groups = users_get_groups(false, 'AW', true, false, null, 'id_grupo');
|
||||||
$user_groups = array_keys($user_groups);
|
$user_groups = array_keys($user_groups);
|
||||||
|
|
||||||
if (isset($this->page) === false
|
if (isset($this->page) && $this->page == 1) {
|
||||||
|| $this->page == 0
|
// Parse page 0 responses.
|
||||||
) {
|
$this->parseNetScan();
|
||||||
$form = [];
|
}
|
||||||
|
|
||||||
// Input task name.
|
if (!isset($this->page) || $this->page == 0) {
|
||||||
// Input Discovery Server.
|
// Interval.
|
||||||
// Input Network.
|
$interv_manual = 0;
|
||||||
// Input interval.
|
if ((int) $interval == 0) {
|
||||||
// Input group.
|
$interv_manual = 1;
|
||||||
$form['inputs'] = [
|
}
|
||||||
[
|
|
||||||
'label' => __('Task name'),
|
if (isset($this->page) === false
|
||||||
|
|| $this->page == 0
|
||||||
|
) {
|
||||||
|
$form = [];
|
||||||
|
|
||||||
|
// Input task name.
|
||||||
|
$form['inputs'][] = [
|
||||||
|
'label' => '<b>'.__('Task name').'</b>',
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'taskname',
|
||||||
|
'value' => '',
|
||||||
|
'type' => 'text',
|
||||||
|
'size' => 25,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Input Discovery Server.
|
||||||
|
$form['inputs'][] = [
|
||||||
|
'label' => '<b>'.__('Discovery server').'</b>'.ui_print_help_tip(
|
||||||
|
__('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'),
|
||||||
|
true
|
||||||
|
),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'select_from_sql',
|
||||||
|
'sql' => sprintf(
|
||||||
|
'SELECT id_server, name
|
||||||
|
FROM tserver
|
||||||
|
WHERE server_type = %d
|
||||||
|
ORDER BY name',
|
||||||
|
SERVER_TYPE_DISCOVERY
|
||||||
|
),
|
||||||
|
'name' => 'id_recon_server',
|
||||||
|
'selected' => 0,
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Input Network.
|
||||||
|
$form['inputs'][] = [
|
||||||
|
|
||||||
|
'label' => '<b>'.__('Network').'</b>'.ui_print_help_tip(
|
||||||
|
__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'),
|
||||||
|
true
|
||||||
|
),
|
||||||
'arguments' => [
|
'arguments' => [
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'size' => 25,
|
'size' => 25,
|
||||||
],
|
],
|
||||||
],
|
];
|
||||||
];
|
|
||||||
|
|
||||||
$this->printForm($form);
|
// Input interval.
|
||||||
|
$form['inputs'][] = [
|
||||||
|
'label' => '<b>'.__('Interval').'</b>'.ui_print_help_tip(
|
||||||
|
__('Manual interval means that it will be executed only On-demand'),
|
||||||
|
true
|
||||||
|
),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'selected' => $interv_manual,
|
||||||
|
'fields' => [
|
||||||
|
0 => __('Defined'),
|
||||||
|
1 => __('Manual'),
|
||||||
|
],
|
||||||
|
'name' => 'interval_manual_defined',
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
'extra' => '<span id="interval_manual_container">'.html_print_extended_select_for_time(
|
||||||
|
'interval',
|
||||||
|
$interval,
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'0',
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
).ui_print_help_tip(
|
||||||
|
__('The minimum recomended interval for Recon Task is 5 minutes'),
|
||||||
|
true
|
||||||
|
).'</span>',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Input Group.
|
||||||
|
$form['inputs'][] = [
|
||||||
|
'label' => '<b>'.__('Group').'</b>',
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'id_group',
|
||||||
|
'privilege' => 'PM',
|
||||||
|
'type' => 'select_groups',
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Hidden, page.
|
||||||
|
$form['inputs'][] = [
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'page',
|
||||||
|
'value' => ($this->page + 1),
|
||||||
|
'type' => 'hidden',
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Submit button.
|
||||||
|
$form['inputs'][] = [
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'submit',
|
||||||
|
'label' => __('Next'),
|
||||||
|
'type' => 'submit',
|
||||||
|
'attributes' => 'class="sub next"',
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$form['form'] = [
|
||||||
|
'method' => 'POST',
|
||||||
|
'action' => '#',
|
||||||
|
];
|
||||||
|
|
||||||
|
$form['js'] = '
|
||||||
|
$("select#interval_manual_defined").change(function() {
|
||||||
|
if ($("#interval_manual_defined").val() == 1) {
|
||||||
|
$("#interval_manual_container").hide();
|
||||||
|
$("#text-interval_text").val(0);
|
||||||
|
$("#hidden-interval").val(0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#interval_manual_container").show();
|
||||||
|
$("#text-interval_text").val(10);
|
||||||
|
$("#hidden-interval").val(600);
|
||||||
|
$("#interval_units").val(60);
|
||||||
|
}
|
||||||
|
}).change();';
|
||||||
|
|
||||||
|
// Print NetScan page 0.
|
||||||
|
$this->printForm($form);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->page == 1) {
|
||||||
|
// Page 1.
|
||||||
|
echo 'page 1!';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->page == 100) {
|
if ($this->page == 100) {
|
||||||
|
@ -45,6 +45,7 @@ class Wizard
|
|||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
|
ui_require_css_file('wizard');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -214,6 +215,77 @@ class Wizard
|
|||||||
((isset($data['options']) === true) ? $data['options'] : false)
|
((isset($data['options']) === true) ? $data['options'] : false)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
case 'select':
|
||||||
|
return html_print_select(
|
||||||
|
$data['fields'],
|
||||||
|
$data['name'],
|
||||||
|
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||||
|
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||||
|
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||||
|
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : false),
|
||||||
|
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||||
|
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||||
|
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||||
|
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||||
|
((isset($data['style']) === true) ? $data['style'] : false),
|
||||||
|
((isset($data['option_style']) === true) ? $data['option_style'] : false),
|
||||||
|
((isset($data['size']) === true) ? $data['size'] : false),
|
||||||
|
((isset($data['modal']) === true) ? $data['modal'] : false),
|
||||||
|
((isset($data['message']) === true) ? $data['message'] : ''),
|
||||||
|
((isset($data['select_all']) === true) ? $data['select_all'] : false)
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'select_from_sql':
|
||||||
|
return html_print_select_from_sql(
|
||||||
|
$data['sql'],
|
||||||
|
$data['name'],
|
||||||
|
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||||
|
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||||
|
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||||
|
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : '0'),
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : false),
|
||||||
|
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||||
|
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||||
|
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||||
|
((isset($data['style']) === true) ? $data['style'] : false),
|
||||||
|
((isset($data['size']) === true) ? $data['size'] : false),
|
||||||
|
((isset($data['trucate_size']) === true) ? $data['trucate_size'] : GENERIC_SIZE_TEXT)
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'select_groups':
|
||||||
|
return html_print_select_groups(
|
||||||
|
((isset($data['id_user']) === true) ? $data['id_user'] : false),
|
||||||
|
((isset($data['privilege']) === true) ? $data['privilege'] : 'AR'),
|
||||||
|
((isset($data['returnAllGroup']) === true) ? $data['returnAllGroup'] : true),
|
||||||
|
$data['name'],
|
||||||
|
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||||
|
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||||
|
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||||
|
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : false),
|
||||||
|
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||||
|
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||||
|
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||||
|
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||||
|
((isset($data['style']) === true) ? $data['style'] : false),
|
||||||
|
((isset($data['option_style']) === true) ? $data['option_style'] : false),
|
||||||
|
((isset($data['id_group']) === true) ? $data['id_group'] : false),
|
||||||
|
((isset($data['keys_field']) === true) ? $data['keys_field'] : 'id_grupo'),
|
||||||
|
((isset($data['strict_user']) === true) ? $data['strict_user'] : false),
|
||||||
|
((isset($data['delete_groups']) === true) ? $data['delete_groups'] : false),
|
||||||
|
((isset($data['include_groups']) === true) ? $data['include_groups'] : false)
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'submit':
|
||||||
|
return html_print_submit_button(
|
||||||
|
((isset($data['label']) === true) ? $data['label'] : 'OK'),
|
||||||
|
((isset($data['name']) === true) ? $data['name'] : ''),
|
||||||
|
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||||
|
((isset($data['attributes']) === true) ? $data['attributes'] : ''),
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : false)
|
||||||
|
);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Ignore.
|
// Ignore.
|
||||||
break;
|
break;
|
||||||
@ -239,16 +311,19 @@ class Wizard
|
|||||||
$output = '<form action="'.$form['action'].'" method="'.$form['method'];
|
$output = '<form action="'.$form['action'].'" method="'.$form['method'];
|
||||||
$output .= '" '.$form['extra'].'>';
|
$output .= '" '.$form['extra'].'>';
|
||||||
|
|
||||||
$ouput .= '<ul>';
|
$output .= '<ul class="wizard">';
|
||||||
|
|
||||||
foreach ($inputs as $input) {
|
foreach ($inputs as $input) {
|
||||||
$output .= '<li><label>'.$input['label'].'</label>';
|
$output .= '<li><label>'.$input['label'].'</label>';
|
||||||
$output .= $this->printInput($input['arguments']).'</li>';
|
$output .= $this->printInput($input['arguments']);
|
||||||
|
// Allow dynamic content.
|
||||||
|
$output .= $input['extra'];
|
||||||
|
$output .= '</li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= '</ul>';
|
$output .= '</ul>';
|
||||||
$output .= '</form>';
|
$output .= '</form>';
|
||||||
$output .= $js;
|
$output .= '<script>'.$js.'</script>';
|
||||||
|
|
||||||
if ($return === false) {
|
if ($return === false) {
|
||||||
echo $output;
|
echo $output;
|
||||||
|
11
pandora_console/include/styles/wizard.css
Normal file
11
pandora_console/include/styles/wizard.css
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
ul.wizard {
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.wizard li {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.wizard li > label {
|
||||||
|
width: 250px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user