Use the CSV extension to import CSV on host and devices

Former-commit-id: ed95b09992ee681e35e7f934b8a8ac70c83bc8be
This commit is contained in:
fermin831 2019-02-14 10:30:01 +01:00
parent 10a37c313c
commit 57991495e4
3 changed files with 37 additions and 45 deletions

View File

@ -1,8 +1,19 @@
<?php
global $config;
ui_print_page_header(__('Discover'), 'wizards/hostDevices.png', false, '', true);
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;
}
ui_print_page_header(__('Discover'), 'wizards/hostDevices.png', false, '', true);
/**
* Undocumented function

View File

@ -70,7 +70,10 @@ class HostDevices implements Wizard
$mode = get_parameter('mode', null);
if ($mode === null) {
echo '<a href="'.$this->url.'&mode=importcsv" alt="importcsv">Importar csv</a>';
if (extensions_is_enabled_extension('csv_import')) {
echo '<a href="'.$this->url.'&mode=importcsv" alt="importcsv">Importar csv</a>';
}
echo '<a href="'.$this->url.'&mode=netscan" alt="netscan">Escanear red</a>';
return;
}
@ -116,50 +119,27 @@ class HostDevices implements Wizard
public function runCSV()
{
global $config;
echo 'formulario csv';
if (isset($this->page) === false || $this->page === 0) {
$this->page = 0;
$test = get_parameter('test', null);
// Check user answers.
if ($test !== null) {
// $this->process_page_0($respuestas_usuario)
$this->page++;
header(
'Location: '.$this->url.'&page='.$this->page
);
} else {
// Mostrar pagina 0.
echo 'Aqui vamos a empezar a construir el formulario.';
?>
<form action="#" method="POST">
<input name='test' type="text"/>
</form>
<?php
}
} else if ($this->page == 1) {
// Code...
$this->page++;
if (!check_acl($config['id_user'], 0, 'AW')
) {
db_pandora_audit(
'ACL Violation',
'Trying to access db status'
);
include 'general/noaccess.php';
return;
header('Location: index.php?class=HostDevices&page='.$this->page);
} else if ($this->page == 2) {
// Code...
$this->page++;
header('Location: index.php?class=HostDevices&page='.$this->page);
} else if ($this->page == 3) {
// Code...
$this->page++;
header('Location: /XXX/discovery/index.php?class=HostDevices&page='.$this->page);
}
// Page 4, last.
return [
'result' => $this->result,
'id' => $this->id,
'msg' => $this->msg,
];
if (!extensions_is_enabled_extension('csv_import')) {
ui_print_error_message(
[
'message' => __('Extension CSV Import is not enabled.'),
'no_close' => true,
]
);
return;
}
include_once $config['homedir'].'/enterprise/extensions/csv_import/main.php';
}
@ -818,8 +798,8 @@ function get_explanation_recon_script (id) {
}
</script>
<?php
return null;
<?php
return null;
/*
Page 4, last.
return [

View File

@ -178,7 +178,8 @@ function extensions_get_extensions($enterprise=false, $rel_path='')
function extensions_is_enabled_extension($name)
{
global $config;
return isset($config['extensions'][$name]);
return isset($config['extensions'][$name])
|| isset($config['extensions'][$name.'.php']);
}