WIP Discovery RDS

Former-commit-id: fba3f7dbd44ca131404aa2d3986d3925b9754382
This commit is contained in:
fbsanchez 2019-04-09 18:33:02 +02:00
parent d5b1ac5565
commit e59ce5412c
4 changed files with 75 additions and 52 deletions

View File

@ -149,7 +149,8 @@ class HostDevices extends Wizard
), ),
'label' => __('Discovery'), 'label' => __('Discovery'),
], ],
] ],
true
); );
ui_print_page_header(__('Host & devices'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true)); ui_print_page_header(__('Host & devices'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true));
@ -533,7 +534,19 @@ class HostDevices extends Wizard
if ($this->page < $this->maxPagesNetScan) { if ($this->page < $this->maxPagesNetScan) {
// Avoid to print header out of wizard. // Avoid to print header out of wizard.
$this->prepareBreadcrum($breadcrum); $this->prepareBreadcrum($breadcrum);
ui_print_page_header(__('NetScan'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true)); ui_print_page_header(
__('NetScan'),
'',
false,
'',
true,
'',
false,
'',
GENERIC_SIZE_TEXT,
'',
$this->printHeader(true)
);
} }
if (isset($this->page) === true if (isset($this->page) === true

View File

@ -191,21 +191,20 @@ class Wizard
* Builder for breadcrum * Builder for breadcrum
* *
* @param array $urls Array of urls to be stored in breadcrum. * @param array $urls Array of urls to be stored in breadcrum.
* @param boolean $add True if breadcrum should be added instead of * @param boolean $add True if breadcrum should be added
* overwrite it. * instead of overwrite it.
* *
* @return void * @return void
*/ */
public function prepareBreadcrum(array $urls, bool $add=false, bool $separator_beginning=false) public function prepareBreadcrum(
{ array $urls,
bool $add=false
) {
$bc = []; $bc = [];
$i = 0; $i = 0;
$count = 0; $array_size = (count($urls) - 1);
$array_size = count($urls);
foreach ($urls as $url) { foreach ($urls as $url) {
$count++;
if ($url['selected'] == 1) { if ($url['selected'] == 1) {
$class = 'selected'; $class = 'selected';
} else { } else {
@ -213,20 +212,10 @@ class Wizard
} }
$bc[$i] = ''; $bc[$i] = '';
$bc[$i] .= '<span><a class="breadcrumb_link '.$class.'" href="'.$url['link'].'">';
if ($separator_beginning === true) { $bc[$i] .= $url['label'];
$bc[$i] .= '<span class="breadcrumb_link">&nbsp/&nbsp</span>'; $bc[$i] .= '</a>';
}
$bc[$i] .= '<span><a class="breadcrumb_link '.$class.'" href="'.$url['link'].'">';
$bc[$i] .= $url['label'];
$bc[$i] .= '</a>';
if ($count < $array_size) {
$bc[$i] .= '<span class="breadcrumb_link">&nbsp/&nbsp</span>';
}
$bc[$i] .= '</span>'; $bc[$i] .= '</span>';
$i++; $i++;
} }
@ -235,7 +224,6 @@ class Wizard
} else { } else {
$this->setBreadcrum($bc); $this->setBreadcrum($bc);
} }
} }
@ -275,7 +263,10 @@ class Wizard
*/ */
public function printBreadcrum() public function printBreadcrum()
{ {
return implode('', $this->breadcrum); return implode(
'<span class="breadcrumb_link">&nbsp/&nbsp</span>',
$this->breadcrum
);
} }

View File

