diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index cbbe36739d..b730a8e8f8 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1, AIX version +# Version 5.1SP1RC1, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index 440925b478..30a918fed6 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1, FreeBSD Version +# Version 5.1SP1RC1, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index 74946575e3..9b25290ecf 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1, HP-UX Version +# Version 5.1SP1RC1, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index e22090c259..c9e20014d3 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1, GNU/Linux +# Version 5.1SP1RC1, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index cde1997252..d8cdfde597 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1, GNU/Linux +# Version 5.1SP1RC1, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index 9e3cc17f76..6154528478 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1, Solaris Version +# Version 5.1SP1RC1, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 08a50499c6..73c27f8eaa 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2010 Artica Soluciones Tecnologicas -# Version 5.1SP1 +# Version 5.1SP1RC1 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index 85492f5959..f06e2d7084 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 5.1SP1, AIX version +# Version 5.1SP1RC1, AIX version # General Parameters # ================== diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index 1ef7d862a0..daf920dc0a 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 5.1SP1 +# Version 5.1SP1RC1 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index d868c9ee10..e0fdf88610 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 5.1SP1, HPUX Version +# Version 5.1SP1RC1, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 53efe77f9f..d6b43d22c1 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1 +# Version 5.1SP1RC1 # Licensed under GPL license v2, # (c) 2003-2010 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index 544cc859d4..85abb4caeb 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1 +# Version 5.1SP1RC1 # Licensed under GPL license v2, # (c) 2003-2009 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index dd356d5710..53617b89f6 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1 +# Version 5.1SP1RC1 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index 17eba11134..8f946bef09 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 5.1SP1, Solaris version +# Version 5.1SP1RC1, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index 452ddc40f4..e83eee11ad 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1, AIX version +# Version 5.1SP1RC1, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 41fc04fc3b..fa336d77fc 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 5.1SP1-141007 +Version: 5.1SP1RC1-141014 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 d07cf0f740..c33cf4123b 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="5.1SP1-141007" +pandora_version="5.1SP1RC1-141014" 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/Darwin/pandora_agent.conf b/pandora_agents/unix/Darwin/pandora_agent.conf index 0ad3c344b1..4e3dd130c3 100644 --- a/pandora_agents/unix/Darwin/pandora_agent.conf +++ b/pandora_agents/unix/Darwin/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1, GNU/Linux +# Version 5.1SP1RC1, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2012 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/FreeBSD/pandora_agent.conf b/pandora_agents/unix/FreeBSD/pandora_agent.conf index 3df69c78c1..c421fc0ac1 100644 --- a/pandora_agents/unix/FreeBSD/pandora_agent.conf +++ b/pandora_agents/unix/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1, FreeBSD Version +# Version 5.1SP1RC1, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/HP-UX/pandora_agent.conf b/pandora_agents/unix/HP-UX/pandora_agent.conf index 9fad78c88d..f494c44f0f 100644 --- a/pandora_agents/unix/HP-UX/pandora_agent.conf +++ b/pandora_agents/unix/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1, HP-UX Version +# Version 5.1SP1RC1, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index ce4928402e..f315009dc8 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1, GNU/Linux +# Version 5.1SP1RC1, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2014 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NT4/pandora_agent.conf b/pandora_agents/unix/NT4/pandora_agent.conf index 7ed2d32f0d..a247d589a4 100644 --- a/pandora_agents/unix/NT4/pandora_agent.conf +++ b/pandora_agents/unix/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1, GNU/Linux +# Version 5.1SP1RC1, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NetBSD/pandora_agent.conf b/pandora_agents/unix/NetBSD/pandora_agent.conf index de30e39514..1b3083a6b3 100644 --- a/pandora_agents/unix/NetBSD/pandora_agent.conf +++ b/pandora_agents/unix/NetBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1, NetBSD Version +# Version 5.1SP1RC1, NetBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/SunOS/pandora_agent.conf b/pandora_agents/unix/SunOS/pandora_agent.conf index a5c644a2a9..3a6214f26f 100644 --- a/pandora_agents/unix/SunOS/pandora_agent.conf +++ b/pandora_agents/unix/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 5.1SP1, Solaris Version +# Version 5.1SP1RC1, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 92c3e02654..5879dd7e06 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -40,8 +40,8 @@ my $Sem = undef; # Semaphore used to control the number of threads my $ThreadSem = undef; -use constant AGENT_VERSION => '5.1SP1'; -use constant AGENT_BUILD => '141007'; +use constant AGENT_VERSION => '5.1SP1RC1'; +use constant AGENT_BUILD => '141014'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index cb1e2ed08c..f934d5b818 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 5.1SP1 -%define release 141007 +%define version 5.1SP1RC1 +%define release 141014 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 78e5fda936..067d14a776 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 5.1SP1 -%define release 141007 +%define version 5.1SP1RC1 +%define release 141014 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/win32/ChangeLog b/pandora_agents/win32/ChangeLog new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index f75fd15368..5022fc9751 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2014 Artica Soluciones Tecnologicas -# Version 5.1SP1 +# Version 5.1SP1RC1 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index cc317f3356..aa17b49174 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -3,7 +3,7 @@ AllowLanguageSelection {Yes} AppName -{Pandora FMS Windows Agent v5.1SP1} +{Pandora FMS Windows Agent v5.1SP1RC1} ApplicationID {17E3D2CF-CA02-406B-8A80-9D31C17BD08F} @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{141007} +{141014} ViewReadme {Yes} diff --git a/pandora_agents/win32/modules/pandora_module.cc b/pandora_agents/win32/modules/pandora_module.cc index 9cc6c4758a..67f6c48533 100644 --- a/pandora_agents/win32/modules/pandora_module.cc +++ b/pandora_agents/win32/modules/pandora_module.cc @@ -1464,6 +1464,7 @@ Pandora_Module::evaluateConditions () { } WaitForSingleObject(pi.hProcess, this->module_timeout); CloseHandle (pi.hProcess); + CloseHandle (pi.hThread); } } } diff --git a/pandora_agents/win32/modules/pandora_module_logevent.cc b/pandora_agents/win32/modules/pandora_module_logevent.cc index e20ad0995d..0848edd824 100755 --- a/pandora_agents/win32/modules/pandora_module_logevent.cc +++ b/pandora_agents/win32/modules/pandora_module_logevent.cc @@ -640,6 +640,7 @@ Pandora_Module_Logevent::getEventDescriptionXPATH (PEVENTLOGRECORD pevlr) { description = strUnicodeToAnsi (pwsMessage); // Cleanup + free(pwsMessage); free(pRenderedValues); EvtCloseF(hProviderMetadata); EvtCloseF(hContext); diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 8df566e1c9..b35a64a401 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 ("5.1SP1(Build 141007)") +#define PANDORA_VERSION ("5.1SP1RC1(Build 141014)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index f234182797..c5408023ff 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", "(5.1SP1(Build 141007))" + VALUE "ProductVersion", "(5.1SP1RC1(Build 141014))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 519399e4f8..b441b7e0ba 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 5.1SP1-141007 +Version: 5.1SP1RC1-141014 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 2b7ee5d217..17499aff0e 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="5.1SP1-141007" +pandora_version="5.1SP1RC1-141014" package_pear=0 package_pandora=1 diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index 48499b7a89..d603a5c9c5 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -105,7 +105,16 @@ if (!empty($macros)) { ?> diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php index d5455f22f4..44312abe7f 100755 --- a/pandora_console/godmode/agentes/planned_downtime.editor.php +++ b/pandora_console/godmode/agentes/planned_downtime.editor.php @@ -164,7 +164,7 @@ if ($create_downtime || $update_downtime) { || ($type_periodicity == 'monthly' && $periodically_day_from == $periodically_day_to && $periodically_time_from >= $periodically_time_to))) { ui_print_error_message(__('Not created. Error inserting data') . ". " .__('The end time must be higher than the start time')); } - else if ($type_execution == 'periodically' && $type_periodicity == 'monthly' && $periodically_day_from >= $periodically_day_to) { + else if ($type_execution == 'periodically' && $type_periodicity == 'monthly' && $periodically_day_from > $periodically_day_to) { ui_print_error_message(__('Not created. Error inserting data') . ". " .__('The end day must be higher than the start day')); } else { @@ -442,7 +442,7 @@ $table->data[5][1] = " "; -echo '
'; +echo ''; if ($id_downtime > 0) { echo ""; @@ -502,7 +502,7 @@ if ($id_downtime > 0) { $disabled_add_button = true; } - echo ""; + echo ""; html_print_select_groups(false, "AW", true, 'filter_group', $filter_group, '', '', '', false, false, true, '', false, 'width:180px'); @@ -510,7 +510,7 @@ if ($id_downtime > 0) { html_print_submit_button (__('Filter by group'), '', false, 'class="sub next"',false); echo ""; - echo ""; + echo ""; echo html_print_select ($data, "id_agents[]", '', '', '', 0, false, true, true, '', false, 'width: 180px;'); echo '

