diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 799b2bb8c9..84c220a198 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.747-200710 +Version: 7.0NG.747-200713 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 3437330ef9..1a49f60823 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.747-200710" +pandora_version="7.0NG.747-200713" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 64ce2248b4..2b7cdb9192 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -55,7 +55,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.747'; -use constant AGENT_BUILD => '200710'; +use constant AGENT_BUILD => '200713'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 513e302e15..9489a8a8e7 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.747 -%define release 200710 +%define release 200713 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 4dd166c66d..a9d6d34408 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.747 -%define release 200710 +%define release 200713 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 45d5d0574f..baab89854a 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.747" -PI_BUILD="200710" +PI_BUILD="200713" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 4500b02a3f..cf2d5e0755 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{200710} +{200713} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 4ec5410610..d776a76693 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.747(Build 200710)") +#define PANDORA_VERSION ("7.0NG.747(Build 200713)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 8536573beb..225da7799d 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.747(Build 200710))" + VALUE "ProductVersion", "(7.0NG.747(Build 200713))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 1361fc7177..0bfda896c5 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.747-200710 +Version: 7.0NG.747-200713 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 6146d7d4e2..9bf5796be0 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.747-200710" +pandora_version="7.0NG.747-200713" package_pear=0 package_pandora=1 diff --git a/pandora_console/general/mysqlerr.php b/pandora_console/general/mysqlerr.php index 67d38c56f8..79e6372c33 100644 --- a/pandora_console/general/mysqlerr.php +++ b/pandora_console/general/mysqlerr.php @@ -106,7 +106,7 @@ img.modalclose { - images/icono_cerrar.png'> + /images/icono_cerrar.png'>
diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index 672470397a..f4502c1413 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -171,6 +171,11 @@ if ($delete_action) { ); } +if (is_central_policies_on_node() === true) { + ui_print_warning_message( + __('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.') + ); +} $search_string = (string) get_parameter('search_string', ''); $group = (int) get_parameter('group', 0); @@ -224,8 +229,11 @@ $table->data = []; $table->head = []; $table->head[0] = __('Name'); $table->head[1] = __('Group'); -$table->head[2] = __('Copy'); -$table->head[3] = __('Delete'); +if (is_central_policies_on_node() === false) { + $table->head[2] = __('Copy'); + $table->head[3] = __('Delete'); +} + $table->style = []; $table->style[0] = 'font-weight: bold'; $table->size = []; @@ -292,7 +300,9 @@ foreach ($actions as $action) { ); } - if (check_acl($config['id_user'], $action['id_group'], 'LM')) { + if (is_central_policies_on_node() === false + && check_acl($config['id_user'], $action['id_group'], 'LM') + ) { $table->cellclass[] = [ 2 => 'action_buttons', 3 => 'action_buttons', @@ -318,12 +328,14 @@ if (isset($data)) { ui_print_info_message(['no_close' => true, 'message' => __('No alert actions configured') ]); } -echo '
'; -echo '
'; -html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); -html_print_input_hidden('create_alert', 1); -echo '
'; -echo '
'; +if (is_central_policies_on_node() === false) { + echo '
'; + echo '
'; + html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); + html_print_input_hidden('create_alert', 1); + echo '
'; + echo '
'; +} enterprise_hook('close_meta_frame'); ?> diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index f14cc37902..5df94f29c3 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -46,6 +46,8 @@ if (is_ajax()) { $id = (int) get_parameter('id', 0); $get_recovery_fields = (int) get_parameter('get_recovery_fields', 1); + $is_central_policies_on_node = is_central_policies_on_node(); + // If command ID is not provided, check for action id. if ($id == 0) { $id_action = (int) get_parameter('id_action'); @@ -124,40 +126,142 @@ if (is_ajax()) { // HTML type. if (preg_match('/^_html_editor_$/i', $field_value)) { $editor_type_chkbx = '
'; - $editor_type_chkbx .= __('Basic').ui_print_help_tip(__('For sending emails, text must be HTML format, if you want to use plain text, type it between the following labels:
'), true);
-                    $editor_type_chkbx .= html_print_radio_button_extended('editor_type_value_'.$i, 0, '', false, false, "removeTinyMCE('textarea_field".$i."_value')", '', true);
+                    $editor_type_chkbx .= __('Basic');
+                    $editor_type_chkbx .= ui_print_help_tip(
+                        __('For sending emails, text must be HTML format, if you want to use plain text, type it between the following labels: 
'),
+                        true
+                    );
+                    $editor_type_chkbx .= html_print_radio_button_extended(
+                        'editor_type_value_'.$i,
+                        0,
+                        '',
+                        false,
+                        $is_central_policies_on_node,
+                        "removeTinyMCE('textarea_field".$i."_value')",
+                        '',
+                        true
+                    );
                     $editor_type_chkbx .= '    ';
                     $editor_type_chkbx .= __('Advanced').'  ';
-                    $editor_type_chkbx .= html_print_radio_button_extended('editor_type_value_'.$i, 0, '', true, false, "addTinyMCE('textarea_field".$i."_value')", '', true);
+                    $editor_type_chkbx .= html_print_radio_button_extended(
+                        'editor_type_value_'.$i,
+                        0,
+                        '',
+                        true,
+                        $is_central_policies_on_node,
+                        "addTinyMCE('textarea_field".$i."_value')",
+                        '',
+                        true
+                    );
                     $editor_type_chkbx .= '
'; $ffield = $editor_type_chkbx; - $ffield .= html_print_textarea('field'.$i.'_value', 1, 1, '', 'class="fields"', true); + $ffield .= html_print_textarea( + 'field'.$i.'_value', + 1, + 1, + '', + 'class="fields"', + true, + '', + $is_central_policies_on_node + ); $editor_type_chkbx = '
'; $editor_type_chkbx .= __('Basic').'  '; - $editor_type_chkbx .= html_print_radio_button_extended('editor_type_recovery_value_'.$i, 0, '', false, false, "removeTinyMCE('textarea_field".$i."_recovery_value')", '', true); + $editor_type_chkbx .= html_print_radio_button_extended( + 'editor_type_recovery_value_'.$i, + 0, + '', + false, + $is_central_policies_on_node, + "removeTinyMCE('textarea_field".$i."_recovery_value')", + '', + true + ); $editor_type_chkbx .= '    '; $editor_type_chkbx .= __('Advanced').'  '; - $editor_type_chkbx .= html_print_radio_button_extended('editor_type_recovery_value_'.$i, 0, '', true, false, "addTinyMCE('textarea_field".$i."_recovery_value')", '', true); + $editor_type_chkbx .= html_print_radio_button_extended( + 'editor_type_recovery_value_'.$i, + 0, + '', + true, + $is_central_policies_on_node, + "addTinyMCE('textarea_field".$i."_recovery_value')", + '', + true + ); $editor_type_chkbx .= '
'; $rfield = $editor_type_chkbx; - $rfield .= html_print_textarea('field'.$i.'_recovery_value', 1, 1, '', 'class="fields_recovery"', true); + $rfield .= html_print_textarea( + 'field'.$i.'_recovery_value', + 1, + 1, + '', + 'class="fields_recovery"', + true, + '', + $is_central_policies_on_node + ); } else if (preg_match('/^_content_type_$/i', $field_value)) { $editor_type_chkbx = '
'; - $editor_type_chkbx .= __('Text/plain').ui_print_help_tip(__('For sending emails only text plain'), true); - $editor_type_chkbx .= html_print_radio_button_extended('field'.$i.'_value', 'text/plain', '', '', false, '', '', true); + $editor_type_chkbx .= __('Text/plain'); + $editor_type_chkbx .= ui_print_help_tip( + __('For sending emails only text plain'), + true + ); + $editor_type_chkbx .= html_print_radio_button_extended( + 'field'.$i.'_value', + 'text/plain', + '', + '', + $is_central_policies_on_node, + '', + '', + true + ); $editor_type_chkbx .= '    '; $editor_type_chkbx .= __('Text/html').'  '; - $editor_type_chkbx .= html_print_radio_button_extended('field'.$i.'_value', 'text/html', '', 'text/html', false, '', '', true); + $editor_type_chkbx .= html_print_radio_button_extended( + 'field'.$i.'_value', + 'text/html', + '', + 'text/html', + $is_central_policies_on_node, + '', + '', + true + ); $editor_type_chkbx .= '
'; $ffield = $editor_type_chkbx; $editor_type_chkbx = '
'; - $editor_type_chkbx .= __('Text/plain').ui_print_help_tip(__('For sending emails only text plain'), true); - $editor_type_chkbx .= html_print_radio_button_extended('field'.$i.'_recovery_value', 'text/plain', '', '', false, '', '', true); + $editor_type_chkbx .= __('Text/plain'); + $editor_type_chkbx .= ui_print_help_tip( + __('For sending emails only text plain'), + true + ); + $editor_type_chkbx .= html_print_radio_button_extended( + 'field'.$i.'_recovery_value', + 'text/plain', + '', + '', + $is_central_policies_on_node, + '', + '', + true + ); $editor_type_chkbx .= '    '; $editor_type_chkbx .= __('Text/html').'  '; - $editor_type_chkbx .= html_print_radio_button_extended('field'.$i.'_recovery_value', 'text/html', '', 'text/html', false, '', '', true); + $editor_type_chkbx .= html_print_radio_button_extended( + 'field'.$i.'_recovery_value', + 'text/html', + '', + 'text/html', + $is_central_policies_on_node, + '', + '', + true + ); $editor_type_chkbx .= '
'; $rfield = $editor_type_chkbx; // Select type. @@ -192,7 +296,8 @@ if (is_ajax()) { true, false, false, - 'fields' + 'fields', + $is_central_policies_on_node ); $rfield = html_print_select( $fields_value_select, @@ -204,7 +309,8 @@ if (is_ajax()) { true, false, false, - 'fields_recovery' + 'fields_recovery', + $is_central_policies_on_node ); } else { $ffield = html_print_textarea( @@ -213,7 +319,9 @@ if (is_ajax()) { 1, $fv[0], 'style="min-height:40px; '.$style.'" class="fields"', - true + true, + '', + $is_central_policies_on_node ); $rfield = html_print_textarea( 'field'.$i.'_recovery_value', @@ -221,7 +329,9 @@ if (is_ajax()) { 1, $fv[0], 'style="min-height:40px; '.$style.'" class="fields_recovery', - true + true, + '', + $is_central_policies_on_node ); } } @@ -232,7 +342,9 @@ if (is_ajax()) { 1, '', 'style="min-height:40px; '.$style.'" class="fields"', - true + true, + '', + $is_central_policies_on_node ); $rfield = html_print_textarea( 'field'.$i.'_recovery_value', @@ -240,7 +352,9 @@ if (is_ajax()) { 1, '', 'style="min-height:40px; '.$style.'" class="fields_recovery"', - true + true, + '', + $is_central_policies_on_node ); } @@ -404,6 +518,15 @@ if ($copy_command) { } } +$is_central_policies_on_node = is_central_policies_on_node(); + +if ($is_central_policies_on_node === true) { + ui_print_warning_message( + __('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.') + ); +} + +$table = new stdClass; $table->width = '100%'; $table->class = 'info_table'; @@ -457,7 +580,7 @@ foreach ($commands as $command) { ); $data['action'] = ''; $table->cellclass[]['action'] = 'action_buttons'; - if (! $command['internal']) { + if ($is_central_policies_on_node === false && !$command['internal']) { $data['action'] = ''; $data['action'] .= ''.html_print_image('images/copy.png', true).''; @@ -475,11 +598,13 @@ if (count($table->data) > 0) { ui_print_info_message(['no_close' => true, 'message' => __('No alert commands configured') ]); } -echo '
'; -echo '
'; -html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); -html_print_input_hidden('create_alert', 1); -echo '
'; -echo '
'; +if ($is_central_policies_on_node === false) { + echo '
'; + echo '
'; + html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); + html_print_input_hidden('create_alert', 1); + echo '
'; + echo '
'; +} enterprise_hook('close_meta_frame'); diff --git a/pandora_console/godmode/alerts/alert_templates.php b/pandora_console/godmode/alerts/alert_templates.php index 4147367379..150245acaf 100644 --- a/pandora_console/godmode/alerts/alert_templates.php +++ b/pandora_console/godmode/alerts/alert_templates.php @@ -125,13 +125,13 @@ if (defined('METACONSOLE')) { $sec = 'galertas'; } -// This prevents to duplicate the header in case delete_templete action is performed +// This prevents to duplicate the header in +// case delete_templete action is performed. if (!$delete_template) { - // Header + // Header. if (defined('METACONSOLE')) { alerts_meta_print_header(); } else { - // ~ ui_print_page_header (__('Alerts')." » ". __('Alert templates'), "images/gm_alerts.png", false, "alerts_config", true); ui_print_page_header( __('Alerts').' » '.__('Alert templates'), 'images/gm_alerts.png', @@ -142,7 +142,6 @@ if (!$delete_template) { } } - if ($update_template) { $id = (int) get_parameter('id'); @@ -151,7 +150,7 @@ if ($update_template) { $fields_recovery = []; for ($i = 1; $i <= 10; $i++) { $values['field'.$i] = (string) get_parameter('field'.$i); - $values['field'.$i.'_recovery'] = $recovery_notify ? (string) get_parameter('field'.$i.'_recovery') : ''; + $values['field'.$i.'_recovery'] = ($recovery_notify) ? (string) get_parameter('field'.$i.'_recovery') : ''; } $values['recovery_notify'] = $recovery_notify; @@ -164,13 +163,15 @@ if ($update_template) { ); } -// If user tries to delete a template with group=ALL then must have "PM" access privileges +// If user tries to delete a template with group=ALL +// then must have "PM" access privileges. if ($delete_template) { $id = get_parameter('id'); $al_template = alerts_get_alert_template($id); if ($al_template !== false) { - // If user tries to delete a template with group=ALL then must have "PM" access privileges + // If user tries to delete a template with group=ALL + // then must have "PM" access privileges. if ($al_template['id_group'] == 0) { if (! check_acl($config['id_user'], 0, 'PM')) { db_pandora_audit( @@ -192,8 +193,7 @@ if ($delete_template) { ); } } - } //end if - else { + } else { $own_info = get_user_info($config['id_user']); if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) { $own_groups = array_keys(users_get_groups($config['id_user'], 'LM')); @@ -202,7 +202,7 @@ if ($delete_template) { } $is_in_group = in_array($al_template['id_group'], $own_groups); - // Then template group have to be is his own groups + // Then template group have to be is his own groups. if ($is_in_group) { if (defined('METACONSOLE')) { alerts_meta_print_header(); @@ -241,9 +241,15 @@ if ($delete_template) { $result = alerts_delete_alert_template($id); if ($result) { - db_pandora_audit('Template alert management', 'Delete alert template #'.$id); + db_pandora_audit( + 'Template alert management', + 'Delete alert template #'.$id + ); } else { - db_pandora_audit('Template alert management', 'Fail try to delete alert template #'.$id); + db_pandora_audit( + 'Template alert management', + 'Fail try to delete alert template #'.$id + ); } ui_print_result_message( @@ -253,6 +259,11 @@ if ($delete_template) { ); } +if (is_central_policies_on_node() === true) { + ui_print_warning_message( + __('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.') + ); +} $search_string = (string) get_parameter('search_string'); $search_type = (string) get_parameter('search_type'); @@ -269,7 +280,7 @@ $url = ui_get_url_refresh( $table = new stdClass(); $table->width = '100%'; $table->class = 'databox filters'; -if (defined('METACONSOLE')) { +if (is_metaconsole() === true) { $table->cellspacing = 0; $table->cellpadding = 0; } @@ -313,7 +324,7 @@ $table->data[0][4] .= html_print_submit_button( ); $table->data[0][4] .= '
'; -if (defined('METACONSOLE')) { +if (is_metaconsole() === true) { $filter = '
'; $filter .= html_print_table($table, true); $filter .= '
'; @@ -394,18 +405,34 @@ foreach ($templates as $template) { $data[1] = ui_print_group_icon($template['id_group'], true); $data[3] = alerts_get_alert_templates_type_name($template['type']); - if (check_acl($config['id_user'], $template['id_group'], 'LM')) { + if (is_central_policies_on_node() === false + && check_acl($config['id_user'], $template['id_group'], 'LM') + ) { $table->cellclass[][4] = 'action_buttons'; $data[4] = '
'; $data[4] .= html_print_input_hidden('duplicate_template', 1, true); $data[4] .= html_print_input_hidden('source_id', $template['id'], true); - $data[4] .= html_print_input_image('dup', 'images/copy.png', 1, '', true, ['title' => __('Duplicate')]); + $data[4] .= html_print_input_image( + 'dup', + 'images/copy.png', + 1, + '', + true, + ['title' => __('Duplicate')] + ); $data[4] .= '
'; $data[4] .= '
'; $data[4] .= html_print_input_hidden('delete_template', 1, true); $data[4] .= html_print_input_hidden('id', $template['id'], true); - $data[4] .= html_print_input_image('del', 'images/cross.png', 1, '', true, ['title' => __('Delete')]); + $data[4] .= html_print_input_image( + 'del', + 'images/cross.png', + 1, + '', + true, + ['title' => __('Delete')] + ); $data[4] .= '
'; } else { $data[4] = ''; @@ -415,18 +442,34 @@ foreach ($templates as $template) { } ui_pagination($total_templates, $url); -if (isset($data)) { +if (isset($data) === true) { html_print_table($table); - ui_pagination($total_templates, $url, 0, 0, false, 'offset', true, 'pagination-bottom'); + ui_pagination( + $total_templates, + $url, + 0, + 0, + false, + 'offset', + true, + 'pagination-bottom' + ); } else { - ui_print_info_message(['no_close' => true, 'message' => __('No alert templates defined') ]); + ui_print_info_message( + [ + 'no_close' => true, + 'message' => __('No alert templates defined'), + ] + ); } -echo '
'; -echo '
'; -html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); -html_print_input_hidden('create_alert', 1); -echo '
'; -echo '
'; +if (is_central_policies_on_node() === false) { + echo '
'; + echo '
'; + html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); + html_print_input_hidden('create_alert', 1); + echo '
'; + echo '
'; +} enterprise_hook('close_meta_frame'); diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index 3d39941bf8..da68135ad3 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -80,12 +80,20 @@ if ($al_action !== false) { } +$is_central_policies_on_node = is_central_policies_on_node(); + +if ($is_central_policies_on_node === true) { + ui_print_warning_message( + __('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.') + ); +} + + $name = ''; $id_command = ''; $group = 0; -// All group is 0 $action_threshold = 0; -// All group is 0 +// All group is 0. if ($id) { $action = alerts_get_alert_action($id); $name = $action['name']; @@ -95,7 +103,7 @@ if ($id) { $action_threshold = $action['action_threshold']; } -// Hidden div with help hint to fill with javascript +// Hidden div with help hint to fill with javascript. html_print_div( [ 'id' => 'help_alert_macros_hint', @@ -126,7 +134,26 @@ $table->size = []; $table->size[0] = '20%'; $table->data = []; $table->data[0][0] = __('Name'); -$table->data[0][1] = html_print_input_text('name', $name, '', 35, 255, true); +$table->data[0][1] = html_print_input_text( + 'name', + $name, + '', + 35, + 255, + true, + false, + false, + '', + '', + '', + '', + false, + '', + '', + '', + $is_central_policies_on_node +); + if (io_safe_output($name) == 'Monitoring Event') { $table->data[0][1] .= '  '.ui_print_help_tip( __('This action may stop working, if you change its name.'), @@ -141,7 +168,21 @@ $table->data[1][0] = __('Group'); $own_info = get_user_info($config['id_user']); -$table->data[1][1] = html_print_select_groups(false, 'LW', true, 'group', $group, '', '', 0, true); +$table->data[1][1] = html_print_select_groups( + false, + 'LW', + true, + 'group', + $group, + '', + '', + 0, + true, + false, + true, + '', + $is_central_policies_on_node +); $table->colspan[1][1] = 2; $table->data[2][0] = __('Command'); @@ -163,10 +204,15 @@ $table->data[2][1] = html_print_select_from_sql( '', __('None'), 0, - true + true, + false, + false, + $is_central_policies_on_node ); $table->data[2][1] .= ' '; -if (check_acl($config['id_user'], 0, 'PM')) { +if ($is_central_policies_on_node === false + && check_acl($config['id_user'], 0, 'PM') +) { $table->data[2][1] .= __('Create Command'); $table->data[2][1] .= ''; $table->data[2][1] .= html_print_image('images/add.png', true); @@ -188,7 +234,7 @@ $table->data[3][1] = html_print_extended_select_for_time( false, true, '', - false, + $is_central_policies_on_node, false, '', false, @@ -251,46 +297,44 @@ for ($i = 1; $i <= $config['max_macro_fields']; $i++) { echo '
'; $table_html = html_print_table($table, true); -// -// Hack to hook the bubble dialog of clippy in any place, the intro.js -// fails with new elements in the dom from javascript code -// ---------------------------------------------------------------------- -/* - $table_html = str_replace( - "", - "", - $table_html); - $table_html = str_replace( - '', - " -
- - - ", - $table_html); -*/ -// echo $table_html; - -echo '
'; -if ($id) { - html_print_input_hidden('id', $id); - if ($al_action['id_group'] == 0) { - // then must have "PM" access privileges - if (check_acl($config['id_user'], 0, 'PM')) { +if ($is_central_policies_on_node === false) { + echo '
'; + if ($id) { + html_print_input_hidden('id', $id); + if ($al_action['id_group'] == 0) { + // Then must have "PM" access privileges. + if (check_acl($config['id_user'], 0, 'PM')) { + html_print_input_hidden('update_action', 1); + html_print_submit_button( + __('Update'), + 'create', + false, + 'class="sub upd"' + ); + } + } else { html_print_input_hidden('update_action', 1); - html_print_submit_button(__('Update'), 'create', false, 'class="sub upd"'); + html_print_submit_button( + __('Update'), + 'create', + false, + 'class="sub upd"' + ); } } else { - html_print_input_hidden('update_action', 1); - html_print_submit_button(__('Update'), 'create', false, 'class="sub upd"'); + html_print_input_hidden('create_action', 1); + html_print_submit_button( + __('Create'), + 'create', + false, + 'class="sub wand"' + ); } -} else { - html_print_input_hidden('create_action', 1); - html_print_submit_button(__('Create'), 'create', false, 'class="sub wand"'); + + echo '
'; } -echo '
'; echo ''; enterprise_hook('close_meta_frame'); diff --git a/pandora_console/godmode/alerts/configure_alert_command.php b/pandora_console/godmode/alerts/configure_alert_command.php index 417564e5f2..2091a9ee54 100644 --- a/pandora_console/godmode/alerts/configure_alert_command.php +++ b/pandora_console/godmode/alerts/configure_alert_command.php @@ -36,7 +36,7 @@ $pure = get_parameter('pure', 0); $alert = []; // Header. -if (defined('METACONSOLE')) { +if (is_metaconsole() === true) { alerts_meta_print_header(); } else { ui_print_page_header( @@ -135,30 +135,39 @@ if ($id) { $fields_hidden = $alert['fields_hidden']; } -if (!empty($fields_descriptions)) { +if (empty($fields_descriptions) === false) { $fields_descriptions = json_decode($fields_descriptions, true); } -if (!empty($fields_values)) { +if (empty($fields_values) === false) { $fields_values = json_decode($fields_values, true); } -if (!empty($fields_hidden)) { +if (empty($fields_hidden) === false) { $fields_hidden = json_decode($fields_hidden, true); } + +$is_central_policies_on_node = is_central_policies_on_node(); + +if ($is_central_policies_on_node === true) { + ui_print_warning_message( + __('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.') + ); +} + $table = new stdClass(); $table->width = '100%'; $table->class = 'databox filters'; -if (defined('METACONSOLE')) { +if (is_metaconsole() === true) { $table->head[0] = ($id) ? __('Update Command') : __('Create Command'); $table->head_colspan[0] = 4; $table->headstyle[0] = 'text-align: center'; } $table->style = []; -if (!defined('METACONSOLE')) { +if (is_metaconsole() === false) { $table->style[0] = 'font-weight: bold'; $table->style[2] = 'font-weight: bold'; $table->style[4] = 'font-weight: bold'; @@ -170,11 +179,38 @@ $table->data = []; $table->colspan['name'][1] = 3; $table->data['name'][0] = __('Name'); -$table->data['name'][2] = html_print_input_text('name', $name, '', 35, 255, true); +$table->data['name'][2] = html_print_input_text( + 'name', + $name, + '', + 35, + 255, + true, + false, + false, + '', + '', + '', + '', + false, + '', + '', + '', + $is_central_policies_on_node +); $table->colspan['command'][1] = 3; $table->data['command'][0] = __('Command'); -$table->data['command'][1] = html_print_textarea('command', 8, 30, $command, '', true); +$table->data['command'][1] = html_print_textarea( + 'command', + 8, + 30, + $command, + '', + true, + '', + $is_central_policies_on_node +); $table->colspan['group'][1] = 3; $table->data['group'][0] = __('Group'); @@ -187,60 +223,124 @@ $table->data['group'][1] = html_print_select_groups( false, '', 0, - true + true, + false, + true, + '', + $is_central_policies_on_node ); $table->colspan['description'][1] = 3; $table->data['description'][0] = __('Description'); -$table->data['description'][1] = html_print_textarea('description', 10, 30, $description, '', true); +$table->data['description'][1] = html_print_textarea( + 'description', + 10, + 30, + $description, + '', + true, + '', + $is_central_policies_on_node +); for ($i = 1; $i <= $config['max_macro_fields']; $i++) { $table->data['field'.$i][0] = sprintf(__('Field %s description'), $i); - if (!empty($fields_descriptions)) { + if (empty($fields_descriptions) === false) { $field_description = $fields_descriptions[($i - 1)]; } else { $field_description = ''; } - $table->data['field'.$i][1] = html_print_input_text('field'.$i.'_description', $field_description, '', 30, 255, true); + $table->data['field'.$i][1] = html_print_input_text( + 'field'.$i.'_description', + $field_description, + '', + 30, + 255, + true, + false, + false, + '', + '', + '', + '', + false, + '', + '', + '', + $is_central_policies_on_node + ); - $table->data['field'.$i][2] = sprintf(__('Field %s values'), $i).ui_print_help_tip(__('value1,tag1;value2,tag2;value3,tag3'), true); + $table->data['field'.$i][2] = sprintf(__('Field %s values'), $i); + $table->data['field'.$i][2] .= ui_print_help_tip( + __('value1,tag1;value2,tag2;value3,tag3'), + true + ); - if (!empty($fields_values)) { + if (empty($fields_values) === false) { $field_values = $fields_values[($i - 1)]; } else { $field_values = ''; } - if (!empty($fields_hidden)) { + if (empty($fields_hidden) === false) { $selected = (bool) $fields_hidden[($i - 1)]; } else { $selected = false; } - $table->data['field'.$i][3] = html_print_input_text('field'.$i.'_values', $field_values, '', 55, 255, true, false, false, '', 'field_value'); + $table->data['field'.$i][3] = html_print_input_text( + 'field'.$i.'_values', + $field_values, + '', + 55, + 255, + true, + false, + false, + '', + 'field_value', + '', + '', + false, + '', + '', + '', + $is_central_policies_on_node + ); $table->data['field'.$i][4] = __('Hide'); - $table->data['field'.$i][5] = html_print_checkbox_extended('field'.$i.'_hide', 1, $selected, false, 'cursor: \'pointer\'', 'class="hide_inputs"', true); + $table->data['field'.$i][5] = html_print_checkbox_extended( + 'field'.$i.'_hide', + 1, + $selected, + $is_central_policies_on_node, + 'cursor: \'pointer\'', + 'class="hide_inputs"', + true + ); } echo ''; html_print_table($table); -echo '
'; -if ($id) { - html_print_input_hidden('id', $id); - html_print_input_hidden('update_command', 1); - html_print_submit_button(__('Update'), 'create', false, 'class="sub upd"'); -} else { - html_print_input_hidden('create_command', 1); - html_print_submit_button(__('Create'), 'create', false, 'class="sub wand"'); +if ($is_central_policies_on_node === false) { + echo '
'; + if ($id) { + html_print_input_hidden('id', $id); + html_print_input_hidden('update_command', 1); + html_print_submit_button(__('Update'), 'create', false, 'class="sub upd"'); + } else { + html_print_input_hidden('create_command', 1); + html_print_submit_button(__('Create'), 'create', false, 'class="sub wand"'); + } + + echo '
'; } -echo '
'; echo ''; enterprise_hook('close_meta_frame'); @@ -251,20 +351,20 @@ $(document).ready (function () { $(".hide_inputs").each(function(index) { var $input_in_row = $(this).closest('tr').find('.field_value'); - if($(this).is(':checked')) { + if($(this).is(':checked')) { $input_in_row.prop('style', '-webkit-text-security: disc;'); - } else { + } else { $input_in_row.prop('style', ''); } }); $(".hide_inputs").click(function() { var $input_in_row = $(this).closest('tr').find('.field_value'); - if($(this).is(':checked')) { + if($(this).is(':checked')) { $input_in_row.prop('style', '-webkit-text-security: disc;'); - } else { + } else { $input_in_row.prop('style', ''); - } + } }); }); diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index 533bc32caf..f9f8876e9c 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -363,7 +363,15 @@ function update_template($step) } -// We set here the number of steps +$is_central_policies_on_node = is_central_policies_on_node(); + +if ($is_central_policies_on_node === true) { + ui_print_warning_message( + __('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.') + ); +} + +// We set here the number of steps. define('LAST_STEP', 3); $step = (int) get_parameter('step', 1); @@ -579,27 +587,74 @@ if ($step == 2) { $show_matches = false; } - // Firing conditions and events + // Firing conditions and events. $table->colspan = []; - // $table->colspan[4][1] = 1; $table->data[0][0] = __('Days of week'); $table->data[0][1] = __('Mon'); - $table->data[0][1] .= html_print_checkbox('monday', 1, $monday, true); + $table->data[0][1] .= html_print_checkbox( + 'monday', + 1, + $monday, + true, + $is_central_policies_on_node + ); $table->data[0][1] .= __('Tue'); - $table->data[0][1] .= html_print_checkbox('tuesday', 1, $tuesday, true); + $table->data[0][1] .= html_print_checkbox( + 'tuesday', + 1, + $tuesday, + true, + $is_central_policies_on_node + ); $table->data[0][1] .= __('Wed'); - $table->data[0][1] .= html_print_checkbox('wednesday', 1, $wednesday, true); + $table->data[0][1] .= html_print_checkbox( + 'wednesday', + 1, + $wednesday, + true, + $is_central_policies_on_node + ); $table->data[0][1] .= __('Thu'); - $table->data[0][1] .= html_print_checkbox('thursday', 1, $thursday, true); + $table->data[0][1] .= html_print_checkbox( + 'thursday', + 1, + $thursday, + true, + $is_central_policies_on_node + ); $table->data[0][1] .= __('Fri'); - $table->data[0][1] .= html_print_checkbox('friday', 1, $friday, true); + $table->data[0][1] .= html_print_checkbox( + 'friday', + 1, + $friday, + true, + $is_central_policies_on_node + ); $table->data[0][1] .= __('Sat'); - $table->data[0][1] .= html_print_checkbox('saturday', 1, $saturday, true); + $table->data[0][1] .= html_print_checkbox( + 'saturday', + 1, + $saturday, + true, + $is_central_policies_on_node + ); $table->data[0][1] .= __('Sun'); - $table->data[0][1] .= html_print_checkbox('sunday', 1, $sunday, true); + $table->data[0][1] .= html_print_checkbox( + 'sunday', + 1, + $sunday, + true, + $is_central_policies_on_node + ); $table->data[0][2] = __('Use special days list'); - $table->data[0][3] = html_print_checkbox('special_day', 1, $special_day, true); + $table->data[0][3] = html_print_checkbox( + 'special_day', + 1, + $special_day, + true, + $is_central_policies_on_node + ); $table->data[1][0] = __('Time from'); $table->data[1][1] = html_print_input_text( @@ -608,7 +663,18 @@ if ($step == 2) { '', 7, 8, - true + true, + false, + false, + '', + '', + '', + '', + false, + '', + '', + '', + $is_central_policies_on_node ); $table->data[1][2] = __('Time to'); $table->data[1][3] = html_print_input_text( @@ -617,7 +683,18 @@ if ($step == 2) { '', 7, 8, - true + true, + false, + false, + '', + '', + '', + '', + false, + '', + '', + '', + $is_central_policies_on_node ); $table->colspan['threshold'][1] = 3; @@ -629,7 +706,11 @@ if ($step == 2) { '', '', false, - true + true, + false, + true, + '', + $is_central_policies_on_node ); $table->data[3][0] = __('Min. number of alerts'); @@ -639,11 +720,32 @@ if ($step == 2) { '', 5, 7, - true + true, + false, + false, + '', + '', + '', + '', + false, + '', + '', + '', + $is_central_policies_on_node ); - $table->data[3][2] = __('Reset counter for non-sustained alerts').ui_print_help_tip(__('Enable this option if you want the counter to be reset when the alert is not being fired consecutively, even if it\'s within the time threshold'), true); - $table->data[3][3] = html_print_checkbox('min_alerts_reset_counter', 1, $min_alerts_reset_counter, true); + $table->data[3][2] = __('Reset counter for non-sustained alerts'); + $table->data[3][2] .= ui_print_help_tip( + __('Enable this option if you want the counter to be reset when the alert is not being fired consecutively, even if it\'s within the time threshold'), + true + ); + $table->data[3][3] = html_print_checkbox( + 'min_alerts_reset_counter', + 1, + $min_alerts_reset_counter, + true, + $is_central_policies_on_node + ); $table->data[4][0] = __('Max. number of alerts'); $table->data[4][1] = html_print_input_text( @@ -652,39 +754,43 @@ if ($step == 2) { '', 5, 7, - true + true, + false, + false, + '', + '', + '', + '', + false, + '', + '', + '', + $is_central_policies_on_node ); $table->data[4][2] = __('Disable event'); - $table->data[4][3] = html_print_checkbox('disable_event', 1, $disable_event, true); + $table->data[4][3] = html_print_checkbox( + 'disable_event', + 1, + $disable_event, + true, + $is_central_policies_on_node + ); $table->data[5][0] = __('Default action'); - $usr_groups = implode(',', array_keys(users_get_groups($config['id_user'], 'LM', true))); - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - $sql_query = sprintf( - ' - SELECT id, name - FROM talert_actions - WHERE id_group IN (%s) - ORDER BY name', - $usr_groups - ); - break; + $usr_groups = implode( + ',', + array_keys(users_get_groups($config['id_user'], 'LM', true)) + ); - case 'oracle': - $sql_query = sprintf( - ' - SELECT id, - dbms_lob.substr(name,4000,1) AS nombre - FROM talert_actions - WHERE id_group IN (%s) - ORDER BY dbms_lob.substr(name,4000,1)', - $usr_groups - ); - break; - } + $sql_query = sprintf( + ' + SELECT id, name + FROM talert_actions + WHERE id_group IN (%s) + ORDER BY name', + $usr_groups + ); $table->data[5][1] = html_print_select_from_sql( $sql_query, @@ -696,11 +802,12 @@ if ($step == 2) { true, false, false, - false, + $is_central_policies_on_node, false, false, 0 - ).ui_print_help_tip( + ); + $table->data[5][1] .= ui_print_help_tip( __('Unless they\'re left blank, the fields from the action will override those set on the template.'), true ); @@ -715,7 +822,9 @@ if ($step == 2) { 0, true, false, - false + false, + '', + $is_central_policies_on_node ); $table->data[6][1] .= ''; $table->data[6][1] .= ' '.html_print_checkbox('matches_value', 1, $matches, true); @@ -760,7 +869,7 @@ if ($step == 2) { $table->data['value'][1] .= ''; $table->colspan['value'][1] = 3; - // Min first, then max, that's more logical + // Min first, then max, that's more logical. $table->data['min'][0] = __('Min.'); $table->data['min'][1] = html_print_input_text( 'min', @@ -798,25 +907,12 @@ if ($step == 2) { $table->size[1] = '45%'; $table->size[2] = '45%'; - // Alert recover + // Alert recover. if (! $recovery_notify) { $table->cellstyle['label_fields'][2] = 'display:none;'; for ($i = 1; $i <= $config['max_macro_fields']; $i++) { $table->cellstyle['field'.$i][2] = 'display:none;'; } - - /* - $table->cellstyle['field1'][2] = 'display:none;'; - $table->cellstyle['field2'][2] = 'display:none;'; - $table->cellstyle['field3'][2] = 'display:none;'; - $table->cellstyle['field4'][2] = 'display:none;'; - $table->cellstyle['field5'][2] = 'display:none;'; - $table->cellstyle['field6'][2] = 'display:none;'; - $table->cellstyle['field7'][2] = 'display:none;'; - $table->cellstyle['field8'][2] = 'display:none;'; - $table->cellstyle['field9'][2] = 'display:none;'; - $table->cellstyle['field10'][2] = 'display:none;'; - */ } $table->data[0][0] = __('Alert recovery'); @@ -833,7 +929,9 @@ if ($step == 2) { '', true, false, - false + false, + '', + $is_central_policies_on_node ); $table->colspan[0][1] = 2; @@ -842,45 +940,98 @@ if ($step == 2) { $table->data['label_fields'][2] = __('Recovery fields'); for ($i = 1; $i <= $config['max_macro_fields']; $i++) { - if (isset($template[$name])) { + if (isset($template[$name]) === true) { $value = $template[$name]; } else { $value = ''; } - // $table->rowclass['field'.$i] = 'row_field'; $table->data['field'.$i][0] = sprintf(__('Field %s'), $i); - // TinyMCE - // triggering fields - // basic - $table->data['field'.$i][1] = '
'; - $table->data['field'.$i][1] .= __('Basic').'  '; - $table->data['field'.$i][1] .= html_print_radio_button_extended('editor_type_value_'.$i, 0, '', false, false, "removeTinyMCE('textarea_field".$i."')", '', true); - // Advanced - $table->data['field'.$i][1] .= '    '; - $table->data['field'.$i][1] .= __('Advanced').'  '; - $table->data['field'.$i][1] .= html_print_radio_button_extended('editor_type_value_'.$i, 0, '', true, false, "addTinyMCE('textarea_field".$i."')", '', true); - $table->data['field'.$i][1] .= '
'; + // TinyMCE. + // triggering fields. + // Basic. + $table->data['field'.$i][1] = '
'; + $table->data['field'.$i][1] .= __('Basic').'  '; + $table->data['field'.$i][1] .= html_print_radio_button_extended( + 'editor_type_value_'.$i, + 0, + '', + false, + $is_central_policies_on_node, + "removeTinyMCE('textarea_field".$i."')", + '', + true + ); + // Advanced. + $table->data['field'.$i][1] .= '    '; + $table->data['field'.$i][1] .= __('Advanced').'  '; + $table->data['field'.$i][1] .= html_print_radio_button_extended( + 'editor_type_value_'.$i, + 0, + '', + true, + $is_central_policies_on_node, + "addTinyMCE('textarea_field".$i."')", + '', + true + ); + $table->data['field'.$i][1] .= '
'; - // Texarea - $table->data['field'.$i][1] .= html_print_textarea('field'.$i, 1, 1, isset($fields[$i]) ? $fields[$i] : '', 'style="min-height:40px;" class="fields"', true); + // Texarea. + $table->data['field'.$i][1] .= html_print_textarea( + 'field'.$i, + 1, + 1, + isset($fields[$i]) ? $fields[$i] : '', + 'style="min-height:40px;" class="fields"', + true, + '', + $is_central_policies_on_node + ); - // Recovery - // basic - $table->data['field'.$i][2] = '
'; - $table->data['field'.$i][2] .= __('Basic').'  '; - $table->data['field'.$i][2] .= html_print_radio_button_extended('editor_type_recovery_value_'.$i, 0, '', false, false, "removeTinyMCE('textarea_field".$i."_recovery')", '', true); - // advanced - $table->data['field'.$i][2] .= '    '; - $table->data['field'.$i][2] .= __('Advanced').'  '; - $table->data['field'.$i][2] .= html_print_radio_button_extended('editor_type_recovery_value_'.$i, 0, '', true, false, "addTinyMCE('textarea_field".$i."_recovery')", '', true); - $table->data['field'.$i][2] .= '
'; + // Recovery. + // Basic. + $table->data['field'.$i][2] = '
'; + $table->data['field'.$i][2] .= __('Basic').'  '; + $table->data['field'.$i][2] .= html_print_radio_button_extended( + 'editor_type_recovery_value_'.$i, + 0, + '', + false, + $is_central_policies_on_node, + "removeTinyMCE('textarea_field".$i."_recovery')", + '', + true + ); + // Advanced. + $table->data['field'.$i][2] .= '    '; + $table->data['field'.$i][2] .= __('Advanced').'  '; + $table->data['field'.$i][2] .= html_print_radio_button_extended( + 'editor_type_recovery_value_'.$i, + 0, + '', + true, + $is_central_policies_on_node, + "addTinyMCE('textarea_field".$i."_recovery')", + '', + true + ); + $table->data['field'.$i][2] .= '
'; - // Texarea - $table->data['field'.$i][2] .= html_print_textarea('field'.$i.'_recovery', 1, 1, isset($fields_recovery[$i]) ? $fields_recovery[$i] : '', 'style="min-height:40px" class="fields"', true); + // Texarea. + $table->data['field'.$i][2] .= html_print_textarea( + 'field'.$i.'_recovery', + 1, + 1, + isset($fields_recovery[$i]) ? $fields_recovery[$i] : '', + 'style="min-height:40px" class="fields"', + true, + '', + $is_central_policies_on_node + ); } } else { - // Step 1 by default + // Step 1 by default. $table->size = []; $table->size[0] = '20%'; $table->data = []; @@ -916,20 +1067,53 @@ if ($step == 2) { } $table->data[0][0] = __('Name'); - $table->data[0][1] = html_print_input_text('name', $name, '', 35, 255, true); + $table->data[0][1] = html_print_input_text( + 'name', + $name, + '', + 35, + 255, + true, + false, + false, + '', + '', + '', + '', + false, + '', + '', + '', + $is_central_policies_on_node + ); $table->data[0][1] .= '  '.__('Group'); $groups = users_get_groups(); $own_info = get_user_info($config['id_user']); - // Only display group "All" if user is administrator or has "PM" privileges + // Only display group "All" if user is administrator or has "PM" privileges. if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) { $display_all_group = true; } else { $display_all_group = false; } - $table->data[0][1] .= ' '.html_print_select_groups(false, 'AR', $display_all_group, 'id_group', $id_group, '', '', 0, true); + $table->data[0][1] .= ' '; + $table->data[0][1] .= html_print_select_groups( + false, + 'AR', + $display_all_group, + 'id_group', + $id_group, + '', + '', + 0, + true, + false, + true, + '', + $is_central_policies_on_node + ); $table->data[1][0] = __('Description'); @@ -939,7 +1123,9 @@ if ($step == 2) { 30, $description, '', - true + true, + '', + $is_central_policies_on_node ); $table->data[2][0] = __('Priority'); @@ -952,7 +1138,9 @@ if ($step == 2) { 0, true, false, - false + false, + '', + $is_central_policies_on_node ); if (defined('METACONSOLE')) { @@ -1000,25 +1188,32 @@ if (!$create_alert && !$create_template) { } if (!$disabled) { - if ($step >= LAST_STEP) { - html_print_submit_button(__('Finish'), 'finish', false, 'class="sub upd"'); - } else { - html_print_input_hidden('step', ($step + 1)); - if ($step == 2) { - // Javascript onsubmit to avoid min = 0 and max = 0 + if ($is_central_policies_on_node === false) { + if ($step >= LAST_STEP) { html_print_submit_button( - __('Next'), - 'next', + __('Finish'), + 'finish', false, - 'class="sub next" onclick="return check_fields_step2();"' + 'class="sub upd"' ); } else { - html_print_submit_button( - __('Next'), - 'next', - false, - 'class="sub next"' - ); + html_print_input_hidden('step', ($step + 1)); + if ($step == 2) { + // Javascript onsubmit to avoid min = 0 and max = 0 + html_print_submit_button( + __('Next'), + 'next', + false, + 'class="sub next" onclick="return check_fields_step2();"' + ); + } else { + html_print_submit_button( + __('Next'), + 'next', + false, + 'class="sub next"' + ); + } } } } @@ -1041,7 +1236,7 @@ var matches_not = ')."'"; ?>; var is_not = ')."'"; ?>; var between = and ')."'"; ?>; -var between_not = and ").'"'; ?>; +var between_not = and ').'"'; ?>; var under = ')."'"; ?>; var over = ')."'"; ?>; var warning = ; diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index d69729eac9..1227494e91 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -190,8 +190,20 @@ if ($editGraph) { $weights = implode(',', $weight_array); } + + +$count_module_array = count($module_array); +if ($count_module_array > 10) { + ui_print_warning_message( + __( + 'The maximum number of items in a chart is 10. You have %s elements, only first 10 will be displayed.', + $count_module_array + ) + ); +} + // Modules table. -if (count($module_array) > 0) { +if ($count_module_array > 0) { echo "
"; echo ' @@ -202,7 +214,7 @@ if (count($module_array) > 0) { '; $color = 0; - for ($a = 0; $a < count($module_array); $a++) { + for ($a = 0; $a < $count_module_array; $a++) { // Calculate table line color. if ($color == 1) { $tdcolor = 'datos'; diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php index cd401b0cc5..9062eab0a4 100644 --- a/pandora_console/godmode/servers/modificar_server.php +++ b/pandora_console/godmode/servers/modificar_server.php @@ -140,8 +140,8 @@ if (isset($_GET['server'])) { ui_print_error_message(__('There was a problem deleting the server')); } } else if (isset($_GET['update'])) { - $address = get_parameter_post('address'); - $description = get_parameter_post('description'); + $address = trim(get_parameter_post('address'), ' '); + $description = trim(get_parameter_post('description'), ' '); $id_server = get_parameter_post('server'); $exec_proxy = get_parameter_post('exec_proxy'); $port = get_parameter_post('port'); diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 4b5bffa2b4..ca17c8ab9f 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -871,6 +871,11 @@ if ($get_response_description) { } if ($get_response_params) { + if (! check_acl($config['id_user'], 0, 'EW')) { + echo 'unauthorized'; + return; + } + $response_id = get_parameter('response_id'); $params = db_get_value('params', 'tevent_response', 'id', $response_id); @@ -885,6 +890,11 @@ if ($get_response_params) { } if ($get_response_target) { + if (! check_acl($config['id_user'], 0, 'EW')) { + echo 'unauthorized'; + return; + } + $response_id = (int) get_parameter('response_id'); $event_id = (int) get_parameter('event_id'); $server_id = (int) get_parameter('server_id'); @@ -901,6 +911,11 @@ if ($get_response_target) { } if ($get_response) { + if (! check_acl($config['id_user'], 0, 'EW')) { + echo 'unauthorized'; + return; + } + $response_id = get_parameter('response_id'); $event_response = db_get_row('tevent_response', 'id', $response_id); @@ -917,6 +932,11 @@ if ($get_response) { if ($perform_event_response) { global $config; + if (! check_acl($config['id_user'], 0, 'EW')) { + echo 'unauthorized'; + return; + } + $response_id = get_parameter('response_id'); $event_id = (int) get_parameter('event_id'); $server_id = (int) get_parameter('server_id', 0); @@ -1011,6 +1031,11 @@ if ($perform_event_response) { if ($dialogue_event_response) { global $config; + if (! check_acl($config['id_user'], 0, 'EW')) { + echo 'unauthorized'; + return; + } + $event_id = get_parameter('event_id'); $response_id = get_parameter('response_id'); $command = get_parameter('target'); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index df3861493e..8db7138763 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC200710'; +$build_version = 'PC200713'; $pandora_version = 'v7.0NG.747'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index a5b442d69c..9fc5f8a6af 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2118,7 +2118,7 @@ function events_comment( switch ($comments_format) { case 'new': - $comment_for_json['comment'] = $comment; + $comment_for_json['comment'] = io_safe_input($comment); $comment_for_json['action'] = $action; $comment_for_json['id_user'] = $config['id_user']; $comment_for_json['utimestamp'] = time(); @@ -2141,7 +2141,7 @@ function events_comment( $comment = str_replace(["\r\n", "\r", "\n"], '
', $comment); if ($comment != '') { - $commentbox = '
'.$comment.'
'; + $commentbox = '
'.io_safe_input($comment).'
'; } else { $commentbox = ''; } @@ -3377,7 +3377,7 @@ function events_page_responses($event, $childrens_ids=[]) ); if ($strict_user) { $user_name = db_get_value( - 'fullname', + 'id_user', 'tusuario', 'id_user', $config['id_user'] @@ -3395,14 +3395,14 @@ function events_page_responses($event, $childrens_ids=[]) } foreach ($users as $u) { - $owners[$u['id_user']] = $u['fullname']; + $owners[$u['id_user']] = $u['id_user']; } if ($event['owner_user'] == '') { $owner_name = __('None'); } else { $owner_name = db_get_value( - 'fullname', + 'id_user', 'tusuario', 'id_user', $event['owner_user'] diff --git a/pandora_console/include/functions_forecast.php b/pandora_console/include/functions_forecast.php index 4dcf08db73..a7e5545d55 100644 --- a/pandora_console/include/functions_forecast.php +++ b/pandora_console/include/functions_forecast.php @@ -36,7 +36,8 @@ function forecast_projection_graph( $prediction_period, $max_value=false, $min_value=false, - $csv=false + $csv=false, + $server_name='' ) { global $config; @@ -55,7 +56,7 @@ function forecast_projection_graph( 'projection' => true, ]; - $module_data = grafico_modulo_sparse($params); + $module_data = grafico_modulo_sparse($params, $server_name); if (empty($module_data)) { return []; @@ -252,12 +253,13 @@ function forecast_prediction_date( $module_id, $period=SECONDS_2MONTHS, $max_value=0, - $min_value=0 + $min_value=0, + $server_name='' ) { // Checks interval if ($min_value > $max_value) { return false; } - return forecast_projection_graph($module_id, $period, false, $max_value, $min_value); + return forecast_projection_graph($module_id, $period, false, $max_value, $min_value, false, $server_name); } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index c3402237c8..a0a06473cc 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -616,7 +616,7 @@ function grafico_modulo_sparse_data( * * @return string html Content graphs. */ -function grafico_modulo_sparse($params) +function grafico_modulo_sparse($params, $server_name='') { global $config; @@ -812,6 +812,12 @@ function grafico_modulo_sparse($params) $date_array['final_date'] = $params['date']; $date_array['start_date'] = ($params['date'] - $params['period']); + if (is_metaconsole()) { + $id_meta = metaconsole_get_id_server($server_name); + $server = metaconsole_get_connection_by_id($id_meta); + metaconsole_connect($server); + } + if ($agent_module_id) { $module_data = db_get_row_sql( 'SELECT * FROM tagente_modulo @@ -1022,6 +1028,10 @@ function grafico_modulo_sparse($params) } } + if (is_metaconsole()) { + metaconsole_restore_db(); + } + return $return; } @@ -1483,6 +1493,11 @@ function graphic_combined_module( continue; } + // Only 10 item for chart. + if ($i > 9) { + break; + } + if (is_metaconsole()) { $server = metaconsole_get_connection_by_id( $agent_module_id['server'] @@ -1826,28 +1841,23 @@ function graphic_combined_module( } foreach ($module_list as $module_item) { - $automatic_custom_graph_meta = false; - if ($config['metaconsole']) { + if (is_metaconsole() === true) { // Automatic custom graph from the report // template in metaconsole. - if (is_array($module_list[$i])) { - $server = metaconsole_get_connection_by_id( - $module_item['server'] - ); - metaconsole_connect($server); - $automatic_custom_graph_meta = true; - } - } - - if ($automatic_custom_graph_meta) { - $module = $module_item['module']; - } else { - $module = $module_item; + $server = metaconsole_get_connection_by_id( + $module_item['server'] + ); + + metaconsole_connect($server); } + $module = $module_item['module']; $search_in_history_db = db_search_in_history_db($datelimit); - $temp[$module] = io_safe_output(modules_get_agentmodule($module)); + $temp[$module] = io_safe_output( + modules_get_agentmodule($module) + ); + $query_last_value = sprintf( ' SELECT datos @@ -1912,12 +1922,8 @@ function graphic_combined_module( $temp[$module]['min'] = ($temp_min === false) ? 0 : $temp_min; - if ($config['metaconsole']) { - // Automatic custom graph from the - // report template in metaconsole. - if (is_array($module_list[0])) { - metaconsole_restore_db(); - } + if (is_metaconsole() === true) { + metaconsole_restore_db(); } } @@ -1962,25 +1968,15 @@ function graphic_combined_module( $i = 0; $number_elements = count($module_list); foreach ($module_list as $module_item) { - $automatic_custom_graph_meta = false; - if ($config['metaconsole']) { - // Automatic custom graph from - // the report template in metaconsole. - if (is_array($module_list[$i])) { - $server = metaconsole_get_connection_by_id( - $module_item['server'] - ); - metaconsole_connect($server); - $automatic_custom_graph_meta = true; - } - } - - if ($automatic_custom_graph_meta) { - $module = $module_item['module']; - } else { - $module = $module_item; + if (is_metaconsole() === true) { + $server = metaconsole_get_connection_by_id( + $module_item['server'] + ); + + metaconsole_connect($server); } + $module = $module_item['module']; $temp[$module] = modules_get_agentmodule($module); $query_last_value = sprintf( ' @@ -2036,12 +2032,8 @@ function graphic_combined_module( $temp[$module]['gauge'] = uniqid('gauge_'); - if ($config['metaconsole']) { - // Automatic custom graph from the report - // template in metaconsole. - if (is_array($module_list[0])) { - metaconsole_restore_db(); - } + if (is_metaconsole() === true) { + metaconsole_restore_db(); } $i++; @@ -2089,25 +2081,15 @@ function graphic_combined_module( case CUSTOM_GRAPH_VBARS: $label = ''; foreach ($module_list as $module_item) { - $automatic_custom_graph_meta = false; if (is_metaconsole() === true) { - // Automatic custom graph from the report - // template in metaconsole. - if (is_array($module_list[$i]) === true) { - $server = metaconsole_get_connection_by_id( - $module_item['server'] - ); - metaconsole_connect($server); - $automatic_custom_graph_meta = true; - } - } - - if ($automatic_custom_graph_meta === true) { - $module = $module_item['module']; - } else { - $module = $module_item; + $server = metaconsole_get_connection_by_id( + $module_item['server'] + ); + + metaconsole_connect($server); } + $module = $module_item['module']; $module_data = modules_get_agentmodule($module); $query_last_value = sprintf( 'SELECT datos @@ -2156,11 +2138,7 @@ function graphic_combined_module( } if (is_metaconsole() === true) { - // Automatic custom graph from the report - // template in metaconsole. - if (is_array($module_list[0]) === true) { - metaconsole_restore_db(); - } + metaconsole_restore_db(); } } @@ -2230,29 +2208,18 @@ function graphic_combined_module( case CUSTOM_GRAPH_PIE: $total_modules = 0; foreach ($module_list as $module_item) { - $automatic_custom_graph_meta = false; - if ($config['metaconsole']) { - // Automatic custom graph from the report - // template in metaconsole. - if (is_array($module_list[$i])) { - $server = metaconsole_get_connection_by_id( - $module_item['server'] - ); - metaconsole_connect($server); - $automatic_custom_graph_meta = true; - } - } - - if ($automatic_custom_graph_meta) { - $module = $module_item['module']; - } else { - $module = $module_item; + if (is_metaconsole() === true) { + $server = metaconsole_get_connection_by_id( + $module_item['server'] + ); + + metaconsole_connect($server); } + $module = $module_item['module']; $data_module = modules_get_agentmodule($module); $query_last_value = sprintf( - ' - SELECT datos + 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d @@ -2297,12 +2264,9 @@ function graphic_combined_module( 'value' => $value, 'unit' => $data_module['unit'], ]; - if ($config['metaconsole']) { - // Automatic custom graph from the report - // template in metaconsole. - if (is_array($module_list[0])) { - metaconsole_restore_db(); - } + + if (is_metaconsole() === true) { + metaconsole_restore_db(); } } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 24c9a6863b..61d86d222a 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1833,13 +1833,14 @@ function html_print_input_text_extended( $alt, $size, $maxlength, - $disabled, + $readonly, $script, $attributes, $return=false, $password=false, $function='', - $autocomplete='off' + $autocomplete='off', + $disabled=false ) { static $idcounter = 0; @@ -1895,10 +1896,14 @@ function html_print_input_text_extended( $output = ' $attr_value) { if (! in_array($attribute, $valid_attrs)) { @@ -2102,7 +2107,7 @@ function html_print_input_text( $size=50, $maxlength=255, $return=false, - $disabled=false, + $readonly=false, $required=false, $function='', $class='', @@ -2111,7 +2116,8 @@ function html_print_input_text( $autofocus=false, $onKeyDown='', $formTo='', - $onKeyUp='' + $onKeyUp='', + $disabled=false ) { if ($maxlength == 0) { $maxlength = 255; @@ -2163,12 +2169,14 @@ function html_print_input_text( $alt, $size, $maxlength, - $disabled, + $readonly, '', $attr, $return, false, - $function + $function, + 'off', + $disabled ); } @@ -2661,8 +2669,16 @@ function html_print_button($label='OK', $name='', $disabled=false, $script='', $ * * @return string HTML code if return parameter is true. */ -function html_print_textarea($name, $rows, $columns, $value='', $attributes='', $return=false, $class='', $disable=false) -{ +function html_print_textarea( + $name, + $rows, + $columns, + $value='', + $attributes='', + $return=false, + $class='', + $disable=false +) { $disabled = ($disable) ? 'disabled' : ''; $output = '
'.__('P.').''.__('Delete').' '.__('Sort').'