@ -54,10 +54,13 @@ function snmp_browser_print_tree(
$last=0, $last=0,
$last_array=[], $last_array=[],
$sufix=false, $sufix=false,
$checked=[] $checked=[],
$return=false
) { ) {
static $url = false; static $url = false;
$output = '';
// Get the base URL for images. // Get the base URL for images.
if ($url === false) { if ($url === false) {
$url = ui_get_full_url('operation/tree', false, false, false); $url = ui_get_full_url('operation/tree', false, false, false);
@ -73,9 +76,9 @@ function snmp_browser_print_tree(
$last_array[$depth] = $last; $last_array[$depth] = $last;
if ($depth > 0) { if ($depth > 0) {
echo "<ul id='ul_$id' style='margin: 0; padding: 0; display: none'>\n"; $output .= "<ul id='ul_$id' style='margin: 0; padding: 0; display: none'>\n";
} else { } else {
echo "<ul id='ul_$id' style='margin: 0; padding: 0;'>\n"; $output .= "<ul id='ul_$id' style='margin: 0; padding: 0;'>\n";
} }
foreach ($tree['__LEAVES__'] as $level => $sub_level) { foreach ($tree['__LEAVES__'] as $level => $sub_level) {
@ -83,73 +86,89 @@ function snmp_browser_print_tree(
$sub_id = time().rand(0, getrandmax()); $sub_id = time().rand(0, getrandmax());
// Display the branch. // Display the branch.
echo "<li id='li_$sub_id' style='margin: 0; padding: 0;'>"; $output .= "<li id='li_$sub_id' style='margin: 0; padding: 0;'>";
// Indent sub branches. // Indent sub branches.
for ($i = 1; $i <= $depth; $i++) { for ($i = 1; $i <= $depth; $i++) {
if ($last_array[$i] == 1) { if ($last_array[$i] == 1) {
echo '<img src="'.$url.'/no_branch.png" style="vertical-align: middle;">'; $output .= '<img src="'.$url.'/no_branch.png" style="vertical-align: middle;">';
} else { } else {
echo '<img src="'.$url.'/branch.png" style="vertical-align: middle;">'; $output .= '<img src="'.$url.'/branch.png" style="vertical-align: middle;">';
} }
} }
// Branch. // Branch.
if (! empty($sub_level['__LEAVES__'])) { if (! empty($sub_level['__LEAVES__'])) {
echo "<a id='anchor_$sub_id' onfocus='javascript: this.blur();' href='javascript: toggleTreeNode(\"$sub_id\", \"$id\");'>"; $output .= "<a id='anchor_$sub_id' onfocus='javascript: this.blur();' href='javascript: toggleTreeNode(\"$sub_id\", \"$id\");'>";
if ($depth == 0 && $count == 0) { if ($depth == 0 && $count == 0) {
if ($count == $total) { if ($count == $total) {
echo '<img src="'.$url.'/one_closed.png" style="vertical-align: middle;">'; $output .= '<img src="'.$url.'/one_closed.png" style="vertical-align: middle;">';
} else { } else {
echo '<img src="'.$url.'/first_closed.png" style="vertical-align: middle;">'; $output .= '<img src="'.$url.'/first_closed.png" style="vertical-align: middle;">';
} }
} else if ($count == $total) { } else if ($count == $total) {
echo '<img src="'.$url.'/last_closed.png" style="vertical-align: middle;">'; $output .= '<img src="'.$url.'/last_closed.png" style="vertical-align: middle;">';
} else { } else {
echo '<img src="'.$url.'/closed.png" style="vertical-align: middle;">'; $output .= '<img src="'.$url.'/closed.png" style="vertical-align: middle;">';
} }
echo '</a>'; $output .= '</a>';
} }
// Leave. // Leave.
else { else {
if ($depth == 0 && $count == 0) { if ($depth == 0 && $count == 0) {
if ($count == $total) { if ($count == $total) {
echo '<img src="'.$url.'/no_branch.png" style="vertical-align: middle;">'; $output .= '<img src="'.$url.'/no_branch.png" style="vertical-align: middle;">';
} else { } else {
echo '<img src="'.$url.'/first_leaf.png" style="vertical-align: middle;">'; $output .= '<img src="'.$url.'/first_leaf.png" style="vertical-align: middle;">';
} }
} else if ($count == $total) { } else if ($count == $total) {
echo '<img src="'.$url.'/last_leaf.png" style="vertical-align: middle;">'; $output .= '<img src="'.$url.'/last_leaf.png" style="vertical-align: middle;">';
} else { } else {
echo '<img src="'.$url.'/leaf.png" style="vertical-align: middle;">'; $output .= '<img src="'.$url.'/leaf.png" style="vertical-align: middle;">';
} }
} }
// Branch or leave with branches! // Branch or leave with branches!
if (isset($sub_level['__OID__'])) { if (isset($sub_level['__OID__'])) {
echo "<a onfocus='javascript: this.blur();' href='javascript: snmpGet(\"".addslashes($sub_level['__OID__'])."\");'>"; $output .= "<a onfocus='javascript: this.blur();' href='javascript: snmpGet(\"".addslashes($sub_level['__OID__'])."\");'>";
echo '<img src="'.$url.'/../../images/eye.png" style="vertical-align: middle;">'; $output .= '<img src="'.$url.'/../../images/eye.png" style="vertical-align: middle;">';
echo '</a>'; $output .= '</a>';
} }
$checkbox_name_sufix = ($sufix === true) ? '_'.$level : ''; $checkbox_name_sufix = ($sufix === true) ? '_'.$level : '';
$checkbox_name = 'create_'.$sub_id.$checkbox_name_sufix; $checkbox_name = 'create_'.$sub_id.$checkbox_name_sufix;
$status = (!empty($checked) && isset($checked[$level])); $status = (!empty($checked) && isset($checked[$level]));
echo html_print_checkbox($checkbox_name, 0, $status, true, false, '').'&nbsp;<span>'.$level.'</span>'; $output .= html_print_checkbox($checkbox_name, 0, $status, true, false, '').'&nbsp;<span>'.$level.'</span>';
if (isset($sub_level['__VALUE__'])) { if (isset($sub_level['__VALUE__'])) {
echo '<span class="value" style="display: none;">&nbsp;=&nbsp;'.$sub_level['__VALUE__'].'</span>'; $output .= '<span class="value" style="display: none;">&nbsp;=&nbsp;'.$sub_level['__VALUE__'].'</span>';
} }
echo '</li>'; $output .= '</li>';
// Recursively print sub levels. // Recursively print sub levels.
snmp_browser_print_tree($sub_level, $sub_id, ($depth + 1), ($count == $total ? 1 : 0), $last_array, $sufix, $checked); $output .= snmp_browser_print_tree(
$sub_level,
$sub_id,
($depth + 1),
($count == $total ? 1 : 0),
$last_array,
$sufix,
$checked,
$return
);
$count++; $count++;
} }
echo '</ul>'; $output .= '</ul>';
if ($return == false) {
echo $output;
}
return $output;
} }

View File

@ -1427,9 +1427,9 @@ sub scan_subnet($) {
} }
########################################################################## ##########################################################################
# Perform a DB scan. # Perform an Application scan.
########################################################################## ##########################################################################
sub db_scan($) { sub app_scan($) {
my ($self) = @_; my ($self) = @_;
my ($progress, $step); my ($progress, $step);
@ -1595,7 +1595,7 @@ sub scan($) {
if ($self->{'task_data'}->{'type'} == DISCOVERY_APP_MYSQL if ($self->{'task_data'}->{'type'} == DISCOVERY_APP_MYSQL
|| $self->{'task_data'}->{'type'} == DISCOVERY_APP_ORACLE) { || $self->{'task_data'}->{'type'} == DISCOVERY_APP_ORACLE) {
# Database scan. # Database scan.
return $self->db_scan(); return $self->app_scan();
} }
} }