From bde52df2e846afd59e8d3a475a9ba03545295d7f Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Fri, 30 Oct 2020 13:25:33 +0100 Subject: [PATCH] Added datalist for target ip --- .../include/class/AgentWizard.class.php | 36 ++++++++++++++ pandora_console/include/class/HTML.class.php | 1 + pandora_console/include/functions_html.php | 49 ++++++++++++++++++- 3 files changed, 84 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/class/AgentWizard.class.php b/pandora_console/include/class/AgentWizard.class.php index 7f23e84894..09bf8168d4 100644 --- a/pandora_console/include/class/AgentWizard.class.php +++ b/pandora_console/include/class/AgentWizard.class.php @@ -293,6 +293,29 @@ class AgentWizard extends HTML $this->idAgent = get_parameter('id_agente', ''); $this->idPolicy = get_parameter('id', ''); $this->targetIp = get_parameter('targetIp', ''); + + if (!empty($this->idAgent)) { + $array_aux = db_get_all_rows_sql( + sprintf( + 'SELECT ip FROM taddress ta + INNER JOIN taddress_agent taa ON taa.id_a = ta.id_a + WHERE taa.id_agent = %d', + $this->idAgent + ) + ); + + if (!empty($array_aux)) { + $this->datalist = []; + foreach ($array_aux as $key => $value) { + $this->datalist[] = $value['ip']; + } + } + + if (count($this->datalist) === 1 && $this->targetIp === '') { + $this->targetIp = $this->datalist[0]; + } + } + $this->server = (int) get_parameter('server', '1'); if ($this->server !== 0) { $this->serverType = (int) db_get_value( @@ -563,6 +586,18 @@ class AgentWizard extends HTML ], ]; + if (!empty($this->datalist)) { + $inputs[] = [ + 'id' => 'li_address_list', + 'arguments' => [ + 'name' => 'address_list', + 'type' => 'datalist', + 'value' => $this->datalist, + 'return' => true, + ], + ]; + } + $inputs[] = [ 'label' => __('Target IP'), 'id' => 'txt-targetIp', @@ -573,6 +608,7 @@ class AgentWizard extends HTML 'class' => '', 'value' => $this->targetIp, 'return' => true, + 'list' => 'address_list', ], ]; diff --git a/pandora_console/include/class/HTML.class.php b/pandora_console/include/class/HTML.class.php index 376afc4bfd..41ceabf5ab 100644 --- a/pandora_console/include/class/HTML.class.php +++ b/pandora_console/include/class/HTML.class.php @@ -547,6 +547,7 @@ class HTML } else { if ($input['arguments']['type'] != 'hidden' && $input['arguments']['type'] != 'hidden_extended' + && $input['arguments']['type'] != 'datalist' ) { if (!$direct) { $output .= '
  • '; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index c61d62d686..2c71835165 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2032,6 +2032,7 @@ function html_print_input_text_extended( 'required', 'autocomplete', 'form', + 'list', ]; $output = ''; + foreach ($values as $key => $value) { + $result .= '