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
|
||||
|
||||
require_once __DIR__.'/Wizard.interface.php';
|
||||
require_once __DIR__.'/Wizard.main.php';
|
||||
|
||||
/**
|
||||
* Undocumented class
|
||||
*/
|
||||
class HostDevices implements Wizard
|
||||
class HostDevices extends Wizard
|
||||
{
|
||||
|
||||
/**
|
||||
@ -15,18 +15,53 @@ class HostDevices implements Wizard
|
||||
*/
|
||||
public $values = [];
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
public $result;
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
public $icon;
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
public $label;
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
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 = '';
|
||||
$id_network_profile = 0;
|
||||
$id_os = -1;
|
||||
// Any
|
||||
// Any.
|
||||
$recon_ports = '';
|
||||
// Any
|
||||
// Any.
|
||||
$field1 = '';
|
||||
$field2 = '';
|
||||
$field3 = '';
|
||||
@ -508,7 +543,7 @@ class HostDevices implements Wizard
|
||||
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][1] = html_print_checkbox('snmp_enabled', 1, $snmp_enabled, true);
|
||||
|
||||
@ -673,7 +708,7 @@ class HostDevices implements Wizard
|
||||
echo '</form>';
|
||||
|
||||
ui_require_javascript_file('pandora_modules');
|
||||
?>
|
||||
$a = `
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
$(document).ready (function () {
|
||||
@ -763,9 +798,9 @@ function get_explanation_recon_script (id) {
|
||||
'page': 'godmode/servers/manage_recontask_form',
|
||||
'get_explanation': 1,
|
||||
'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',
|
||||
dataType: 'text',
|
||||
complete: function (xhr, textStatus) {
|
||||
@ -790,9 +825,9 @@ function get_explanation_recon_script (id) {
|
||||
'page': 'godmode/servers/manage_recontask_form',
|
||||
'get_recon_script_macros': 1,
|
||||
'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',
|
||||
dataType: 'json',
|
||||
complete: function (xhr, textStatus) {
|
||||
@ -817,18 +852,13 @@ function get_explanation_recon_script (id) {
|
||||
taskManager.addTask(xhr);
|
||||
}
|
||||
|
||||
</script>
|
||||
<?php
|
||||
return null;
|
||||
/*
|
||||
Page 4, last.
|
||||
</script>`;
|
||||
echo $a;
|
||||
return [
|
||||
'result' => $this->result,
|
||||
'id' => $this->id,
|
||||
'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