diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 8f29aa2b25..5febf4b6b8 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.734-190513 +Version: 7.0NG.734-190520 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 2ba8db8f02..c025c5bcd2 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.734-190513" +pandora_version="7.0NG.734-190520" 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 3ccb533275..ca85a88447 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.734'; -use constant AGENT_BUILD => '190513'; +use constant AGENT_BUILD => '190520'; # 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 677208d4ce..0c952e0c28 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.734 -%define release 190513 +%define release 190520 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 36ba7967c0..b6c61b0bd1 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.734 -%define release 190513 +%define release 190520 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 5630750352..bdd18b6cb5 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.734" -PI_BUILD="190513" +PI_BUILD="190520" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index c2565dea74..7677848578 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190513} +{190520} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index f67e2bbfb3..74af04462f 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.734(Build 190513)") +#define PANDORA_VERSION ("7.0NG.734(Build 190520)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 02092b1b5a..f6c5a10fc9 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.734(Build 190513))" + VALUE "ProductVersion", "(7.0NG.734(Build 190520))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 849366e1a4..1d734606f3 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.734-190513 +Version: 7.0NG.734-190520 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 bb58135ccf..0a7cec4345 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.734-190513" +pandora_version="7.0NG.734-190520" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/resource_registration.php b/pandora_console/extensions/resource_registration.php index 92d106d153..c43e2a97f2 100755 --- a/pandora_console/extensions/resource_registration.php +++ b/pandora_console/extensions/resource_registration.php @@ -998,20 +998,23 @@ function process_upload_xml($xml) { $hook_enterprise = enterprise_include('extensions/resource_registration/functions.php'); - // Extract component + // Extract component. process_upload_xml_component($xml); $group_filter = get_parameter('group'); - // Extract visual map + // Extract visual map. process_upload_xml_visualmap($xml, $group_filter); - // Extract policies + // Extract policies. if ($hook_enterprise === true) { - process_upload_xml_policy($xml, $group_filter); + $centralized_management = !is_central_policies_on_node(); + if ($centralized_management) { + process_upload_xml_policy($xml, $group_filter); + } } - // Extract reports + // Extract reports. process_upload_xml_report($xml, $group_filter); } @@ -1038,6 +1041,11 @@ function resource_registration_extension_main() return; } + $centralized_management = !is_central_policies_on_node(); + if (!$centralized_management) { + ui_print_warning_message(__('This node is configured with centralized mode. Go to metaconsole to create a policy.')); + } + echo '
'; echo __('This extension makes registering resource templates easier.').' '.__('Here you can upload a resource template in .ptr format.').' '.__('Please refer to our documentation for more information on how to obtain and use %s resources.', get_product_name()).' '.'