' . __('Available modules:') . @@ -593,7 +593,7 @@ if ($id_downtime > 0) { html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Delete'))) . ""; } - $data[5] .= '"; + } +} // Header ui_print_page_header( @@ -272,8 +287,9 @@ $table = new StdClass(); $table->class = 'databox'; //Start Overview of existing planned downtime $table->width = '98%'; -$table->data = array (); -$table->head = array (); +$table->cellstyle = array(); +$table->data = array(); +$table->head = array(); $table->head[0] = __('Name #Ag.'); $table->head[1] = __('Description'); $table->head[2] = __('Group'); @@ -285,7 +301,6 @@ $table->head[7] = __('Stop downtime'); $table->head[8] = __('Edit'); $table->head[9] = __('Delete'); $table->align[2] = "center"; -//$table->align[5] = "center"; $table->align[6] = "center"; $table->align[7] = "center"; $table->align[8] = "center"; @@ -478,7 +493,7 @@ else { if ($downtime["executed"] == 0) { $data[8] = '' . + href="index.php?sec=estado&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">' . html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Update'))) . ''; $data[9] = '' . @@ -489,6 +504,16 @@ else { $data[9]= "N/A"; } + + if (!empty($malformed_downtimes_exist) && isset($malformed_downtimes[$downtime['id']])) { + $next_row_num = count($table->data); + $table->cellstyle[$next_row_num][0] = 'color: red'; + $table->cellstyle[$next_row_num][1] = 'color: red'; + $table->cellstyle[$next_row_num][3] = 'color: red'; + $table->cellstyle[$next_row_num][4] = 'color: red'; + $table->cellstyle[$next_row_num][5] = 'color: red'; + } + array_push ($table->data, $data); } html_print_table ($table); @@ -500,7 +525,7 @@ echo '
'; html_print_button(__('Export to CSV'), 'csv_export', false, "location.href='godmode/agentes/planned_downtime.export_csv.php?$filter_params_str'", 'class="sub next"'); echo '
'; echo ' '; -echo ''; +echo ''; html_print_submit_button (__('Create'), 'create', false, 'class="sub next"'); echo ''; echo ''; @@ -522,6 +547,12 @@ $(document).ready (function () { e.preventDefault(); } }); + + if ( && ) { + if (confirm("")) { + window.location.href = "index.php?sec=estado&sec2=godmode/agentes/planned_downtime.list&migrate_malformed=1"; + } + } }); \ No newline at end of file diff --git a/pandora_console/godmode/db/db_info.php b/pandora_console/godmode/db/db_info.php index 0e81a7e679..e694540d99 100644 --- a/pandora_console/godmode/db/db_info.php +++ b/pandora_console/godmode/db/db_info.php @@ -18,78 +18,19 @@ // Load global vars global $config; -require_once ($config['homedir'] . '/include/functions_graph.php'); -require_once($config['homedir'] . '/include/functions_agents.php'); -require_once($config['homedir'] . '/include/functions_modules.php'); +check_login(); -ui_print_page_header (__('Database maintenance').' » '.__('Database information'), "images/gm_db.png", false, "", true); - -check_login (); - if (! check_acl ($config['id_user'], 0, "DM")) { db_pandora_audit("ACL Violation", "Trying to access Database Management Info"); require ("general/noaccess.php"); return; } -// Todo for a good DB maintenance -/* - - Delete too on datos_string and and datos_inc tables - - - A function to "compress" data, and interpolate big chunks of data (1 month - 60000 registers) - onto a small chunk of interpolated data (1 month - 600 registers) - - - A more powerful selection (by Agent, by Module, etc). - */ +require_once ($config['homedir'] . '/include/functions_graph.php'); + +ui_print_page_header (__('Database maintenance').' » '.__('Database information'), "images/gm_db.png", false, "", true); + +echo '

'.__('Module data received').'

'; echo grafico_db_agentes_purge(0, 600, 400); - -echo '
'; -echo '

'; -echo ''; -echo '
'; -echo '

'.__('Modules per agent').'

'; - -echo graph_db_agentes_modulos(600, 250); - -echo '

'; -echo '

'.__('Packets per agent').'

'; - -echo grafico_db_agentes_paquetes(700, 300); - -echo '
'; -echo ''.__('Press here to get database information as text').' ' . html_print_image("images/down.png", true, array("alt" => "down", "title" => "down")) . ''; -echo ''; -?> +?> \ No newline at end of file diff --git a/pandora_console/godmode/db/db_sanity.php b/pandora_console/godmode/db/db_sanity.php deleted file mode 100644 index 6cb81ae12e..0000000000 --- a/pandora_console/godmode/db/db_sanity.php +++ /dev/null @@ -1,124 +0,0 @@ -".__('Checking tagente_estado table').""; - - $rows = db_get_all_rows_in_table('tagente_modulo'); - if ($rows === false) { - $rows = array(); - } - - foreach ($rows as $row) { - $id_agente_modulo = $row['id_agente_modulo']; - $id_agente = $row["id_agente"]; - // check if exist in tagente_estado and create if not - $sql = "SELECT COUNT(*) FROM tagente_estado - WHERE id_agente_modulo = $id_agente_modulo"; - $total = db_get_sql ($sql); - if ($total == 0) { - $sql = "INSERT INTO tagente_estado (id_agente_modulo, datos, timestamp, estado, id_agente, last_try, utimestamp, current_interval, running_by, last_execution_try) VALUE ($id_agente_modulo, 0, '01-01-1970 00:00:00', 0, 100, $id_agente, '01-01-1970 00:00:00', 0, 0, 0)"; - echo "Inserting module $id_agente_modulo in state table
"; - db_process_sql ($sql); - } - } - ui_print_message(__('Check tagente_estado table: Done')); - - echo "

".__('Checking database consistency')."

"; - - $rows = db_get_all_rows_in_table('tagente_estado'); - if ($rows === false) { - $rows = array(); - } - - foreach ($rows as $row) { - $id_agente_modulo = $row['id_agente_modulo']; - # check if exist in tagente_estado and create if not - - $rows = db_get_all_rows_sql("SELECT COUNT(*) AS count FROM tagente_modulo WHERE id_agente_modulo = $id_agente_modulo"); - - if ($rows !== false) { - $row = reset($rows); - $count = $row['count']; - - if ($count == 0) { - echo "Deleting non-existing module $id_agente_modulo in state table
"; - - db_process_sql_delete('tagente_estado', array('id_agente_modulo' => $id_agente_modulo)); - } - } - } - ui_print_message(__('Check database consistency: Done')); -} -elseif ($sanity == 2) { - echo "

".__('Deleting non-init data')."

"; - - $rows = db_get_all_rows_filter("tagente_estado", array("utimestamp" => 0)); - if ($rows === false) { - $rows = array(); - } - - foreach ($rows as $row) { - echo "Deleting non init module " . $row['id_agente_modulo'] ."
"; - - modules_delete_agent_module($row['id_agente_modulo']); - } - - echo "Deleting bad module (id 0)
"; - - $bad_modules = db_get_all_rows_filter('tagente_modulo', array('id_modulo' => 0)); - - foreach($bad_modules as $bm) { - modules_delete_agent_module ($bm['id_agente_modulo']); - } -} - -echo "
"; -echo "
"; -echo __('Pandora FMS Sanity tool is used to remove bad database structure data, created modules with missing status, or modules that cannot be initialized (and don\'t report any valid data) but retry each its own interval to get data. This kind of bad modules could degrade performance of Pandora FMS. This database sanity tool is also implemented in the pandora_db.pl that you should be running each day or week. This console sanity DONT compact your database, only delete bad structured data.'); - -echo "

"; -echo ""; -echo html_print_image('images/status_away.png', true) . "  "; -echo __('Sanitize my database now'); -echo ""; - - -echo "

