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'),
],
]
],
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) {
// Avoid to print header out of wizard.
$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

View File

@ -191,21 +191,20 @@ class Wizard
* Builder for breadcrum
*
* @param array $urls Array of urls to be stored in breadcrum.
* @param boolean $add True if breadcrum should be added instead of
* overwrite it.
* @param boolean $add True if breadcrum should be added
* instead of overwrite it.
*
* @return void
*/
public function prepareBreadcrum(array $urls, bool $add=false, bool $separator_beginning=false)
{
public function prepareBreadcrum(
array $urls,
bool $add=false
) {
$bc = [];
$i = 0;
$count = 0;
$array_size = count($urls);
$array_size = (count($urls) - 1);
foreach ($urls as $url) {
$count++;
if ($url['selected'] == 1) {
$class = 'selected';
} else {
@ -213,20 +212,10 @@ class Wizard
}
$bc[$i] = '';
if ($separator_beginning === true) {
$bc[$i] .= '<span class="breadcrumb_link">&nbsp/&nbsp</span>';
}
$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><a class="breadcrumb_link '.$class.'" href="'.$url['link'].'">';
$bc[$i] .= $url['label'];
$bc[$i] .= '</a>';
$bc[$i] .= '</span>';
$i++;
}
@ -235,7 +224,6 @@ class Wizard
} else {
$this->setBreadcrum($bc);
}
}
@ -275,7 +263,10 @@ class Wizard
*/
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_array=[],
$sufix=false,
$checked=[]
$checked=[],
$return=false
) {
static $url = false;
$output = '';
// Get the base URL for images.
if ($url === false) {
$url = ui_get_full_url('operation/tree', false, false, false);
@ -73,9 +76,9 @@ function snmp_browser_print_tree(
$last_array[$depth] = $last;
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 {
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) {
@ -83,73 +86,89 @@ function snmp_browser_print_tree(
$sub_id = time().rand(0, getrandmax());
// 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.
for ($i = 1; $i <= $depth; $i++) {
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 {
echo '<img src="'.$url.'/branch.png" style="vertical-align: middle;">';
$output .= '<img src="'.$url.'/branch.png" style="vertical-align: middle;">';
}
}
// Branch.
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 ($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 {
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) {
echo '<img src="'.$url.'/last_closed.png" style="vertical-align: middle;">';
$output .= '<img src="'.$url.'/last_closed.png" style="vertical-align: middle;">';
} 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.
else {
if ($depth == 0 && $count == 0) {
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 {
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) {
echo '<img src="'.$url.'/last_leaf.png" style="vertical-align: middle;">';
$output .= '<img src="'.$url.'/last_leaf.png" style="vertical-align: middle;">';
} 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!
if (isset($sub_level['__OID__'])) {
echo "<a onfocus='javascript: this.blur();' href='javascript: snmpGet(\"".addslashes($sub_level['__OID__'])."\");'>";
echo '<img src="'.$url.'/../../images/eye.png" style="vertical-align: middle;">';
echo '</a>';
$output .= "<a onfocus='javascript: this.blur();' href='javascript: snmpGet(\"".addslashes($sub_level['__OID__'])."\");'>";
$output .= '<img src="'.$url.'/../../images/eye.png" style="vertical-align: middle;">';
$output .= '</a>';
}
$checkbox_name_sufix = ($sufix === true) ? '_'.$level : '';
$checkbox_name = 'create_'.$sub_id.$checkbox_name_sufix;
$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__'])) {
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.
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++;
}
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 ($progress, $step);
@ -1595,7 +1595,7 @@ sub scan($) {
if ($self->{'task_data'}->{'type'} == DISCOVERY_APP_MYSQL
|| $self->{'task_data'}->{'type'} == DISCOVERY_APP_ORACLE) {
# Database scan.
return $self->db_scan();
return $self->app_scan();
}
}