'.__("You can get more resurces in our Public Resource Library"); echo '
'; diff --git a/pandora_console/extras/mr/28.sql b/pandora_console/extras/mr/28.sql index 26d39ad142..208487515a 100644 --- a/pandora_console/extras/mr/28.sql +++ b/pandora_console/extras/mr/28.sql @@ -1,9 +1,15 @@ +START TRANSACTION; - START TRANSACTION; +ALTER TABLE `treport_content` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; + +ALTER TABLE `treport_content_template` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; + +ALTER TABLE `talert_commands` ADD COLUMN `fields_hidden` text; ALTER TABLE `talert_templates` MODIFY COLUMN `type` ENUM('regex','max_min','max','min','equal','not_equal','warning','critical','onchange','unknown','always','not_normal'); DELETE FROM `tevent_response` WHERE `name` LIKE 'Create Integria IMS incident from event'; +INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES (1,'admin','Welcome to Pandora FMS Console', '<p style="text-align: center; font-size: 13px;">Hello, congratulations, if you've arrived here you already have an operational monitoring console. Remember that our forums and online documentation are available 24x7 to get you out of any trouble. You can replace this message with a personalized one at Admin tools -> Site news.</p> ',NOW()); INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="Official communication"), "admin", 1, 0); diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index adbbfcf4a8..470f6f615d 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -761,6 +761,23 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` ( PRIMARY KEY(`id_rc`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; +-- ---------------------------------------------------------------------- +-- Table `tnews` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tnews` ( + `id_news` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `author` varchar(255) NOT NULL DEFAULT '', + `subject` varchar(255) NOT NULL DEFAULT '', + `text` TEXT NOT NULL, + `timestamp` DATETIME NOT NULL DEFAULT 0, + `id_group` int(10) NOT NULL default 0, + `modal` tinyint(1) DEFAULT 0, + `expire` tinyint(1) DEFAULT 0, + `expire_timestamp` DATETIME NOT NULL DEFAULT 0, + PRIMARY KEY(`id_news`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + + ALTER TABLE treport_content_template ADD COLUMN `historical_db` tinyint(1) NOT NULL DEFAULT '0'; ALTER TABLE treport_content_template ADD COLUMN `lapse_calc` tinyint(1) default '0'; ALTER TABLE treport_content_template ADD COLUMN `lapse` int(11) default '300'; @@ -778,6 +795,7 @@ ALTER TABLE `treport_content_template` ADD COLUMN `checks_in_ok_status` TINYINT( ALTER TABLE `treport_content_template` ADD COLUMN `unknown_checks` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; -- ----------------------------------------------------- -- Table `treport_content_sla_com_temp` (treport_content_sla_combined_template) @@ -1197,6 +1215,7 @@ ALTER TABLE talert_actions ADD COLUMN `field15_recovery` TEXT NOT NULL DEFAULT " UPDATE `talert_commands` SET `fields_descriptions` = '[\"Integria IMS API path\",\"Integria IMS API pass\",\"Integria IMS user\",\"Integria IMS user pass\",\"Ticket title\",\"Ticket group ID\",\"Ticket priority\",\"Email copy\",\"Ticket owner\",\"Ticket description\"]', `fields_values` = '[\"\",\"\",\"\",\"\",\"\",\"\",\"10,Maintenance;0,Informative;1,Low;2,Medium;3,Serious;4,Very Serious\",\"\",\"\",\"\"]' WHERE `id` = 11 AND `name` = 'Integria IMS Ticket'; UPDATE `talert_commands` SET `description` = 'This alert send an email using internal Pandora FMS Server SMTP capabilities (defined in each server, using: _field1_ as destination email address, and _field2_ as subject for message. _field3_ as text of message. _field4_ as content type (text/plain or html/text).', `fields_descriptions` = '[\"Destination address\",\"Subject\",\"Text\",\"Content Type\",\"\",\"\",\"\",\"\",\"\",\"\"]', `fields_values` = '[\"\",\"\",\"_html_editor_\",\"_content_type_\",\"\",\"\",\"\",\"\",\"\",\"\"]' WHERE id=1; ALTER TABLE `talert_commands` ADD COLUMN `id_group` mediumint(8) unsigned NULL default 0; +ALTER TABLE `talert_commands` ADD COLUMN `fields_hidden` text; UPDATE `talert_actions` SET `field4` = 'text/html', `field4_recovery` = 'text/html' WHERE id = 1; @@ -1392,7 +1411,6 @@ UPDATE treport_custom_sql SET `sql` = 'select t1.alias as agent_n -- ---------------------------------------------------------------------- -- Table `treport_content` -- --------------------------------------------------------------------- - ALTER TABLE treport_content ADD COLUMN `historical_db` tinyint(1) NOT NULL DEFAULT '0'; ALTER TABLE treport_content ADD COLUMN `lapse_calc` tinyint(1) default '0'; ALTER TABLE treport_content ADD COLUMN `lapse` int(11) default '300'; @@ -1413,6 +1431,7 @@ ALTER TABLE `treport_content` ADD COLUMN `checks_in_ok_status` TINYINT(1) DEFAUL ALTER TABLE `treport_content` ADD COLUMN `unknown_checks` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; -- --------------------------------------------------------------------- -- Table `tmodule_relationship` @@ -2107,8 +2126,15 @@ ALTER TABLE `tnetflow_filter` DROP COLUMN `output`; -- ---------------------------------------------------------------------- UPDATE tuser_task set parameters = 'a:5:{i:0;a:6:{s:11:\"description\";s:28:\"Report pending to be created\";s:5:\"table\";s:7:\"treport\";s:8:\"field_id\";s:9:\"id_report\";s:10:\"field_name\";s:4:\"name\";s:4:\"type\";s:3:\"int\";s:9:\"acl_group\";s:8:\"id_group\";}i:1;a:2:{s:11:\"description\";s:46:\"Send to email addresses (separated by a comma)\";s:4:\"type\";s:4:\"text\";}i:2;a:2:{s:11:\"description\";s:7:\"Subject\";s:8:\"optional\";i:1;}i:3;a:3:{s:11:\"description\";s:7:\"Message\";s:4:\"type\";s:4:\"text\";s:8:\"optional\";i:1;}i:4;a:2:{s:11:\"description\";s:11:\"Report Type\";s:4:\"type\";s:11:\"report_type\";}}' where function_name = "cron_task_generate_report"; +------------------------------------------------------------------------ +------ ADD message in table 'tnews' +------------------------------------------------------------------------ + +INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES (1,'admin','Welcome to Pandora FMS Console', '<p style="text-align: center; font-size: 13px;">Hello, congratulations, if you've arrived here you already have an operational monitoring console. Remember that our forums and online documentation are available 24x7 to get you out of any trouble. You can replace this message with a personalized one at Admin tools -> Site news.</p> ',NOW()); + -- ---------------------------------------------------------------------- -- Alter table `talert_templates` -- ---------------------------------------------------------------------- ALTER TABLE `talert_templates` MODIFY COLUMN `type` ENUM('regex','max_min','max','min','equal','not_equal','warning','critical','onchange','unknown','always','not_normal'); + diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php index e4ce258c72..2db98de05e 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -197,12 +197,15 @@ if (!empty($all_data)) { } foreach ($news as $article) { - $text = io_safe_output($article['text']); - - + $text_bbdd = io_safe_output($article['text']); + $text = html_entity_decode($text_bbdd); echo ''.$article['subject'].''; echo ''.__('by').' '.$article['author'].' '.ui_print_timestamp($article['timestamp'], true).' '.$comparation_suffix.''; echo ''; + if ($article['id_news'] == 1) { + echo '
img colabora con nosotros - Support
'; + } + echo nl2br($text); echo ''; } @@ -214,6 +217,7 @@ if (!empty($all_data)) { // END OF NEWS BOARD. } + // LAST ACTIVITY. // Show last activity from this user. echo '
'; diff --git a/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php b/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php index f424252e32..cd85759d52 100644 --- a/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php @@ -1062,7 +1062,7 @@ $(document).ready (function () { $("select[name='module[]']").append($("").val(id).html(name)); } else { - alert(''); + alert(""); } $("#module").find("option[value='0']").remove(); } @@ -1078,7 +1078,7 @@ $(document).ready (function () { $("select[name='module[]']").append($("").val(id).html(name)); } else { - alert(''); + alert(""); } $("#module").find("option[value='0']").remove(); } @@ -1094,7 +1094,7 @@ $(document).ready (function () { $("select[name='module[]']").append($("").val(id).html(name)); } else { - alert(''); + alert(""); } $("#module").find("option[value='0']").remove(); } @@ -1110,7 +1110,7 @@ $(document).ready (function () { $("select[name='module[]']").append($("").val(id).html(name)); } else { - alert(''); + alert(""); } $("#module").find("option[value='0']").remove(); } @@ -1126,7 +1126,7 @@ $(document).ready (function () { $("select[name='module[]']").append($("").val(id).html(name)); } else { - alert(''); + alert(""); } $("#module").find("option[value='0']").remove(); } @@ -1151,7 +1151,7 @@ $(document).ready (function () { || ($("#module option").length == 1 && $("#module option").eq(0).val() == 0)) { - alert(''); + alert(""); return false; } $('#module option').map(function() { diff --git a/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php b/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php index 167dd64eb5..2a61f02de4 100644 --- a/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php @@ -571,7 +571,7 @@ $(document).ready (function () { $("select[name='module[]']").append($("").val(id).html(name)); } else { - alert(''); + alert(""); } $("#module").find("option[value='0']").remove(); } @@ -587,7 +587,7 @@ $(document).ready (function () { $("select[name='module[]']").append($("").val(id).html(name)); } else { - alert(''); + alert(""); } $("#module").find("option[value='0']").remove(); } @@ -603,7 +603,7 @@ $(document).ready (function () { $("select[name='module[]']").append($("").val(id).html(name)); } else { - alert(''); + alert(""); } $("#module").find("option[value='0']").remove(); } @@ -619,7 +619,7 @@ $(document).ready (function () { $("select[name='module[]']").append($("").val(id).html(name)); } else { - alert(''); + alert(""); } $("#module").find("option[value='0']").remove(); } @@ -641,7 +641,7 @@ $(document).ready (function () { $("#submit-create_modules_btn").click(function () { if($("#module option").length == 0 || ($("#module option").length == 1 && $("#module option").eq(0).val() == 0)) { - alert(''); + alert(""); return false; } $('#module option').map(function() { diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php index bc5ac2a09c..c8c8748178 100644 --- a/pandora_console/godmode/agentes/planned_downtime.editor.php +++ b/pandora_console/godmode/agentes/planned_downtime.editor.php @@ -1038,7 +1038,7 @@ ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript } function show_executing_alert () { - alert(''); + alert(""); } function show_editor_module(id_agent) { @@ -1168,7 +1168,7 @@ ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript var module_sel = $("#modules", $('#module_editor_' + id_agent)).val(); if (module_sel == 0) { - alert(''); + alert(""); } else { action_in_progress = true; diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index e8378d1fc0..34bf6a7fdb 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -11,7 +11,7 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// Load global vars +// Load global vars. global $config; require_once $config['homedir'].'/include/functions_alerts.php'; @@ -46,7 +46,7 @@ if (is_ajax()) { $id = (int) get_parameter('id', 0); $get_recovery_fields = (int) get_parameter('get_recovery_fields', 1); - // If command ID is not provided, check for action id + // If command ID is not provided, check for action id. if ($id == 0) { $id_action = (int) get_parameter('id_action'); $id = alerts_get_alert_action_alert_command_id($id_action); @@ -59,31 +59,31 @@ if (is_ajax()) { $command['description'] = io_safe_input(str_replace("\r\n", '
', io_safe_output($command['description']))); } - // Descriptions are stored in json + // Descriptions are stored in json. $fields_descriptions = empty($command['fields_descriptions']) ? '' : json_decode(io_safe_output($command['fields_descriptions']), true); - // Fields values are stored in json + // Fields values are stored in json. $fields_values = empty($command['fields_values']) ? '' : io_safe_output(json_decode($command['fields_values'], true)); + // Fields hidden conditions are stored in json. + $fields_hidden_checked = empty($command['fields_hidden']) ? '' : io_safe_output(json_decode($command['fields_hidden'], true)); $fields_rows = []; for ($i = 1; $i <= $config['max_macro_fields']; $i++) { - if (($i == 5) && ($command['id'] == 3)) { - continue; - } - $field_description = $fields_descriptions[($i - 1)]; $field_value = $fields_values[($i - 1)]; + $field_hidden = $fields_hidden_checked[($i - 1)]; + if (!empty($field_description)) { - // If the value is 5, this because severity in snmp alerts is not permit to show + // If the value is 5, this because severity in snmp alerts is not permit to show. if (($i > 5) && ($command['id'] == 3)) { $fdesc = $field_description.'
'.sprintf(__('Field %s'), ($i - 1)).''; } else { $fdesc = $field_description.'
'.sprintf(__('Field %s'), $i).''; } - // If the field is the number one, print the help message + // If the field is the number one, print the help message. if ($i == 1) { - // If our context is snmpconsole, show snmp_alert helps + // If our context is snmpconsole, show snmp_alert helps. if ((isset($_SERVER['HTTP_REFERER'])) && ( preg_match('/snmp_alert/', $_SERVER['HTTP_REFERER']) > 0 )) { $fdesc .= ui_print_help_icon('snmp_alert_field1', true); } else { @@ -91,7 +91,7 @@ if (is_ajax()) { } } } else { - // If the macro hasn't description and doesnt appear in command, set with empty description to dont show it + // If the macro hasn't description and doesnt appear in command, set with empty description to dont show it. if (($i > 5) && ($command['id'] == 3)) { if (substr_count($command['command'], '_field'.($i - 1).'_') > 0) { $fdesc = sprintf(__('Field %s'), ($i - 1)); @@ -107,9 +107,11 @@ if (is_ajax()) { } } + $style = ((int) $field_hidden === 1) ? '-webkit-text-security: disc;' : ''; + if (!empty($field_value)) { $field_value = io_safe_output($field_value); - // HTML type + // 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);
@@ -148,7 +150,7 @@ if (is_ajax()) {
                     $editor_type_chkbx .= html_print_radio_button_extended('field'.$i.'_recovery_value', 'text/html', '', 'text/html', false, '', '', true);
                     $editor_type_chkbx .= '
'; $rfield = $editor_type_chkbx; - // Select type + // Select type. } else { $fields_value_select = []; $fv = explode(';', $field_value); @@ -200,7 +202,7 @@ if (is_ajax()) { 1, 1, $fv[0], - 'style="min-height:40px" class="fields"', + 'style="min-height:40px; '.$style.'" class="fields"', true ); $rfield = html_print_textarea( @@ -208,7 +210,7 @@ if (is_ajax()) { 1, 1, $fv[0], - 'style="min-height:40px" class="fields_recovery"', + 'style="min-height:40px; '.$style.'" class="fields_recovery', true ); } @@ -219,7 +221,7 @@ if (is_ajax()) { 1, 1, '', - 'style="min-height:40px" class="fields"', + 'style="min-height:40px; '.$style.'" class="fields"', true ); $rfield = html_print_textarea( @@ -227,13 +229,13 @@ if (is_ajax()) { 1, 1, '', - 'style="min-height:40px" class="fields_recovery"', + 'style="min-height:40px; '.$style.'" class="fields_recovery"', true ); } - // The empty descriptions will be ignored + // The empty descriptions will be ignored. if ($fdesc == '') { $fields_rows[$i] = ''; } else { @@ -248,11 +250,7 @@ if (is_ajax()) { } } - // If command is PandoraFMS event, field 5 must be empty because "severity" must be set by the alert - if ($command['id'] == 3) { - $fields_rows[5] = ''; - } - + // If command is PandoraFMS event, field 5 must be empty because "severity" must be set by the alert. $command['fields_rows'] = $fields_rows; echo json_encode($command); @@ -268,7 +266,7 @@ if ($update_command) { return; } -// Header +// Header. if (defined('METACONSOLE')) { alerts_meta_print_header(); } else { @@ -283,16 +281,19 @@ if ($create_command) { $fields_descriptions = []; $fields_values = []; + $fields_hidden = []; $info_fields = ''; $values = []; for ($i = 1; $i <= $config['max_macro_fields']; $i++) { $fields_descriptions[] = (string) get_parameter('field'.$i.'_description'); $fields_values[] = (string) get_parameter('field'.$i.'_values'); + $fields_hidden[] = get_parameter('field'.$i.'_hide'); $info_fields .= ' Field'.$i.': '.$fields_values[($i - 1)]; } $values['fields_values'] = io_json_mb_encode($fields_values); $values['fields_descriptions'] = io_json_mb_encode($fields_descriptions); + $values['fields_hidden'] = io_json_mb_encode($fields_hidden); $values['description'] = $description; $values['id_group'] = $id_group; @@ -316,7 +317,7 @@ if ($create_command) { db_pandora_audit('Command management', 'Fail try to create alert command', false, false); } - // Show errors + // Show errors. if (!isset($messageAction)) { $messageAction = __('Could not be created'); } @@ -340,7 +341,7 @@ if ($create_command) { if ($delete_command) { $id = (int) get_parameter('id'); - // Internal commands cannot be deleted + // Internal commands cannot be deleted. if (alerts_get_alert_command_internal($id)) { db_pandora_audit( 'ACL Violation', @@ -368,17 +369,17 @@ if ($delete_command) { if ($copy_command) { $id = (int) get_parameter('id'); - // Get the info from the source command + // Get the info from the source command. $command_to_copy = db_get_row('talert_commands', 'id', $id); if ($command_to_copy === false) { ui_print_error_message(__("Command with id $id does not found.")); } else { - // Prepare to insert the copy with same values + // Prepare to insert the copy with same values. unset($command_to_copy['id']); $command_to_copy['name'] .= __(' (copy)'); $result = db_process_sql_insert('talert_commands', $command_to_copy); - // Print the result + // Print the result. ui_print_result_message( $result, __('Successfully copied'), diff --git a/pandora_console/godmode/alerts/configure_alert_command.php b/pandora_console/godmode/alerts/configure_alert_command.php index 3e93319b76..df03e42c45 100644 --- a/pandora_console/godmode/alerts/configure_alert_command.php +++ b/pandora_console/godmode/alerts/configure_alert_command.php @@ -11,7 +11,7 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// Load global vars +// Load global vars. global $config; require_once $config['homedir'].'/include/functions_alerts.php'; @@ -35,7 +35,7 @@ $id = (int) get_parameter('id'); $pure = get_parameter('pure', 0); $alert = []; -// Header +// Header. if (defined('METACONSOLE')) { alerts_meta_print_header(); } else { @@ -65,16 +65,19 @@ if ($update_command) { $fields_descriptions = []; $fields_values = []; + $fields_hidden = []; $info_fields = ''; $values = []; for ($i = 1; $i <= $config['max_macro_fields']; $i++) { $fields_descriptions[] = (string) get_parameter('field'.$i.'_description'); $fields_values[] = (string) get_parameter('field'.$i.'_values'); + $fields_hidden[] = get_parameter('field'.$i.'_hide'); $info_fields .= ' Field'.$i.': '.$fields_values[($i - 1)]; } $values['fields_values'] = io_json_mb_encode($fields_values); $values['fields_descriptions'] = io_json_mb_encode($fields_descriptions); + $values['fields_hidden'] = io_json_mb_encode($fields_hidden); $values['name'] = $name; $values['command'] = $command; @@ -129,6 +132,7 @@ if ($id) { $id_group = $alert['id_group']; $fields_descriptions = $alert['fields_descriptions']; $fields_values = $alert['fields_values']; + $fields_hidden = $alert['fields_hidden']; } if (!empty($fields_descriptions)) { @@ -139,6 +143,10 @@ if (!empty($fields_values)) { $fields_values = json_decode($fields_values, true); } +if (!empty($fields_hidden)) { + $fields_hidden = json_decode($fields_hidden, true); +} + $table = new stdClass(); $table->width = '100%'; $table->class = 'databox filters'; @@ -153,6 +161,7 @@ $table->style = []; if (!defined('METACONSOLE')) { $table->style[0] = 'font-weight: bold'; $table->style[2] = 'font-weight: bold'; + $table->style[4] = 'font-weight: bold'; } $table->size = []; @@ -190,7 +199,7 @@ $table->data['description'][1] = html_print_textarea('description', 10, 30, $des for ($i = 1; $i <= $config['max_macro_fields']; $i++) { $table->data['field'.$i][0] = sprintf(__('Field %s description'), $i); - // Only show help on first row + // Only show help on first row. if ($i == 1) { $table->data['field'.$i][0] .= ui_print_help_icon('alert_fields_description', true); } @@ -201,11 +210,11 @@ for ($i = 1; $i <= $config['max_macro_fields']; $i++) { $field_description = ''; } - $table->data['field'.$i][1] = html_print_input_text('field'.$i.'_description', $field_description, '', 35, 255, true); + $table->data['field'.$i][1] = html_print_input_text('field'.$i.'_description', $field_description, '', 30, 255, true); $table->data['field'.$i][2] = sprintf(__('Field %s values'), $i); - // Only show help on first row + // Only show help on first row. if ($i == 1) { $table->data['field'.$i][2] .= ui_print_help_icon('alert_fields_values', true); } @@ -216,7 +225,17 @@ for ($i = 1; $i <= $config['max_macro_fields']; $i++) { $field_values = ''; } - $table->data['field'.$i][3] = html_print_input_text('field'.$i.'_values', $field_values, '', 65, 255, true); + if (!empty($fields_hidden)) { + $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][4] = __('Hide'); + + $table->data['field'.$i][5] = html_print_checkbox_extended('field'.$i.'_hide', 1, $selected, false, 'cursor: \'pointer\'', 'class="hide_inputs"', true); } echo '
'; @@ -236,3 +255,27 @@ echo '
'; echo ''; enterprise_hook('close_meta_frame'); +?> + + diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index 9e52ddeae9..bbe0b48089 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -357,7 +357,7 @@ function addConnectionMap() { for (var index in connectionMaps) { if (isInt(index)) { if (connectionMaps[index] == idConnectionMap) { - alert(' "' + connectionMapName + '" '); + alert(" "' + connectionMapName + '" "); return; } diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index 5626c51dab..a03a67737f 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -391,7 +391,7 @@ $(document).ready (function () { }); if($('#module')[0].childElementCount == 1 && ($('#module')[0].value == "" || $('#module')[0].value == "0")) { - alert(''); + alert(""); return false; } }); diff --git a/pandora_console/godmode/reporting/graphs.php b/pandora_console/godmode/reporting/graphs.php index 804855c02d..cb52af5e04 100644 --- a/pandora_console/godmode/reporting/graphs.php +++ b/pandora_console/godmode/reporting/graphs.php @@ -151,100 +151,193 @@ if ($multiple_delete) { } +$id_group = (int) get_parameter('id_group', 0); +$search = trim(get_parameter('search', '')); $graphs = custom_graphs_get_user($config['id_user'], false, true, $access); $offset = (int) get_parameter('offset'); +$table_aux = new stdClass(); -ui_pagination(count($graphs)); + $table_aux->width = '100%'; + $table_aux->class = 'databox filters'; + $table_aux->cellpadding = 0; + $table_aux->cellspacing = 0; -if (!empty($graphs)) { - $table = new stdClass(); - $table->width = '100%'; - $table->class = 'info_table'; - $table->cellpadding = 0; - $table->cellspacing = 0; - $table->align = []; - $table->head = []; - if ($report_w || $report_m) { - $table->align[5] = 'left'; - $table->head[5] = html_print_checkbox('all_delete', 0, false, true, false); - $table->size[5] = '20px'; - } + $table_aux->colspan[0][0] = 4; + $table_aux->data[0][0] = ''.__('Group').''; - $table->head[0] = __('Graph name'); - $table->head[1] = __('Description'); - $table->head[2] = __('Number of Graphs'); - $table->head[3] = __('Group'); - $table->size[0] = '30%'; - $table->size[2] = '200px'; - $table->size[3] = '200px'; - $table->align[2] = 'left'; - $table->align[3] = 'left'; - $op_column = false; - if ($report_w || $report_m) { - $op_column = true; - $table->align[4] = 'left'; - $table->head[4] = __('Op.'); - $table->size[4] = '90px'; - } + $table_aux->data[0][1] = html_print_select_groups(false, $access, true, 'id_group', $id_group, '', '', '', true, false, true, '', false, '', false, false, 'id_grupo', $strict_user).'
'; - $table->data = []; + $table_aux->data[0][2] = ''.__('Free text for search: ').ui_print_help_tip( + __('Search by report name or description, list matches.'), + true + ).''; + $table_aux->data[0][3] = html_print_input_text('search', $search, '', 30, '', true); - $result_graphs = array_slice($graphs, $offset, $config['block_size']); + $table_aux->data[0][6] = html_print_submit_button(__('Search'), 'search_submit', false, 'class="sub upd"', true); - foreach ($result_graphs as $graph) { - $data = []; - - if ($report_m) { - $data[5] .= html_print_checkbox_extended('delete_multiple[]', $graph['id_graph'], false, false, '', 'class="check_delete" style="margin-left:2px;"', true); + if (is_metaconsole()) { + $filter = "
"; + $filter .= html_print_table($table_aux, true); + $filter .= '
'; + ui_toggle($filter, __('Show Option')); + } else { + echo "
"; + html_print_table($table_aux); + echo '
'; } - $data[0] = ''.ui_print_truncate_text($graph['name'], 70).''; - - $data[1] = ui_print_truncate_text($graph['description'], 70); - - $data[2] = $graph['graphs_count']; - $data[3] = ui_print_group_icon($graph['id_group'], true); - - $data[4] = ''; - $table->cellclass[][4] = 'action_buttons'; - if (($report_w || $report_m)) { - $data[4] = ''.html_print_image('images/config.png', true).''; + // Show only selected groups. + if ($id_group > 0) { + $group = ["$id_group" => $id_group]; + } else { + $group = false; } - if ($report_m) { - $data[4] .= ' $id_group]; + $filter['id_group'] = $id_group; + } else { + $group = false; + } + + // Filter normal and metaconsole reports. + if ($config['metaconsole'] == 1 && defined('METACONSOLE')) { + $filter['metaconsole'] = 1; + } else { + $filter['metaconsole'] = 0; + } + + + /* + $reports = reports_get_reports( + $filter, + [ + 'name', + 'description', + 'id_graph', + 'id_group', + ], + $return_all_group, + $access, + $group, + false + );*/ + + if ($id_group != null || $search != null) { + $graphs = custom_graphs_search($id_group, $search); + } + + ui_pagination(count($graphs)); + + if (!empty($graphs)) { + $table = new stdClass(); + $table->width = '100%'; + $table->class = 'info_table'; + $table->cellpadding = 0; + $table->cellspacing = 0; + $table->align = []; + $table->head = []; + if ($report_w || $report_m) { + $table->align[5] = 'left'; + $table->head[5] = html_print_checkbox('all_delete', 0, false, true, false); + $table->size[5] = '20px'; + } + + $table->head[0] = __('Graph name'); + $table->head[1] = __('Description'); + $table->head[2] = __('Number of Graphs'); + $table->head[3] = __('Group'); + $table->size[0] = '30%'; + $table->size[2] = '200px'; + $table->size[3] = '200px'; + $table->align[2] = 'left'; + $table->align[3] = 'left'; + $op_column = false; + if ($report_w || $report_m) { + $op_column = true; + $table->align[4] = 'left'; + $table->head[4] = __('Op.'); + $table->size[4] = '90px'; + } + + $table->data = []; + + $result_graphs = array_slice($graphs, $offset, $config['block_size']); + + foreach ($result_graphs as $graph) { + $data = []; + + if ($report_m) { + $data[5] .= html_print_checkbox_extended('delete_multiple[]', $graph['id_graph'], false, false, '', 'class="check_delete" style="margin-left:2px;"', true); + } + + $data[0] = ''.ui_print_truncate_text($graph['name'], 70).''; + + $data[1] = ui_print_truncate_text($graph['description'], 70); + + $data[2] = $graph['graphs_count']; + $data[3] = ui_print_group_icon($graph['id_group'], true); + + $data[4] = ''; + $table->cellclass[][4] = 'action_buttons'; + if (($report_w || $report_m)) { + $data[4] = ''.html_print_image('images/config.png', true).''; + } + + if ($report_m) { + $data[4] .= ''.html_print_image('images/cross.png', true, ['alt' => __('Delete'), 'title' => __('Delete')]).''; + } + + array_push($table->data, $data); + } + + + if (!empty($result_graphs)) { + echo "
"; + html_print_input_hidden('multiple_delete', 1); + html_print_table($table); + ui_pagination(count($graphs), false, 0, 0, false, 'offset', true, 'pagination-bottom'); + echo "
"; + html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); + echo '
'; + echo '
'; + } + + + echo "
"; + if ($report_w || $report_m) { + echo '
'; + html_print_submit_button(__('Create graph'), 'create', false, 'class="sub next" style="margin-right:5px;"'); + echo '
'; + } + + echo '
'; + } else { + include_once $config['homedir'].'/general/firts_task/custom_graphs.php'; } - array_push($table->data, $data); - } - - - if (!empty($result_graphs)) { - echo "
"; - html_print_input_hidden('multiple_delete', 1); - html_print_table($table); - ui_pagination(count($graphs), false, 0, 0, false, 'offset', true, 'pagination-bottom'); - echo "
"; - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); - echo '
'; - echo '
'; - } - - - echo "
"; - if ($report_w || $report_m) { - echo '
'; - html_print_submit_button(__('Create graph'), 'create', false, 'class="sub next" style="margin-right:5px;"'); - echo '
'; - } - - echo '
'; -} else { - include_once $config['homedir'].'/general/firts_task/custom_graphs.php'; -} - -?> + ?> $id_unsort) { if ($pos == $position_to_sort) { @@ -340,8 +355,6 @@ switch ($action) { $items = $sorted_items; - - foreach ($items as $order => $id) { switch ($config['dbtype']) { case 'mysql': @@ -372,6 +385,10 @@ switch ($action) { $resultOperationDB = false; } break; + + default: + // Default. + break; } break; @@ -380,7 +397,8 @@ switch ($action) { $ids_serialize = (string) get_parameter('ids_items_to_delete', ''); if (!empty($ids_serialize)) { - $sql = "DELETE FROM treport_content WHERE id_rc IN ($ids_serialize)"; + $sql = 'DELETE FROM treport_content + WHERE id_rc IN ('.$ids_serialize.')'; $resultOperationDB = db_process_sql($sql); } else { $resultOperationDB = false; @@ -400,7 +418,9 @@ switch ($action) { if (($countItems < $position_to_delete) || ($position_to_delete < 1)) { $resultOperationDB = false; } else { - $sql = "SELECT id_rc FROM treport_content WHERE id_report=$idReport ORDER BY '`order`'"; + $sql = 'SELECT id_rc + FROM treport_content + WHERE id_report='.$idReport." ORDER BY '`order`'"; $items = db_get_all_rows_sql($sql); switch ($pos_delete) { case 'above': @@ -410,7 +430,10 @@ switch ($action) { $i = 1; foreach ($items as $key => $item) { if ($i < $position_to_delete) { - $resultOperationDB = db_process_sql_delete('treport_content', ['id_rc' => $item['id_rc']]); + $resultOperationDB = db_process_sql_delete( + 'treport_content', + ['id_rc' => $item['id_rc']] + ); } $i++; @@ -464,7 +487,10 @@ switch ($action) { break; default: - $subsection = reporting_enterprise_add_subsection_main($activeTab, $buttons); + $subsection = reporting_enterprise_add_subsection_main( + $activeTab, + $buttons + ); break; } @@ -482,11 +508,19 @@ switch ($action) { // Print header. ui_meta_print_header(__('Reporting'), '', $buttons); - } - - // Page header for normal console. - else { - ui_print_page_header(__('Custom reporting'), 'images/op_reporting.png', false, '', false, $buttons, false, '', 60); + } else { + // Page header for normal console. + ui_print_page_header( + __('Custom reporting'), + 'images/op_reporting.png', + false, + '', + false, + $buttons, + false, + '', + 60 + ); } @@ -494,7 +528,9 @@ switch ($action) { $delete = false; switch ($type_access_selected) { case 'group_view': - if ($config['id_user'] == $report['id_user'] || is_user_admin($config['id_user'])) { + if ($config['id_user'] == $report['id_user'] + || is_user_admin($config['id_user']) + ) { $delete = true; // Owner can delete. } else { @@ -507,7 +543,9 @@ switch ($action) { break; case 'group_edit': - if ($config['id_user'] == $report['id_user'] || is_user_admin($config['id_user'])) { + if ($config['id_user'] == $report['id_user'] + || is_user_admin($config['id_user']) + ) { $delete = true; // Owner can delete. } else { @@ -543,9 +581,15 @@ switch ($action) { $result = reports_delete_report($idReport); if ($result !== false) { - db_pandora_audit('Report management', "Delete report #$idReport"); + db_pandora_audit( + 'Report management', + 'Delete report #'.$idReport + ); } else { - db_pandora_audit('Report management', "Fail try to delete report #$idReport"); + db_pandora_audit( + 'Report management', + 'Fail try to delete report #'.$idReport + ); } ui_print_result_message( @@ -560,7 +604,7 @@ switch ($action) { $search_sql = ''; if ($search != '') { - $search_name = "%$search%' OR description LIKE '%$search%"; + $search_name = '%'.$search."%' OR description LIKE '%".$search.'%'; } $table_aux = new stdClass(); @@ -572,25 +616,57 @@ switch ($action) { $table_aux->colspan[0][0] = 4; $table_aux->data[0][0] = ''.__('Group').''; - $table_aux->data[0][1] = html_print_select_groups(false, $access, true, 'id_group', $id_group, '', '', '', true, false, true, '', false, '', false, false, 'id_grupo', $strict_user).'
'; + $table_aux->data[0][1] = html_print_select_groups( + false, + $access, + true, + 'id_group', + $id_group, + '', + '', + '', + true, + false, + true, + '', + false, + '', + false, + false, + 'id_grupo' + ).'
'; - $table_aux->data[0][2] = ''.__('Free text for search: ').ui_print_help_tip( + $table_aux->data[0][2] = ''.__('Free text for search: '); + $table_aux->data[0][2] .= ui_print_help_tip( __('Search by report name or description, list matches.'), true - ).''; - $table_aux->data[0][3] = html_print_input_text('search', $search, '', 30, '', true); + ); + $table_aux->data[0][2] .= ''; + $table_aux->data[0][3] = html_print_input_text( + 'search', + $search, + '', + 30, + '', + true + ); - $table_aux->data[0][6] = html_print_submit_button(__('Search'), 'search_submit', false, 'class="sub upd"', true); + $table_aux->data[0][6] = html_print_submit_button( + __('Search'), + 'search_submit', + false, + 'class="sub upd"', + true + ); + $url_rb = 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder'; if (is_metaconsole()) { - $filter = "
"; + $filter = ''; $filter .= html_print_table($table_aux, true); $filter .= '
'; ui_toggle($filter, __('Show Option')); } else { - echo "
"; + echo ''; html_print_table($table_aux); echo '
'; } @@ -602,7 +678,7 @@ switch ($action) { // Show only selected groups. if ($id_group > 0) { - $group = ["$id_group" => $id_group]; + $group = [$id_group => $id_group]; } else { $group = false; } @@ -626,7 +702,7 @@ switch ($action) { // Fix : group filter was not working // Show only selected groups. if ($id_group > 0) { - $group = ["$id_group" => $id_group]; + $group = [$id_group => $id_group]; $filter['id_group'] = $id_group; } else { $group = false; @@ -652,8 +728,7 @@ switch ($action) { ], $return_all_group, $access, - $group, - $strict_user + $group ); $total_reports = (int) count( @@ -662,13 +737,12 @@ switch ($action) { ['name'], $return_all_group, $access, - $group, - $strict_user + $group ) ); - if (sizeof($reports)) { + if (count($reports)) { $url = 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder'; ui_pagination($total_reports, $url, $offset, $pagination); @@ -744,18 +818,44 @@ switch ($action) { foreach ($reports as $report) { if (!is_user_admin($config['id_user'])) { - if ($report['private'] && $report['id_user'] != $config['id_user']) { - if (!check_acl($config['id_user'], $report['id_group'], 'RR') - && !check_acl($config['id_user'], $report['id_group'], 'RW') - && !check_acl($config['id_user'], $report['id_group'], 'RM') + if ($report['private'] + && $report['id_user'] != $config['id_user'] + ) { + if (!check_acl( + $config['id_user'], + $report['id_group'], + 'RR' + ) + && !check_acl( + $config['id_user'], + $report['id_group'], + 'RW' + ) + && !check_acl( + $config['id_user'], + $report['id_group'], + 'RM' + ) ) { continue; } } - if (!check_acl($config['id_user'], $report['id_group'], 'RR') - && !check_acl($config['id_user'], $report['id_group'], 'RW') - && !check_acl($config['id_user'], $report['id_group'], 'RM') + if (!check_acl( + $config['id_user'], + $report['id_group'], + 'RR' + ) + && !check_acl( + $config['id_user'], + $report['id_group'], + 'RW' + ) + && !check_acl( + $config['id_user'], + $report['id_group'], + 'RM' + ) ) { continue; } @@ -763,7 +863,9 @@ switch ($action) { $data = []; - if (check_acl($config['id_user'], $report['id_group'], 'RW') || check_acl($config['id_user'], $report['id_group'], 'RM')) { + if (check_acl($config['id_user'], $report['id_group'], 'RW') + || check_acl($config['id_user'], $report['id_group'], 'RM') + ) { $data[0] = ''.ui_print_truncate_text($report['name'], 70).''; } else { $data[0] = ui_print_truncate_text($report['name'], 70); @@ -773,15 +875,35 @@ switch ($action) { $data[1] = ui_print_truncate_text($report['description'], 70); // Remove html and xml button if items are larger than limit. - $item_count = db_get_num_rows('SELECT * FROM treport_content WHERE id_report='.$report['id_report']); + $item_count = db_get_num_rows( + 'SELECT * FROM treport_content + WHERE id_report='.$report['id_report'] + ); $report['overload'] = $item_count >= $config['report_limit']; if ($report['overload']) { - $data[2] = html_print_image('images/application_not_writable.png', true, ['title' => __('This report exceeds the item limit for realtime operations')]); + $data[2] = html_print_image( + 'images/application_not_writable.png', + true, + ['title' => __('This report exceeds the item limit for realtime operations')] + ); $data[3] = null; } else if (!$report['non_interactive']) { - $data[2] = ''.html_print_image('images/html.png', true, ['title' => __('HTML view')]).''; - $data[3] = ''.html_print_image('images/xml.png', true, ['title' => __('Export to XML')]).''; - // I chose ajax.php because it's supposed to give XML anyway. + $data[2] = ''; + $data[2] .= html_print_image( + 'images/html.png', + true, + ['title' => __('HTML view')] + ); + $data[2] .= ''; + $data[3] = ''; + $data[3] .= html_print_image( + 'images/xml.png', + true, + ['title' => __('Export to XML')] + ); + $data[3] .= ''; + // I chose ajax.php because it's supposed + // to give XML anyway. } else { $data[2] = html_print_image( 'images/html_disabled.png', @@ -793,14 +915,12 @@ switch ($action) { ); } - // Calculate dinamically the number of the column. $next = 4; if (enterprise_hook('load_custom_reporting_2') !== ENTERPRISE_NOT_HOOK) { $next = 7; } - // Admin options only for RM flag. if (check_acl($config['id_user'], 0, 'RM')) { if ($report['private'] == 1) { @@ -828,14 +948,22 @@ switch ($action) { switch ($type_access_selected) { case 'group_view': - $edit = check_acl($config['id_user'], $report['id_group'], 'RW'); + $edit = check_acl( + $config['id_user'], + $report['id_group'], + 'RW' + ); $delete = $edit || is_user_admin($config['id_user']) || $config['id_user'] == $report['id_user']; break; case 'group_edit': - $edit = check_acl($config['id_user'], $report['id_group_edit'], 'RW'); + $edit = check_acl( + $config['id_user'], + $report['id_group_edit'], + 'RW' + ); $delete = $edit || is_user_admin($config['id_user']) || $config['id_user'] == $report['id_user']; @@ -894,10 +1022,26 @@ switch ($action) { true, ['title' => __('Delete')] ); - $data[$next] .= html_print_input_hidden('id_report', $report['id_report'], true); - $data[$next] .= html_print_input_hidden('action', 'delete_report', true); + $data[$next] .= html_print_input_hidden( + 'id_report', + $report['id_report'], + true + ); + $data[$next] .= html_print_input_hidden( + 'action', + 'delete_report', + true + ); - $data[$next] .= html_print_checkbox_extended('massive_report_check', $report['id_report'], false, false, '', 'class="check_delete"', true); + $data[$next] .= html_print_checkbox_extended( + 'massive_report_check', + $report['id_report'], + false, + false, + '', + 'class="check_delete"', + true + ); $data[$next] .= ''; } @@ -922,12 +1066,28 @@ switch ($action) { } html_print_table($table); - ui_pagination($total_reports, $url, $offset, $pagination, false, 'offset', true, 'pagination-bottom'); + ui_pagination( + $total_reports, + $url, + $offset, + $pagination, + false, + 'offset', + true, + 'pagination-bottom' + ); } else { - ui_print_info_message([ 'no_close' => true, 'message' => __('No data found.') ]); + ui_print_info_message( + [ + 'no_close' => true, + 'message' => __('No data found.'), + ] + ); } - if (check_acl($config['id_user'], 0, 'RW') || check_acl($config['id_user'], 0, 'RM')) { + if (check_acl($config['id_user'], 0, 'RW') + || check_acl($config['id_user'], 0, 'RM') + ) { echo '
'; if (defined('METACONSOLE')) { echo '
'; @@ -935,7 +1095,12 @@ switch ($action) { echo '
'; } - html_print_submit_button(__('Create report'), 'create', false, 'class="sub next"'); + html_print_submit_button( + __('Create report'), + 'create', + false, + 'class="sub next"' + ); echo ''; echo '
'; @@ -945,7 +1110,12 @@ switch ($action) { } echo ''; - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete" style="margin-left:5px;"'); + html_print_submit_button( + __('Delete'), + 'delete_btn', + false, + 'class="sub delete" style="margin-left:5px;"' + ); echo '
'; echo '
'; } @@ -959,7 +1129,7 @@ switch ($action) { case 'main': $reportName = ''; $idGroupReport = 0; - // All groups + // All groups. $description = ''; $resultOperationDB = null; $report_id_user = 0; @@ -992,12 +1162,15 @@ switch ($action) { $reportName = get_parameter('name'); $idGroupReport = get_parameter('id_group'); $description = get_parameter('description'); - $type_access_selected = get_parameter('type_access', 'group_view'); + $type_access_selected = get_parameter( + 'type_access', + 'group_view' + ); $id_group_edit_param = (int) get_parameter('id_group_edit', 0); $report_id_user = get_parameter('report_id_user'); $non_interactive = get_parameter('non_interactive', 0); - // Pretty font by default for pdf + // Pretty font by default for pdf. $custom_font = 'FreeSans.ttf'; switch ($type_access_selected) { @@ -1054,12 +1227,12 @@ switch ($action) { if ($resultOperationDB !== false) { db_pandora_audit( 'Report management', - "Update report #$idReport" + 'Update report #'.$idReport ); } else { db_pandora_audit( 'Report management', - "Fail try to update report #$idReport" + 'Fail try to update report #'.$idReport ); } } else { @@ -1069,10 +1242,10 @@ switch ($action) { $action = 'edit'; } else if ($action == 'save') { if ($reportName != '' && $idGroupReport != '') { - // This flag allow to differentiate between normal console and metaconsole reports. + // This flag allow to differentiate + // between normal console and metaconsole reports. $metaconsole_report = (int) is_metaconsole(); - // Juanma (07/05/2014) New feature: Custom front page for reports. if ($config['custom_report_front']) { $custom_font = $config['custom_report_front_font']; $logo = $config['custom_report_front_logo']; @@ -1080,9 +1253,16 @@ switch ($action) { $first_page = $config['custom_report_front_firstpage']; $footer = $config['custom_report_front_footer']; } else { - $start_url = ui_get_full_url(false, false, false, false); + $start_url = ui_get_full_url( + false, + false, + false, + false + ); $first_page = '<p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;"><img src="'.$start_url.'/images/pandora_report_logo.png" alt="" width="800" /></p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;"><span style="font-size: xx-large;">(_REPORT_NAME_)</span></p> <p style="text-align: center;"><span style="font-size: large;">(_DATETIME_)</span></p>'; - $logo = $header = $footer = null; + $logo = null; + $header = null; + $footer = null; } $idOrResult = db_process_sql_insert( @@ -1105,9 +1285,15 @@ switch ($action) { ); if ($idOrResult !== false) { - db_pandora_audit('Report management', "Create report #$idOrResult"); + db_pandora_audit( + 'Report management', + 'Create report #'.$idOrResult + ); } else { - db_pandora_audit('Report management', 'Fail try to create report'); + db_pandora_audit( + 'Report management', + 'Fail try to create report' + ); } } else { $idOrResult = false; @@ -1121,7 +1307,7 @@ switch ($action) { $report_id_user = $config['id_user']; } - $action = $resultOperationDB ? 'edit' : 'new'; + $action = ($resultOperationDB) ? 'edit' : 'new'; } break; @@ -1132,9 +1318,6 @@ switch ($action) { ['id_report' => $idReport] ); - - - $reportName = $report['name']; $idGroupReport = $report['id_group']; $description = $report['description']; @@ -1143,20 +1326,23 @@ switch ($action) { case 'update': $values = []; $values['id_report'] = $idReport; - // --------------------------------------------------- - // $values['name'] = (string) get_parameter('name'); $values['description'] = get_parameter('description'); $values['type'] = get_parameter('type', null); $values['recursion'] = get_parameter('recursion', null); $label = get_parameter('label', ''); - // Add macros name + // Add macros name. $items_label = []; $items_label['type'] = get_parameter('type'); $items_label['id_agent'] = get_parameter('id_agent'); - $items_label['id_agent_module'] = get_parameter('id_agent_module'); + $items_label['id_agent_module'] = get_parameter( + 'id_agent_module' + ); $name_it = (string) get_parameter('name'); - $values['name'] = reporting_label_macro($items_label, $name_it); + $values['name'] = reporting_label_macro( + $items_label, + $name_it + ); /* Added support for projection graphs, @@ -1168,7 +1354,9 @@ switch ($action) { switch ($values['type']) { case 'projection_graph': $values['period'] = get_parameter('period1'); - $values['top_n_value'] = get_parameter('period2'); + $values['top_n_value'] = get_parameter( + 'period2' + ); $values['text'] = get_parameter('text'); $good_format = true; break; @@ -1191,16 +1379,29 @@ switch ($action) { case 'prediction_date': $values['period'] = get_parameter('period1'); - $values['top_n'] = get_parameter('radiobutton_max_min_avg'); - $values['top_n_value'] = get_parameter('quantity'); + $values['top_n'] = get_parameter( + 'radiobutton_max_min_avg' + ); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $interval_max = get_parameter('max_interval'); $interval_min = get_parameter('min_interval'); // Checks intervals fields. - if (preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_max) and preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_min)) { + if (preg_match( + '/^(\-)*[0-9]*\.?[0-9]+$/', + $interval_max + ) + && preg_match( + '/^(\-)*[0-9]*\.?[0-9]+$/', + $interval_min + ) + ) { $good_format = true; } - $intervals = get_parameter('max_interval').';'.get_parameter('min_interval'); + $intervals = get_parameter('max_interval').';'; + $intervals .= get_parameter('min_interval'); $values['text'] = $intervals; break; @@ -1211,19 +1412,32 @@ switch ($action) { case 'SLA': case 'availability_graph': $values['period'] = get_parameter('period'); - $values['top_n'] = get_parameter('combo_sla_sort_options', 0); - $values['top_n_value'] = get_parameter('quantity'); + $values['top_n'] = get_parameter( + 'combo_sla_sort_options', + 0 + ); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $values['text'] = get_parameter('text'); - $values['show_graph'] = get_parameter('combo_graph_options'); + $values['show_graph'] = get_parameter( + 'combo_graph_options' + ); $good_format = true; break; case 'agent_module': $agents_to_report = get_parameter('id_agents2'); - $modules_to_report = get_parameter('module', ''); + $modules_to_report = get_parameter( + 'module', + '' + ); - $es['module'] = get_same_modules($agents_to_report, $modules_to_report); + $es['module'] = get_same_modules( + $agents_to_report, + $modules_to_report + ); $es['id_agents'] = $agents_to_report; $values['external_source'] = json_encode($es); @@ -1234,7 +1448,9 @@ switch ($action) { $values['period'] = 0; $es['date'] = get_parameter('date'); $es['id_agents'] = get_parameter('id_agents'); - $es['inventory_modules'] = get_parameter('inventory_modules'); + $es['inventory_modules'] = get_parameter( + 'inventory_modules' + ); $description = get_parameter('description'); $values['external_source'] = json_encode($es); $good_format = true; @@ -1243,7 +1459,9 @@ switch ($action) { case 'inventory_changes': $values['period'] = get_parameter('period'); $es['id_agents'] = get_parameter('id_agents'); - $es['inventory_modules'] = get_parameter('inventory_modules'); + $es['inventory_modules'] = get_parameter( + 'inventory_modules' + ); $description = get_parameter('description'); $values['external_source'] = json_encode($es); $good_format = true; @@ -1252,38 +1470,74 @@ switch ($action) { case 'netflow_area': case 'netflow_data': case 'netflow_summary': - $values['text'] = get_parameter('netflow_filter'); - $values['description'] = get_parameter('description'); + $values['text'] = get_parameter( + 'netflow_filter' + ); + $values['description'] = get_parameter( + 'description' + ); $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter('resolution'); - $values['top_n_value'] = get_parameter('max_values'); + $values['top_n_value'] = get_parameter( + 'max_values' + ); $good_format = true; break; case 'availability': // HACK it is saved in show_graph field. // Show interfaces instead the modules. - $values['show_graph'] = get_parameter('checkbox_show_address_agent'); - $values['period'] = get_parameter('period'); - $values['total_time'] = get_parameter('total_time'); - $values['time_failed'] = get_parameter('time_failed'); - $values['time_in_ok_status'] = get_parameter('time_in_ok_status'); - $values['time_in_unknown_status'] = get_parameter('time_in_unknown_status'); - $values['time_of_not_initialized_module'] = get_parameter('time_of_not_initialized_module'); - $values['time_of_downtime'] = get_parameter('time_of_downtime'); - $values['total_checks'] = get_parameter('total_checks'); - $values['checks_failed'] = get_parameter('checks_failed'); - $values['checks_in_ok_status'] = get_parameter('checks_in_ok_status'); - $values['unknown_checks'] = get_parameter('unknown_checks'); - $values['agent_max_value'] = get_parameter('agent_max_value'); - $values['agent_min_value'] = get_parameter('agent_min_value'); + $values['show_graph'] = get_parameter( + 'checkbox_show_address_agent' + ); + $values['period'] = get_parameter( + 'period' + ); + $values['total_time'] = get_parameter( + 'total_time' + ); + $values['time_failed'] = get_parameter( + 'time_failed' + ); + $values['time_in_ok_status'] = get_parameter( + 'time_in_ok_status' + ); + $values['time_in_unknown_status'] = get_parameter( + 'time_in_unknown_status' + ); + $values['time_of_not_initialized_module'] = get_parameter( + 'time_of_not_initialized_module' + ); + $values['time_of_downtime'] = get_parameter( + 'time_of_downtime' + ); + $values['total_checks'] = get_parameter( + 'total_checks' + ); + $values['checks_failed'] = get_parameter( + 'checks_failed' + ); + $values['checks_in_ok_status'] = get_parameter( + 'checks_in_ok_status' + ); + $values['unknown_checks'] = get_parameter( + 'unknown_checks' + ); + $values['agent_max_value'] = get_parameter( + 'agent_max_value' + ); + $values['agent_min_value'] = get_parameter( + 'agent_min_value' + ); $good_format = true; break; case 'simple_graph': case 'simple_baseline_graph': // HACK it is saved in show_graph field. - $values['show_graph'] = (int) get_parameter('time_compare_overlapped'); + $values['show_graph'] = (int) get_parameter( + 'time_compare_overlapped' + ); $values['period'] = get_parameter('period'); $good_format = true; break; @@ -1292,24 +1546,37 @@ switch ($action) { case 'max_value': case 'avg_value': $values['period'] = get_parameter('period'); - $values['lapse_calc'] = get_parameter('lapse_calc'); + $values['lapse_calc'] = get_parameter( + 'lapse_calc' + ); $values['lapse'] = get_parameter('lapse'); - $values['visual_format'] = get_parameter('visual_format'); + $values['visual_format'] = get_parameter( + 'visual_format' + ); $good_format = true; break; case 'nt_top_n': $values['period'] = get_parameter('period'); - $values['top_n_value'] = get_parameter('quantity'); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $good_format = true; break; default: $values['period'] = get_parameter('period'); - $values['top_n'] = get_parameter('radiobutton_max_min_avg', 0); - $values['top_n_value'] = get_parameter('quantity'); + $values['top_n'] = get_parameter( + 'radiobutton_max_min_avg', + 0 + ); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $values['text'] = get_parameter('text'); - $values['show_graph'] = get_parameter('combo_graph_options'); + $values['show_graph'] = get_parameter( + 'combo_graph_options' + ); $good_format = true; break; } @@ -1319,16 +1586,27 @@ switch ($action) { $values['id_agent_module'] = ''; if (isset($values['type'])) { - if (($values['type'] == 'alert_report_agent') or ($values['type'] == 'event_report_agent') or ($values['type'] == 'agent_configuration') or ($values['type'] == 'group_configuration')) { + if (($values['type'] == 'alert_report_agent') + || ($values['type'] == 'event_report_agent') + || ($values['type'] == 'agent_configuration') + || ($values['type'] == 'group_configuration') + ) { $values['id_agent_module'] = ''; } else { - $values['id_agent_module'] = get_parameter('id_agent_module'); + $values['id_agent_module'] = get_parameter( + 'id_agent_module' + ); } } else { - $values['id_agent_module'] = get_parameter('id_agent_module'); + $values['id_agent_module'] = get_parameter( + 'id_agent_module' + ); } - $values['only_display_wrong'] = (int) get_parameter('checkbox_only_display_wrong', 0); + $values['only_display_wrong'] = (int) get_parameter( + 'checkbox_only_display_wrong', + 0 + ); $values['monday'] = get_parameter('monday', 0); $values['tuesday'] = get_parameter('tuesday', 0); $values['wednesday'] = get_parameter('wednesday', 0); @@ -1337,105 +1615,220 @@ switch ($action) { $values['saturday'] = get_parameter('saturday', 0); $values['sunday'] = get_parameter('sunday', 0); $values['total_time'] = get_parameter('total_time', 0); - $values['time_failed'] = get_parameter('time_failed', 0); - $values['time_in_ok_status'] = get_parameter('time_in_ok_status', 0); - $values['time_in_unknown_status'] = get_parameter('time_in_unknown_status', 0); - $values['time_of_not_initialized_module'] = get_parameter('time_of_not_initialized_module', 0); - $values['time_of_downtime'] = get_parameter('time_of_downtime', 0); - $values['total_checks'] = get_parameter('total_checks', 0); - $values['checks_failed'] = get_parameter('checks_failed', 0); - $values['checks_in_ok_status'] = get_parameter('checks_in_ok_status', 0); - $values['unknown_checks'] = get_parameter('unknown_checks', 0); - $values['agent_max_value'] = get_parameter('agent_max_value', 0); - $values['agent_min_value'] = get_parameter('agent_min_value', 0); + $values['time_failed'] = get_parameter( + 'time_failed', + 0 + ); + $values['time_in_ok_status'] = get_parameter( + 'time_in_ok_status', + 0 + ); + $values['time_in_unknown_status'] = get_parameter( + 'time_in_unknown_status', + 0 + ); + $values['time_of_not_initialized_module'] = get_parameter( + 'time_of_not_initialized_module', + 0 + ); + $values['time_of_downtime'] = get_parameter( + 'time_of_downtime', + 0 + ); + $values['total_checks'] = get_parameter( + 'total_checks', + 0 + ); + $values['checks_failed'] = get_parameter( + 'checks_failed', + 0 + ); + $values['checks_in_ok_status'] = get_parameter( + 'checks_in_ok_status', + 0 + ); + $values['unknown_checks'] = get_parameter( + 'unknown_checks', + 0 + ); + $values['agent_max_value'] = get_parameter( + 'agent_max_value', + 0 + ); + $values['agent_min_value'] = get_parameter( + 'agent_min_value', + 0 + ); - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - $values['time_from'] = get_parameter('time_from'); - $values['time_to'] = get_parameter('time_to'); - break; + $values['time_from'] = get_parameter( + 'time_from' + ); + $values['time_to'] = get_parameter('time_to'); - case 'oracle': - $values['time_from'] = '#to_date(\''.get_parameter('time_from').'\',\'hh24:mi:ss\')'; - $values['time_to'] = '#to_date(\''.get_parameter('time_to').'\', \'hh24:mi:ss\')'; - break; - - default: - // Default. - break; - } - - $values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent'); - $values['show_resume'] = get_parameter('checkbox_show_resume'); - $values['order_uptodown'] = get_parameter('radiobutton_order_uptodown'); - $values['exception_condition'] = (int) get_parameter('exception_condition', 0); - $values['exception_condition_value'] = get_parameter('exception_condition_value'); - $values['id_module_group'] = get_parameter('combo_modulegroup'); + $values['group_by_agent'] = get_parameter( + 'checkbox_row_group_by_agent' + ); + $values['show_resume'] = get_parameter( + 'checkbox_show_resume' + ); + $values['order_uptodown'] = get_parameter( + 'radiobutton_order_uptodown' + ); + $values['exception_condition'] = (int) get_parameter( + 'exception_condition', + 0 + ); + $values['exception_condition_value'] = get_parameter( + 'exception_condition_value' + ); + $values['id_module_group'] = get_parameter( + 'combo_modulegroup' + ); $values['id_group'] = get_parameter('combo_group'); $values['server_name'] = get_parameter('server_name'); $server_id = (int) get_parameter('server_id'); if ($server_id != 0) { - $connection = metaconsole_get_connection_by_id($server_id); + $connection = metaconsole_get_connection_by_id( + $server_id + ); $values['server_name'] = $connection['server_name']; } if ($values['server_name'] == '') { - $values['server_name'] = get_parameter('combo_server'); + $values['server_name'] = get_parameter( + 'combo_server' + ); } - if ((($values['type'] == 'custom_graph') || ($values['type'] == 'automatic_custom_graph')) && ($values['id_gs'] == 0 || $values['id_gs'] == '')) { + if ((($values['type'] == 'custom_graph') + || ($values['type'] == 'automatic_custom_graph')) + && ($values['id_gs'] == 0 || $values['id_gs'] == '') + ) { $resultOperationDB = false; break; } - $show_summary_group = get_parameter('show_summary_group', 0); - $filter_event_severity = get_parameter('filter_event_severity', 0); - $filter_event_type = get_parameter('filter_event_type', ''); - $filter_event_status = get_parameter('filter_event_status', 0); + $show_summary_group = get_parameter( + 'show_summary_group', + 0 + ); + $filter_event_severity = get_parameter( + 'filter_event_severity', + 0 + ); + $filter_event_type = get_parameter( + 'filter_event_type', + '' + ); + $filter_event_status = get_parameter( + 'filter_event_status', + 0 + ); - $event_graph_by_agent = get_parameter('event_graph_by_agent', 0); - $event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0); - $event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0); - $event_graph_validated_vs_unvalidated = get_parameter('event_graph_validated_vs_unvalidated', 0); + $event_graph_by_agent = get_parameter( + 'event_graph_by_agent', + 0 + ); + $event_graph_by_user_validator = get_parameter( + 'event_graph_by_user_validator', + 0 + ); + $event_graph_by_criticity = get_parameter( + 'event_graph_by_criticity', + 0 + ); + $event_graph_validated_vs_unvalidated = get_parameter( + 'event_graph_validated_vs_unvalidated', + 0 + ); - $event_filter_search = get_parameter('filter_search', ''); + $event_filter_search = get_parameter( + 'filter_search', + '' + ); // If metaconsole is activated. - if ($config['metaconsole'] == 1 && defined('METACONSOLE')) { - if (($values['type'] == 'custom_graph') or ($values['type'] == 'automatic_custom_graph')) { - $id_gs = substr($values['id_gs'], 0, strpos($values['id_gs'], '|')); + if ($config['metaconsole'] == 1 + && defined('METACONSOLE') + ) { + if (($values['type'] == 'custom_graph') + || ($values['type'] == 'automatic_custom_graph') + ) { + $id_gs = substr( + $values['id_gs'], + 0, + strpos($values['id_gs'], '|') + ); if ($id_gs !== false) { - $server_name = strstr($values['id_gs'], '|'); + $server_name = strstr( + $values['id_gs'], + '|' + ); $values['id_gs'] = $id_gs; - $values['server_name'] = substr($server_name, 1, strlen($server_name)); + $values['server_name'] = substr( + $server_name, + 1, + strlen($server_name) + ); } } // Get agent and server name. - $agent_name_server = io_safe_output(get_parameter('agent')); + $agent_name_server = io_safe_output( + get_parameter('agent') + ); if (isset($agent_name_server)) { - $separator_pos = strpos($agent_name_server, '('); + $separator_pos = strpos( + $agent_name_server, + '(' + ); - if (($separator_pos != false) and ($separator_pos != 0)) { - $server_name = substr($agent_name_server, $separator_pos); - $server_name = str_replace('(', '', $server_name); - $server_name = str_replace(')', '', $server_name); + if (($separator_pos != false) + || ($separator_pos != 0) + ) { + $server_name = substr( + $agent_name_server, + $separator_pos + ); + $server_name = str_replace( + '(', + '', + $server_name + ); + $server_name = str_replace( + ')', + '', + $server_name + ); // Will update server_name variable. $values['server_name'] = trim($server_name); - $agent_name = substr($agent_name_server, 0, $separator_pos); + $agent_name = substr( + $agent_name_server, + 0, + $separator_pos + ); } } } - if (($values['type'] == 'sql') or ($values['type'] == 'sql_graph_hbar') or ($values['type'] == 'sql_graph_vbar') or ($values['type'] == 'sql_graph_pie')) { - $values['treport_custom_sql_id'] = get_parameter('id_custom'); + if (($values['type'] == 'sql') + || ($values['type'] == 'sql_graph_hbar') + || ($values['type'] == 'sql_graph_vbar') + || ($values['type'] == 'sql_graph_pie') + ) { + $values['treport_custom_sql_id'] = get_parameter( + 'id_custom' + ); if ($values['treport_custom_sql_id'] == 0) { - $values['external_source'] = get_parameter('sql'); + $values['external_source'] = get_parameter( + 'sql' + ); } - $values['historical_db'] = get_parameter('historical_db_check'); + $values['historical_db'] = get_parameter( + 'historical_db_check' + ); $values['top_n_value'] = get_parameter('max_items'); } else if ($values['type'] == 'url') { $values['external_source'] = get_parameter('url'); @@ -1447,22 +1840,45 @@ switch ($action) { $values['column_separator'] = get_parameter('field'); $values['line_separator'] = get_parameter('line'); + $values['current_month'] = get_parameter('current_month'); + $style = []; - $style['show_in_same_row'] = get_parameter('show_in_same_row', 0); - $style['show_in_landscape'] = get_parameter('show_in_landscape', 0); - $style['hide_notinit_agents'] = get_parameter('hide_notinit_agents', 0); - $style['priority_mode'] = get_parameter('priority_mode', REPORT_PRIORITY_MODE_OK); - $style['dyn_height'] = get_parameter('dyn_height', 230); + $style['show_in_same_row'] = get_parameter( + 'show_in_same_row', + 0 + ); + $style['show_in_landscape'] = get_parameter( + 'show_in_landscape', + 0 + ); + $style['hide_notinit_agents'] = get_parameter( + 'hide_notinit_agents', + 0 + ); + $style['priority_mode'] = get_parameter( + 'priority_mode', + REPORT_PRIORITY_MODE_OK + ); + $style['dyn_height'] = get_parameter( + 'dyn_height', + 230 + ); switch ($values['type']) { case 'event_report_agent': case 'event_report_group': case 'event_report_module': - // Added for events items - $style['show_summary_group'] = $show_summary_group; - $style['filter_event_severity'] = json_encode($filter_event_severity); - $style['filter_event_type'] = json_encode($filter_event_type); - $style['filter_event_status'] = json_encode($filter_event_status); + // Added for events items. + $style['show_summary_group'] = $show_summary_group; + $style['filter_event_severity'] = json_encode( + $filter_event_severity + ); + $style['filter_event_type'] = json_encode( + $filter_event_type + ); + $style['filter_event_status'] = json_encode( + $filter_event_status + ); $style['event_graph_by_agent'] = $event_graph_by_agent; $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; @@ -1478,10 +1894,15 @@ switch ($action) { break; case 'simple_graph': - // Warning. We are using this column to hold this value to avoid - // the modification of the database for compatibility reasons. - $style['percentil'] = (int) get_parameter('percentil'); - $style['fullscale'] = (int) get_parameter('fullscale'); + // Warning. We are using this column to hold + // this value to avoid the modification of the + // database for compatibility reasons. + $style['percentil'] = (int) get_parameter( + 'percentil' + ); + $style['fullscale'] = (int) get_parameter( + 'fullscale' + ); if ($label != '') { $style['label'] = $label; } else { @@ -1490,7 +1911,9 @@ switch ($action) { break; case 'network_interfaces_report': - $style['fullscale'] = (int) get_parameter('fullscale'); + $style['fullscale'] = (int) get_parameter( + 'fullscale' + ); break; case 'module_histogram_graph': @@ -1553,11 +1976,9 @@ switch ($action) { break; case 'save': - $values = []; $values['id_report'] = $idReport; $values['type'] = get_parameter('type', null); - // $values['name'] = (string) get_parameter('name'); $values['description'] = get_parameter('description'); $label = get_parameter('label', ''); @@ -1565,42 +1986,71 @@ switch ($action) { $items_label = []; $items_label['type'] = get_parameter('type'); $items_label['id_agent'] = get_parameter('id_agent'); - $items_label['id_agent_module'] = get_parameter('id_agent_module'); + $items_label['id_agent_module'] = get_parameter( + 'id_agent_module' + ); $name_it = (string) get_parameter('name'); $values['recursion'] = get_parameter('recursion', null); - $values['name'] = reporting_label_macro($items_label, $name_it); + $values['name'] = reporting_label_macro( + $items_label, + $name_it + ); - // Support for projection graph, prediction date and SLA reports - // 'top_n_value', 'top_n' and 'text' fields will be reused for these types of report. + // Support for projection graph, prediction date + // and SLA reports 'top_n_value', 'top_n' and 'text' + // fields will be reused for these types of report. switch ($values['type']) { case 'projection_graph': $values['period'] = get_parameter('period1'); - $values['top_n_value'] = get_parameter('period2'); + $values['top_n_value'] = get_parameter( + 'period2' + ); $values['text'] = get_parameter('text'); $good_format = true; break; case 'prediction_date': $values['period'] = get_parameter('period1'); - $values['top_n'] = get_parameter('radiobutton_max_min_avg'); - $values['top_n_value'] = get_parameter('quantity'); + $values['top_n'] = get_parameter( + 'radiobutton_max_min_avg' + ); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $interval_max = get_parameter('max_interval'); $interval_min = get_parameter('min_interval'); - // Checks intervals fields - if (preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_max) and preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_min)) { + // Checks intervals fields. + if (preg_match( + '/^(\-)*[0-9]*\.?[0-9]+$/', + $interval_max + ) + && preg_match( + '/^(\-)*[0-9]*\.?[0-9]+$/', + $interval_min + ) + ) { $good_format = true; } - $intervals = get_parameter('max_interval').';'.get_parameter('min_interval'); + $intervals = get_parameter( + 'max_interval' + ).';'.get_parameter('min_interval'); $values['text'] = $intervals; break; case 'SLA': $values['period'] = get_parameter('period'); - $values['top_n'] = get_parameter('combo_sla_sort_options', 0); - $values['top_n_value'] = get_parameter('quantity'); + $values['top_n'] = get_parameter( + 'combo_sla_sort_options', + 0 + ); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $values['text'] = get_parameter('text'); - $values['show_graph'] = get_parameter('combo_graph_options'); + $values['show_graph'] = get_parameter( + 'combo_graph_options' + ); $good_format = true; break; @@ -1609,7 +2059,9 @@ switch ($action) { $values['period'] = 0; $es['date'] = get_parameter('date'); $es['id_agents'] = get_parameter('id_agents'); - $es['inventory_modules'] = get_parameter('inventory_modules'); + $es['inventory_modules'] = get_parameter( + 'inventory_modules' + ); $values['external_source'] = json_encode($es); $good_format = true; break; @@ -1632,9 +2084,15 @@ switch ($action) { case 'agent_module': $agents_to_report = get_parameter('id_agents2'); - $modules_to_report = get_parameter('module', ''); + $modules_to_report = get_parameter( + 'module', + '' + ); - $es['module'] = get_same_modules($agents_to_report, $modules_to_report); + $es['module'] = get_same_modules( + $agents_to_report, + $modules_to_report + ); $es['id_agents'] = $agents_to_report; $values['external_source'] = json_encode($es); @@ -1644,7 +2102,9 @@ switch ($action) { case 'inventory_changes': $values['period'] = get_parameter('period'); $es['id_agents'] = get_parameter('id_agents'); - $es['inventory_modules'] = get_parameter('inventory_modules'); + $es['inventory_modules'] = get_parameter( + 'inventory_modules' + ); $values['external_source'] = json_encode($es); $good_format = true; break; @@ -1662,11 +2122,17 @@ switch ($action) { case 'netflow_area': case 'netflow_data': case 'netflow_summary': - $values['text'] = get_parameter('netflow_filter'); - $values['description'] = get_parameter('description'); + $values['text'] = get_parameter( + 'netflow_filter' + ); + $values['description'] = get_parameter( + 'description' + ); $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter('resolution'); - $values['top_n_value'] = get_parameter('max_values'); + $values['top_n_value'] = get_parameter( + 'max_values' + ); $good_format = true; break; @@ -1674,14 +2140,18 @@ switch ($action) { $values['period'] = get_parameter('period'); // HACK it is saved in show_graph field. // Show interfaces instead the modules. - $values['show_graph'] = get_parameter('checkbox_show_address_agent'); + $values['show_graph'] = get_parameter( + 'checkbox_show_address_agent' + ); $good_format = true; break; case 'simple_graph': case 'simple_baseline_graph': // HACK it is saved in show_graph field. - $values['show_graph'] = (int) get_parameter('time_compare_overlapped'); + $values['show_graph'] = (int) get_parameter( + 'time_compare_overlapped' + ); $values['period'] = get_parameter('period'); $good_format = true; break; @@ -1690,24 +2160,37 @@ switch ($action) { case 'max_value': case 'avg_value': $values['period'] = get_parameter('period'); - $values['lapse_calc'] = get_parameter('lapse_calc'); + $values['lapse_calc'] = get_parameter( + 'lapse_calc' + ); $values['lapse'] = get_parameter('lapse'); - $values['visual_format'] = get_parameter('visual_format'); + $values['visual_format'] = get_parameter( + 'visual_format' + ); $good_format = true; break; case 'nt_top_n': - $values['top_n_value'] = get_parameter('quantity'); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $values['period'] = get_parameter('period'); $good_format = true; break; default: $values['period'] = get_parameter('period'); - $values['top_n'] = get_parameter('radiobutton_max_min_avg', 0); - $values['top_n_value'] = get_parameter('quantity'); + $values['top_n'] = get_parameter( + 'radiobutton_max_min_avg', + 0 + ); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $values['text'] = get_parameter('text'); - $values['show_graph'] = get_parameter('combo_graph_options'); + $values['show_graph'] = get_parameter( + 'combo_graph_options' + ); $good_format = true; break; } @@ -1717,42 +2200,37 @@ switch ($action) { $values['server_name'] = get_parameter('server_name'); $server_id = (int) get_parameter('server_id'); if ($server_id != 0) { - $connection = metaconsole_get_connection_by_id($server_id); + $connection = metaconsole_get_connection_by_id( + $server_id + ); $values['server_name'] = $connection['server_name']; } if ($values['server_name'] == '') { - $values['server_name'] = get_parameter('combo_server'); + $values['server_name'] = get_parameter( + 'combo_server' + ); } $values['id_agent'] = get_parameter('id_agent'); $values['id_gs'] = get_parameter('id_custom_graph'); - if (($values['type'] == 'alert_report_agent') or ($values['type'] == 'event_report_agent') or ($values['type'] == 'agent_configuration') or ($values['type'] == 'group_configuration')) { + if (($values['type'] == 'alert_report_agent') + || ($values['type'] == 'event_report_agent') + || ($values['type'] == 'agent_configuration') + || ($values['type'] == 'group_configuration') + ) { $values['id_agent_module'] = ''; } else { - $values['id_agent_module'] = get_parameter('id_agent_module'); + $values['id_agent_module'] = get_parameter( + 'id_agent_module' + ); } - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - $values['only_display_wrong'] = (int) get_parameter('checkbox_only_display_wrong', 0); - break; - - case 'oracle': - $only_display_wrong_tmp = get_parameter('checkbox_only_display_wrong'); - if (empty($only_display_wrong_tmp)) { - $values['only_display_wrong'] = 0; - } else { - $values['only_display_wrong'] = $only_display_wrong_tmp; - } - break; - - default: - // Default. - break; - } + $values['only_display_wrong'] = (int) get_parameter( + 'checkbox_only_display_wrong', + 0 + ); $values['monday'] = get_parameter('monday', 0); $values['tuesday'] = get_parameter('tuesday', 0); @@ -1762,68 +2240,132 @@ switch ($action) { $values['saturday'] = get_parameter('saturday', 0); $values['sunday'] = get_parameter('sunday', 0); $values['total_time'] = get_parameter('total_time', 0); - $values['time_failed'] = get_parameter('time_failed', 0); - $values['time_in_ok_status'] = get_parameter('time_in_ok_status', 0); - $values['time_in_unknown_status'] = get_parameter('time_in_unknown_status', 0); - $values['time_of_not_initialized_module'] = get_parameter('time_of_not_initialized_module', 0); - $values['time_of_downtime'] = get_parameter('time_of_downtime', 0); - $values['total_checks'] = get_parameter('total_checks', 0); - $values['checks_failed'] = get_parameter('checks_failed', 0); - $values['checks_in_ok_status'] = get_parameter('checks_in_ok_status', 0); - $values['unknown_checks'] = get_parameter('unknown_checks', 0); - $values['agent_max_value'] = get_parameter('agent_max_value', 0); - $values['agent_min_value'] = get_parameter('agent_min_value', 0); - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - $values['time_from'] = get_parameter('time_from'); - $values['time_to'] = get_parameter('time_to'); - break; + $values['time_failed'] = get_parameter( + 'time_failed', + 0 + ); + $values['time_in_ok_status'] = get_parameter( + 'time_in_ok_status', + 0 + ); + $values['time_in_unknown_status'] = get_parameter( + 'time_in_unknown_status', + 0 + ); + $values['time_of_not_initialized_module'] = get_parameter( + 'time_of_not_initialized_module', + 0 + ); + $values['time_of_downtime'] = get_parameter( + 'time_of_downtime', + 0 + ); + $values['total_checks'] = get_parameter( + 'total_checks', + 0 + ); + $values['checks_failed'] = get_parameter( + 'checks_failed', + 0 + ); + $values['checks_in_ok_status'] = get_parameter( + 'checks_in_ok_status', + 0 + ); + $values['unknown_checks'] = get_parameter( + 'unknown_checks', + 0 + ); + $values['agent_max_value'] = get_parameter( + 'agent_max_value', + 0 + ); + $values['agent_min_value'] = get_parameter( + 'agent_min_value', + 0 + ); - case 'oracle': - $values['time_from'] = '#to_date(\''.get_parameter('time_from').'\',\'hh24:mi:ss\')'; - $values['time_to'] = '#to_date(\''.get_parameter('time_to').'\', \'hh24:mi:ss\')'; - break; + $values['time_from'] = get_parameter( + 'time_from' + ); + $values['time_to'] = get_parameter('time_to'); - default: - // Default. - break; - } - - $values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent', 0); - $values['show_resume'] = get_parameter('checkbox_show_resume', 0); - $values['order_uptodown'] = get_parameter('radiobutton_order_uptodown', 0); - $values['exception_condition'] = (int) get_parameter('radiobutton_exception_condition', 0); - $values['exception_condition_value'] = get_parameter('exception_condition_value'); - $values['id_module_group'] = get_parameter('combo_modulegroup'); + $values['group_by_agent'] = get_parameter( + 'checkbox_row_group_by_agent', + 0 + ); + $values['show_resume'] = get_parameter( + 'checkbox_show_resume', + 0 + ); + $values['order_uptodown'] = get_parameter( + 'radiobutton_order_uptodown', + 0 + ); + $values['exception_condition'] = (int) get_parameter( + 'radiobutton_exception_condition', + 0 + ); + $values['exception_condition_value'] = get_parameter( + 'exception_condition_value' + ); + $values['id_module_group'] = get_parameter( + 'combo_modulegroup' + ); $values['id_group'] = get_parameter('combo_group'); - if ((($values['type'] == 'custom_graph') or ($values['type'] == 'automatic_custom_graph')) && ($values['id_gs'] == 0 || $values['id_gs'] == '')) { + if ((($values['type'] == 'custom_graph') + || ($values['type'] == 'automatic_custom_graph')) + && ($values['id_gs'] == 0 || $values['id_gs'] == '') + ) { $resultOperationDB = false; break; } - if ($config['metaconsole'] == 1 && defined('METACONSOLE')) { - if (($values['type'] == 'custom_graph') or ($values['type'] == 'automatic_custom_graph')) { - $id_gs = substr($values['id_gs'], 0, strpos($values['id_gs'], '|')); + if ($config['metaconsole'] == 1 + && defined('METACONSOLE') + ) { + if (($values['type'] == 'custom_graph') + || ($values['type'] == 'automatic_custom_graph') + ) { + $id_gs = substr( + $values['id_gs'], + 0, + strpos($values['id_gs'], '|') + ); if ($id_gs !== false && $id_gs !== '') { - $server_name = strstr($values['id_gs'], '|'); + $server_name = strstr( + $values['id_gs'], + '|' + ); $values['id_gs'] = $id_gs; - $values['server_name'] = substr($server_name, 1, strlen($server_name)); + $values['server_name'] = substr( + $server_name, + 1, + strlen($server_name) + ); } } } - if (($values['type'] == 'sql') || ($values['type'] == 'sql_graph_hbar') - || ($values['type'] == 'sql_graph_vbar') || ($values['type'] == 'sql_graph_pie') + if (($values['type'] == 'sql') + || ($values['type'] == 'sql_graph_hbar') + || ($values['type'] == 'sql_graph_vbar') + || ($values['type'] == 'sql_graph_pie') ) { - $values['treport_custom_sql_id'] = get_parameter('id_custom'); + $values['treport_custom_sql_id'] = get_parameter( + 'id_custom' + ); if ($values['treport_custom_sql_id'] == 0) { - $values['external_source'] = get_parameter('sql'); + $values['external_source'] = get_parameter( + 'sql' + ); } - $values['historical_db'] = get_parameter('historical_db_check'); + $values['historical_db'] = get_parameter( + 'historical_db_check' + ); $values['top_n_value'] = get_parameter('max_items'); } else if ($values['type'] == 'url') { $values['external_source'] = get_parameter('url'); @@ -1835,38 +2377,85 @@ switch ($action) { $values['column_separator'] = get_parameter('field'); $values['line_separator'] = get_parameter('line'); + $values['current_month'] = get_parameter('current_month'); + $style = []; - $style['show_in_same_row'] = get_parameter('show_in_same_row', 0); - $style['show_in_landscape'] = get_parameter('show_in_landscape', 0); - $style['hide_notinit_agents'] = get_parameter('hide_notinit_agents', 0); - $style['priority_mode'] = get_parameter('priority_mode', REPORT_PRIORITY_MODE_OK); + $style['show_in_same_row'] = get_parameter( + 'show_in_same_row', + 0 + ); + $style['show_in_landscape'] = get_parameter( + 'show_in_landscape', + 0 + ); + $style['hide_notinit_agents'] = get_parameter( + 'hide_notinit_agents', + 0 + ); + $style['priority_mode'] = get_parameter( + 'priority_mode', + REPORT_PRIORITY_MODE_OK + ); $style['dyn_height'] = get_parameter('dyn_height', 230); switch ($values['type']) { case 'event_report_agent': case 'event_report_group': case 'event_report_module': - $show_summary_group = get_parameter('show_summary_group', 0); - $filter_event_severity = get_parameter('filter_event_severity', ''); - $filter_event_type = get_parameter('filter_event_type', ''); - $filter_event_status = get_parameter('filter_event_status', ''); + $show_summary_group = get_parameter( + 'show_summary_group', + 0 + ); + $filter_event_severity = get_parameter( + 'filter_event_severity', + '' + ); + $filter_event_type = get_parameter( + 'filter_event_type', + '' + ); + $filter_event_status = get_parameter( + 'filter_event_status', + '' + ); - $event_graph_by_agent = get_parameter('event_graph_by_agent', 0); - $event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0); - $event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0); - $event_graph_validated_vs_unvalidated = get_parameter('event_graph_validated_vs_unvalidated', 0); + $event_graph_by_agent = get_parameter( + 'event_graph_by_agent', + 0 + ); + $event_graph_by_user_validator = get_parameter( + 'event_graph_by_user_validator', + 0 + ); + $event_graph_by_criticity = get_parameter( + 'event_graph_by_criticity', + 0 + ); + $event_graph_validated_vs_unvalidated = get_parameter( + 'event_graph_validated_vs_unvalidated', + 0 + ); - $event_filter_search = get_parameter('filter_search', ''); + $event_filter_search = get_parameter( + 'filter_search', + '' + ); // Added for events items. - $style['show_summary_group'] = $show_summary_group; - $style['filter_event_severity'] = json_encode($filter_event_severity); - $style['filter_event_type'] = json_encode($filter_event_type); - $style['filter_event_status'] = json_encode($filter_event_status); + $style['show_summary_group'] = $show_summary_group; + $style['filter_event_severity'] = json_encode( + $filter_event_severity + ); + $style['filter_event_type'] = json_encode( + $filter_event_type + ); + $style['filter_event_status'] = json_encode( + $filter_event_status + ); - $style['event_graph_by_agent'] = $event_graph_by_agent; - $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; - $style['event_graph_by_criticity'] = $event_graph_by_criticity; + $style['event_graph_by_agent'] = $event_graph_by_agent; + $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; + $style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; @@ -1888,10 +2477,15 @@ switch ($action) { break; case 'simple_graph': - // Warning. We are using this column to hold this value to avoid - // the modification of the database for compatibility reasons. - $style['percentil'] = (int) get_parameter('percentil'); - $style['fullscale'] = (int) get_parameter('fullscale'); + // Warning. We are using this column to hold + // this value to avoid the modification + // of the database for compatibility reasons. + $style['percentil'] = (int) get_parameter( + 'percentil' + ); + $style['fullscale'] = (int) get_parameter( + 'fullscale' + ); if ($label != '') { $style['label'] = $label; } else { @@ -1900,7 +2494,9 @@ switch ($action) { break; case 'network_interfaces_report': - $style['fullscale'] = (int) get_parameter('fullscale'); + $style['fullscale'] = (int) get_parameter( + 'fullscale' + ); break; case 'module_histogram_graph': @@ -1937,21 +2533,6 @@ switch ($action) { $values['style'] = io_safe_input(json_encode($style)); if ($good_format) { - switch ($config['dbtype']) { - case 'oracle': - if (isset($values['type'])) { - $values[db_escape_key_identifier( - 'type' - )] = $values['type']; - unset($values['type']); - } - break; - - default: - // Default. - break; - } - $result = db_process_sql_insert( 'treport_content', $values @@ -1962,28 +2543,11 @@ switch ($action) { } else { $idItem = $result; - switch ($config['dbtype']) { - case 'mysql': - $max = db_get_all_rows_sql( - 'SELECT max(`order`) AS max - FROM treport_content - WHERE id_report = '.$idReport.';' - ); - break; - - case 'postgresql': - case 'oracle': - $max = db_get_all_rows_sql( - 'SELECT max("order") AS max - FROM treport_content - WHERE id_report = '.$idReport - ); - break; - - default: - // Default. - break; - } + $max = db_get_all_rows_sql( + 'SELECT max(`order`) AS max + FROM treport_content + WHERE id_report = '.$idReport.';' + ); if ($max === false) { $max = 0; @@ -1991,39 +2555,25 @@ switch ($action) { $max = $max[0]['max']; } - switch ($config['dbtype']) { - case 'mysql': - db_process_sql_update( - 'treport_content', - ['`order`' => ($max + 1)], - ['id_rc' => $idItem] - ); - break; - - case 'postgresql': - case 'oracle': - db_process_sql_update( - 'treport_content', - ['"order"' => ($max + 1)], - ['id_rc' => $idItem] - ); - break; - - default: - // Default. - break; - } + db_process_sql_update( + 'treport_content', + ['`order`' => ($max + 1)], + ['id_rc' => $idItem] + ); $resultOperationDB = true; } break; - } - - // If fields dont have good format. - else { + } else { + // If fields dont have good format. $resultOperationDB = false; } + break; + + default: + // Default. + break; } break; @@ -2058,20 +2608,35 @@ switch ($action) { $report = db_get_row_filter('treport', ['id_report' => $idReport]); $reportName = $report['name']; - $resultOperationDB = db_process_sql_delete('treport_content_sla_combined', ['id_report_content' => $idItem]); - $resultOperationDB2 = db_process_sql_delete('treport_content_item', ['id_report_content' => $idItem]); + $resultOperationDB = db_process_sql_delete( + 'treport_content_sla_combined', + ['id_report_content' => $idItem] + ); + $resultOperationDB2 = db_process_sql_delete( + 'treport_content_item', + ['id_report_content' => $idItem] + ); if ($resultOperationDB !== false) { - $resultOperationDB = db_process_sql_delete('treport_content', ['id_rc' => $idItem]); + $resultOperationDB = db_process_sql_delete( + 'treport_content', + ['id_rc' => $idItem] + ); } if ($resultOperationDB2 !== false) { - $resultOperationDB2 = db_process_sql_delete('treport_content', ['id_rc' => $idItem]); + $resultOperationDB2 = db_process_sql_delete( + 'treport_content', + ['id_rc' => $idItem] + ); } break; case 'order': $resultOperationDB = null; - $report = db_get_row_filter('treport', ['id_report' => $idReport]); + $report = db_get_row_filter( + 'treport', + ['id_report' => $idReport] + ); $reportName = $report['name']; $idGroupReport = $report['id_group']; @@ -2142,14 +2707,17 @@ switch ($action) { } $ids = db_get_all_rows_sql($sql); - } - // Sort functionality for metaconsole. - else if ($config['metaconsole'] == 1) { + } else if ($config['metaconsole'] == 1) { + // Sort functionality for metaconsole. switch ($field) { case 'agent': case 'module': $sql = 'SELECT id_rc, id_agent, id_agent_module, server_name FROM treport_content WHERE %s ORDER BY server_name'; - $sql = sprintf($sql, 'id_report = '.$idReport, '%s'); + $sql = sprintf( + $sql, + 'id_report = '.$idReport, + '%s' + ); $report_items = db_get_all_rows_sql($sql); @@ -2159,26 +2727,35 @@ switch ($action) { if (!empty($report_items)) { foreach ($report_items as $report_item) { - $connection = metaconsole_get_connection($report_item['server_name']); + $connection = metaconsole_get_connection( + $report_item['server_name'] + ); if (metaconsole_load_external_db($connection) != NOERR) { - // ui_print_error_message ("Error connecting to ".$server_name);. + continue; } switch ($field) { case 'agent': - $agents_name = agents_get_agents(['id_agente' => $report_item['id_agent']], 'nombre'); + $agents_name = agents_get_agents( + ['id_agente' => $report_item['id_agent']], + 'nombre' + ); // Item without agent. if (!$agents_name) { $element_name = ''; } else { - $agent_name = array_shift($agents_name); + $agent_name = array_shift( + $agents_name + ); $element_name = $agent_name['nombre']; } break; case 'module': - $module_name = modules_get_agentmodule_name($report_item['id_agent_module']); + $module_name = modules_get_agentmodule_name( + $report_item['id_agent_module'] + ); // Item without module. if (!$module_name) { @@ -2252,50 +2829,38 @@ switch ($action) { $ids = db_get_all_rows_sql($sql); break; + + default: + // Default. + break; } } $count = 1; $resultOperationDB = true; foreach ($ids as $id) { - $result = db_process_sql_update('treport_content', ['order' => $count], ['id_rc' => $id['id_rc']]); + $result = db_process_sql_update( + 'treport_content', + ['order' => $count], + ['id_rc' => $id['id_rc']] + ); if ($result === false) { $resultOperationDB = false; break; } - $count = ($count + 1); + $count++; } break; default: - switch ($config['dbtype']) { - case 'mysql': - $oldOrder = db_get_value_sql( - ' - SELECT `order` - FROM treport_content - WHERE id_rc = '.$idItem - ); - break; + $oldOrder = db_get_value_sql( + 'SELECT `order` + FROM treport_content + WHERE id_rc = '.$idItem + ); - case 'postgresql': - case 'oracle': - $oldOrder = db_get_value_sql( - ' - SELECT "order" - FROM treport_content - WHERE id_rc = '.$idItem - ); - break; - - default: - // Default. - break; - } - - // db_get_value_filter('order', 'treport_content', array('id_rc' => $idItem)); switch ($dir) { case 'up': $newOrder = ($oldOrder - 1); @@ -2310,79 +2875,22 @@ switch ($action) { break; } - switch ($config['dbtype']) { - case 'mysql': - $resultOperationDB = db_process_sql_update( - 'treport_content', - ['`order`' => $oldOrder], - [ - '`order`' => $newOrder, - 'id_report' => $idReport, - ] - ); - break; + $resultOperationDB = db_process_sql_update( + 'treport_content', + ['`order`' => $oldOrder], + [ + '`order`' => $newOrder, + 'id_report' => $idReport, + ] + ); - case 'postgresql': - $resultOperationDB = db_process_sql_update( - 'treport_content', - ['"order"' => $oldOrder], - [ - '"order"' => $newOrder, - 'id_report' => $idReport, - ] - ); - break; - - case 'oracle': - $resultOperationDB = db_process_sql_update( - 'treport_content', - ['"order"' => $oldOrder], - [ - '"order"' => $newOrder, - 'id_report' => $idReport, - ], - 'AND', - false - ); - break; - - default: - // Default. - break; - } if ($resultOperationDB !== false) { - switch ($config['dbtype']) { - case 'mysql': - $resultOperationDB = db_process_sql_update( - 'treport_content', - ['`order`' => $newOrder], - ['id_rc' => $idItem] - ); - break; - - case 'postgresql': - $resultOperationDB = db_process_sql_update( - 'treport_content', - ['"order"' => $newOrder], - ['id_rc' => $idItem] - ); - break; - - case 'oracle': - $resultOperationDB = db_process_sql_update( - 'treport_content', - ['"order"' => $newOrder], - ['id_rc' => $idItem], - 'AND', - false - ); - break; - - default: - // Default. - break; - } + $resultOperationDB = db_process_sql_update( + 'treport_content', + ['`order`' => $newOrder], + ['id_rc' => $idItem] + ); } break; } @@ -2408,13 +2916,16 @@ switch ($action) { break; default: - $subsection = reporting_enterprise_add_subsection_main($activeTab, $buttons); + $subsection = reporting_enterprise_add_subsection_main( + $activeTab, + $buttons + ); break; } // Page header for metaconsole. - if ($enterpriseEnable and defined('METACONSOLE')) { - // Bread crumbs + if ($enterpriseEnable && defined('METACONSOLE')) { + // Bread crumbs. ui_meta_add_breadcrumb( [ 'link' => 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure, @@ -2426,12 +2937,20 @@ switch ($action) { // Print header. ui_meta_print_header(__('Reporting'), '', $buttons); + } else { + // Page header for normal console. + ui_print_page_header( + $subsection, + 'images/op_reporting.png', + false, + '', + false, + $buttons, + false, + '', + 60 + ); } - // Page header for normal console. - else { - ui_print_page_header($subsection, 'images/op_reporting.png', false, '', false, $buttons, false, '', 60); - } - reporting_enterprise_select_main_tab($action); } @@ -2466,7 +2985,10 @@ $buttons = [ ]; if ($enterpriseEnable) { - $buttons = reporting_enterprise_add_Tabs($buttons, $idReport); + $buttons = reporting_enterprise_add_Tabs( + $buttons, + $idReport + ); } $buttons['view'] = [ @@ -2491,7 +3013,7 @@ if ($idReport != 0) { } // Page header for metaconsole. -if ($enterpriseEnable and defined('METACONSOLE')) { +if ($enterpriseEnable && defined('METACONSOLE')) { // Bread crumbs. ui_meta_add_breadcrumb( [ @@ -2532,7 +3054,11 @@ if ($resultOperationDB !== null) { break; } - ui_print_result_message($resultOperationDB, __('Successfull action'), __('Unsuccessful action

'.$err)); + ui_print_result_message( + $resultOperationDB, + __('Successfull action'), + __('Unsuccessful action

'.$err) + ); } switch ($activeTab) { diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index 03841a342e..bc00f703c8 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -674,12 +674,17 @@ function update_button_palette_callback() { return false; } } - if (values["module"] == 0) { + var radio_value = $("input[name='radio_choice']:checked").val(); + if (values["agent"] == "" && radio_value == "module_graph") { + dialog_message("#message_alert_no_agent"); + return false; + } + if (values["module"] == 0 && radio_value == "module_graph") { dialog_message("#message_alert_no_module"); return false; } - if (values["agent"] == "") { - dialog_message("#message_alert_no_agent"); + if (values["id_custom_graph"] == 0 && radio_value == "custom_graph") { + dialog_message("#message_alert_no_custom_graph"); return false; } if ($("input[name=width_module_graph]").val() == "") { @@ -1425,11 +1430,12 @@ function create_button_palette_callback() { break; case "module_graph": - if (values["module"] == 0) { + var radio_value = $("input[name='radio_choice']:checked").val(); + if (values["module"] == 0 && radio_value == "module_graph") { dialog_message("#message_alert_no_module"); validate = false; } - if (values["id_custom_graph"] == 0) { + if (values["id_custom_graph"] == 0 && radio_value == "module_graph") { if (values["agent"] == "") { dialog_message("#message_alert_no_agent"); validate = false; @@ -1439,6 +1445,10 @@ function create_button_palette_callback() { validate = false; } } + if (values["id_custom_graph"] == 0 && radio_value == "custom_graph") { + dialog_message("#message_alert_no_custom_graph"); + validate = false; + } if ( values["height_module_graph"] == "" || values["height_module_graph"] == 0 diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index 645815e6c0..e205203f9d 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -1189,13 +1189,13 @@ ui_require_javascript_file('pandora_modules'); } } else { - alert(''); + alert(""); } } } var macros_click_locked_event = function (event) { - alert(''); + alert(""); } if (locked) { diff --git a/pandora_console/godmode/setup/setup_ehorus.php b/pandora_console/godmode/setup/setup_ehorus.php index fc2ebd3d3a..5492552ce1 100644 --- a/pandora_console/godmode/setup/setup_ehorus.php +++ b/pandora_console/godmode/setup/setup_ehorus.php @@ -139,47 +139,49 @@ if ($config['ehorus_enabled'] && !$custom_field_exists) { ui_print_error_message($error_message); } +echo "
"; // Form enable. -echo ''; +echo '
'; html_print_input_hidden('update_config', 1); html_print_table($table_enable); -echo ''; +echo '
'; // Form remote. -if ($config['ehorus_enabled']) { - echo '
'; + echo '
'; echo '
'; echo ''.__('eHorus API').''; html_print_input_hidden('update_config', 1); html_print_table($table_remote); - echo '
'; + + echo '
'; + echo '
'; + echo '
'; html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"'); echo '
'; - echo ''; echo '
'; -} ?>