From a87de02e0bb532c1198c827bf73035076a79eef2 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Wed, 8 Jun 2016 19:15:43 +0200 Subject: [PATCH] Removed the tinyMCE from the agent description and custom fields. Removed the url injection feature from the agent description. Added the url injection feature to the agent custom fields of some sections (cherry picked from commit c4bbe38b69e9b076b45871bc35b8c861b8ed2cc9) --- .../godmode/agentes/agent_manager.php | 55 +++++-------------- .../godmode/massive/massive_edit_agents.php | 11 +++- pandora_console/include/functions_events.php | 4 +- .../include/functions_reporting.php | 3 +- .../include/functions_treeview.php | 2 +- pandora_console/include/functions_ui.php | 7 +-- pandora_console/mobile/operation/agent.php | 2 +- .../operation/agentes/agent_fields.php | 3 + .../operation/agentes/estado_agente.php | 2 +- .../agentes/estado_generalagente.php | 9 ++- 10 files changed, 42 insertions(+), 56 deletions(-) diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 46403f256f..2b51cac09e 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -277,7 +277,7 @@ $table->data[6][1] = html_print_select (servers_get_names (), // Description $table->data[7][0] = __('Description'); $table->data[7][1] = html_print_input_text ('comentarios', $comentarios, - '', 45, 255, true); + '', 45, 200, true); html_print_table ($table); unset($table); @@ -417,6 +417,13 @@ if ($fields === false) $fields = array(); foreach ($fields as $field) { $data[0] = ''.$field['name'].''; + $data[0] .= ui_print_help_tip( + __('This field allows url insertion using the BBCode\'s url tag') + . '.
' + . __('The format is: [url=\'url to navigate\']\'text to show\'[/url]') + . '.

' + . __('e.g.: [url=pandorafms.org]Pandora FMS Community[/url]') + , true); $custom_value = db_get_value_filter('description', 'tagent_custom_data', @@ -452,7 +459,6 @@ echo ""; if ($id_agente) { - html_print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"'); html_print_input_hidden ('update_agent', 1); @@ -465,17 +471,16 @@ else { } echo ''; -ui_require_jquery_file ('pandora.controls'); -ui_require_jquery_file ('ajaxqueue'); -ui_require_jquery_file ('bgiframe'); -ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/'); +ui_require_jquery_file('pandora.controls'); +ui_require_jquery_file('ajaxqueue'); +ui_require_jquery_file('bgiframe'); + ?> + diff --git a/pandora_console/godmode/massive/massive_edit_agents.php b/pandora_console/godmode/massive/massive_edit_agents.php index 5f32531e87..d89c0dcef0 100755 --- a/pandora_console/godmode/massive/massive_edit_agents.php +++ b/pandora_console/godmode/massive/massive_edit_agents.php @@ -423,6 +423,13 @@ if ($fields === false) $fields = array(); foreach ($fields as $field) { $data[0] = ''.$field['name'].''; + $data[0] .= ui_print_help_tip( + __('This field allows url insertion using the BBCode\'s url tag') + . '.
' + . __('The format is: [url=\'url to navigate\']\'text to show\'[/url]') + . '.

