mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
WIP H&D
Former-commit-id: c3b0b6f56ff0591f8c5839d61144bbb72ddd7033
This commit is contained in:
parent
10a37c313c
commit
0db88817a9
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/Wizard.interface.php';
|
require_once __DIR__.'/Wizard.main.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented class
|
* Undocumented class
|
||||||
*/
|
*/
|
||||||
class HostDevices implements Wizard
|
class HostDevices extends Wizard
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,18 +15,53 @@ class HostDevices implements Wizard
|
|||||||
*/
|
*/
|
||||||
public $values = [];
|
public $values = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented variable
|
||||||
|
*
|
||||||
|
* @var [type]
|
||||||
|
*/
|
||||||
public $result;
|
public $result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented variable
|
||||||
|
*
|
||||||
|
* @var [type]
|
||||||
|
*/
|
||||||
public $id;
|
public $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented variable
|
||||||
|
*
|
||||||
|
* @var [type]
|
||||||
|
*/
|
||||||
public $msg;
|
public $msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented variable
|
||||||
|
*
|
||||||
|
* @var [type]
|
||||||
|
*/
|
||||||
public $icon;
|
public $icon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented variable
|
||||||
|
*
|
||||||
|
* @var [type]
|
||||||
|
*/
|
||||||
public $label;
|
public $label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented variable
|
||||||
|
*
|
||||||
|
* @var [type]
|
||||||
|
*/
|
||||||
public $url;
|
public $url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented variable
|
||||||
|
*
|
||||||
|
* @var [type]
|
||||||
|
*/
|
||||||
public $page;
|
public $page;
|
||||||
|
|
||||||
|
|
||||||
@ -105,7 +140,7 @@ class HostDevices implements Wizard
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// extra methods
|
// Extra methods.
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -333,9 +368,9 @@ class HostDevices implements Wizard
|
|||||||
$snmp3_security_level = '';
|
$snmp3_security_level = '';
|
||||||
$id_network_profile = 0;
|
$id_network_profile = 0;
|
||||||
$id_os = -1;
|
$id_os = -1;
|
||||||
// Any
|
// Any.
|
||||||
$recon_ports = '';
|
$recon_ports = '';
|
||||||
// Any
|
// Any.
|
||||||
$field1 = '';
|
$field1 = '';
|
||||||
$field2 = '';
|
$field2 = '';
|
||||||
$field3 = '';
|
$field3 = '';
|
||||||
@ -508,7 +543,7 @@ class HostDevices implements Wizard
|
|||||||
true
|
true
|
||||||
).' '.ui_print_help_tip(__('Choose if the discovery of a new system creates an incident or not.'), true);
|
).' '.ui_print_help_tip(__('Choose if the discovery of a new system creates an incident or not.'), true);
|
||||||
|
|
||||||
// snmp_enabled.
|
// Snmp_enabled.
|
||||||
$table->data[11][0] = '<b>'.__('SNMP enabled');
|
$table->data[11][0] = '<b>'.__('SNMP enabled');
|
||||||
$table->data[11][1] = html_print_checkbox('snmp_enabled', 1, $snmp_enabled, true);
|
$table->data[11][1] = html_print_checkbox('snmp_enabled', 1, $snmp_enabled, true);
|
||||||
|
|
||||||
@ -673,99 +708,99 @@ class HostDevices implements Wizard
|
|||||||
echo '</form>';
|
echo '</form>';
|
||||||
|
|
||||||
ui_require_javascript_file('pandora_modules');
|
ui_require_javascript_file('pandora_modules');
|
||||||
?>
|
$a = `
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
/* <![CDATA[ */
|
/* <![CDATA[ */
|
||||||
$(document).ready (function () {
|
$(document).ready (function () {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var xhrManager = function () {
|
var xhrManager = function () {
|
||||||
var manager = {};
|
var manager = {};
|
||||||
|
|
||||||
manager.tasks = [];
|
manager.tasks = [];
|
||||||
|
|
||||||
manager.addTask = function (xhr) {
|
manager.addTask = function (xhr) {
|
||||||
manager.tasks.push(xhr);
|
manager.tasks.push(xhr);
|
||||||
}
|
}
|
||||||
|
|
||||||
manager.stopTasks = function () {
|
manager.stopTasks = function () {
|
||||||
while (manager.tasks.length > 0)
|
while (manager.tasks.length > 0)
|
||||||
manager.tasks.pop().abort();
|
manager.tasks.pop().abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
return manager;
|
return manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
var taskManager = new xhrManager();
|
var taskManager = new xhrManager();
|
||||||
|
|
||||||
$('select#interval_manual_defined').change(function() {
|
$('select#interval_manual_defined').change(function() {
|
||||||
if ($("#interval_manual_defined").val() == 1) {
|
if ($("#interval_manual_defined").val() == 1) {
|
||||||
$('#interval_manual_container').hide();
|
$('#interval_manual_container').hide();
|
||||||
$('#text-interval_text').val(0);
|
$('#text-interval_text').val(0);
|
||||||
$('#hidden-interval').val(0);
|
$('#hidden-interval').val(0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('#interval_manual_container').show();
|
$('#interval_manual_container').show();
|
||||||
$('#text-interval_text').val(10);
|
$('#text-interval_text').val(10);
|
||||||
$('#hidden-interval').val(600);
|
$('#hidden-interval').val(600);
|
||||||
$('#interval_units').val(60);
|
$('#interval_units').val(60);
|
||||||
}
|
}
|
||||||
}).change();
|
}).change();
|
||||||
|
|
||||||
$('select#id_recon_script').change(function() {
|
$('select#id_recon_script').change(function() {
|
||||||
if ($('select#mode').val() == 'recon_script')
|
if ($('select#mode').val() == 'recon_script')
|
||||||
get_explanation_recon_script($(this).val());
|
get_explanation_recon_script($(this).val());
|
||||||
});
|
});
|
||||||
|
|
||||||
$('select#snmp_version').change(function () {
|
$('select#snmp_version').change(function () {
|
||||||
if (this.value == "3") {
|
if (this.value == "3") {
|
||||||
$(".recon_v3").show();
|
$(".recon_v3").show();
|
||||||
$("input[name=active_snmp_v3]").val(1);
|
$("input[name=active_snmp_v3]").val(1);
|
||||||
$("input[name=snmp_community]").attr("disabled", true);
|
$("input[name=snmp_community]").attr("disabled", true);
|
||||||
$("input[name=vlan_enabled]").removeAttr("checked");
|
$("input[name=vlan_enabled]").removeAttr("checked");
|
||||||
$("input[name=vlan_enabled]").attr("disabled", true);
|
$("input[name=vlan_enabled]").attr("disabled", true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$(".recon_v3").hide();
|
$(".recon_v3").hide();
|
||||||
$("input[name=active_snmp_v3]").val(0);
|
$("input[name=active_snmp_v3]").val(0);
|
||||||
$("input[name=snmp_community]").removeAttr('disabled');
|
$("input[name=snmp_community]").removeAttr('disabled');
|
||||||
$("input[name=vlan_enabled]").removeAttr('disabled');
|
$("input[name=vlan_enabled]").removeAttr('disabled');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('select#mode').change(function() {
|
$('select#mode').change(function() {
|
||||||
var type = $(this).val();
|
var type = $(this).val();
|
||||||
if (type == 'recon_script') {
|
if (type == 'recon_script') {
|
||||||
$(".recon_script").show();
|
$(".recon_script").show();
|
||||||
$(".network_sweep").hide();
|
$(".network_sweep").hide();
|
||||||
|
|
||||||
get_explanation_recon_script($("#id_recon_script").val());
|
get_explanation_recon_script($("#id_recon_script").val());
|
||||||
}
|
}
|
||||||
else if (type == 'network_sweep') {
|
else if (type == 'network_sweep') {
|
||||||
$(".recon_script").hide();
|
$(".recon_script").hide();
|
||||||
$(".network_sweep").show();
|
$(".network_sweep").show();
|
||||||
$('.macro_field').remove();
|
$('.macro_field').remove();
|
||||||
$('select#snmp_version').trigger('change');
|
$('select#snmp_version').trigger('change');
|
||||||
}
|
}
|
||||||
}).change();
|
}).change();
|
||||||
|
|
||||||
function get_explanation_recon_script (id) {
|
function get_explanation_recon_script (id) {
|
||||||
// Stop old ajax tasks
|
// Stop old ajax tasks
|
||||||
taskManager.stopTasks();
|
taskManager.stopTasks();
|
||||||
|
|
||||||
// Show the spinners
|
// Show the spinners
|
||||||
$("#textarea_explanation").hide();
|
$("#textarea_explanation").hide();
|
||||||
$("#spinner_layout").show();
|
$("#spinner_layout").show();
|
||||||
|
|
||||||
var xhr = jQuery.ajax ({
|
var xhr = jQuery.ajax ({
|
||||||
data: {
|
data: {
|
||||||
'page': 'godmode/servers/manage_recontask_form',
|
'page': 'godmode/servers/manage_recontask_form',
|
||||||
'get_explanation': 1,
|
'get_explanation': 1,
|
||||||
'id': id,
|
'id': id,
|
||||||
'id_rt': <?php echo json_encode((int) $id_rt); ?>
|
'id_rt': `.json_encode((int) $id_rt).`
|
||||||
},
|
},
|
||||||
url: "<?php echo $config['homeurl']; ?>ajax.php",
|
url: "`.$config['homeurl'].`ajax.php",
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'text',
|
dataType: 'text',
|
||||||
complete: function (xhr, textStatus) {
|
complete: function (xhr, textStatus) {
|
||||||
@ -778,21 +813,21 @@ function get_explanation_recon_script (id) {
|
|||||||
error: function (xhr, textStatus, errorThrown) {
|
error: function (xhr, textStatus, errorThrown) {
|
||||||
console.log(errorThrown);
|
console.log(errorThrown);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
taskManager.addTask(xhr);
|
taskManager.addTask(xhr);
|
||||||
|
|
||||||
// Delete all the macro fields
|
// Delete all the macro fields
|
||||||
$('.macro_field').remove();
|
$('.macro_field').remove();
|
||||||
$("#spinner_recon_script").show();
|
$("#spinner_recon_script").show();
|
||||||
|
|
||||||
var xhr = jQuery.ajax ({
|
var xhr = jQuery.ajax ({
|
||||||
data: {
|
data: {
|
||||||
'page': 'godmode/servers/manage_recontask_form',
|
'page': 'godmode/servers/manage_recontask_form',
|
||||||
'get_recon_script_macros': 1,
|
'get_recon_script_macros': 1,
|
||||||
'id': id,
|
'id': id,
|
||||||
'id_rt': <?php echo json_encode((int) $id_rt); ?>
|
'id_rt': `.json_encode((int) $id_rt).`
|
||||||
},
|
},
|
||||||
url: "<?php echo $config['homeurl']; ?>ajax.php",
|
url: "`.$config['homeurl'].`ajax.php",
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
complete: function (xhr, textStatus) {
|
complete: function (xhr, textStatus) {
|
||||||
@ -813,22 +848,17 @@ function get_explanation_recon_script (id) {
|
|||||||
error: function (xhr, textStatus, errorThrown) {
|
error: function (xhr, textStatus, errorThrown) {
|
||||||
console.log(errorThrown);
|
console.log(errorThrown);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
taskManager.addTask(xhr);
|
taskManager.addTask(xhr);
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>`;
|
||||||
<?php
|
echo $a;
|
||||||
return null;
|
return [
|
||||||
/*
|
|
||||||
Page 4, last.
|
|
||||||
return [
|
|
||||||
'result' => $this->result,
|
'result' => $this->result,
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'msg' => $this->msg,
|
'msg' => $this->msg,
|
||||||
];
|
];
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interfaz tope gama que obliga a implementar metodos.
|
|
||||||
*/
|
|
||||||
interface Wizard
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
public function run();
|
|
||||||
|
|
||||||
|
|
||||||
public function load();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
198
pandora_console/godmode/wizards/Wizard.main.php
Normal file
198
pandora_console/godmode/wizards/Wizard.main.php
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interfaz tope gama que obliga a implementar metodos.
|
||||||
|
*/
|
||||||
|
class Wizard
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To be overwritten.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To be overwritten.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function load()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print input using functions html lib.
|
||||||
|
*
|
||||||
|
* @param array $data Input definition.
|
||||||
|
*
|
||||||
|
* @return string HTML code for desired input.
|
||||||
|
*/
|
||||||
|
public function printInput(array $data)
|
||||||
|
{
|
||||||
|
if (is_array($data) === false) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($data['type']) {
|
||||||
|
case 'text':
|
||||||
|
return html_print_input_text(
|
||||||
|
$data['name'],
|
||||||
|
$data['value'],
|
||||||
|
$data['alt'] = '',
|
||||||
|
$data['size'] = 50,
|
||||||
|
$data['maxlength'] = 255,
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : true),
|
||||||
|
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||||
|
((isset($data['required']) === true) ? $data['required'] : false),
|
||||||
|
((isset($data['function']) === true) ? $data['function'] : ''),
|
||||||
|
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||||
|
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
|
||||||
|
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '')
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'image':
|
||||||
|
return html_print_input_image(
|
||||||
|
$data['name'],
|
||||||
|
$data['src'],
|
||||||
|
$data['value'],
|
||||||
|
((isset($data['style']) === true) ? $data['style'] : ''),
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : false),
|
||||||
|
((isset($data['options']) === true) ? $data['options'] : false)
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'text_extended':
|
||||||
|
return html_print_input_text_extended(
|
||||||
|
$data['name'],
|
||||||
|
$data['value'],
|
||||||
|
$data['id'],
|
||||||
|
$data['alt'],
|
||||||
|
$data['size'],
|
||||||
|
$data['maxlength'],
|
||||||
|
$data['disabled'],
|
||||||
|
$data['script'],
|
||||||
|
$data['attributes'],
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : false),
|
||||||
|
((isset($data['password']) === true) ? $data['password'] : false),
|
||||||
|
((isset($data['function']) === true) ? $data['function'] : '')
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'password':
|
||||||
|
return html_print_input_password(
|
||||||
|
$data['name'],
|
||||||
|
$data['value'],
|
||||||
|
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||||
|
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||||
|
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : false),
|
||||||
|
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||||
|
((isset($data['required']) === true) ? $data['required'] : false),
|
||||||
|
((isset($data['class']) === true) ? $data['class'] : '')
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'text':
|
||||||
|
return html_print_input_text(
|
||||||
|
$data['name'],
|
||||||
|
$data['value'],
|
||||||
|
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||||
|
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||||
|
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : false),
|
||||||
|
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||||
|
((isset($data['required']) === true) ? $data['required'] : false),
|
||||||
|
((isset($data['function']) === true) ? $data['function'] : ''),
|
||||||
|
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||||
|
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
|
||||||
|
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '')
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'image':
|
||||||
|
return html_print_input_image(
|
||||||
|
$data['name'],
|
||||||
|
$data['src'],
|
||||||
|
$data['value'],
|
||||||
|
((isset($data['style']) === true) ? $data['style'] : ''),
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : false),
|
||||||
|
((isset($data['options']) === true) ? $data['options'] : false)
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'hidden':
|
||||||
|
return html_print_input_hidden(
|
||||||
|
$data['name'],
|
||||||
|
$data['value'],
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : false),
|
||||||
|
((isset($data['class']) === true) ? $data['class'] : false)
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'hidden_extended':
|
||||||
|
return html_print_input_hidden_extended(
|
||||||
|
$data['name'],
|
||||||
|
$data['value'],
|
||||||
|
$data['id'],
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : false),
|
||||||
|
((isset($data['class']) === true) ? $data['class'] : false)
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'color':
|
||||||
|
return html_print_input_color(
|
||||||
|
$data['name'],
|
||||||
|
$data['value'],
|
||||||
|
((isset($data['class']) === true) ? $data['class'] : false),
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : false)
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'file':
|
||||||
|
return html_print_input_file(
|
||||||
|
$data['name'],
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : false),
|
||||||
|
((isset($data['options']) === true) ? $data['options'] : false)
|
||||||
|
);
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Ignore.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a form.
|
||||||
|
*
|
||||||
|
* @param array $data Definition of target form to be printed.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function printForm(array $data)
|
||||||
|
{
|
||||||
|
$form = $data['form'];
|
||||||
|
$inputs = $data['inputs'];
|
||||||
|
$js = $data['js'];
|
||||||
|
|
||||||
|
$output = '<form action="'.$form['action'].'" method="'.$form['method'];
|
||||||
|
$output .= '" '.$form['extra'].'>';
|
||||||
|
|
||||||
|
$ouput .= '<ul>';
|
||||||
|
|
||||||
|
foreach ($inputs as $input) {
|
||||||
|
$output .= '<li><label>'.$input['label'].'</label>';
|
||||||
|
$output .= '<label>'.$this->printInput($input['var']).'</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= '</ul>';
|
||||||
|
$output .= '</form>';
|
||||||
|
$output .= $js;
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 5.1 KiB |
Loading…
x
Reference in New Issue
Block a user