"; -echo ""; -echo html_print_image('images/status_away.png', true) . "  "; -echo __('Delete non-initialized modules now'); -echo ""; - -echo "
"; -?> diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 7e42f8aae7..b93a0e42e2 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -247,7 +247,6 @@ if (check_acl ($config['id_user'], 0, "DM")) { $sub["godmode/db/db_refine"]["text"] = __('Database debug'); $sub["godmode/db/db_audit"]["text"] = __('Database audit'); $sub["godmode/db/db_event"]["text"] = __('Database event'); - $sub["godmode/db/db_sanity"]["text"] = __('Database sanity'); $menu_godmode["gdbman"]["sub"] = $sub; } diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index abd2752c9f..364f36e15e 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -209,6 +209,37 @@ elseif ($disable_user !== false) { //disable_user } } +$filter_group = (int)get_parameter('filter_group', 0); +$filter_search = get_parameter('filter_search', ''); +$search = (bool)get_parameter('search', false); + +if (($filter_group == 0) && ($filter_search == '')) { + $search = false; +} + +$table = null; +$table->width = '99%'; +$table->class = "databox"; +$table->rowclass[0] = ''; +$table->data[0][0] = '' . __('Group') . ''; +$table->data[0][1] = html_print_select_groups(false, "AR", true, + 'filter_group', $filter_group, '', '', 0, true); +$table->data[0][2] = '' . __('Search') . '' . + ui_print_help_tip(__('Search by username, fullname or email'), true); +$table->data[0][3] = html_print_input_text('filter_search', + $filter_search, __('Search by username, fullname or email'), 30, 90, true); +$table->data[0][4] = html_print_submit_button(__('Search'), 'search', + false, array('class' => 'sub search'), true); + + + +$form_filter = "
"; +$form_filter .= html_print_table($table, true); +$form_filter .= "
"; + +ui_toggle($form_filter, __('Users control filter'), __('Toggle filter(s)'), !$search); + +$table = null; $table->cellpadding = 4; $table->cellspacing = 4; $table->width = '99%'; @@ -252,10 +283,53 @@ $table->valign[4] = 'top'; $table->valign[5] = 'top'; $table->valign[6] = 'top'; + + $info1 = array (); $info1 = get_users ($order); +//Filter the users +if ($search) { + foreach ($info1 as $iterator => $user_info) { + $found = false; + + if (!empty($filter_search)) { + if (preg_match("/.*" . $filter_search . ".*/", $user_info['fullname']) != 0) { + $found = true; + } + + if (preg_match("/.*" . $filter_search . ".*/", $user_info['id_user']) != 0) { + $found = true; + } + + if (preg_match("/.*" . $filter_search . ".*/", $user_info['email']) != 0) { + $found = true; + } + } + + if ($filter_group != 0) { + $groups = users_get_groups($user_info['id_user'], 'AR', + $user_info['is_admin']); + + $id_groups = array_keys($groups); + + if (array_search($filter_group, $id_groups) !== false) { + $found = true; + } + } + + if (!$found) { + unset($info1[$iterator]); + } + } +} + +//~ +//~ $filter_group +//~ $filter_search +//~ + $info = array(); $own_info = get_user_info ($config['id_user']); $own_groups = users_get_groups ($config['id_user'], 'AR', $own_info['is_admin']); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 6bae453c10..435a1c1a4e 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,8 +22,8 @@ /** * Pandora build version and version */ -$build_version = 'PC141007'; -$pandora_version = 'v5.1SP1'; +$build_version = 'PC141014'; +$pandora_version = 'v5.1SP1RC1'; // Do not overwrite default timezone set if defined. $script_tz = @date_default_timezone_get(); diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index ba24e77458..d00a5e4c64 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -377,7 +377,10 @@ define("CUSTOM_GRAPH_LINE", 2); define("CUSTOM_GRAPH_STACKED_LINE", 3); /* COLLECTIONS */ -define("COLLECTION_CORRECT", 0); -define("COLLECTION_PENDING_APPLY", 1); +define("COLLECTION_PENDING_APPLY", 0); +define("COLLECTION_CORRECT", 1); define("COLLECTION_ERROR_LOST_DIRECTORY", 2); + +/* PAGINATION */ +define("PAGINATION_BLOCKS_LIMIT", 15); ?> diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 80ddd70b6b..93b6f593ea 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -378,6 +378,9 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType) 'group_parent', 'disabled', 'custom_id', + 'group_description', + 'group_contact', + 'group_other', 'agent_id', 'agent_name', @@ -677,7 +680,10 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType) $returnVar = array(); - $groups = db_get_all_rows_sql('SELECT id_grupo as group_id, nombre as group_name, parent as group_parent, disabled, custom_id FROM tgrupo'); + $groups = db_get_all_rows_sql('SELECT id_grupo as group_id, ' . + 'nombre as group_name, parent as group_parent, disabled, custom_id, ' . + 'description as group_description, contact as group_contact, ' . + 'other as group_other FROM tgrupo'); if ($groups === false) $groups = array(); $groups = str_replace('\n', $returnReplace, $groups); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 350984b3b3..370a8638b9 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -102,9 +102,12 @@ function get_statwin_graph_statistics ($chart_array, $series_suffix = '') { foreach ($chart_array as $item) { if ($series_suffix != '') { - $item['sum'] = $item['sum' . $series_suffix]; - $item['min'] = $item['min' . $series_suffix]; - $item['max'] = $item['max' . $series_suffix]; + if (isset($item['sum' . $series_suffix])) + $item['sum'] = $item['sum' . $series_suffix]; + if (isset($item['min' . $series_suffix])) + $item['min'] = $item['min' . $series_suffix]; + if (isset($item['max' . $series_suffix])) + $item['max'] = $item['max' . $series_suffix]; } //Get stats for normal graph @@ -1746,60 +1749,205 @@ function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) { if ($id_agent < 1) { - $id_agent = -1; $query = ""; } else { - $modules = agents_get_modules ($id_agent); - $query = sprintf (" AND id_agente_modulo IN (%s)", implode (",", array_keys ($modules))); + $modules = agents_get_modules($id_agent); + $module_ids = array_keys($modules); + + if (!empty($module_ids)) { + $module_ids_str = implode(",", $module_ids); + + if (empty($module_ids_str)) + $module_ids_str = "0"; + } + else { + $module_ids_str = "0"; + } + + $query = sprintf (" AND id_agente_modulo IN (%s)", $module_ids_str); } // All data (now) - $time["all"] = get_system_time (); + $time_now = time(); // 1 day ago - $time["1day"] = $time["all"] - SECONDS_1DAY; + $time_1day = $time_now - SECONDS_1DAY; // 1 week ago - $time["1week"] = $time["all"] - SECONDS_1WEEK; + $time_1week = $time_now - SECONDS_1WEEK; // 1 month ago - $time["1month"] = $time["all"] - SECONDS_1MONTH; + $time_1month = $time_now - SECONDS_1MONTH; // Three months ago - $time["3month"] = $time["all"] - SECONDS_3MONTHS; + $time_3months = $time_now - SECONDS_3MONTHS; - $data[__("Today")] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1day"], $query), 0, true); - $data["1 ".__("Week")] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1week"], $query), 0, true); - $data["1 ".__("Month")] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1month"], $query), 0, true); - $data["3 ".__("Months")] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["3month"], $query), 0, true); - $data[__("Older")] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE 1=1 %s", $query)); - - $data[__("Today")] += db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1day"], $query), 0, true); - $data["1 ".__("Week")] += db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1week"], $query), 0, true); - $data["1 ".__("Month")] += db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1month"], $query), 0, true); - $data["3 ".__("Months")] += db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["3month"], $query), 0, true); - $data[__("Older")] += db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE 1=1 %s", $query), 0, true); - - $data[__("Today")] += db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_log4x WHERE utimestamp > %d %s", $time["1day"], $query), 0, true); - $data["1 ".__("Week")] += db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_log4x WHERE utimestamp > %d %s", $time["1week"], $query), 0, true); - $data["1 ".__("Month")] += db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_log4x WHERE utimestamp > %d %s", $time["1month"], $query), 0, true); - $data["3 ".__("Months")] += db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_log4x WHERE utimestamp > %d %s", $time["3month"], $query), 0, true); - $data[__("Older")] += db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_log4x WHERE 1=1 %s", $query), 0, true); - - $data[__("Older")] = $data[__("Older")] - $data["3 ".__("Months")]; - - if ($data[__("Today")] == 0 && $data["1 ".__("Week")] == 0 && - $data["1 ".__("Month")] == 0 && $data["3 ".__("Months")] == 0 && $data[__("Older")] == 0) { + $query_error = false; + + // Data from 1 day ago + $sql_1day = sprintf("SELECT COUNT(*) + + (SELECT COUNT(*) + FROM tagente_datos_string + WHERE utimestamp >= %d %s) + + (SELECT COUNT(*) + FROM tagente_datos_log4x + WHERE utimestamp >= %d %s) + FROM tagente_datos + WHERE utimestamp > %d %s", + $time_1day, $query, + $time_1day, $query, + $time_1day, $query); + $num_1day = db_get_sql($sql_1day); + + if ($num_1day !== false) { + // Data from 1 week ago + $sql_1week = sprintf("SELECT COUNT(*) + + (SELECT COUNT(*) + FROM tagente_datos_string + WHERE utimestamp >= %d %s) + + (SELECT COUNT(*) + FROM tagente_datos_log4x + WHERE utimestamp >= %d %s) + FROM tagente_datos + WHERE utimestamp >= %d %s", + $time_1week, $query, + $time_1week, $query, + $time_1week, $query); + $num_1week = db_get_sql($sql_1week); + + if ($num_1week !== false) { + // Data from 1 month ago + $sql_1month = sprintf("SELECT COUNT(*) + + (SELECT COUNT(*) + FROM tagente_datos_string + WHERE utimestamp >= %d %s) + + (SELECT COUNT(*) + FROM tagente_datos_log4x + WHERE utimestamp >= %d %s) + FROM tagente_datos + WHERE utimestamp >= %d %s", + $time_1month, $query, + $time_1month, $query, + $time_1month, $query); + $num_1month = db_get_sql($sql_1month); + + if ($num_1month !== false) { + // Data from 3 months ago + $sql_3months = sprintf("SELECT COUNT(*) + + (SELECT COUNT(*) + FROM tagente_datos_string + WHERE utimestamp >= %d %s) + + (SELECT COUNT(*) + FROM tagente_datos_log4x + WHERE utimestamp >= %d %s) + FROM tagente_datos + WHERE utimestamp >= %d %s", + $time_3months, $query, + $time_3months, $query, + $time_3months, $query); + $num_3months = db_get_sql($sql_3months); + + if ($num_3months !== false) { + // All data + $sql_all = sprintf("SELECT COUNT(*) + + (SELECT COUNT(*) + FROM tagente_datos_string + WHERE 1=1 %s) + + (SELECT COUNT(*) + FROM tagente_datos_log4x + WHERE 1=1 %s) + FROM tagente_datos + WHERE 1=1 %s", + $query, $query, $query); + $num_all = db_get_sql($sql_all); + + if ($num_all !== false) { + $num_older = $num_all - $num_3months; + + if ($config['history_db_enabled'] == 1) { + // All data in common and history database + $sql_all_w_history = sprintf("SELECT COUNT(*) + + (SELECT COUNT(*) + FROM tagente_datos_string + WHERE 1=1 %s) + + (SELECT COUNT(*) + FROM tagente_datos_log4x + WHERE 1=1 %s) + FROM tagente_datos + WHERE 1=1 %s", + $query, $query, $query); + $num_all_w_history = db_get_sql($sql_all_w_history, 0, true); + + if ($num_all_w_history !== false) { + $num_history = $num_all_w_history - $num_all; + } else { + $query_error = true; + } + } + } else { + $query_error = true; + } + } else { + $query_error = true; + } + } else { + $query_error = true; + } + } else { + $query_error = true; + } + } else { + $query_error = true; + } + + // Error + if ($query_error || $num_older < 0 || ($config['history_db_enabled'] == 1 && $num_history < 0) + || (empty($num_1day) && empty($num_1week) && empty($num_1month) + && empty($num_3months) && empty($num_all) + && ($config['history_db_enabled'] == 1 && empty($num_all_w_history)))) { return html_print_image('images/image_problem.png', true); } + + // Data indexes + $str_1day = __("Today"); + $str_1week = "1 ".__("Week"); + $str_1month = "1 ".__("Month"); + $str_3months = "3 ".__("Months"); + $str_older = "> 3 ".__("Months"); - $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", - 'url' => ui_get_full_url("/images/logo_vertical_water.png")); + // Filling the data array + $data = array(); + if (!empty($num_1day)) + $data[$str_1day] = $num_1day; + if (!empty($num_1week)) + $data[$str_1week] = $num_1week; + if (!empty($num_1month)) + $data[$str_1month] = $num_1month; + if (!empty($num_3months)) + $data[$str_3months] = $num_3months; + if (!empty($num_older)) + $data[$str_older] = $num_older; + + if ($config['history_db_enabled'] == 1 && !empty($num_history)) { + // In this pie chart only 5 elements are shown, so we need to remove + // an element. With a history db enabled the >3 months element are dispensable + if (count($data) >= 5 && isset($data[$str_3months])) + unset($data[$str_3months]); + + $time_historic_db = time() - ((int)$config['history_db_days'] * SECONDS_1DAY); + $date_human = human_time_comparation($time_historic_db); + $str_history = "> $date_human (".__("History db").")"; + $data[$str_history] = $num_history; + } + + $water_mark = array( + 'file' => $config['homedir'] . "/images/logo_vertical_water.png", + 'url' => ui_get_full_url("/images/logo_vertical_water.png") + ); return pie3d_graph($config['flash_charts'], $data, $width, $height, - __('Other'), '', $water_mark, - $config['fontpath'], $config['font_size']); + __('Other'), '', $water_mark, $config['fontpath'], $config['font_size']); } /** @@ -3726,8 +3874,8 @@ function graphic_module_events ($id_module, $width, $height, $period = 0, $homeu } else { $data[$cont]['data'] = 1; - $current_timestamp = $bottom; } + $current_timestamp = $bottom; $legend[] = date($time_format, $current_timestamp); $cont++; diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index 0ab49638c5..b12a88bdc6 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -521,7 +521,7 @@ function menu_get_sec($with_categories = false) { * * @return array Sections list */ -function menu_get_sec_pages($sec,$menu_hash = false) { +function menu_get_sec_pages($sec, $menu_hash = false) { if ($menu_hash === false) { $menu = menu_get_full_sec(); } @@ -529,21 +529,30 @@ function menu_get_sec_pages($sec,$menu_hash = false) { $menu = json_decode(base64_decode($menu_hash),true); } - // Get the sec2 of the main section - $sec2_array[$menu[$sec]['sec2']] = $menu[$sec]['text']; + $sec2_array = array(); - // Get the sec2 of the subsections - foreach ($menu[$sec]['sub'] as $k => $v) { - // Avoid special cases of standalone windows - if (preg_match('/^javascript:/',$k) || preg_match('/\.php/',$k)) { - continue; + if (isset($sec)) { + + // Get the sec2 of the main section + $sec2_array[$menu[$sec]['sec2']] = $menu[$sec]['text']; + + + // Get the sec2 of the subsections + foreach ($menu[$sec]['sub'] as $k => $v) { + // Avoid special cases of standalone windows + if (preg_match('/^javascript:/', $k) || preg_match('/\.php/', $k)) { + continue; + } + + + // If this value has various parameters, we only get the first + $k = explode('&',$k); + $k = $k[0]; + + + $sec2_array[$k] = $v['text']; } - // If this value has various parameters, we only get the first - $k = explode('&',$k); - $k = $k[0]; - - $sec2_array[$k] = $v['text']; } return $sec2_array; diff --git a/pandora_console/include/functions_planned_downtimes.php b/pandora_console/include/functions_planned_downtimes.php new file mode 100644 index 0000000000..a4476651b6 --- /dev/null +++ b/pandora_console/include/functions_planned_downtimes.php @@ -0,0 +1,521 @@ + false, + 'message' => '' + ); + + if ($type_execution == 'once' && !$config["past_planned_downtimes"] && $datetime_from < $now) { + $result['message'] = ui_print_error_message(__('Not created. Error inserting data. Start time must be higher than the current time' ), '', true); + } + else if ($type_execution == 'once' && $datetime_from >= $datetime_to) { + $result['message'] = ui_print_error_message(__('Not created. Error inserting data') . ". " .__('The end date must be higher than the start date'), '', true); + } + else if ($type_execution == 'periodically' + && (($type_periodicity == 'weekly' && $periodically_time_from >= $periodically_time_to) + || ($type_periodicity == 'monthly' && $periodically_day_from == $periodically_day_to && $periodically_time_from >= $periodically_time_to))) { + $result['message'] = ui_print_error_message(__('Not created. Error inserting data') . ". " .__('The end time must be higher than the start time'), '', true); + } + else if ($type_execution == 'periodically' && $type_periodicity == 'monthly' && $periodically_day_from > $periodically_day_to) { + $result['message'] = ui_print_error_message(__('Not created. Error inserting data') . ". " .__('The end day must be higher than the start day'), '', true); + } + else { + $result['result'] = true; + } + + return $result; +} + +/** + * Update or create a planned downtime. + * + * @param array Values of the planned downtime. + * @param int Id of the planned downtime. Empty to create a new downtime. + * + * @return array Id of the updated/created planned downtime, result of the operation and result message. + */ +function planned_downtimes_update ($values, $downtime_id = 0, $check_dates = true) { + $result = array( + 'id' => $downtime_id, + 'result' => false, + 'message' => '' + ); + + if ($check_dates) { + $dates_check = planned_downtimes_check_dates($values['type_execution'], $values['type_periodicity'], + $values['date_from'], $values['date_to'], $values['periodically_time_from'], $values['periodically_time_to'], + $values['periodically_day_from'], $values['periodically_day_to']); + + if (!$dates_check['result']) { + $result['message'] = $dates_check['message']; + + return $result; + } + } + + $name_trimmed = trim(io_safe_output($values['name'])); + if (!empty($name_trimmed)) { + $name_exists = (bool) db_get_value('id', 'tplanned_downtime', 'name', $values['name']); + + if ($name_exists) { + $result['message'] = ui_print_error_message(__('Each planned downtime must have a different name'), '', true); + + return $result; + } + } + else { + $result['message'] = ui_print_error_message(__('Planned downtime must have a name'), '', true); + + return $result; + } + + + if (empty($downtime_id)) { + $res = db_process_sql_insert('tplanned_downtime', $values); + + if ($res === false) { + $result['message'] = ui_print_error_message(__('Could not be created'), '', true); + } + else { + $result['message'] = ui_print_success_message(__('Successfully created'), '', true); + $result['result'] = true; + $result['id'] = $res; + } + } + else { + $res = db_process_sql_update('tplanned_downtime', $values, array('id' => $downtime_id)); + + if (empty($res)) { + $result['message'] = ui_print_error_message(__('Could not be updated'), '', true); + } + else { + $result['message'] = ui_print_success_message(__('Successfully updated'), '', true); + $result['result'] = true; + } + } + + + return $result; +} + +/** + * Add new agents and modules to the planned downtime. + * + * @param int Id of the planned downtime. + * @param array IDs of the agents to add. + * @param bool Add all modules of the agents or not. + * @param array Names of the modules to add. Empty to add all the modules. + * + * @return array The status will be false id any insertion fails. + * The failed insertions will be added to bad_agents and bad_modules. + */ +function planned_downtimes_add_items ($downtime_id, $agents, $all_modules = true, $module_names = array()) { + global $config; + + include_once($config['homedir'] . "/include/functions_modules.php"); + + $result = array( + 'status' => true, + 'bad_agents' => array(), + 'bad_modules' => array() + ); + + if (empty($module_names)) { + $all_modules = true; + } + else { + //It is empty. + if ($module_names[0] == "0") + $all_modules = true; + } + + if (empty($agents)) { + $agents = array(); + $result['status'] = false; + } + + foreach ($agents as $agent_id) { + $values = array( + 'id_downtime' => $downtime_id, + 'id_agent' => $agent_id, + 'all_modules' => $all_modules, + 'id_user' => $config['id_user'] + ); + $result = db_process_sql_insert('tplanned_downtime_agents', $values); + + if (empty($result)) { + $result['bad_agents'][] = $agent_id; + } + else if (!$all_modules) { + foreach ($module_names as $module_name) { + $module = modules_get_agentmodule_id($module_name, $agent_id); + $module_id = $module["id_agente_modulo"]; + + $values = array( + 'id_downtime' => $downtime_id, + 'id_agent' => $agent_id, + 'id_agent_module' => $module_id + ); + $result = db_process_sql_insert('tplanned_downtime_modules', $values); + + if (empty($result)) { + $result['bad_modules'][] = $module_id; + } + } + } + } + + return $result; +} + +/** + * Delete the agents and modules asociated to a planned downtime. + * + * @param int Id of the planned downtime. + * @param int ID of the agent to delete. + * + * @return bool The result of the operation. + */ +function planned_downtimes_delete_items ($downtime_id, $agent_id) { + $filter = array( + 'id_downtime' => $downtime_id, + 'id_agent' => $agent_id + ); + $downtime_agent_row = db_get_row('tplanned_downtime_agents', $filter); + + $result = db_process_sql_delete('tplanned_downtime_agents', array('id' => $downtime_agent_row['id'])); + + if (!empty($result) && $downtime_agent_row['all_modules'] == 0) { + //Delete modules in downtime + $filter = array( + 'id_downtime' => $downtime_id, + 'id_agent' => $agent_id + ); + db_process_sql_delete('tplanned_downtime_modules', $filter); + } + + return $result; +} + +/** + * Get the planned downtimes that don't comply the actual rules of dates + * + * @return array List of planned downtimes + */ +function planned_downtimes_get_malformed () { + + $sql = "SELECT * + FROM tplanned_downtime + WHERE type_execution = 'periodically' + AND ((type_periodicity = 'monthly' + AND (periodically_day_from > periodically_day_to + OR (periodically_day_from = periodically_day_to + AND periodically_time_from >= periodically_time_to))) + OR (type_periodicity = 'weekly' + AND periodically_time_from >= periodically_time_to))"; + $malformed_downtimes = db_get_all_rows_sql($sql); + + if ($malformed_downtimes === false) { + return false; + } + + $malformed_downtimes_aux = array(); + foreach ($malformed_downtimes as $malformed_downtime) { + $malformed_downtimes_aux[$malformed_downtime['id']] = $malformed_downtime; + } + $malformed_downtimes = $malformed_downtimes_aux; + + return $malformed_downtimes; +} + +/** + * Create new downtimes with the correct format and delete the malformed + * + * @param array List with the malformed downtimes + * + * @return bool The result of the migration + */ +function planned_downtimes_migrate_malformed_downtimes ($malformed_downtimes = array()) { + global $config; + + $migration_result = array( + 'status' => true, + 'bad_downtimes' => array() + ); + + if (empty($malformed_downtimes)) + $malformed_downtimes = planned_downtimes_get_malformed(); + + foreach ($malformed_downtimes as $key => $downtime) { + $downtime_type = $downtime['type_downtime']; + $downtime_execution = $downtime['type_execution']; + $downtime_periodicity = $downtime['type_periodicity']; + + $downtime_time_from = $downtime['periodically_time_from']; + $downtime_time_to = $downtime['periodically_time_to']; + + if ($downtime_execution == 'periodically') { + if ($downtime_periodicity == 'monthly') { + $downtime_day_from = $downtime['periodically_day_from']; + $downtime_day_to = $downtime['periodically_day_to']; + + if (($downtime_day_from > $downtime_day_to) || ($downtime_day_from == $downtime_day_to && $downtime_time_from > $downtime_time_to)) { + $values_first = array( + 'name' => $downtime['name'] . " [1/2]", + 'description' => $downtime['description'], + 'executed' => $downtime['executed'], + 'id_group' => $downtime['id_group'], + 'only_alerts' => $downtime['only_alerts'], + 'periodically_time_from' => $downtime_time_from, + 'periodically_time_to' => "23:59:59", + 'periodically_day_from' => $downtime_day_from, + 'periodically_day_to' => 31, + 'type_downtime' => $downtime_type, + 'type_execution' => $downtime_execution, + 'type_periodicity' => $downtime_periodicity, + 'id_user' => $config['id_user'] + ); + $values_second = $values_first; + $values_second['name'] = $downtime['name'] . " [2/2]"; + $values_second['periodically_day_from'] = 1; + $values_second['periodically_time_from'] = "00:00:00"; + $values_second['periodically_day_to'] = $downtime_day_to; + $values_second['periodically_time_to'] = $downtime_time_to; + + $result_first = planned_downtimes_update($values_first, 0, false); + + if ($result_first['result']) { + $result_second = planned_downtimes_update($values_second, 0, false); + + if (!$result_second['result']) { + db_process_sql_delete('tplanned_downtime', array('id' => $result_first['id'])); + } + } + + if ($result_first['result'] && $result_second['result']) { + $result_copy = planned_downtimes_migrate_malformed_downtimes_copy_items($downtime['id'], $result_first['id'], $result_second['id']); + + if (!$result_copy) { + $migration_result['status'] = false; + $migration_result['bad_downtimes'][] = $downtime['id']; + } + } + else { + $migration_result['status'] = false; + $migration_result['bad_downtimes'][] = $downtime['id']; + } + } + else if ($downtime_day_from == $downtime_day_to && $downtime_time_from == $downtime_time_to) { + + $utimestamp = strtotime("1-1-1970 $downtime_time_to"); + $time = date('H:i:s', $utimestamp + 1); + + if ($time != '00:00:00') { + $values = array('periodically_time_to' => $time); + } + else { + $utimestamp = strtotime("1-1-1970 $downtime_time_from"); + $time = date('H:i:s', $utimestamp - 1); + $values = array('periodically_time_from' => $time); + } + + $filter = array('id' => $downtime['id']); + $result_update = db_process_sql_update('tplanned_downtime', $values, $filter); + + if (!$result_update) { + $migration_result['status'] = false; + $migration_result['bad_downtimes'][] = $downtime['id']; + } + } + } + else if ($downtime_periodicity == 'weekly') { + if ($downtime_time_from > $downtime_time_to) { + $days = array("monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"); + + $values_first = array( + 'name' => $downtime['name'] . " [1/2]", + 'description' => $downtime['description'], + 'executed' => $downtime['executed'], + 'id_group' => $downtime['id_group'], + 'only_alerts' => $downtime['only_alerts'], + 'monday' => $downtime['monday'], + 'tuesday' => $downtime['tuesday'], + 'wednesday' => $downtime['wednesday'], + 'thursday' => $downtime['thursday'], + 'friday' => $downtime['friday'], + 'saturday' => $downtime['saturday'], + 'sunday' => $downtime['sunday'], + 'periodically_time_from' => $downtime_time_from, + 'periodically_time_to' => "23:59:59", + 'type_downtime' => $downtime_type, + 'type_execution' => $downtime_execution, + 'type_periodicity' => $downtime_periodicity, + 'id_user' => $config['id_user'] + ); + + $values_second = $values_first; + $values_second['name'] = $downtime['name'] . " [2/2]"; + $values_second['periodically_time_from'] = "00:00:00"; + $values_second['periodically_time_to'] = $downtime_time_to; + $values_second['tuesday'] = $downtime['monday'] ? 1 : 0; + $values_second['wednesday'] = $downtime['tuesday'] ? 1 : 0; + $values_second['thursday'] = $downtime['wednesday'] ? 1 : 0; + $values_second['friday'] = $downtime['thursday'] ? 1 : 0; + $values_second['saturday'] = $downtime['friday'] ? 1 : 0; + $values_second['sunday'] = $downtime['saturday'] ? 1 : 0; + $values_second['monday'] = $downtime['sunday'] ? 1 : 0; + + $result_first = planned_downtimes_update($values_first, 0, false); + + if ($result_first['result']) { + $result_second = planned_downtimes_update($values_second, 0, false); + + if (!$result_second['result']) { + db_process_sql_delete('tplanned_downtime', array('id' => $result_first['id'])); + } + } + + if ($result_first['result'] && $result_second['result']) { + $result_copy = planned_downtimes_migrate_malformed_downtimes_copy_items($downtime['id'], $result_first['id'], $result_second['id']); + + if (!$result_copy) { + $migration_result['status'] = false; + $migration_result['bad_downtimes'][] = $downtime['id']; + } + } + else { + $migration_result['status'] = false; + $migration_result['bad_downtimes'][] = $downtime['id']; + } + } + else if ($downtime_time_from == $downtime_time_to) { + $utimestamp = strtotime("1-1-1970 $downtime_time_to"); + $time = date('H:i:s', $utimestamp + 1); + + if ($time != '00:00:00') { + $values = array('periodically_time_to' => $time); + } + else { + $utimestamp = strtotime("1-1-1970 $downtime_time_from"); + $time = date('H:i:s', $utimestamp - 1); + $values = array('periodically_time_from' => $time); + } + + $filter = array('id' => $downtime['id']); + $result_update = db_process_sql_update('tplanned_downtime', $values, $filter); + + if (!$result_update) { + $migration_result['status'] = false; + $migration_result['bad_downtimes'][] = $downtime['id']; + } + } + } + } + } + + return $migration_result; +} + +/** + * Aux function to copy the items of the selected downtime to the new downtimes. + * Deletes the new downtimes if the items are not copied. + */ +function planned_downtimes_migrate_malformed_downtimes_copy_items ($original_downtime_id, $new_downtime_first_id, $new_downtime_second_id) { + $sql = "SELECT * + FROM tplanned_downtime_agents + WHERE id_downtime = " . $original_downtime_id; + $downtime_agents_rows = db_get_all_rows_sql($sql); + $sql = "SELECT * + FROM tplanned_downtime_modules + WHERE id_downtime = " . $original_downtime_id; + $downtime_modules_rows = db_get_all_rows_sql($sql); + + if (!empty($downtime_agents_rows)) { + $result_agents = true; + + foreach ($downtime_agents_rows as $downtime_agents_row) { + $values_agent = array( + 'id_agent' => $downtime_agents_row['id_agent'], + 'all_modules' => $downtime_agents_row['all_modules'] + ); + $values_agent['id_downtime'] = $new_downtime_first_id; + $result_agent_first = db_process_sql_insert('tplanned_downtime_agents', $values_agent); + $values_agent['id_downtime'] = $new_downtime_second_id; + $result_agent_second = db_process_sql_insert('tplanned_downtime_agents', $values_agent); + + if (empty($result_agent_first) || empty($result_agent_second)) { + $result_agents = false; + db_process_sql_delete('tplanned_downtime', array('id' => $new_downtime_first_id)); + db_process_sql_delete('tplanned_downtime', array('id' => $new_downtime_second_id)); + break; + } + } + + if ($result_agents) { + if (!empty($downtime_modules_rows)) { + foreach ($downtime_modules_rows as $downtime_modules_row) { + $values_module = array( + 'id_agent' => $downtime_modules_row['id_agent'], + 'id_agent_module' => $downtime_modules_row['id_agent_module'] + ); + $values_module['id_downtime'] = $new_downtime_first_id; + $result_module_first = db_process_sql_insert('tplanned_downtime_modules', $values_module); + $values_module['id_downtime'] = $new_downtime_second_id; + $result_module_second = db_process_sql_insert('tplanned_downtime_modules', $values_module); + + if (empty($result_module_first) || empty($result_module_second)) { + db_process_sql_delete('tplanned_downtime', array('id' => $new_downtime_first_id)); + db_process_sql_delete('tplanned_downtime', array('id' => $new_downtime_second_id)); + break; + } + } + } + } + } + + // The new downtimes are created + $new_planned_downtimes_exists = (bool) db_get_value('id', 'tplanned_downtime', 'id', $new_downtime_first_id) + && (bool) db_get_value('id', 'tplanned_downtime', 'id', $new_downtime_second_id); + + if ($new_planned_downtimes_exists) { + // Delete the migrated downtime and its items + db_process_sql_delete('tplanned_downtime', array('id' => $original_downtime_id)); + } + + return $new_planned_downtimes_exists; +} + +?> \ No newline at end of file diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 4bf73d8a5b..b01ab3aa99 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -871,14 +871,22 @@ function reporting_get_agentmodule_sla_array ($id_agent_module, $period = 0, $mi * @return Array with time intervals. */ function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_date, $end_date, $check_services = false) { + global $config; + + require_once ($config['homedir'] . '/include/functions_planned_downtimes.php'); + + $malformed_planned_downtimes = planned_downtimes_get_malformed(); + if (empty($malformed_planned_downtimes)) + $malformed_planned_downtimes = array(); + $sql_downtime = "SELECT DISTINCT(tpd.id), tpd.* - FROM tplanned_downtime tpd, tplanned_downtime_agents tpda, tplanned_downtime_modules tpdm, tagente_modulo tam + FROM tplanned_downtime_agents tpda, tagente_modulo tam, tplanned_downtime tpd + LEFT OUTER JOIN tplanned_downtime_modules tpdm ON tpd.id = tpdm.id_downtime WHERE (tpd.id = tpda.id_downtime AND tpda.all_modules = 1 AND tpda.id_agent = tam.id_agente AND tam.id_agente_modulo = $id_agent_module) - OR (tpd.id = tpdm.id_downtime - AND tpdm.id_agent_module = $id_agent_module)"; + OR (tpdm.id_agent_module = $id_agent_module)"; $downtimes = db_get_all_rows_sql($sql_downtime); if ($downtimes == false) { $downtimes = array(); @@ -896,6 +904,20 @@ function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_dat $downtime_dates[] = $dates; } else if ($downtime_type == 'periodically') { + + // If a planned downtime have malformed dates, its intervals aren't taken account + $downtime_malformed = false; + foreach ($malformed_planned_downtimes as $malformed_planned_downtime) { + if ($downtime_id == $malformed_planned_downtime['id']) { + $downtime_malformed = true; + break; + } + } + if ($downtime_malformed == true) { + continue; + } + // If a planned downtime have malformed dates, its intervals aren't taken account + $downtime_time_from = $downtime['periodically_time_from']; $downtime_time_to = $downtime['periodically_time_to']; @@ -1160,21 +1182,21 @@ function reporting_get_planned_downtimes ($start_date, $end_date, $id_agent_modu if (!empty($id_agent_modules)) { $id_agent_modules_str = implode(",", $id_agent_modules); $agent_modules_condition_tpda = "AND tam.id_agente_modulo IN ($id_agent_modules_str)"; - $agent_modules_condition_tpdm = "AND tpdm.id_agent_module IN ($id_agent_modules_str)"; + $agent_modules_condition_tpdm = "tpdm.id_agent_module IN ($id_agent_modules_str)"; } else { $agent_modules_condition_tpda = ""; - $agent_modules_condition_tpdm = ""; + $agent_modules_condition_tpdm = "1=1"; } $sql_downtime = "SELECT DISTINCT(tpd.id), tpd.* - FROM tplanned_downtime tpd, tplanned_downtime_agents tpda, tplanned_downtime_modules tpdm, tagente_modulo tam + FROM tplanned_downtime_agents tpda, tagente_modulo tam, tplanned_downtime tpd + LEFT OUTER JOIN tplanned_downtime_modules tpdm ON tpd.id = tpdm.id_downtime WHERE ((tpd.id = tpda.id_downtime AND tpda.all_modules = 1 AND tpda.id_agent = tam.id_agente $agent_modules_condition_tpda) - OR (tpd.id = tpdm.id_downtime - $agent_modules_condition_tpdm)) + OR ($agent_modules_condition_tpdm)) AND ((type_execution = 'periodically' AND $periodically_condition) OR (type_execution = 'once' @@ -3695,6 +3717,266 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $table1->style[5] = 'text-align: right'; $table1->style[6] = 'text-align: center'; } + + // Table Planned Downtimes + require_once ($config['homedir'] . '/include/functions_planned_downtimes.php'); + $metaconsole_on = ($config['metaconsole'] == 1) && defined('METACONSOLE'); + $downtime_malformed = false; + + $planned_downtimes_empty = true; + $malformed_planned_downtimes_empty = true; + + if ($metaconsole_on) { + $id_agent_modules_by_server = array(); + + foreach ($slas as $sla) { + $server = $sla['server_name']; + if (empty($server)) + continue; + + if (!isset($id_agent_modules_by_server[$server])) + $id_agent_modules_by_server[$server] = array(); + + $id_agent_modules_by_server[$server][] = $sla['id_agent_module']; + } + + $planned_downtimes_by_server = array(); + $malformed_planned_downtimes_by_server = array(); + foreach ($id_agent_modules_by_server as $server => $id_agent_modules) { + //Metaconsole connection + if (!empty($server)) { + $connection = metaconsole_get_connection($server); + if (!metaconsole_load_external_db($connection)) { + continue; + } + + $planned_downtimes_by_server[$server] = reporting_get_planned_downtimes(($report['datetime']-$content['period']), $report['datetime'], $id_agent_modules); + $malformed_planned_downtimes_by_server[$server] = planned_downtimes_get_malformed(); + + if (!empty($planned_downtimes_by_server[$server])) + $planned_downtimes_empty = false; + if (!empty($malformed_planned_downtimes_by_server[$server])) + $malformed_planned_downtimes_empty = false; + + //Restore db connection + metaconsole_restore_db(); + } + } + + if (!$planned_downtimes_empty) { + $table_planned_downtimes = new StdClass(); + $table_planned_downtimes->width = '100%'; + $table_planned_downtimes->title = __('This SLA has been affected by the following planned downtimes'); + $table_planned_downtimes->head = array(); + $table_planned_downtimes->head[0] = __('Server'); + $table_planned_downtimes->head[1] = __('Name'); + $table_planned_downtimes->head[2] = __('Description'); + $table_planned_downtimes->head[3] = __('Execution'); + $table_planned_downtimes->head[4] = __('Dates'); + $table_planned_downtimes->headstyle = array(); + $table_planned_downtimes->style = array(); + $table_planned_downtimes->cellstyle = array(); + $table_planned_downtimes->data = array(); + + foreach ($planned_downtimes_by_server as $server => $planned_downtimes) { + foreach ($planned_downtimes as $planned_downtime) { + $data = array(); + $data[0] = $server; + $data[1] = $planned_downtime['name']; + $data[2] = $planned_downtime['description']; + $data[3] = ucfirst($planned_downtime['type_execution']); + $data[4] = ""; + switch ($planned_downtime['type_execution']) { + case 'once': + $data[3] = date ("Y-m-d H:i", $planned_downtime['date_from']) . + " " . __('to') . " ". + date ("Y-m-d H:i", $planned_downtime['date_to']); + break; + case 'periodically': + switch ($planned_downtime['type_periodicity']) { + case 'weekly': + $data[4] = __('Weekly:'); + $data[4] .= " "; + if ($planned_downtime['monday']) { + $data[4] .= __('Mon'); + $data[4] .= " "; + } + if ($planned_downtime['tuesday']) { + $data[4] .= __('Tue'); + $data[4] .= " "; + } + if ($planned_downtime['wednesday']) { + $data[4] .= __('Wed'); + $data[4] .= " "; + } + if ($planned_downtime['thursday']) { + $data[4] .= __('Thu'); + $data[4] .= " "; + } + if ($planned_downtime['friday']) { + $data[4] .= __('Fri'); + $data[4] .= " "; + } + if ($planned_downtime['saturday']) { + $data[4] .= __('Sat'); + $data[4] .= " "; + } + if ($planned_downtime['sunday']) { + $data[4] .= __('Sun'); + $data[4] .= " "; + } + $data[4] .= " (" . $planned_downtime['periodically_time_from']; + $data[4] .= "-" . $planned_downtime['periodically_time_to'] . ")"; + break; + case 'monthly': + $data[4] = __('Monthly:') . " "; + $data[4] .= __('From day') . " " . $planned_downtime['periodically_day_from']; + $data[4] .= " " . strtolower(__('To day')) . " "; + $data[4] .= $planned_downtime['periodically_day_to']; + $data[4] .= " (" . $planned_downtime['periodically_time_from']; + $data[4] .= "-" . $planned_downtime['periodically_time_to'] . ")"; + break; + } + break; + } + + if (!$malformed_planned_downtimes_empty + && isset($malformed_planned_downtimes_by_server[$server]) + && isset($malformed_planned_downtimes_by_server[$server][$planned_downtime['id']])) { + $next_row_num = count($table_planned_downtimes->data); + $table_planned_downtimes->cellstyle[$next_row_num][0] = 'color: red'; + $table_planned_downtimes->cellstyle[$next_row_num][1] = 'color: red'; + $table_planned_downtimes->cellstyle[$next_row_num][2] = 'color: red'; + $table_planned_downtimes->cellstyle[$next_row_num][3] = 'color: red'; + $table_planned_downtimes->cellstyle[$next_row_num][4] = 'color: red'; + + if (!$downtime_malformed) + $downtime_malformed = true; + } + + $table_planned_downtimes->data[] = $data; + } + } + } + } + else { + $id_agent_modules = array(); + foreach ($slas as $sla) { + if (!empty($sla['id_agent_module'])) + $id_agent_modules[] = $sla['id_agent_module']; + } + + $planned_downtimes = reporting_get_planned_downtimes(($report['datetime']-$content['period']), $report['datetime'], $id_agent_modules); + $malformed_planned_downtimes = planned_downtimes_get_malformed(); + + if (!empty($planned_downtimes)) + $planned_downtimes_empty = false; + if (!empty($malformed_planned_downtimes)) + $malformed_planned_downtimes_empty = false; + + if (!$planned_downtimes_empty) { + $table_planned_downtimes = new StdClass(); + $table_planned_downtimes->width = '100%'; + $table_planned_downtimes->title = __('This SLA has been affected by the following planned downtimes'); + $table_planned_downtimes->head = array(); + $table_planned_downtimes->head[0] = __('Name'); + $table_planned_downtimes->head[1] = __('Description'); + $table_planned_downtimes->head[2] = __('Execution'); + $table_planned_downtimes->head[3] = __('Dates'); + $table_planned_downtimes->headstyle = array(); + $table_planned_downtimes->style = array(); + $table_planned_downtimes->cellstyle = array(); + $table_planned_downtimes->data = array(); + + foreach ($planned_downtimes as $planned_downtime) { + + $data = array(); + $data[0] = $planned_downtime['name']; + $data[1] = $planned_downtime['description']; + $data[2] = ucfirst($planned_downtime['type_execution']); + $data[3] = ""; + switch ($planned_downtime['type_execution']) { + case 'once': + $data[3] = date ("Y-m-d H:i", $planned_downtime['date_from']) . + " " . __('to') . " ". + date ("Y-m-d H:i", $planned_downtime['date_to']); + break; + case 'periodically': + switch ($planned_downtime['type_periodicity']) { + case 'weekly': + $data[3] = __('Weekly:'); + $data[3] .= " "; + if ($planned_downtime['monday']) { + $data[3] .= __('Mon'); + $data[3] .= " "; + } + if ($planned_downtime['tuesday']) { + $data[3] .= __('Tue'); + $data[3] .= " "; + } + if ($planned_downtime['wednesday']) { + $data[3] .= __('Wed'); + $data[3] .= " "; + } + if ($planned_downtime['thursday']) { + $data[3] .= __('Thu'); + $data[3] .= " "; + } + if ($planned_downtime['friday']) { + $data[3] .= __('Fri'); + $data[3] .= " "; + } + if ($planned_downtime['saturday']) { + $data[3] .= __('Sat'); + $data[3] .= " "; + } + if ($planned_downtime['sunday']) { + $data[3] .= __('Sun'); + $data[3] .= " "; + } + $data[3] .= " (" . $planned_downtime['periodically_time_from']; + $data[3] .= "-" . $planned_downtime['periodically_time_to'] . ")"; + break; + case 'monthly': + $data[3] = __('Monthly:') . " "; + $data[3] .= __('From day') . " " . $planned_downtime['periodically_day_from']; + $data[3] .= " " . strtolower(__('To day')) . " "; + $data[3] .= $planned_downtime['periodically_day_to']; + $data[3] .= " (" . $planned_downtime['periodically_time_from']; + $data[3] .= "-" . $planned_downtime['periodically_time_to'] . ")"; + break; + } + break; + } + + if (!$malformed_planned_downtimes_empty && isset($malformed_planned_downtimes[$planned_downtime['id']])) { + $next_row_num = count($table_planned_downtimes->data); + $table_planned_downtimes->cellstyle[$next_row_num][0] = 'color: red'; + $table_planned_downtimes->cellstyle[$next_row_num][1] = 'color: red'; + $table_planned_downtimes->cellstyle[$next_row_num][2] = 'color: red'; + $table_planned_downtimes->cellstyle[$next_row_num][3] = 'color: red'; + + if (!$downtime_malformed) + $downtime_malformed = true; + } + + $table_planned_downtimes->data[] = $data; + } + } + } + + if ($downtime_malformed) { + $info_malformed = ui_print_error_message(__('This item is affected by a malformed planned downtime') . ". " . + __('Go to the planned downtimes section to solve this') . ".", '', true); + + $data = array(); + $data[0] = $info_malformed; + $data[0] .= html_print_table($table_planned_downtimes, true); + $table->colspan[$next_row][0] = 3; + $next_row++; + array_push ($table->data, $data); + break; + } $data_graph = array (); $data_horin_graph = array(); @@ -3818,8 +4100,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f if ($sla_value === false) { $data[4] = ''; - $data[5] = html_print_image('images/status_sets/default/severity_maintenance.png',true,array('title'=>__('Unknown'))); - $data[6] = ''.__('Unknown').''; + $data[5] = ''.__('Unknown').''; + $data[6] = html_print_image('images/status_sets/default/severity_maintenance.png',true,array('title'=>__('Unknown'))); } else { $data[4] = ''; @@ -3928,103 +4210,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f array_push ($table->data, $data); } - // Table Planned Downtimes - $id_agent_modules = array(); - foreach ($slas as $sla) { - if (!empty($sla['id_agent_module'])) - $id_agent_modules[] = $sla['id_agent_module']; - } - $planned_downtimes = reporting_get_planned_downtimes(($report['datetime']-$content['period']), $report['datetime'], $id_agent_modules); - - if (!empty($planned_downtimes)) { - - $table_planned_downtimes = new StdClass(); - $table_planned_downtimes->width = '100%'; - $table_planned_downtimes->title = __('This SLA has been affected by the following planned downtimes'); - $table_planned_downtimes->head = array(); - $table_planned_downtimes->head[0] = __('Name'); - $table_planned_downtimes->head[1] = __('Description'); - $table_planned_downtimes->head[2] = __('Execution'); - $table_planned_downtimes->head[3] = __('Dates'); - $table_planned_downtimes->headstyle = array(); - $table_planned_downtimes->style = array(); - $table_planned_downtimes->data = array(); - - if ($for_pdf) { - $table_planned_downtimes->titlestyle = 'background: #373737; color: #FFF; display: table-cell; font-size: 12px; border: 1px solid grey'; - $table_planned_downtimes->class = 'table_sla table_beauty'; - - for ($i = 0; $i < count($table_planned_downtimes->head); $i++) { - $table_planned_downtimes->headstyle[$i] = 'background: #666; color: #FFF; display: table-cell; font-size: 11px; border: 1px solid grey'; - } - for ($i = 0; $i < count($table_planned_downtimes->head); $i++) { - $table_planned_downtimes->style[$i] = 'display: table-cell; font-size: 10px;'; - } - } - - foreach ($planned_downtimes as $planned_downtime) { - $data = array(); - $data[0] = $planned_downtime['name']; - $data[1] = $planned_downtime['description']; - $data[2] = ucfirst($planned_downtime['type_execution']); - - switch ($planned_downtime['type_execution']) { - case 'once': - $data[3] = date ("Y-m-d H:i", $planned_downtime['date_from']) . - " " . __('to') . " ". - date ("Y-m-d H:i", $planned_downtime['date_to']); - break; - case 'periodically': - switch ($planned_downtime['type_periodicity']) { - case 'weekly': - $data[3] = __('Weekly:'); - $data[3] .= " "; - if ($planned_downtime['monday']) { - $data[3] .= __('Mon'); - $data[3] .= " "; - } - if ($planned_downtime['tuesday']) { - $data[3] .= __('Tue'); - $data[3] .= " "; - } - if ($planned_downtime['wednesday']) { - $data[3] .= __('Wed'); - $data[3] .= " "; - } - if ($planned_downtime['thursday']) { - $data[3] .= __('Thu'); - $data[3] .= " "; - } - if ($planned_downtime['friday']) { - $data[3] .= __('Fri'); - $data[3] .= " "; - } - if ($planned_downtime['saturday']) { - $data[3] .= __('Sat'); - $data[3] .= " "; - } - if ($planned_downtime['sunday']) { - $data[3] .= __('Sun'); - $data[3] .= " "; - } - $data[3] .= " (" . $planned_downtime['periodically_time_from']; - $data[3] .= "-" . $planned_downtime['periodically_time_to'] . ")"; - break; - case 'monthly': - $data[3] = __('Monthly:') . " "; - $data[3] .= __('From day') . " " . $planned_downtime['periodically_day_from']; - $data[3] .= " " . strtolower(__('To day')) . " "; - $data[3] .= $planned_downtime['periodically_day_to']; - $data[3] .= " (" . $planned_downtime['periodically_time_from']; - $data[3] .= "-" . $planned_downtime['periodically_time_to'] . ")"; - break; - } - break; - } - - $table_planned_downtimes->data[] = $data; - } - + if (!empty($table_planned_downtimes)) { $data = array(); $data[0] = html_print_table($table_planned_downtimes, true); $table->colspan[$next_row][0] = 3; diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index daf94ab559..6ccda6fa8a 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -756,10 +756,9 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = ' break; case 'event_condition': // Return the condition of the tags for tevento table - $condition = tags_get_acl_tags_event_condition($acltags); - + $condition = tags_get_acl_tags_event_condition($acltags); if(!empty($condition)) { - return " $query_prefix ".$condition; + return " $query_prefix "."(".$condition.")"; } break; } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index bea2ef2502..d710f6ba39 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1527,7 +1527,10 @@ function ui_process_page_body ($string, $bitfield) { * * @return string The pagination div or nothing if no pagination needs to be done */ -function ui_pagination ($count, $url = false, $offset = 0, $pagination = 0, $return = false, $offset_name = 'offset', $print_total_items = true, $other_class = '') { +function ui_pagination ($count, $url = false, $offset = 0, + $pagination = 0, $return = false, $offset_name = 'offset', + $print_total_items = true, $other_class = '') { + global $config; if (empty ($pagination)) { @@ -1547,13 +1550,14 @@ function ui_pagination ($count, $url = false, $offset = 0, $pagination = 0, $ret $url = ui_get_url_refresh (array ($offset_name => false)); } - /* URL passed render links with some parameter + /* + URL passed render links with some parameter &offset - Offset records passed to next page &counter - Number of items to be blocked Pagination needs $url to build the base URL to render links, its a base url, like " http://pandora/index.php?sec=godmode&sec2=godmode/admin_access_logs " */ - $block_limit = 15; // Visualize only $block_limit blocks + $block_limit = PAGINATION_BLOCKS_LIMIT; // Visualize only $block_limit blocks if ($count <= $pagination) { if ($print_total_items) { @@ -1572,32 +1576,22 @@ function ui_pagination ($count, $url = false, $offset = 0, $pagination = 0, $ret return false; } - // If exists more registers than I can put in a page, calculate index markers - $index_counter = ceil ($count /$pagination); // Number of blocks of block_size with data - $index_page = ceil ($offset / $pagination) - (ceil ($block_limit / 2)); // block to begin to show data; - if ($index_page < 0) - $index_page = 0; + $number_of_pages = ceil($count / $pagination); + //~ html_debug_print('number_of_pages'); + //~ html_debug_print($number_of_pages); + $actual_page = floor($offset / $pagination); + //~ html_debug_print('actual_page'); + //~ html_debug_print($actual_page); + $ini_page = floor($actual_page / $block_limit) * $block_limit; + //~ html_debug_print('ini_page'); + //~ html_debug_print($ini_page); + $end_page = $ini_page + $block_limit - 1; + if ($end_page > $number_of_pages) { + $end_page = $number_of_pages - 1; + } + //~ html_debug_print('end_page'); + //~ html_debug_print($end_page); - // This calculate index_limit, block limit for this search. - if (($index_page + $block_limit) > $index_counter) - $index_limit = $index_counter; - else - $index_limit = $index_page + $block_limit; - - // This calculate if there are more blocks than visible (more than $block_limit blocks) - if ($index_counter > $block_limit ) - $paginacion_maxima = 1; // If maximum blocks ($block_limit), show only 10 and "...." - else - $paginacion_maxima = 0; - - // This setup first block of query - if ( $paginacion_maxima == 1) - if ($index_page == 0) - $inicio_pag = 0; - else - $inicio_pag = $index_page; - else - $inicio_pag = 0; $output = " diff --git a/pandora_console/mobile/operation/visualmap.php b/pandora_console/mobile/operation/visualmap.php index 75c510c4fe..a07b9e6005 100644 --- a/pandora_console/mobile/operation/visualmap.php +++ b/pandora_console/mobile/operation/visualmap.php @@ -70,7 +70,8 @@ class Visualmap { case 'render_map': $map_id = $system->getRequest('map_id', '0'); $width = $system->getRequest('width', '400'); - visual_map_print_visual_map($map_id, false, true, $width); + $height = $system->getRequest('height', '400'); + visual_map_print_visual_map($map_id, false, true, $width, $height); exit; } } @@ -123,6 +124,7 @@ class Visualmap { postvars[\"parameter2\"] = \"render_map\"; postvars[\"map_id\"] = \"" . $this->id . "\"; postvars[\"width\"] = map_width; + postvars[\"height\"] = map_height; $.post(\"index.php\", postvars, diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index 521675294b..85698fea76 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -723,6 +723,7 @@ foreach ($modules as $module) { "; +ui_print_help_tip(__('For to view the list modules paginated, set in setup visuals.')); echo __('Full list of monitors'); $modules_not_init = agents_monitor_notinit($id_agente); if (!empty($modules_not_init)) { diff --git a/pandora_console/operation/events/events.build_query.php b/pandora_console/operation/events/events.build_query.php index 81c8b2fee7..b0e814369d 100755 --- a/pandora_console/operation/events/events.build_query.php +++ b/pandora_console/operation/events/events.build_query.php @@ -162,20 +162,27 @@ else { if ($id_user_ack != "0") $sql_post .= " AND id_usuario = '" . $id_user_ack . "'"; +if (!isset($date_from)) { + $date_from = ""; +} +if (!isset($date_to)) { + $date_to = ""; +} if (($date_from == '') && ($date_to == '')) { if ($event_view_hr > 0) { $unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR); $sql_post .= " AND (utimestamp > " . $unixtime . ")"; } -} else { +} +else { if ($date_from != '') { - $udate_from = strtotime($date_from." 00:00:00"); + $udate_from = strtotime($date_from . " 00:00:00"); $sql_post .= " AND (utimestamp >= " . $udate_from . ")"; } if ($date_to != '') { - $udate_to = strtotime($date_to." 23:59:59"); + $udate_to = strtotime($date_to . " 23:59:59"); $sql_post .= " AND (utimestamp <= " . $udate_to . ")"; } } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index ebc6c07221..fbe612946d 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -200,8 +200,6 @@ $group_rep = (int) get_parameter ("group_rep", 1); $delete = (bool) get_parameter ("delete"); $validate = (bool) get_parameter ("validate", 0); $section = (string) get_parameter ("section", "list"); -$text_agent = (string) get_parameter('text_agent', __("All")); -$text_module = (string) get_parameter('module_search', ''); $filter_only_alert = (int) get_parameter('filter_only_alert', -1); $filter_id = (int) get_parameter('filter_id', 0); $id_name = (string) get_parameter('id_name', ''); @@ -210,6 +208,24 @@ $date_from = (string)get_parameter('date_from', ''); $date_to = (string)get_parameter('date_to', ''); $text_agent = (string) get_parameter("text_agent", __("All")); +$id_agent = get_parameter('id_agent', 0); +if ($id_agent != 0) { + $text_agent = db_get_value('nombre', 'tagente', 'id_agente', $id_agent); + if ($text_agent == false) { + $text_agent = ''; + } +} + + +$text_module = (string) get_parameter('module_search', ''); +$id_agent_module = get_parameter('id_agent_module', 0); +if ($id_agent_module != 0) { + $text_module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_agent_module); + if ($text_module == false) { + $text_module = ''; + } +} + $tag_with_json = base64_decode(get_parameter("tag_with", '')) ; $tag_with_json_clean = io_safe_output($tag_with_json); diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index a6527cd648..127cafd831 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -386,7 +386,7 @@ $data[0] .= html_print_select($user_users, "id_user_ack", $id_user_ack, '', if (!$meta) { $data[1] = __('Module search') . '
'; $data[1] .= html_print_autocomplete_modules('module_search', - '', false, true, '', array(), true); + $text_module, false, true, '', array(), true); } else { $data[1] .= ''; diff --git a/pandora_console/operation/events/events_rss.php b/pandora_console/operation/events/events_rss.php index e3fd4340f4..9cbca5badd 100644 --- a/pandora_console/operation/events/events_rss.php +++ b/pandora_console/operation/events/events_rss.php @@ -28,6 +28,9 @@ $ipOrigin = $_SERVER['REMOTE_ADDR']; // Uncoment this to activate ACL on RSS Events if (!isInACL($ipOrigin)) { + rss_error_handler(null, null, null, null, + __("Your IP is not into the IP list with API access.")); + exit; } @@ -39,25 +42,52 @@ $pss = get_user_info($user); $hashup2 = md5($user.$pss['password']); if ($hashup != $hashup2) { + rss_error_handler(null, null, null, null, + __("The URL of your feed has bad hash.")); + exit; } header("Content-Type: application/xml; charset=UTF-8"); //Send header before starting to output -function rss_error_handler ($errno, $errstr, $errfile, $errline) { +function rss_error_handler ($errno, $errstr, $errfile, $errline, $error_human_description = null) { $url = ui_get_full_url(false); $selfurl = ui_get_full_url('?' . $_SERVER['QUERY_STRING'], false, true); $rss_feed = ''; //' Fixes certain highlighters freaking out on the PHP closing tag + $rss_feed .= "\n"; $rss_feed .= ''; - $rss_feed .= 'Pandora RSS FeedLatest events on Pandora'; + $rss_feed .= "\n"; + $rss_feed .= ''; + $rss_feed .= "\n"; + $rss_feed .= 'Pandora RSS Feed'; + $rss_feed .= "\n"; + $rss_feed .= 'Latest events on Pandora'; + $rss_feed .= "\n"; $rss_feed .= ''.date (DATE_RFC822, 0).''; - $rss_feed .= ''.$url.''; //Link back to the main Pandora page - $rss_feed .= ''; //Alternative for Atom feeds. It's the same. - - $rss_feed .= ''.$url.'/index.php?sec=eventos&sec2=operation/events/eventsError creating feed'; - $rss_feed .= 'There was an error creating the feed: '.$errno.' - '.$errstr.' in '.$errfile.' on line '.$errline.''; - $rss_feed .= ''.$url.'/index.php?sec=eventos&sec2=operation/events/events'; + $rss_feed .= "\n"; + $rss_feed .= '' . $url . ''; //Link back to the main Pandora page + $rss_feed .= "\n"; + $rss_feed .= ''; //Alternative for Atom feeds. It's the same. + $rss_feed .= "\n"; + $rss_feed .= ''; + $rss_feed .= "\n"; + $rss_feed .= ''.$url.'/index.php?sec=eventos&sec2=operation/events/events'; + $rss_feed .= "\n"; + $rss_feed .= 'Error creating feed'; + $rss_feed .= "\n"; + if (empty($error_human_description)) { + $rss_feed .= 'There was an error creating the feed: '.$errno.' - '.$errstr.' in '.$errfile.' on line '.$errline.''; + } + else { + $rss_feed .= '' . xml_entities(io_safe_input($error_human_description)) .''; + } + $rss_feed .= "\n"; + $rss_feed .= ''.$url.'/index.php?sec=eventos&sec2=operation/events/events'; + $rss_feed .= "\n"; + $rss_feed .= ''; + $rss_feed .= "\n"; + $rss_feed .= ''; exit ($rss_feed); //Exit by displaying the feed } @@ -128,13 +158,13 @@ $rss_feed .= 'Pandora RSS Feed'. "\n"; $rss_feed .= 'Latest events on Pandora' . "\n"; $rss_feed .= ''.date (DATE_RFC822, $lastbuild).''. "\n"; //Last build date is the last event - that way readers won't mark it as having new posts $rss_feed .= ''.$url.''. "\n"; //Link back to the main Pandora page -$rss_feed .= ''. "\n";; //Alternative for Atom feeds. It's the same. +$rss_feed .= ''. "\n";; //Alternative for Atom feeds. It's the same. if (empty ($result)) { $result = array(); - $rss_feed .= ''.io_safe_input ($url.'/index.php?sec=eventos&sec2=operation/events/events').'No results'; + $rss_feed .= '' . xml_entities(io_safe_input ($url.'/index.php?sec=eventos&sec2=operation/events/events')) . 'No results'; $rss_feed .= 'There are no results. Click on the link to see all Pending events'; - $rss_feed .= ''.io_safe_input ($url.'/index.php?sec=eventos&sec2=operation/events/events').''. "\n"; + $rss_feed .= '' . xml_entities(io_safe_input ($url.'/index.php?sec=eventos&sec2=operation/events/events')) . ''. "\n"; } foreach ($result as $row) { @@ -152,18 +182,18 @@ foreach ($result as $row) { $agent_name = __('Alert').__('SNMP'); } -//This is mandatory + //This is mandatory $rss_feed .= ''; - $rss_feed .= io_safe_input($url . "/index.php?sec=eventos&sec2=operation/events/events&id_event=" . $row['id_evento']); + $rss_feed .= xml_entities(io_safe_input($url . "/index.php?sec=eventos&sec2=operation/events/events&id_event=" . $row['id_evento'])); $rss_feed .= ''; - $rss_feed .= $agent_name; + $rss_feed .= xml_entities($agent_name); $rss_feed .= ''; - $rss_feed .= $row['evento']; - if($row['estado'] == 1) { - $rss_feed .= io_safe_input('

'.'Validated by ' . $row['id_usuario']); + $rss_feed .= xml_entities($row['evento']); + if ($row['estado'] == 1) { + $rss_feed .= xml_entities(io_safe_input('

'.'Validated by ' . $row['id_usuario'])); } $rss_feed .= '
'; - $rss_feed .= io_safe_input($url . "/index.php?sec=eventos&sec2=operation/events/events&id_event=" . $row["id_evento"]); + $rss_feed .= xml_entities(io_safe_input($url . "/index.php?sec=eventos&sec2=operation/events/events&id_event=" . $row["id_evento"])); $rss_feed .= ''; //The rest is optional @@ -176,4 +206,35 @@ foreach ($result as $row) { $rss_feed .= "\n\n"; echo $rss_feed; + + +function xml_entities($str) { + + if (!is_string($str)) { + return ""; + } + + if (preg_match_all('/(&[^;]+;)/', $str, $matches) != 0) { + + $matches = $matches[0]; + + foreach ($matches as $entity) { + $char = html_entity_decode($entity, ENT_COMPAT | ENT_HTML401, 'UTF-8'); + + $html_entity_numeric = "&#" . uniord($char) . ";"; + + $str = str_replace($entity, $html_entity_numeric, $str); + } + } + + return $str; +} + +function uniord($u) { + $k = mb_convert_encoding($u, 'UCS-2LE', 'UTF-8'); + $k1 = ord(substr($k, 0, 1)); + $k2 = ord(substr($k, 1, 1)); + + return $k2 * 256 + $k1; +} ?> diff --git a/pandora_console/operation/events/sound_events.php b/pandora_console/operation/events/sound_events.php index 1cd0682e8b..80e26f2919 100644 --- a/pandora_console/operation/events/sound_events.php +++ b/pandora_console/operation/events/sound_events.php @@ -77,8 +77,12 @@ $table->data[1][1] = html_print_checkbox('alert_fired', 'alert_fired', true, tru html_print_checkbox('critical', 'critical', true, true, false, 'changeType();') . __('Monitor critical') . '
' . html_print_checkbox('warning', 'warning', true, true, false, 'changeType();') . __('Monitor warning') . '
' . $table->data[2][0] = ''; -$table->data[2][1] = '' . html_print_image("images/play.button.png", true, array("id" => "button")) . ''; -$table->data[2][1] .= '' . html_print_image("images/ok.button.png", true, array("style" => "margin-left: 10px;")) . ''; +$table->data[2][1] = '' . + html_print_image("images/play.button.png", true, array("id" => "button")) . + ''; +$table->data[2][1] .= '' . + html_print_image("images/ok.button.png", true, + array("style" => "margin-left: 10px;")) . ''; html_print_table($table); ?> @@ -96,6 +100,8 @@ var id_row = 0; var redBackground = false; +var button_play_status = "play"; + function changeGroup() { group = $("#group").val(); } @@ -107,14 +113,22 @@ function changeType() { } function toggleButton() { - if ($("#button").attr('src') == '../../images/pause.button.png') { + + if (button_play_status == 'pause') { + //~ if ($("#button").attr('src') == '../../images/pause.button.png') { + $("#button").attr('src', '../../images/play.button.png'); stopSound(); + + button_play_status = 'play'; } else { + $("#button").attr('src', '../../images/pause.button.png'); forgetPreviousEvents(); startSound(); + + button_play_status = 'pause'; } } @@ -135,7 +149,6 @@ function stopSound() { } function startSound() { - $('embed').remove(); //running = true; } @@ -177,7 +190,6 @@ function check_event() { if (firedId != 0) { id_row = firedId; fired = true; - $('embed').remove(); $('body').append("