' + . __('e.g.: [url=pandorafms.org]Pandora FMS Community[/url]') + , true); $custom_value = db_get_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente)); @@ -542,7 +549,7 @@ $(document).ready (function () { }); function changeIcons() { - icon = $("#icon_path :selected").val(); + var icon = $("#icon_path :selected").val(); $("#icon_without_status").attr("src", "images/spinner.png"); $("#icon_default").attr("src", "images/spinner.png"); @@ -574,7 +581,5 @@ function changeIcons() { $("#icon_bad").attr("style", ""); $("#icon_warning").attr("style", ""); } - - //$("#icon_default").attr("src", "" + icon + } diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index b4b2347728..1a9c4e44af 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1939,7 +1939,9 @@ function events_page_custom_fields ($event) { $data = array(); $data[0] = $field['name']; - $data[1] = empty($fields_data[$field['id_field']]) ? ''.__('N/A').'' : $fields_data[$field['id_field']]; + $data[1] = empty($fields_data[$field['id_field']]) + ? ''.__('N/A').'' + : ui_bbcode_to_html($fields_data[$field['id_field']]); $field['id_field']; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index b6b0136a07..0090135b7d 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -3374,8 +3374,7 @@ function reporting_agent_configuration($report, $content) { $agent_configuration['os'] = os_get_name($agent_data["id_os"]); $agent_configuration['os_icon'] = ui_print_os_icon($agent_data["id_os"], true, true); $agent_configuration['address'] = $agent_data['direccion']; - $agent_configuration['description'] = - strip_tags(ui_bbcode_to_html($agent_data['comentarios'])); + $agent_configuration['description'] = $agent_data['comentarios']; $agent_configuration['enabled'] = (int)!$agent_data['disabled']; $agent_configuration['group'] = $report["group"]; diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 2ea8ba5839..64c5c7ccf2 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -530,7 +530,7 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals if (!empty($custom_value)) { $row = array(); $row['title'] = $field['name'] . ui_print_help_tip (__('Custom field'), true); - $row['data'] = $custom_value; + $row['data'] = ui_bbcode_to_html($custom_value); $table->data['custom_field_'.$field['id_field']] = $row; } } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index a94edba05e..c7e37facb8 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -30,13 +30,12 @@ if (isset($config['homedir'])) { } function ui_bbcode_to_html($text, $allowed_tags = array('[url]')) { - $return = ""; - $return = $text; if (array_search('[url]', $allowed_tags) !== false) { + $return = preg_replace("/\[url=([^\]]*)\]/", + "", $return); $return = str_replace('[/url]', '', $return); - $return = preg_replace("/\[url=([^\]]*)\]/", "", $return); } return $return; @@ -3699,4 +3698,4 @@ function ui_print_module_string_value($value, $id_agente_module, return $salida; } -?> \ No newline at end of file +?> diff --git a/pandora_console/mobile/operation/agent.php b/pandora_console/mobile/operation/agent.php index e70dd5e073..1fb7958679 100644 --- a/pandora_console/mobile/operation/agent.php +++ b/pandora_console/mobile/operation/agent.php @@ -143,7 +143,7 @@ class Agent { $description .= '' . __('N/A') . ''; } else { - $description .= ui_bbcode_to_html($this->agent["comentarios"]); + $description .= $this->agent["comentarios"]; } diff --git a/pandora_console/operation/agentes/agent_fields.php b/pandora_console/operation/agentes/agent_fields.php index cf9c8803f8..cf2cf179f9 100755 --- a/pandora_console/operation/agentes/agent_fields.php +++ b/pandora_console/operation/agentes/agent_fields.php @@ -47,6 +47,9 @@ foreach($fields as $field) { if($custom_value === false || $custom_value == '') { $custom_value = '-'.__('empty').'-'; } + else { + $custom_value = ui_bbcode_to_html($custom_value); + } echo ''.$custom_value.''; } diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index 7850b7add2..7ec1876743 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -531,7 +531,7 @@ foreach ($agents as $agent) { } $data[0] .= ''; - $data[1] = ui_print_truncate_text(strip_tags(ui_bbcode_to_html($agent["description"])), 'description', false, true, true, '[…]', 'font-size: 6.5pt'); + $data[1] = ui_print_truncate_text($agent["description"], 'description', false, true, true, '[…]', 'font-size: 6.5pt'); $data[2] = ui_print_os_icon ($agent["id_os"], false, true); diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 703d965f2e..18689b30c4 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -173,9 +173,9 @@ $data[2] = html_print_image('images/default_list.png', true, $table_agent->cellstyle[count($table_agent->data)][2] = 'width: 16px; text-align: right; padding: 0px;'; $data[3] = ''; -$data[3] .= empty($agent["comentarios"]) ? - '' . __('N/A') . '' : - io_safe_output(ui_bbcode_to_html($agent["comentarios"])); +$data[3] .= empty($agent["comentarios"]) + ? '' . __('N/A') . '' + : $agent["comentarios"]; $data[3] .= ''; $table_agent->colspan[count($table_agent->data)][3] = 2; @@ -359,6 +359,9 @@ foreach ($fields as $field) { if ($custom_value === false || $custom_value == '') { $custom_value = ''.__('N/A').''; } + else { + $custom_value = ui_bbcode_to_html($custom_value); + } $data[1] = $custom_value; $table_data->data[] = $data; }