2019-02-12 14:39:01 +01:00
|
|
|
<?php
|
|
|
|
|
2019-02-14 10:56:25 +01:00
|
|
|
require_once __DIR__.'/Wizard.main.php';
|
2019-02-12 14:39:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Undocumented class
|
|
|
|
*/
|
2019-02-14 10:56:25 +01:00
|
|
|
class HostDevices extends Wizard
|
2019-02-12 14:39:01 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Undocumented variable
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $values = [];
|
|
|
|
|
2019-02-14 10:56:25 +01:00
|
|
|
/**
|
|
|
|
* Undocumented variable
|
|
|
|
*
|
|
|
|
* @var [type]
|
|
|
|
*/
|
2019-02-12 14:39:01 +01:00
|
|
|
public $result;
|
|
|
|
|
2019-02-14 10:56:25 +01:00
|
|
|
/**
|
|
|
|
* Undocumented variable
|
|
|
|
*
|
|
|
|
* @var [type]
|
|
|
|
*/
|
2019-02-12 14:39:01 +01:00
|
|
|
public $id;
|
|
|
|
|
2019-02-14 10:56:25 +01:00
|
|
|
/**
|
|
|
|
* Undocumented variable
|
|
|
|
*
|
|
|
|
* @var [type]
|
|
|
|
*/
|
2019-02-12 14:39:01 +01:00
|
|
|
public $msg;
|
|
|
|
|
2019-02-14 10:56:25 +01:00
|
|
|
/**
|
|
|
|
* Undocumented variable
|
|
|
|
*
|
|
|
|
* @var [type]
|
|
|
|
*/
|
2019-02-12 14:39:01 +01:00
|
|
|
public $icon;
|
|
|
|
|
2019-02-14 10:56:25 +01:00
|
|
|
/**
|
|
|
|
* Undocumented variable
|
|
|
|
*
|
|
|
|
* @var [type]
|
|
|
|
*/
|
2019-02-12 14:39:01 +01:00
|
|
|
public $label;
|
|
|
|
|
2019-02-14 10:56:25 +01:00
|
|
|
/**
|
|
|
|
* Undocumented variable
|
|
|
|
*
|
|
|
|
* @var [type]
|
|
|
|
*/
|
2019-02-12 14:39:01 +01:00
|
|
|
public $url;
|
|
|
|
|
2019-02-14 10:56:25 +01:00
|
|
|
/**
|
|
|
|
* Undocumented variable
|
|
|
|
*
|
|
|
|
* @var [type]
|
|
|
|
*/
|
2019-02-12 14:39:01 +01:00
|
|
|
public $page;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Undocumented function.
|
|
|
|
*
|
2019-02-14 11:32:07 +01:00
|
|
|
* @param integer $page Start page, by default 0.
|
2019-02-12 14:39:01 +01:00
|
|
|
* @param string $msg Mensajito.
|
|
|
|
* @param string $icon Mensajito.
|
|
|
|
* @param string $label Mensajito.
|
|
|
|
*
|
|
|
|
* @return class HostDevices
|
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
int $page=0,
|
|
|
|
string $msg='hola',
|
|
|
|
string $icon='hostDevices.png',
|
|
|
|
string $label='Host & Devices'
|
|
|
|
) {
|
2019-02-14 11:32:07 +01:00
|
|
|
$this->setBreadcrum([]);
|
|
|
|
|
2019-02-12 14:39:01 +01:00
|
|
|
$this->id = null;
|
|
|
|
$this->msg = $msg;
|
|
|
|
$this->icon = $icon;
|
|
|
|
$this->label = $label;
|
|
|
|
$this->page = $page;
|
|
|
|
$this->url = ui_get_full_url(
|
|
|
|
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd'
|
|
|
|
);
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Undocumented function
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function run()
|
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
$mode = get_parameter('mode', null);
|
|
|
|
|
|
|
|
if ($mode === null) {
|
2019-02-14 11:32:07 +01:00
|
|
|
$this->setBreadcrum(['<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd">Host&devices</a>']);
|
|
|
|
$this->printHeader();
|
2019-02-14 10:30:01 +01:00
|
|
|
if (extensions_is_enabled_extension('csv_import')) {
|
|
|
|
echo '<a href="'.$this->url.'&mode=importcsv" alt="importcsv">Importar csv</a>';
|
|
|
|
}
|
|
|
|
|
2019-02-12 14:39:01 +01:00
|
|
|
echo '<a href="'.$this->url.'&mode=netscan" alt="netscan">Escanear red</a>';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($mode == 'importcsv') {
|
2019-02-14 11:32:07 +01:00
|
|
|
$this->setBreadcrum(
|
|
|
|
[
|
|
|
|
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd">Host&devices</a>',
|
|
|
|
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=csv">Import CSV</a>',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
$this->printHeader();
|
2019-02-12 14:39:01 +01:00
|
|
|
return $this->runCSV();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($mode == 'netscan') {
|
2019-02-14 11:32:07 +01:00
|
|
|
$this->setBreadcrum(
|
|
|
|
[
|
|
|
|
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd">Host&devices</a>',
|
|
|
|
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan">Net scan</a>',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
$this->printHeader();
|
2019-02-12 14:39:01 +01:00
|
|
|
return $this->runNetScan();
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if environment is ready,
|
|
|
|
* returns array
|
|
|
|
* icon: icon to be displayed
|
|
|
|
* label: label to be displayed
|
|
|
|
*
|
|
|
|
* @return array With data.
|
|
|
|
**/
|
|
|
|
public function load()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'icon' => $this->icon,
|
|
|
|
'label' => $this->label,
|
|
|
|
'url' => $this->url,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-14 10:56:25 +01:00
|
|
|
// Extra methods.
|
2019-02-12 14:39:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Undocumented function
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function runCSV()
|
|
|
|
{
|
|
|
|
global $config;
|
2019-02-14 11:32:07 +01:00
|
|
|
|
2019-02-14 10:30:01 +01:00
|
|
|
if (!check_acl($config['id_user'], 0, 'AW')
|
|
|
|
) {
|
|
|
|
db_pandora_audit(
|
|
|
|
'ACL Violation',
|
|
|
|
'Trying to access db status'
|
|
|
|
);
|
|
|
|
include 'general/noaccess.php';
|
2019-02-12 14:39:01 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-02-14 10:30:01 +01:00
|
|
|
if (!extensions_is_enabled_extension('csv_import')) {
|
|
|
|
ui_print_error_message(
|
|
|
|
[
|
|
|
|
'message' => __('Extension CSV Import is not enabled.'),
|
|
|
|
'no_close' => true,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
2019-02-12 14:39:01 +01:00
|
|
|
|
2019-02-14 10:30:01 +01:00
|
|
|
include_once $config['homedir'].'/enterprise/extensions/csv_import/main.php';
|
2019-02-12 14:39:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Undocumented function
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function runNetScan()
|
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
check_login();
|
|
|
|
|
|
|
|
if (! check_acl($config['id_user'], 0, 'PM')) {
|
|
|
|
db_pandora_audit(
|
|
|
|
'ACL Violation',
|
|
|
|
'Trying to access Agent Management'
|
|
|
|
);
|
|
|
|
include 'general/noaccess.php';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
include_once $config['homedir'].'/include/functions_users.php';
|
|
|
|
|
|
|
|
$user_groups = users_get_groups(false, 'AW', true, false, null, 'id_grupo');
|
|
|
|
$user_groups = array_keys($user_groups);
|
|
|
|
|
2019-02-14 11:53:06 +01:00
|
|
|
if (isset($this->page) === false
|
|
|
|
|| $this->page == 0
|
|
|
|
) {
|
|
|
|
$form = [];
|
|
|
|
|
|
|
|
// Input task name.
|
|
|
|
// Input Discovery Server.
|
|
|
|
// Input Network.
|
|
|
|
// Input interval.
|
|
|
|
// Input group.
|
|
|
|
$form['inputs'] = [
|
|
|
|
[
|
|
|
|
'label' => __('Task name'),
|
|
|
|
'arguments' => [
|
|
|
|
'name' => 'name',
|
|
|
|
'value' => '',
|
|
|
|
'type' => 'text',
|
|
|
|
'size' => 25,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
$this->printForm($form);
|
2019-02-12 14:39:01 +01:00
|
|
|
}
|
|
|
|
|
2019-02-14 11:53:06 +01:00
|
|
|
if ($this->page == 100) {
|
|
|
|
return [
|
|
|
|
'result' => $this->result,
|
|
|
|
'id' => $this->id,
|
|
|
|
'msg' => $this->msg,
|
|
|
|
];
|
2019-02-12 14:39:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|