diff options
Diffstat (limited to 'net-mgmt/pandorafms_console/files/patch-update')
-rw-r--r-- | net-mgmt/pandorafms_console/files/patch-update | 9578 |
1 files changed, 0 insertions, 9578 deletions
diff --git a/net-mgmt/pandorafms_console/files/patch-update b/net-mgmt/pandorafms_console/files/patch-update deleted file mode 100644 index 2d0fb9aee46d..000000000000 --- a/net-mgmt/pandorafms_console/files/patch-update +++ /dev/null @@ -1,9578 +0,0 @@ -Index: pandoradb_data.sql -=================================================================== ---- pandoradb_data.sql (revision 10314) -+++ pandoradb_data.sql (working copy) -@@ -283,7 +283,7 @@ - -- Dumping data for table `tnews` - -- - --INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES (1,'admin','Welcome to Pandora FMS 5.0!','This is the new Pandora FMS Console. A lot of new features have been added since last version. Please read the documentation about it, and feel free to test any option.\r\n\r\nThe Pandora FMS Team.',NOW()); -+INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES (1,'admin','Welcome to Pandora FMS!','This is the Pandora FMS Console. A lot of new features have been added since last version. Please read the documentation about it, and feel free to test any option.\r\n\r\nThe Pandora FMS Team.',NOW()); - INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES (2,'admin','New Pandora FMS Agent Features','Feel free to test our new features for both Windows and Linux agents: Proxy and Broker modes.',NOW()); - - INSERT INTO tmodule VALUES (1,'Agent module'); -Index: include/functions_clippy.php -=================================================================== ---- include/functions_clippy.php (revision 0) -+++ include/functions_clippy.php (revision 10417) -@@ -0,0 +1,176 @@ -+<?php -+ -+// Pandora FMS - http://pandorafms.com -+// ================================================== -+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas -+// Please see http://pandorafms.org for full contribution list -+ -+// This program is free software; you can redistribute it and/or -+// modify it under the terms of the GNU Lesser General Public License -+// as published by the Free Software Foundation; version 2 -+ -+// This program is distributed in the hope that it will be useful, -+// 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. -+ -+/** -+ * @package Include -+ * @subpackage Clippy -+ */ -+ -+function clippy_start($sec2) { -+ global $config; -+ -+ if ($sec2 === false) { -+ $sec2 = 'homepage'; -+ } -+ -+ $sec2 = str_replace('/', '_', $sec2); -+ -+ if ($sec2 != 'homepage') { -+ if (is_file("include/help/clippy/" . $sec2 . ".php")) { -+ require("include/help/clippy/" . $sec2 . ".php"); -+ -+ clippy_start_page(); -+ } -+ -+ //Add homepage for all pages for to show the "task sugestions" -+ require("include/help/clippy/homepage.php"); -+ clippy_start_page_homepage(); -+ } -+ else { -+ require("include/help/clippy/homepage.php"); -+ clippy_start_page_homepage(); -+ } -+} -+ -+function clippy_clean_help() { -+ set_cookie('clippy', null); -+} -+ -+function clippy_write_javascript_helps_steps($helps, -+ $force_first_step_by_default = true) { -+ -+ global $config; -+ -+ $clippy = get_cookie('clippy', false); -+ set_cookie('clippy', null); -+ -+ -+ //Get the help steps from a task -+ $steps = $helps[$clippy]['steps']; -+ if ($force_first_step_by_default) { -+ if (empty($steps)) { -+ //Get the first by default -+ $temp = reset($helps); -+ $steps = $temp['steps']; -+ } -+ } -+ -+ $conf = $helps[$clippy]['conf']; -+ if ($force_first_step_by_default) { -+ if (empty($conf)) { -+ //Get the first by default -+ $temp = reset($helps); -+ $conf = $temp['conf']; -+ } -+ } -+ -+ if (!empty($steps)) { -+ $name_obj_tour = 'intro'; -+ if (!empty($conf['name_obj_tour'])) { -+ $name_obj_tour = $conf['name_obj_tour']; -+ } -+ -+ $autostart = true; -+ if (!is_null($conf['autostart'])) { -+ $autostart = $conf['autostart']; -+ } -+ -+ $other_js = ''; -+ if (!empty($conf['other_js'])) { -+ $other_js = $conf['other_js']; -+ } -+ -+ ?> -+ <script type="text/javascript"> -+ var <?php echo $name_obj_tour; ?> = null; -+ -+ $(document).ready(function() { -+ <?php echo $name_obj_tour; ?> = introJs(); -+ -+ <?php echo $name_obj_tour; ?>.setOptions({ -+ steps: <?php echo json_encode($steps); ?>, -+ showBullets: <?php echo json_encode($conf['showBullets']); ?>, -+ showStepNumbers: <?php echo json_encode($conf['showStepNumbers']); ?>, -+ nextLabel: "<?php echo __('Next →'); ?>", -+ prevLabel: "<?php echo __('← Back'); ?>", -+ skipLabel: "<?php echo __('Skip'); ?>", -+ doneLabel: "<?php echo __('Done'); ?>", -+ exitOnOverlayClick: false, -+ exitOnEsc: true, //false, -+ }) -+ .onexit(function(value) { -+ exit = confirm("<?php echo __("Do you want to exit the help tour?"); ?>"); -+ return exit; -+ }); -+ -+ <?php -+ if (!empty($conf['next_help'])) { -+ ?> -+ clippy_set_help('<?php echo $conf['next_help']; ?>'); -+ <?php -+ } -+ ?> -+ -+ <?php -+ if ($autostart) { -+ ?> -+ <?php echo $name_obj_tour; ?>.start(); -+ <?php -+ } -+ ?> -+ }); -+ -+ <?php echo $other_js; ?> -+ </script> -+ <?php -+ } -+} -+ -+function clippy_context_help($help = null) { -+ $id = uniqid("id_"); -+ -+ $return = ''; -+ -+ require_once("include/help/clippy/" . $help . ".php"); -+ -+ ob_start(); -+ $function = "clippy_" . $help; -+ $function(); -+ $code = ob_get_clean(); -+ -+ $code = str_replace('{clippy}', '#' . $id, $code); html_debug_print($code, true); -+ $code = str_replace('{clippy_obj}', 'intro_' . $id, $code); html_debug_print($code, true); -+ -+ $return = $code . -+ '<div id="' . $id . '" style="display: inline;">' . -+ '<a onclick="intro_' . $id . '.start();" href="javascript: return false;" >' . -+ html_print_image( -+ "images/clippy_icon.png", -+ true) . -+ '</a>' . -+ '</div> -+ <script type="text/javascript"> -+ $(document).ready(function() { -+ $("#' . $id . ' img").pulsate (); -+ }); -+ </script> -+ '; -+ -+ -+ -+ return $return; -+} -+?> -\ No newline at end of file -Index: include/styles/menu.css -=================================================================== ---- include/styles/menu.css (revision 10314) -+++ include/styles/menu.css (working copy) -@@ -81,7 +81,6 @@ - .submenu { - font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; - margin: 0px 10px 0px 0; -- width: 173px; - } - .submenu li a { - background-color: #222; -@@ -143,10 +142,6 @@ - background-position: 4px 8px; - } - --.menu { -- width: 173px; -- --} - /* Icons specified here */ - #icon_oper-networkconsole { - background-image: url(../../images/op_network.png); -@@ -234,7 +229,6 @@ - #menu_container { - z-index: 3; - position: absolute; -- left: -140px; -+ left: -80px; - background-color: #AAA; -- height: 100%; - } -Index: include/styles/pandora.css -=================================================================== ---- include/styles/pandora.css (revision 10314) -+++ include/styles/pandora.css (working copy) -@@ -278,7 +278,7 @@ - } - - div#menu { -- width: 165px; -+ width: 175px; - float: left; - } - -@@ -291,6 +291,14 @@ - background-color: #274C00; - } - -+.fixed_header { -+ z-index: 9999; -+ position: fixed; -+ left: 0; -+ top: 0; -+ width: 100%; -+} -+ - div#foot { - font-size: 6pt !important; - border-top: solid 2px #222; -@@ -298,7 +306,6 @@ - padding-bottom: 5px; - text-align: center; - background: #333333; -- width: 960px; - height: 38px; - clear: both; - width: auto; -@@ -901,17 +908,10 @@ - padding: 6px 0px; - height: 14px; - } --.titop { -- -moz-border-top-right-radius: 6px; -- -webkit-border-top-right-radius: 6px; -- border-top-right-radius: 6px; -- heigth: 100px; --} - .tit, .titb { - font-weight: bold; - color: #fff; - text-align: center; -- width: 173px; - } - - .suc * { -@@ -1863,12 +1863,10 @@ - div#main { - width: auto; - float: none; -- padding-right: 0px; -- padding-left: 0px; -- padding-top: 0px; -- padding-bottom: 20px; -- margin-left: 182px; -- margin-right: 20px; -+ margin-top: 10px; -+ margin-left: 185px; -+ margin-right: 10px; -+ padding-bottom: 10px; - background: #ECECEC; - min-width: 720px; - } -@@ -2669,7 +2667,7 @@ - margin: 0px !important; - bottom: 0px; - left: 0px; -- z-index: 1020; -+ z-index: 9001; - } - - #shortcut_bar { -@@ -2704,3 +2702,12 @@ - table#policy_modules td * { - display: inline; - } -+ -+ -+.context_help_title { -+ font-weight: bolder; -+ text-align: left; -+} -+.context_help_body { -+ text-align: left; -+} -\ No newline at end of file -Index: include/functions_update_manager.php -=================================================================== ---- include/functions_update_manager.php (revision 10314) -+++ include/functions_update_manager.php (working copy) -@@ -24,11 +24,17 @@ - global $build_version; - global $pandora_version; - -- $license = db_get_value('`value`', 'tupdate_settings', '`key`', -+ $license = db_get_value( -+ db_encapsule_fields_with_same_name_to_instructions('value'), -+ 'tupdate_settings', -+ db_encapsule_fields_with_same_name_to_instructions('key'), - 'customer_key'); - - if (enterprise_installed()) { -- $current_update = db_get_value('`value`', 'tupdate_settings', '`key`', -+ $current_update = db_get_value( -+ db_encapsule_fields_with_same_name_to_instructions('value'), -+ 'tupdate_settings', -+ db_encapsule_fields_with_same_name_to_instructions('key'), - 'current_package_enterprise'); - - $current_update = 0; -@@ -36,7 +42,10 @@ - $current_update = $config['current_package_enterprise']; - } - else { -- $current_update = db_get_value('`value`', 'tupdate_settings', '`key`', -+ $current_update = db_get_value( -+ db_encapsule_fields_with_same_name_to_instructions('value'), -+ 'tupdate_settings', -+ db_encapsule_fields_with_same_name_to_instructions('key'), - 'current_package'); - - $current_update = 0; -@@ -64,10 +73,12 @@ - function rrmdir($dir) { - if (is_dir($dir)) { - $objects = scandir($dir); -+ - foreach ($objects as $object) { - if ($object != "." && $object != "..") { -- if (filetype($dir."/".$object) == "dir") -- rrmdir($dir."/".$object); else unlink($dir."/".$object); -+ if (filetype($dir . "/" . $object) == "dir") -+ rrmdir($dir . "/" . $object); -+ else unlink($dir . "/" . $object); - } - } - reset($objects); -@@ -264,11 +275,13 @@ - return false; - } - else { -- if ($is_ajax) { -- return true; -+ $result = json_decode($result, true); -+ -+ if (empty($result)) { -+ return false; - } - else { -- return false; -+ return true; - } - } - } -@@ -362,8 +375,10 @@ - "/downloads/last_package.tgz"; - - try { -+ rrmdir($config['attachment_store'] . -+ "/downloads/temp_update/pandora_console"); -+ - $phar = new PharData($path_package); -- rrmdir($config['attachment_store'] . "/downloads/temp_update/pandora_console"); - $phar->extractTo($config['attachment_store'] . "/downloads/temp_update"); - } - catch (Exception $e) { -@@ -384,7 +399,14 @@ - array('value' => 50), - array('token' => 'progress_update')); - -- $full_path = $config['attachment_store'] . "/downloads/temp_update/pandora_console"; -+ $path_array = array('downloads', 'temp_update', 'pandora_console'); -+ $full_path = $config['attachment_store']; -+ foreach ($path_array as $directory) { -+ $full_path = $full_path . '/' . $directory; -+ if (!is_dir($full_path)) { -+ mkdir($full_path); -+ } -+ } - - $homedir = $config['homedir']; - -Index: include/functions_groups.php -=================================================================== ---- include/functions_groups.php (revision 10314) -+++ include/functions_groups.php (working copy) -@@ -236,7 +236,7 @@ - * @param integer $parent The id_group parent to search the childrens. - * @param array $groups The groups, its for optimize the querys to DB. - */ --function groups_get_childrens($parent, $groups = null) { -+function groups_get_childrens($parent, $groups = null, $onlyPropagate = false) { - if (empty($groups)) { - $groups = db_get_all_rows_in_table('tgrupo'); - } -@@ -248,7 +248,7 @@ - continue; - } - -- if ($group['propagate']) { -+ if ($group['propagate'] || $onlyPropagate) { - if ($group['parent'] == $parent) { - $return = $return + array($group['id_grupo'] => $group) + groups_get_childrens($group['id_grupo'], $groups); - } -@@ -1531,4 +1531,42 @@ - } - } - } -+ -+/** -+ * Return an array with the groups hierarchy (Recursive) -+ * -+ * @param array Groups array passed by reference -+ * @param mixed The id of the parent to search or false to begin the search from the first hierarchy level -+ * -+ * @return array The groups reordered by its hierarchy -+ */ -+function groups_get_tree(&$groups, $parent = false) { -+ $return = array(); -+ -+ foreach ($groups as $id => $group) { -+ if ($parent === false && (!isset($group['parent']) || $group['parent'] == 0)) { -+ $return[$id] = $group; -+ unset($groups[$id]); -+ $children = groups_get_tree($groups, $id); -+ -+ if (!empty($children)) { -+ $return[$id]['children'] = $children; -+ } -+ } -+ else if ($parent && isset($group['parent']) && $group['parent'] == $parent) { -+ $return[$id] = $group; -+ unset($groups[$id]); -+ $children = groups_get_tree($groups, $id); -+ -+ if (!empty($children)) { -+ $return[$id]['children'] = $children; -+ } -+ } -+ else { -+ continue; -+ } -+ } -+ -+ return $return; -+} - ?> -Index: include/functions_visual_map.php -=================================================================== ---- include/functions_visual_map.php (revision 10314) -+++ include/functions_visual_map.php (working copy) -@@ -114,9 +114,11 @@ - echo '<div id="' . $id . '" class="item static_graph" style="z-index: 1; text-align: center; color: ' . $color . '; position: absolute; display: inline-block; ' . $sizeStyle . ' top: ' . $top . 'px; left: ' . $left . 'px;">'; - if ($layoutData['image'] != null) { - if (($width != 0) && ($height != 0)) -- echo html_print_image($img, true, array("class" => "image", "id" => "image_" . $id, "width" => "$width", "height" => "$height", "style" => $borderStyle)); -+ echo html_print_image($img, true, -+ array("class" => "image", "id" => "image_" . $id, "width" => "$width", "height" => "$height", "style" => $borderStyle)); - else -- echo html_print_image($img, true, array("class" => "image", "id" => "image_" . $id, "style" => $borderStyle)); -+ echo html_print_image($img, true, -+ array("class" => "image", "id" => "image_" . $id, "style" => $borderStyle)); - echo '<br />'; - } - echo io_safe_output($text); -@@ -1299,8 +1301,28 @@ - } - - $img_style = array (); -+ - $img_style["title"] = strip_tags($layout_data["label"]); -+ if ($layout_data['type'] == STATIC_GRAPH) { -+ if ($layout_data['id_agente_modulo'] != 0) { -+ $unit_text = trim(io_safe_output( -+ modules_get_unit($layout_data['id_agente_modulo']))); -+ -+ $value = modules_get_last_value($layout_data['id_agente_modulo']); -+ -+ if (!is_string($value)) { -+ $value = format_for_graph($value, 2); -+ } -+ -+ if (!empty($unit_text)) -+ $value .= " " . $unit_text; -+ -+ $img_style["title"] .= " <br>" . __("Last value: ") . -+ $value; -+ } -+ } - -+ - if (!empty ($layout_data["width"])) { - $img_style["width"] = $layout_data["width"]; - } -Index: include/ajax/events.php -=================================================================== ---- include/ajax/events.php (revision 10314) -+++ include/ajax/events.php (working copy) -@@ -349,7 +349,13 @@ - } - - $details = events_page_details($event, $server); -- -+ -+ // Juanma (09/05/2014) Fix: Needs to reconnect to node, in previous funct node connection was lost -+ if ($meta) { -+ $server = metaconsole_get_connection_by_id ($server_id); -+ metaconsole_connect($server); -+ } -+ - $custom_fields = events_page_custom_fields($event); - - $custom_data = events_page_custom_data($event); -Index: include/ajax/module.php -=================================================================== ---- include/ajax/module.php (revision 10314) -+++ include/ajax/module.php (working copy) -@@ -23,6 +23,14 @@ - enterprise_include_once ('include/functions_metaconsole.php'); - - $get_plugin_macros = get_parameter('get_plugin_macros'); -+$search_modules = get_parameter('search_modules'); -+$get_module_detail = get_parameter ('get_module_detail', 0); -+$get_module_autocomplete_input = (bool) get_parameter('get_module_autocomplete_input'); -+$add_module_relation = (bool) get_parameter('add_module_relation'); -+$remove_module_relation = (bool) get_parameter('remove_module_relation'); -+$change_module_relation_updates = (bool) get_parameter('change_module_relation_updates'); -+$get_id_tag = (bool) get_parameter('get_id_tag', 0); -+ - if ($get_plugin_macros) { - $id_plugin = get_parameter('id_plugin', 0); - -@@ -37,7 +45,7 @@ - return; - } - --$search_modules = get_parameter('search_modules'); -+ - if ($search_modules) { - $id_agents = json_decode(io_safe_output(get_parameter('id_agents'))); - $filter = get_parameter('q', '') . '%'; -@@ -56,10 +64,9 @@ - return; - } - --$get_module_detail = get_parameter ('get_module_detail', 0); - - if ($get_module_detail) { -- -+ - ui_include_time_picker(); - - ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/"); -@@ -82,6 +89,9 @@ - $conexion = mysql_connect ($server['dbhost'], $server['dbuser'], $server['dbpass']); - $select_db = mysql_select_db ($server['dbname'], $conexion); - } -+ else { -+ $conexion = false; -+ } - - $selection_mode = get_parameter('selection_mode', 'fromnow'); - $date_from = (string) get_parameter ('date_from', date ('Y-m-j')); -@@ -131,15 +141,16 @@ - - html_print_table($formtable); - -- $moduletype_name = modules_get_moduletype_name (modules_get_agentmodule_type ($module_id)); -+ $moduletype_name = modules_get_moduletype_name( -+ modules_get_agentmodule_type($module_id)); - - $offset = (int) get_parameter("offset"); - $block_size = (int) $config["block_size"]; - - $columns = array (); - -- $datetime_from = strtotime ($date_from.' '.$time_from); -- $datetime_to = strtotime ($date_to.' '.$time_to); -+ $datetime_from = strtotime ($date_from . ' ' . $time_from); -+ $datetime_to = strtotime ($date_to . ' ' . $time_to); - - if ($moduletype_name == "log4x") { - $table->width = "100%"; -@@ -222,14 +233,30 @@ - ); - } - -+ - $sql_body = io_safe_output($sql_body); - // Clean all codification characters - - $sql = "SELECT * " . $sql_body; -- $sql_count = "SELECT count(*) " . $sql_body; - -+ switch ($config['dbtype']) { -+ case "mysql": -+ $sql_count = "SELECT count(*) " . $sql_body; -+ break; -+ case "postgresql": -+ $sql_body = str_replace("ORDER BY utimestamp DESC", -+ "GROUP BY utimestamp ORDER BY utimestamp DESC", -+ $sql_body); -+ $sql_count = "SELECT count(DISTINCT utimestamp) " . $sql_body; -+ break; -+ case "oracle": -+ $sql_count = "SELECT count(*) " . $sql_body; -+ break; -+ } -+ - $count = db_get_value_sql ($sql_count, $conexion); - -+ - switch ($config["dbtype"]) { - case "mysql": - $sql .= " LIMIT " . $offset . "," . $block_size; -@@ -337,10 +364,10 @@ - return; - } - --$get_module_autocomplete_input = (bool) get_parameter('get_module_autocomplete_input'); -+ - if ($get_module_autocomplete_input) { - $id_agent = (int) get_parameter("id_agent"); -- -+ - ob_clean(); - if ($id_agent > 0) { - html_print_autocomplete_modules( -@@ -350,7 +377,7 @@ - return; - } - --$add_module_relation = (bool) get_parameter('add_module_relation'); -+ - if ($add_module_relation) { - $result = false; - $id_module_a = (int) get_parameter("id_module_a"); -@@ -384,7 +411,7 @@ - return; - } - --$remove_module_relation = (bool) get_parameter('remove_module_relation'); -+ - if ($remove_module_relation) { - $id_relation = (int) get_parameter("id_relation"); - if ($id_relation > 0) { -@@ -395,23 +422,25 @@ - return; - } - --$change_module_relation_updates = (bool) get_parameter('change_module_relation_updates'); -+ - if ($change_module_relation_updates) { - $id_relation = (int) get_parameter("id_relation"); - if ($id_relation > 0) { - $result = (bool) modules_change_relation_lock($id_relation); - } -+ - echo json_encode($result); - return; - } - --$get_id_tag = (bool) get_parameter('get_id_tag', 0); -+ - if ($get_id_tag) { - $tag_name = get_parameter('tag_name'); -- -+ - if ($tag_name) { - $tag_id = db_get_value('id_tag', 'ttag', 'name', $tag_name); -- } else { -+ } -+ else { - $tag_id = 0; - } - -Index: include/functions_api.php -=================================================================== ---- include/functions_api.php (revision 10314) -+++ include/functions_api.php (working copy) -@@ -757,7 +757,7 @@ - $cascadeProtection = $other['data'][4]; - $intervalSeconds = $other['data'][5]; - $idOS = $other['data'][6]; -- $idServer = $other['data'][7]; -+ $nameServer = $other['data'][7]; - $customId = $other['data'][8]; - $learningMode = $other['data'][9]; - $disabled = $other['data'][10]; -@@ -806,7 +806,8 @@ - $cascadeProtection = $other['data'][4]; - $intervalSeconds = $other['data'][5]; - $idOS = $other['data'][6]; -- $idServer = $other['data'][7]; -+ //$idServer = $other['data'][7]; -+ $nameServer = $other['data'][7]; - $customId = $other['data'][8]; - $learningMode = $other['data'][9]; - $disabled = $other['data'][10]; -@@ -815,12 +816,12 @@ - switch ($config["dbtype"]) { - case "mysql": - $sql1 = 'SELECT name -- FROM tserver WHERE id_server =' . $idServer; -+ FROM tserver WHERE name LIKE "' . $nameServer . '"'; - break; - case "postgresql": - case "oracle": - $sql1 = 'SELECT name -- FROM tserver WHERE id_server =' . $idServer; -+ FROM tserver WHERE name LIKE \'' . $nameServer . '\''; - break; - } - -@@ -2476,7 +2477,7 @@ - if (!$module_values) { - returnError('error_get_module_value_all_agents', 'Error getting module values from all agents.'); - } -- else{ -+ else { - $data = array('type' => 'array', 'data' => $module_values); - - returnData('csv', $data, ';'); -@@ -4856,7 +4857,7 @@ - else { - $return = true; - } -- -+ - $data['type'] = 'string'; - if ($return === false) { - $data['data'] = 0; -@@ -4865,7 +4866,7 @@ - $data['data'] = $return; - } - returnData('string', $data); -- return; -+ return; - } - else { - returnError('error_parameter', 'Error in the parameters.'); -@@ -4900,20 +4901,20 @@ - <data><![CDATA[%s]]></data> - </module> - </agent_data>"; -- -+ - $xml = sprintf($xmlTemplate, io_safe_output(get_os_name($agent['id_os'])), - io_safe_output($agent['os_version']), $agent['intervalo'], - io_safe_output($agent['agent_version']), date('Y/m/d H:i:s', $time), - io_safe_output($agent['nombre']), $agent['timezone_offset'], - io_safe_output($agentModule['nombre']), io_safe_output($agentModule['descripcion']), modules_get_type_name($agentModule['id_tipo_modulo']), $data); -- -- -+ -+ - if (false === @file_put_contents($config['remote_config'] . '/' . io_safe_output($agent['nombre']) . '.' . $time . '.data', $xml)) { - returnError('error_file', 'Can save agent data xml.'); - } - else { - returnData('string', array('type' => 'string', 'data' => $xml)); -- return; -+ return; - } - } - } -@@ -6064,7 +6065,7 @@ - $id_agent = agents_get_agent_id($agent_name); - $id_agent_module = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('id_agente' => $id_agent, 'nombre' => $module_name)); - -- $result = modules_change_disabled($id_agent_module, 1); -+ $result = modules_change_disabled($id_agent_module, 0); - - if ($result === NOERR) { - returnData('string', array('type' => 'string', 'data' => __('Correct module enable'))); -@@ -6665,7 +6666,8 @@ - 'module_lag' => $server["module_lag"], - 'threads' => $server["threads"], - 'queued_modules' => $server["queued_modules"], -- 'keepalive' => $server['keepalive'] -+ 'keepalive' => $server['keepalive'], -+ 'id_server' => $server['id_server'] - ); - - // servers_get_info() returns "<a http:....>servername</a>" for recon server's name. -Index: include/functions_ui.php -=================================================================== ---- include/functions_ui.php (revision 10314) -+++ include/functions_ui.php (working copy) -@@ -1245,7 +1245,13 @@ - } - $output .= "\n\t"; - -+ -+ -+ -+ -+ //////////////////////////////////////////////////////////////////// - //Load CSS -+ //////////////////////////////////////////////////////////////////// - if (empty ($config['css'])) { - $config['css'] = array (); - } -@@ -1270,7 +1276,8 @@ - } - } - -- //First, if user has assigned a skin then try to use css files of skin subdirectory -+ //First, if user has assigned a skin then try to use css files of -+ //skin subdirectory - $isFunctionSkins = enterprise_include_once ('include/functions_skins.php'); - if (!$login_ok) { - if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { -@@ -1278,6 +1285,7 @@ - } - } - -+ - $exists_css = false; - if ($login_ok and $isFunctionSkins !== ENTERPRISE_NOT_HOOK) { - //Checks if user's skin is available -@@ -1305,12 +1313,17 @@ - $config['css']); - } - -+ -+ - // Add the jquery UI styles CSS - $config['css']['jquery-UI'] = "include/styles/jquery-ui-1.10.0.custom.css"; -- - // Add the dialog styles CSS - $config['css']['dialog'] = "include/styles/dialog.css"; -+ // Add the dialog styles CSS -+ $config['css']['dialog'] = "include/javascript/introjs.css"; - -+ -+ - //We can't load empty and we loaded (conditionally) ie - $loaded = array ('', 'ie'); - -@@ -1333,25 +1346,34 @@ - $output .= '<link rel="stylesheet" href="' . $url_css . '" type="text/css" />'."\n\t"; - } - } -+ //////////////////////////////////////////////////////////////////// - //End load CSS -+ //////////////////////////////////////////////////////////////////// - -+ -+ -+ -+ //////////////////////////////////////////////////////////////////// - //Load JS -+ //////////////////////////////////////////////////////////////////// - if (empty ($config['js'])) { - $config['js'] = array (); //If it's empty, false or not init set array to empty just in case - } - -+ - //Pandora specific JavaScript should go first - $config['js'] = array_merge (array ("pandora" => "include/javascript/pandora.js"), $config['js']); -- - //Load base64 javascript library - $config['js']['base64'] = "include/javascript/encode_decode_base64.js"; -- - //Load webchat javascript library - $config['js']['webchat'] = "include/javascript/webchat.js"; -- - //Load qrcode library - $config['js']['qrcode'] = "include/javascript/qrcode.js"; -+ //Load intro.js library (for bubbles and clippy) -+ $config['js']['intro'] = "include/javascript/intro.js"; -+ $config['js']['clippy'] = "include/javascript/clippy.js"; - -+ - //Load other javascript - //We can't load empty - $loaded = array (''); -@@ -1370,9 +1392,15 @@ - $output .= '<script type="text/javascript" src="' . $url_js . '"></script>'."\n\t"; - } - } -+ //////////////////////////////////////////////////////////////////// - //End load JS -+ //////////////////////////////////////////////////////////////////// - -+ -+ -+ //////////////////////////////////////////////////////////////////// - //Load jQuery -+ //////////////////////////////////////////////////////////////////// - if (empty ($config['jquery'])) { - $config['jquery'] = array (); //If it's empty, false or not init set array to empty just in case - } -@@ -1422,8 +1450,13 @@ - $output .= '<script type="text/javascript" src="' . $url_js . '"></script>'."\n\t"; - } - } -+ //////////////////////////////////////////////////////////////////// -+ //End load JQuery -+ //////////////////////////////////////////////////////////////////// - - -+ -+ - if ($config['flash_charts']) { - //Include the javascript for the js charts library - include_once($config["homedir"] . '/include/graphs/functions_flot.php'); -@@ -1576,9 +1609,9 @@ - - // Show GOTO FIRST button - if ($other_class == '') { -- $output .= '<a class="pagination go_first" href="'.$url.'&'.$offset_name.'=0">'.html_print_image ("images/go_first.png", true, array ("class" => "bot")).'</a> '; -+ $output .= '<a class="pagination offset_0" href="'.$url.'&' .$offset_name.'=0">'.html_print_image ("images/go_first.png", true, array ("class" => "bot")).'</a> '; - } else { -- $output .= "<a class='pagination $other_class go_first' href='$url.&$offset_name=0'>".html_print_image ("images/go_first.png", true, array ("class" => "bot"))."</a> "; -+ $output .= "<a class='pagination $other_class offset_0' href='$url.&$offset_name=0'>".html_print_image ("images/go_first.png", true, array ("class" => "bot"))."</a> "; - } - - // Show PREVIOUS button -@@ -1588,9 +1621,9 @@ - $index_page_prev = 0; - - if ($other_class == '') { -- $output .= '<a class="pagination go_rewind" href="'.$url.'&'.$offset_name.'='.$index_page_prev.'">'.html_print_image ("images/go_previous.png", true, array ("class" => "bot")).'</a>'; -+ $output .= '<a class="pagination offset_' . $index_page_prev . '" href="'.$url.'&'.$offset_name.'='.$index_page_prev.'">'.html_print_image ("images/go_previous.png", true, array ("class" => "bot")).'</a>'; - } else { -- $output .= "<a class='pagination $other_class go_rewind' href='$url &$offset_name = $index_page_prev'>".html_print_image ("images/go_previous.png", true, array ("class" => "bot"))."</a>"; -+ $output .= "<a class='pagination $other_class offset_$index_page_prev' href='$url &$offset_name = $index_page_prev'>".html_print_image ("images/go_previous.png", true, array ("class" => "bot"))."</a>"; - } - } - -@@ -1629,13 +1662,12 @@ - // Index_counter stores max of blocks - if (($paginacion_maxima == 1) AND (($index_counter - $i) > 0)) { - $prox_bloque = ($i + ceil ($block_limit / 2)) * $pagination; -- if ($prox_bloque > $count) -- $prox_bloque = ($count -1) - $pagination; -- -+ if ($prox_bloque >= $count) -+ $prox_bloque = (int) (($count - 1) / $pagination) * $pagination; - if ($other_class == '') { -- $output .= '<a class="pagination go_fastforward" href="'.$url.'&'.$offset_name.'='.$prox_bloque.'">'.html_print_image ("images/go_next.png", true, array ("class" => "bot")).'</a>'; -+ $output .= '<a class="pagination offset_' . $prox_bloque . '" href="'.$url.'&'.$offset_name.'='.$prox_bloque.'">'.html_print_image ("images/go_next.png", true, array ("class" => "bot")).'</a>'; - } else { -- $output .= "<a class='pagination $other_class go_fastforward' href='$url&$offset_name=$prox_bloque'>".html_print_image ("images/go_next.png", true, array ("class" => "bot"))."</a>"; -+ $output .= "<a class='pagination $other_class offset_$prox_bloque' href='$url&$offset_name=$prox_bloque'>".html_print_image ("images/go_next.png", true, array ("class" => "bot"))."</a>"; - } - $i = $index_counter; - } -@@ -1647,9 +1679,9 @@ - $myoffset = floor (($count - 1) / $pagination) * $pagination; - - if ($other_class == '') { -- $output .= '<a class="pagination go_last" href="'.$url.'&'.$offset_name.'='.$myoffset.'">'.html_print_image ("images/go_last.png", true, array ("class" => "bot")).'</a>'; -+ $output .= '<a class="pagination offset_' . $myoffset . '" href="'.$url. '&'.$offset_name.'='.$myoffset.'">'.html_print_image ("images/go_last.png", true, array ("class" => "bot")).'</a>'; - } else { -- $output .= "<a class='pagination $other_class go_last' href='$url&$offset_name=$myoffset'>".html_print_image ("images/go_last.png", true, array ("class" => "bot"))."</a>"; -+ $output .= "<a class='pagination $other_class offset_$myoffset' href='$url&$offset_name=$myoffset'>".html_print_image ("images/go_last.png", true, array ("class" => "bot"))."</a>"; - } - } - -@@ -2268,7 +2300,8 @@ - $buffer .= '<span style="display: inline-block; vertical-align: top; margin-top: 2px;">' . - ui_print_truncate_text($title, 38); - if ($help != "") -- $buffer .= "<div class='head_help' style='float: right; margin-top: -3px !important; margin-left: 2px !important;'>" . ui_print_help_icon ($help, true, '', 'images/help_w.png') . "</div>"; -+ $buffer .= "<div class='head_help' style='float: right; margin-top: -3px !important; margin-left: 2px !important;'>" . -+ ui_print_help_icon ($help, true, '', 'images/help_w.png') . "</div>"; - $buffer .= '</span></li></ul></div>'; - - if (is_array($options)) { -Index: include/functions.php -=================================================================== ---- include/functions.php (revision 10314) -+++ include/functions.php (working copy) -@@ -768,6 +768,23 @@ - return get_parameter($name, 0); - } - -+function get_cookie($name, $default = '') { -+ if (isset($_COOKIE[$name])) { -+ return $_COOKIE[$name]; -+ } -+ else { -+ return $default; -+ } -+} -+ -+function set_cookie($name, $value) { -+ if (is_null($value)) { -+ unset($_COOKIE[$value]); -+ setcookie($value, null, -1, '/'); -+ } -+ setcookie($name, $value); -+} -+ - /** - * Get a parameter from a request. - * -@@ -1430,9 +1447,11 @@ - * - * @return array SNMP result. - */ --function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', $snmp3_auth_user = '', -- $snmp3_security_level = '', $snmp3_auth_method = '', $snmp3_auth_pass = '', -- $snmp3_privacy_method = '', $snmp3_privacy_pass = '', $quick_print = 0, $base_oid = "", $snmp_port = '') { -+function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', -+ $snmp3_auth_user = '', $snmp3_security_level = '', -+ $snmp3_auth_method = '', $snmp3_auth_pass = '', -+ $snmp3_privacy_method = '', $snmp3_privacy_pass = '', -+ $quick_print = 0, $base_oid = "", $snmp_port = '') { - - global $config; - -@@ -1464,7 +1483,7 @@ - else { - $snmpwalk_bin = $config['snmpwalk']; - } -- -+ - switch (PHP_OS) { - case "WIN32": - case "WINNT": -@@ -1480,16 +1499,54 @@ - $rc = 0; - switch ($snmp_version) { - case '3': -- exec ($snmpwalk_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($ip_target) . ' ' . $base_oid . ' 2> ' . $error_redir_dir, $output, $rc); -+ switch ($snmp3_security_level) { -+ case "authNoPriv": -+ $command_str = $snmpwalk_bin . -+ ' -m ALL -v 3' . -+ ' -u ' . escapeshellarg($snmp3_auth_user) . -+ ' -A ' . escapeshellarg($snmp3_auth_pass) . -+ ' -l ' . escapeshellarg($snmp3_security_level) . -+ ' -a ' . escapeshellarg($snmp3_auth_method) . -+ ' ' . escapeshellarg($ip_target) . -+ ' ' . $base_oid . -+ ' 2> ' . $error_redir_dir; -+ break; -+ case "noAuthNoPriv": -+ $command_str = $snmpwalk_bin . -+ ' -m ALL -v 3' . -+ ' -u ' . escapeshellarg($snmp3_auth_user) . -+ ' -l ' . escapeshellarg($snmp3_security_level) . -+ ' ' . escapeshellarg($ip_target) . -+ ' ' . $base_oid . -+ ' 2> ' . $error_redir_dir; -+ break; -+ default: -+ $command_str = $snmpwalk_bin . -+ ' -m ALL -v 3' . -+ ' -u ' . escapeshellarg($snmp3_auth_user) . -+ ' -A ' . escapeshellarg($snmp3_auth_pass) . -+ ' -l ' . escapeshellarg($snmp3_security_level) . -+ ' -a ' . escapeshellarg($snmp3_auth_method) . -+ ' -x ' . escapeshellarg($snmp3_privacy_method) . -+ ' -X ' . escapeshellarg($snmp3_privacy_pass) . -+ ' ' . escapeshellarg($ip_target) . -+ ' ' . $base_oid . -+ ' 2> ' . $error_redir_dir; -+ break; -+ } - break; - case '2': - case '2c': - case '1': - default: -- exec ($snmpwalk_bin . ' -m ALL -v ' . escapeshellarg($snmp_version) . ' -c ' . escapeshellarg($snmp_community) . ' ' . escapeshellarg($ip_target) . ' ' . $base_oid . ' 2> ' . $error_redir_dir, $output, $rc); -+ $command_str = $snmpwalk_bin . ' -m ALL -v ' . escapeshellarg($snmp_version) . ' -c ' . escapeshellarg($snmp_community) . ' ' . escapeshellarg($ip_target) . ' ' . $base_oid . ' 2> ' . $error_redir_dir; - break; - } - -+ //html_debug_print($command_str); -+ -+ exec($command_str, $output, $rc); -+ - // Parse the output of snmpwalk - $snmpwalk = array(); - foreach ($output as $line) { -@@ -2134,4 +2191,29 @@ - return $news; - } - -+ -+/** -+ * Print audit data in CSV format. -+ * -+ * @param array Audit data. -+ * -+ */ -+function print_audit_csv ($data) { -+ global $config; -+ global $graphic_type; -+ -+ $config['ignore_callback'] = true; -+ while (@ob_end_clean ()); -+ -+ header("Content-type: application/octet-stream"); -+ header("Content-Disposition: attachment; filename=audit_log".date("Y-m-d_His").".csv"); -+ header("Pragma: no-cache"); -+ header("Expires: 0"); -+ -+ echo __('User') . ';' . __('Action') . ';' . __('Date') . ';' . __('Source ID') . ';'. __('Comments') ."\n"; -+ foreach ($data as $line) { -+ echo io_safe_output($line['id_usuario']) . ';' . io_safe_output($line['accion']) . ';' . $line['fecha'] . ';' . $line['ip_origen'] . ';'. io_safe_output($line['descripcion']). "\n"; -+ } -+} -+ - ?> -Index: include/functions_agents.php -=================================================================== ---- include/functions_agents.php (revision 10314) -+++ include/functions_agents.php (working copy) -@@ -360,6 +360,11 @@ - } - } - -+ //Fix for postgresql -+ if (empty($filter['id_agente'])) { -+ unset($filter['id_agente']); -+ } -+ - $where = db_format_array_where_clause_sql ($filter, 'AND', ''); - - $where_nogroup = db_format_array_where_clause_sql ($filter_nogroup, 'AND', ''); -@@ -412,6 +417,7 @@ - return $sql; - else - $agents = db_get_all_rows_sql($sql); -+ - break; - case "oracle": - $set = array(); -Index: include/functions_graph.php -=================================================================== ---- include/functions_graph.php (revision 10314) -+++ include/functions_graph.php (working copy) -@@ -102,13 +102,14 @@ - - 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]; -+ $item['sum'] = $item['sum' . $series_suffix]; -+ $item['min'] = $item['min' . $series_suffix]; -+ $item['max'] = $item['max' . $series_suffix]; - } - - //Get stats for normal graph - if (isset($item['sum']) && $item['sum']) { -+ - //Sum all values later divide by the number of elements - $stats['sum']['avg'] = $stats['sum']['avg'] + $item['sum']; - -@@ -245,6 +246,7 @@ - $is_unknown = $start_unknown; - - // Calculate chart data -+ $last_known = $previous_data; - for ($i = 0; $i < $resolution; $i++) { - $timestamp = $datelimit + ($interval * $i); - -@@ -270,6 +272,7 @@ - $interval_min = $data[$data_i]['datos']; - } - $total += $data[$data_i]['datos']; -+ $last_known = $data[$data_i]['datos']; - $count++; - $data_i++; - } -@@ -399,7 +402,6 @@ - $chart[$timestamp]['sum'.$series_suffix] = $total; - $chart[$timestamp]['min'.$series_suffix] = $interval_min; - } -- $previous_data = $total; - // Compressed data - } - else { -@@ -415,12 +417,12 @@ - } - else { - if ($avg_only) { -- $chart[$timestamp]['sum'.$series_suffix] = $previous_data; -+ $chart[$timestamp]['sum'.$series_suffix] = $last_known; - } - else { -- $chart[$timestamp]['max'.$series_suffix] = $previous_data; -- $chart[$timestamp]['sum'.$series_suffix] = $previous_data; -- $chart[$timestamp]['min'.$series_suffix] = $previous_data; -+ $chart[$timestamp]['max'.$series_suffix] = $last_known; -+ $chart[$timestamp]['sum'.$series_suffix] = $last_known; -+ $chart[$timestamp]['min'.$series_suffix] = $last_known; - } - } - } -@@ -580,7 +582,7 @@ - if (!$projection) { - return fs_error_image (); - } -- else{ -+ else { - return fs_error_image (); - } - } -@@ -1103,6 +1105,7 @@ - $countAvg = 0; - - // Calculate chart data -+ $last_known = $previous_data; - for ($l = 0; $l < $resolution; $l++) { - $countAvg ++; - -@@ -1117,8 +1120,8 @@ - $count = 0; - - // Read data that falls in the current interval -- $interval_min = $previous_data; -- $interval_max = $previous_data; -+ $interval_min = $last_known; -+ $interval_max = $last_known; - while (isset ($data[$j]) && $data[$j]['utimestamp'] >= $timestamp && $data[$j]['utimestamp'] < ($timestamp + $interval)) { - if ($data[$j]['datos'] > $interval_max) { - $interval_max = $data[$j]['datos']; -@@ -1127,6 +1130,7 @@ - $interval_min = $data[$j]['datos']; - } - $total += $data[$j]['datos']; -+ $last_known = $data[$j]['datos']; - $count++; - $j++; - } -@@ -1153,18 +1157,14 @@ - if ($count > 0) { - //$graph_values[$i][$timestamp] = $total * $weight_list[$i]; - $temp_graph_values[$timestamp_short] = $total * $weight_list[$i]; -- -- $previous_data = $total; - } - else { - // Compressed data - if ($uncompressed_module || ($timestamp > time ())) { -- //$graph_values[$i][$timestamp] = 0; - $temp_graph_values[$timestamp_short] = 0; - } - else { -- //$graph_values[$i][$timestamp] = $previous_data * $weight_list[$i]; -- $temp_graph_values[$timestamp_short] = $previous_data * $weight_list[$i]; -+ $temp_graph_values[$timestamp_short] = $last_known * $weight_list[$i]; - } - } - -@@ -1459,16 +1459,19 @@ - $filter['id_agente'] = $id_agent; - } - -- $fields = array('SUM(critical_count) Critical', -- 'SUM(warning_count) Warning', -- 'SUM(normal_count) Normal', -- 'SUM(unknown_count) Unknown'); -+ $fields = array('SUM(critical_count) AS Critical', -+ 'SUM(warning_count) AS Warning', -+ 'SUM(normal_count) AS Normal', -+ 'SUM(unknown_count) AS Unknown'); - - if ($show_not_init) { - $fields[] = 'SUM(notinit_count) "Not init"'; - } - - $data = db_get_row_filter('tagente', $filter, $fields); -+ if (empty($data)) { -+ $data = array(); -+ } - - array_walk($data, 'truncate_negatives'); - -@@ -1796,6 +1799,7 @@ - if ($modules === false) - $modules = array (); - -+ $data = array(); - foreach ($modules as $module) { - $agent_name = agents_get_name ($module['id_agente'], "none"); - -@@ -1816,7 +1820,8 @@ - $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", - 'url' => ui_get_full_url("/images/logo_vertical_water.png")); - -- return hbar_graph($config['flash_charts'], $data, $width, $height, array(), -+ return hbar_graph($config['flash_charts'], -+ $data, $width, $height, array(), - array(), "", "", true, "", - $water_mark, - $config['fontpath'], $config['font_size'], false); -@@ -2670,6 +2675,7 @@ - $max_value = 0; - - // Calculate chart data -+ $last_known = $previous_data; - for ($i = 0; $i < $resolution; $i++) { - $timestamp = $datelimit + ($interval * $i); - -@@ -2689,6 +2695,7 @@ - $count++; - } - -+ $last_known = $data[$j]['datos']; - $j++; - } - -@@ -2796,43 +2803,20 @@ - //New code set 0 if there is a 0 - //Please check the incident #665 - //http://192.168.50.2/integria/index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=665 -- -- - $chart[$timestamp]['sum'.$series_suffix] = 0; -- $previous_data = 0; -- -- //Old code that make a AVG -- -- //~ if ($avg_only) { -- //~ $chart[$timestamp]['sum'.$series_suffix] = $total; -- //~ } -- //~ else { -- //~ $chart[$timestamp]['sum'.$series_suffix] = $total; -- //~ $chart[$timestamp + 1] = array ('sum'.$series_suffix => 0, -- //~ //'count' => 0, -- //~ //'timestamp_bottom' => $timestamp, -- //~ //'timestamp_top' => $timestamp + $interval, -- //~ 'min'.$series_suffix => 0, -- //~ 'max'.$series_suffix => 0, -- //~ 'event'.$series_suffix => $event_value, -- //~ 'alert'.$series_suffix => $alert_value); -- //~ } -- //~ $previous_data = 0; - } - else if ($zero == 1) { // Just zeros - $chart[$timestamp]['sum'.$series_suffix] = 0; -- $previous_data = 0; - } - else if ($count > 0) { // No zeros - $chart[$timestamp]['sum'.$series_suffix] = $total; -- $previous_data = $total; - } - else { // Compressed data - if ($uncompressed_module || ($timestamp > time ()) || $is_unknown) { - $chart[$timestamp]['sum'.$series_suffix] = 0; - } - else { -- $chart[$timestamp]['sum'.$series_suffix] = $previous_data; -+ $chart[$timestamp]['sum'.$series_suffix] = $last_known; - } - } - -@@ -3279,7 +3263,7 @@ - * @param integer date date - */ - function grafico_modulo_string ($agent_module_id, $period, $show_events, -- $width, $height , $title, $unit_name, $show_alerts, $avg_only = 0, $pure=0, -+ $width, $height , $title, $unit_name, $show_alerts, $avg_only = 0, $pure = 0, - $date = 0, $only_image = false, $homeurl = '', $adapt_key = '', $ttl = 1, $menu = true) { - global $config; - global $graphic_type; -@@ -3381,6 +3365,7 @@ - } - - // Calculate chart data -+ $last_known = $previous_data; - for ($i = 0; $i < $resolution; $i++) { - $timestamp = $datelimit + ($interval * $i); - -@@ -3388,6 +3373,7 @@ - $total = 0; - // Read data that falls in the current interval - while (isset($data[$j]) && isset ($data[$j]) !== null && $data[$j]['utimestamp'] >= $timestamp && $data[$j]['utimestamp'] <= ($timestamp + $interval)) { -+ $last_known = $data[$j]; - $count++; - $j++; - } -@@ -3437,7 +3423,7 @@ - //The order in chart array is very important!!!! - if ($show_events) { - $chart[$timestamp]['event'] = $event_value; -- } -+ } - - if ($show_alerts) { - $chart[$timestamp]['alert'] = $alert_value; -@@ -3449,11 +3435,10 @@ - - if ($count > 0) { - $chart[$timestamp]['sum'] = $count; -- $previous_data = $total; - } - else { - // Compressed data -- $chart[$timestamp]['sum'] = $previous_data; -+ $chart[$timestamp]['sum'] = $last_known; - } - - if (!$avg_only) { -@@ -4106,47 +4091,304 @@ - /** - * Print a solarburst graph with a representation of all the groups, agents, module groups and modules grouped - */ --function graph_monitor_wheel ($data, $unit, $width = 700, $height = 700) { -+function graph_monitor_wheel ($width = 500, $height = 600) { - global $config; - -- $data = array(); -- - include_once ($config['homedir'] . "/include/functions_users.php"); -- //include_once ($config['homedir'] . "/include/functions_groups.php"); -+ include_once ($config['homedir'] . "/include/functions_groups.php"); - include_once ($config['homedir'] . "/include/functions_agents.php"); -- //include_once ($config['homedir'] . "/include/functions_modules.php"); -+ include_once ($config['homedir'] . "/include/functions_modules.php"); - -+ $graph_data = array(); -+ - $groups = users_get_groups(false, "AR", false, true); - -+ $data_groups = array(); - if (!empty($groups)) { -+ $groups_aux = $groups; -+ $data_groups = groups_get_tree($groups_aux); -+ $groups_aux = $groups = null; -+ } -+ -+ if (!empty($data_groups)) { - $filter = array('id_grupo' => array_keys($groups)); - $fields = array('id_agente', 'id_parent', 'id_grupo', 'nombre'); - $agents = agents_get_agents($filter, $fields); - - if (!empty($agents)) { - $agents_id = array(); -+ $agents_aux = array(); - foreach ($agents as $key => $agent) { -- $agents_id[] = $agent['id_agente']; -+ $agents_aux[$agent['id_agente']] = $agent; - } -+ $agents = $agents_aux; -+ $agents_aux = null; - $fields = array('id_agente_modulo', 'id_agente', 'id_module_group', 'nombre'); - - $module_groups = modules_get_modulegroups(); -- $modules = agents_get_modules($agents_id, $fields); -+ $module_groups[0] = __('Not assigned'); -+ $modules = agents_get_modules(array_keys($agents), '*'); - -+ $data_agents = array(); - if (!empty($modules)) { -- -+ foreach ($modules as $key => $module) { -+ $module_id = (int) $module['id_agente_modulo']; -+ $agent_id = (int) $module['id_agente']; -+ $module_group_id = (int) $module['id_module_group']; -+ $module_name = $module['nombre']; -+ $module_status = modules_get_agentmodule_status($module_id); -+ -+ if (!isset($data_agents[$agent_id])) { -+ $data_agents[$agent_id] = array(); -+ $data_agents[$agent_id]['id'] = $agent_id; -+ $data_agents[$agent_id]['name'] = $agents[$agent_id]['nombre']; -+ $data_agents[$agent_id]['group'] = (int) $agents[$agent_id]['id_grupo']; -+ $data_agents[$agent_id]['type'] = 'agent'; -+ $data_agents[$agent_id]['size'] = 30; -+ $data_agents[$agent_id]['children'] = array(); -+ -+ $tooltip_content = __('Agent') . ": <b>" . $data_agents[$agent_id]['name'] . "</b>"; -+ $data_agents[$agent_id]['tooltip_content'] = $tooltip_content; -+ -+ $data_agents[$agent_id]['modules_critical'] = 0; -+ $data_agents[$agent_id]['modules_warning'] = 0; -+ $data_agents[$agent_id]['modules_normal'] = 0; -+ $data_agents[$agent_id]['modules_not_init'] = 0; -+ $data_agents[$agent_id]['modules_not_normal'] = 0; -+ $data_agents[$agent_id]['modules_unknown'] = 0; -+ -+ $data_agents[$agent_id]['color'] = COL_UNKNOWN; -+ -+ unset($agents[$agent_id]); -+ } -+ if (!isset($data_agents[$agent_id]['children'][$module_group_id])) { -+ $data_agents[$agent_id]['children'][$module_group_id] = array(); -+ $data_agents[$agent_id]['children'][$module_group_id]['id'] = $module_group_id; -+ $data_agents[$agent_id]['children'][$module_group_id]['name'] = $module_groups[$module_group_id]; -+ $data_agents[$agent_id]['children'][$module_group_id]['type'] = 'module_group'; -+ $data_agents[$agent_id]['children'][$module_group_id]['size'] = 10; -+ $data_agents[$agent_id]['children'][$module_group_id]['children'] = array(); -+ -+ $tooltip_content = __('Module group') . ": <b>" . $module_groups[$module_group_id] . "</b>"; -+ $data_agents[$agent_id]['children'][$module_group_id]['tooltip_content'] = $tooltip_content; -+ -+ $data_agents[$agent_id]['children'][$module_group_id]['modules_critical'] = 0; -+ $data_agents[$agent_id]['children'][$module_group_id]['modules_warning'] = 0; -+ $data_agents[$agent_id]['children'][$module_group_id]['modules_normal'] = 0; -+ $data_agents[$agent_id]['children'][$module_group_id]['modules_not_init'] = 0; -+ $data_agents[$agent_id]['children'][$module_group_id]['modules_not_normal'] = 0; -+ $data_agents[$agent_id]['children'][$module_group_id]['modules_unknown'] = 0; -+ -+ $data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_UNKNOWN; -+ } -+ -+ switch ($module_status) { -+ case AGENT_MODULE_STATUS_CRITICAL_BAD: -+ case AGENT_MODULE_STATUS_CRITICAL_ALERT: -+ $data_agents[$agent_id]['modules_critical']++; -+ $data_agents[$agent_id]['children'][$module_group_id]['modules_critical']++; -+ break; -+ -+ case AGENT_MODULE_STATUS_WARNING: -+ case AGENT_MODULE_STATUS_WARNING_ALERT: -+ $data_agents[$agent_id]['modules_warning']++; -+ $data_agents[$agent_id]['children'][$module_group_id]['modules_warning']++; -+ break; -+ -+ case AGENT_MODULE_STATUS_NORMAL: -+ case AGENT_MODULE_STATUS_NORMAL_ALERT: -+ $data_agents[$agent_id]['modules_normal']++; -+ $data_agents[$agent_id]['children'][$module_group_id]['modules_normal']++; -+ break; -+ -+ case AGENT_MODULE_STATUS_NOT_INIT: -+ $data_agents[$agent_id]['modules_not_init']++; -+ $data_agents[$agent_id]['children'][$module_group_id]['modules_not_init']++; -+ break; -+ -+ case AGENT_MODULE_STATUS_NOT_NORMAL: -+ $data_agents[$agent_id]['modules_not_normal']++; -+ $data_agents[$agent_id]['children'][$module_group_id]['modules_not_normal']++; -+ break; -+ -+ case AGENT_MODULE_STATUS_NO_DATA: -+ case AGENT_MODULE_STATUS_UNKNOWN: -+ $data_agents[$agent_id]['modules_unknown']++; -+ $data_agents[$agent_id]['children'][$module_group_id]['modules_unknown']++; -+ break; -+ } -+ -+ if ($data_agents[$agent_id]['modules_critical'] > 0) { -+ $data_agents[$agent_id]['color'] = COL_CRITICAL; -+ } -+ else if ($data_agents[$agent_id]['modules_warning'] > 0) { -+ $data_agents[$agent_id]['color'] = COL_WARNING; -+ } -+ else if ($data_agents[$agent_id]['modules_not_normal'] > 0) { -+ $data_agents[$agent_id]['color'] = COL_WARNING; -+ } -+ else if ($data_agents[$agent_id]['modules_unknown'] > 0) { -+ $data_agents[$agent_id]['color'] = COL_UNKNOWN; -+ } -+ else if ($data_agents[$agent_id]['modules_normal'] > 0) { -+ $data_agents[$agent_id]['color'] = COL_NORMAL; -+ } -+ else { -+ $data_agents[$agent_id]['color'] = COL_NOTINIT; -+ } -+ -+ if ($data_agents[$agent_id]['children'][$module_group_id]['modules_critical'] > 0) { -+ $data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_CRITICAL; -+ } -+ else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_warning'] > 0) { -+ $data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_WARNING; -+ } -+ else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_not_normal'] > 0) { -+ $data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_WARNING; -+ } -+ else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_unknown'] > 0) { -+ $data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_UNKNOWN; -+ } -+ else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_normal'] > 0) { -+ $data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_NORMAL; -+ } -+ else { -+ $data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_NOTINIT; -+ } -+ -+ $data_module = array(); -+ $data_module['id'] = $module_id; -+ $data_module['name'] = $module_name; -+ $data_module['type'] = 'module'; -+ $data_module['size'] = 10; -+ -+ $tooltip_content = __('Module') . ": <b>" . $module_name . "</b>"; -+ $data_module['tooltip_content'] = $tooltip_content; -+ -+ switch ($module_status) { -+ case AGENT_MODULE_STATUS_CRITICAL_BAD: -+ case AGENT_MODULE_STATUS_CRITICAL_ALERT: -+ $data_module['color'] = COL_CRITICAL; -+ break; -+ -+ case AGENT_MODULE_STATUS_WARNING: -+ case AGENT_MODULE_STATUS_WARNING_ALERT: -+ $data_module['color'] = COL_WARNING; -+ break; -+ -+ case AGENT_MODULE_STATUS_NORMAL: -+ case AGENT_MODULE_STATUS_NORMAL_ALERT: -+ $data_module['color'] = COL_NORMAL; -+ break; -+ -+ case AGENT_MODULE_STATUS_NOT_INIT: -+ $data_module['color'] = COL_NOTINIT; -+ break; -+ -+ case AGENT_MODULE_STATUS_NOT_NORMAL: -+ $data_module['color'] = COL_WARNING; -+ break; -+ -+ case AGENT_MODULE_STATUS_NO_DATA: -+ case AGENT_MODULE_STATUS_UNKNOWN: -+ default: -+ $data_module['color'] = COL_UNKNOWN; -+ break; -+ } -+ -+ $data_agents[$agent_id]['children'][$module_group_id]['children'][] = $data_module; -+ -+ unset($modules[$module_id]); -+ } - } -+ foreach ($agents as $id => $agent) { -+ if (!isset($data_agents[$id])) { -+ $data_agents[$id] = array(); -+ $data_agents[$id]['id'] = (int) $id; -+ $data_agents[$id]['name'] = $agent['nombre']; -+ $data_agents[$id]['type'] = 'agent'; -+ $data_agents[$id]['color'] = COL_NOTINIT; -+ } -+ } -+ $agents = null; - } - } - -+ function iterate_group_array ($groups, &$data_agents) { -+ -+ $data = array(); - -- if (empty ($data)) { -- return fs_error_image (); -+ foreach ($groups as $id => $group) { -+ -+ $group_aux = array(); -+ $group_aux['id'] = (int) $id; -+ $group_aux['name'] = $group['nombre']; -+ $group_aux['parent'] = (int) $group['parent']; -+ $group_aux['type'] = 'group'; -+ $group_aux['size'] = 100; -+ $group_aux['status'] = groups_get_status($id); -+ -+ switch ($group_aux['status']) { -+ case AGENT_STATUS_CRITICAL: -+ $group_aux['color'] = COL_CRITICAL; -+ break; -+ -+ case AGENT_STATUS_WARNING: -+ case AGENT_STATUS_ALERT_FIRED: -+ $group_aux['color'] = COL_WARNING; -+ break; -+ -+ case AGENT_STATUS_NORMAL: -+ $group_aux['color'] = COL_NORMAL; -+ break; -+ -+ case AGENT_STATUS_UNKNOWN: -+ default: -+ $group_aux['color'] = COL_UNKNOWN; -+ break; -+ } -+ -+ $tooltip_content = html_print_image("images/groups_small/" . $group['icon'] . ".png", true) . " " . __('Group') . ": <b>" . $group_aux['name'] . "</b>"; -+ $group_aux['tooltip_content'] = $tooltip_content; -+ -+ if (!isset($group['children'])) -+ $group_aux['children'] = array(); -+ if (!empty($group['children'])) -+ $group_aux['children'] = iterate_group_array($group['children']); -+ -+ $agents = extract_agents_with_group_id($data_agents, (int) $id); -+ -+ if (!empty($agents)) -+ $group_aux['children'] = array_merge($group_aux['children'], $agents); -+ -+ $data[] = $group_aux; -+ } -+ -+ return $data; - } - -+ function extract_agents_with_group_id (&$agents, $group_id) { -+ $valid_agents = array(); -+ foreach ($agents as $id => $agent) { -+ if (isset($agent['group']) && $agent['group'] == $group_id) { -+ $valid_agents[$id] = $agent; -+ unset($agents[$id]); -+ } -+ } -+ if (!empty($valid_agents)) -+ return $valid_agents; -+ else -+ return false; -+ } -+ -+ $graph_data = array('name' => __('Main node'), 'children' => iterate_group_array($data_groups, $data_agents)); -+ -+ if (empty($graph_data['children'])) -+ return fs_error_image(); -+ - include_once($config['homedir'] . "/include/graphs/functions_d3.php"); - -- return d3_tree_map_graph ($data, $width, $height, true); -+ return d3_sunburst_graph ($graph_data, $width, $height, true); - } - - ?> -Index: include/functions_events.php -=================================================================== ---- include/functions_events.php (revision 10314) -+++ include/functions_events.php (working copy) -@@ -162,7 +162,16 @@ - (SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp - FROM $table te - WHERE 1=1 " . $sql_post . " -- GROUP BY estado, evento, id_agentmodule, id_evento, id_agente, id_usuario, id_grupo, estado, timestamp, utimestamp, event_type, id_alert_am, criticity, user_comment, tags, source, id_extra" . $groupby_extra . " -+ GROUP BY estado, evento, id_agentmodule, id_evento, -+ id_agente, id_usuario, id_grupo, estado, -+ timestamp, utimestamp, event_type, id_alert_am, -+ criticity, user_comment, tags, source, id_extra, -+ te.critical_instructions, -+ te.warning_instructions, -+ te.unknown_instructions, -+ te.owner_user, -+ te.ack_utimestamp, -+ te.custom_data " . $groupby_extra . " - ORDER BY timestamp_rep DESC LIMIT " . $pagination . " OFFSET " . $offset; - } - break; -@@ -582,7 +591,7 @@ - - $event_comments_array[] = $comment_for_json; - -- $event_comments = json_encode($event_comments_array); -+ $event_comments = io_json_mb_encode($event_comments_array); - - // Update comment - $ret = db_process_sql_update($event_table, array('user_comment' => $event_comments), array('id_evento' => implode(',', $id_event))); -@@ -2244,6 +2253,7 @@ - $table_comments->class = "alternate rounded_cells"; - - $event_comments = io_safe_output($event["user_comment"]); -+ $event_comments = str_replace("\n", "<br>", $event_comments); - - // If comments are not stored in json, the format is old - $event_comments_array = json_decode($event_comments, true); -Index: include/graphs/functions_flot.php -=================================================================== ---- include/graphs/functions_flot.php (revision 10314) -+++ include/graphs/functions_flot.php (working copy) -@@ -442,6 +442,7 @@ - - $max = 0; - $i = count($graph_data); -+ $data = array(); - foreach ($graph_data as $label => $values) { - $labels[] = io_safe_output($label); - $i--; -Index: include/graphs/pandora.d3.js -=================================================================== ---- include/graphs/pandora.d3.js (revision 10314) -+++ include/graphs/pandora.d3.js (working copy) -@@ -715,8 +715,11 @@ - .data(partition.nodes(data)) - .enter().append("path") - .attr("d", arc) -- .style("fill", function(d) { return color((d.children ? d : d.parent).name); }) -- .on("click", click); -+ .style("fill", function(d) { return d.color ? d3.rgb(d.color) : color((d.children ? d : d.parent).name); }) -+ .on("click", click) -+ .on("mouseover", over_user) -+ .on("mouseout", out_user) -+ .on("mousemove", move_tooltip); - - function click(d) { - path.transition() -@@ -737,4 +740,68 @@ - : function(t) { x.domain(xd(t)); y.domain(yd(t)).range(yr(t)); return arc(d); }; - }; - } -+ -+ function move_tooltip(d) { -+ var x = d3.event.pageX + 10; -+ var y = d3.event.pageY + 10; -+ -+ $("#tooltip").css('left', x + 'px'); -+ $("#tooltip").css('top', y + 'px'); -+ } -+ -+ function over_user(d) { -+ id = d.id; -+ -+ $("#" + id).css('border', '1px solid black'); -+ $("#" + id).css('z-index', '1'); -+ -+ show_tooltip(d); -+ } -+ -+ function out_user(d) { -+ id = d.id; -+ -+ $("#" + id).css('border', ''); -+ $("#" + id).css('z-index', ''); -+ -+ hide_tooltip(); -+ } -+ -+ function create_tooltip(d, x, y) { -+ var tooltip = (typeof d.tooltip_content != 'undefined') ? d.tooltip_content : d.name; -+ -+ if ($("#tooltip").length == 0) { -+ $(recipient) -+ .append($("<div></div>") -+ .attr('id', 'tooltip') -+ .html(tooltip)); -+ } -+ else { -+ $("#tooltip").html(tooltip); -+ } -+ -+ $("#tooltip").attr('style', 'background: #fff;' + -+ 'position: absolute;' + -+ 'display: block;' + -+ 'width: 200px;' + -+ 'text-align: left;' + -+ 'padding: 10px 10px 10px 10px;' + -+ 'z-index: 2;' + -+ "-webkit-box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75);" + -+ "-moz-box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75);" + -+ "box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75);" + -+ 'left: ' + x + 'px;' + -+ 'top: ' + y + 'px;'); -+ } -+ -+ function show_tooltip(d) { -+ var x = d3.event.pageX + 10; -+ var y = d3.event.pageY + 10; -+ -+ create_tooltip(d, x, y); -+ } -+ -+ function hide_tooltip() { -+ $("#tooltip").hide(); -+ } - } -\ No newline at end of file -Index: include/graphs/fgraph.php -=================================================================== ---- include/graphs/fgraph.php (revision 10314) -+++ include/graphs/fgraph.php (working copy) -@@ -398,11 +398,13 @@ - setup_watermark($water_mark, $water_mark_file, $water_mark_url); - - if ($flash_chart) { -- if ($return){ -- return flot_hcolumn_chart ($chart_data, $width, $height, $water_mark_url); -+ if ($return) { -+ return flot_hcolumn_chart( -+ $chart_data, $width, $height, $water_mark_url); - } -- else{ -- echo flot_hcolumn_chart ($chart_data, $width, $height, $water_mark_url); -+ else { -+ echo flot_hcolumn_chart( -+ $chart_data, $width, $height, $water_mark_url); - } - } - else { -@@ -422,7 +424,7 @@ - - $id_graph = serialize_in_temp($graph, null, $ttl); - -- return "<img src='".$homedir."include/graphs/functions_pchart.php?static_graph=1&graph_type=hbar&ttl=".$ttl."&id_graph=".$id_graph."'>"; -+ return "<img src='" . $homedir . "include/graphs/functions_pchart.php?static_graph=1&graph_type=hbar&ttl=".$ttl."&id_graph=".$id_graph."'>"; - } - } - -Index: include/db/postgresql.php -=================================================================== ---- include/db/postgresql.php (revision 10314) -+++ include/db/postgresql.php (working copy) -@@ -332,6 +332,9 @@ - else if (is_float ($value) || is_double ($value)) { - $values_str .= sprintf("%f", $value); - } -+ elseif (is_string($value) && (strtoupper($value) === 'NULL')) { -+ $values_str .= "NULL"; -+ } - else { - $values_str .= sprintf("'%s'", $value); - } -@@ -346,6 +349,8 @@ - - $query .= ' VALUES (' . $values_str . ')'; - -+ //html_debug_print($query); -+ - return db_process_sql($query, 'insert_id'); - } - -@@ -362,6 +367,18 @@ - return $str; - } - -+function postgresql_encapsule_fields_with_same_name_to_instructions($field) { -+ $return = $field; -+ -+ if (is_string($return)) { -+ if ($return[0] !== '"') { -+ $return = '"' . $return . '"'; -+ } -+ } -+ -+ return $return; -+} -+ - /** - * Get the first value of the first row of a table in the database from an - * array with filter conditions. -Index: include/db/mysql.php -=================================================================== ---- include/db/mysql.php (revision 10314) -+++ include/db/mysql.php (working copy) -@@ -346,6 +346,18 @@ - return $str; - } - -+function mysql_encapsule_fields_with_same_name_to_instructions($field) { -+ $return = $field; -+ -+ if (is_string($return)) { -+ if ($return[0] !== '`') { -+ $return = '`' . $return . '`'; -+ } -+ } -+ -+ return $return; -+} -+ - /** - * Get the first value of the first row of a table in the database from an - * array with filter conditions. -Index: include/db/oracle.php -=================================================================== ---- include/db/oracle.php (revision 10314) -+++ include/db/oracle.php (working copy) -@@ -254,7 +254,7 @@ - else if ($type[0] == '/INSERT'){ - $query = oci_parse($config['dbconnection'], substr($sql,1)); - } -- else{ -+ else { - $query = oci_parse($config['dbconnection'], $sql); - } - } -@@ -448,6 +448,18 @@ - return str_replace(array('"', "'", '\\'), array('\\"', '\\\'', '\\\\'), $string); - } - -+function oracle_encapsule_fields_with_same_name_to_instructions($field) { -+ $return = $field; -+ -+ if (is_string($return)) { -+ if ($return[0] !== '"') { -+ $return = '"' . $return . '"'; -+ } -+ } -+ -+ return $return; -+} -+ - /** - * Get the first value of the first row of a table in the database from an - * array with filter conditions. -@@ -649,7 +661,7 @@ - else if ($value[0] == '%') { - $query .= sprintf ("%s LIKE '%s'", $field, $value); - } -- else{ -+ else { - $query .= sprintf ("%s = '%s'", $field, $value); - } - } -@@ -997,16 +1009,16 @@ - global $config; - - $type = explode(' ',strtoupper(trim($sql))); -- if ($type[0] == 'SELECT'){ -+ if ($type[0] == 'SELECT') { - $sql = "SELECT count(*) as NUM FROM (" . $sql . ")"; - } - $query = oci_parse($config['dbconnection'], $sql); - oci_execute($query); -- if ($type[0] == 'SELECT'){ -+ if ($type[0] == 'SELECT') { - $row = oci_fetch_assoc($query); - $rows = $row['NUM']; - } -- else{ -+ else { - $rows = oci_num_rows($query); - } - -@@ -1027,13 +1039,19 @@ - */ - function oracle_db_get_all_rows_field_filter ($table, $field, $condition, $order_field = "") { - if (is_int ($condition) || is_bool ($condition)) { -- $sql = sprintf ("SELECT * FROM %s WHERE %s = %d", $table, $field, $condition); -+ $sql = sprintf ("SELECT * -+ FROM %s -+ WHERE %s = %d", $table, $field, $condition); - } - else if (is_float ($condition) || is_double ($condition)) { -- $sql = sprintf ("SELECT * FROM %s WHERE %s = %f", $table, $field, $condition); -+ $sql = sprintf ("SELECT * -+ FROM %s -+ WHERE %s = %f", $table, $field, $condition); - } - else { -- $sql = sprintf ("SELECT * FROM %s WHERE %s = '%s'", $table, $field, $condition); -+ $sql = sprintf ("SELECT * -+ FROM %s -+ WHERE %s = '%s'", $table, $field, $condition); - } - - if ($order_field != "") -Index: include/functions_modules.php -=================================================================== ---- include/functions_modules.php (revision 10314) -+++ include/functions_modules.php (working copy) -@@ -1663,15 +1663,15 @@ - $status = STATUS_AGENT_DOWN; - $last_status = modules_get_agentmodule_last_status($id_agent_module); - switch($last_status) { -- case 0: -+ case AGENT_STATUS_NORMAL: - $title = __('UNKNOWN') . " - " . __('Last status') . - " " . __('NORMAL'); - break; -- case 1: -+ case AGENT_STATUS_CRITICAL: - $title = __('UNKNOWN') . " - " . __('Last status') . - " " . __('CRITICAL'); - break; -- case 2: -+ case AGENT_STATUS_WARNING: - $title = __('UNKNOWN') . " - " . __('Last status') . - " " . __('WARNING'); - break; -Index: include/functions_reporting.php -=================================================================== ---- include/functions_reporting.php (revision 10314) -+++ include/functions_reporting.php (working copy) -@@ -907,6 +907,8 @@ - } - - function reporting_get_stats_servers($tiny = true) { -+ global $config; -+ - $server_performance = servers_get_performance(); - - // Alerts table -@@ -959,7 +961,9 @@ - $tdata[0] = html_print_image('images/network.png', true, array('title' => __('Network modules'), 'width' => '25px')); - $tdata[1] = '<span class="big_data">' . format_numeric($server_performance ["total_network_modules"]) . '</span>'; - -- $tdata[2] = '<span class="med_data">' . format_numeric($server_performance ["network_modules_rate"], 2) . '</span>'; -+ $tdata[2] = '<span class="med_data">' . -+ format_numeric($server_performance ["network_modules_rate"], 2) . -+ '</span>'; - $tdata[3] = html_print_image('images/module.png', true, array('title' => __('Ratio') . ': ' . __('Modules by second'), 'width' => '16px')) . '/sec </span>'; - - $table_srv->rowclass[] = ''; -@@ -1020,8 +1024,23 @@ - $table_srv->rowclass[] = ''; - $table_srv->data[] = $tdata; - -- $system_events = db_get_value_sql('SELECT SQL_NO_CACHE COUNT(id_evento) FROM tevento'); -- -+ -+ switch ($config["dbtype"]) { -+ case "mysql": -+ $system_events = db_get_value_sql( -+ 'SELECT SQL_NO_CACHE COUNT(id_evento) -+ FROM tevento'); -+ break; -+ case "postgresql": -+ case "oracle": -+ $system_events = db_get_value_sql( -+ 'SELECT COUNT(id_evento) -+ FROM tevento'); -+ break; -+ } -+ -+ -+ - $tdata = array(); - $tdata[0] = html_print_image('images/lightning_go.png', true, array('title' => __('Total events'), 'width' => '25px')); - $tdata[1] = '<span class="big_data">' . format_numeric($system_events) . '</span>'; -@@ -1109,16 +1128,21 @@ - $tdata = array(); - $table_mbs->colspan[count($table_mbs->data)][0] = 4; - $table_mbs->cellstyle[count($table_mbs->data)][0] = 'text-align: center;'; -- $tdata[0] = '<div id="outter_status_pie" style="height: ' . $graph_height . 'px"><div id="status_pie" style="margin: auto; width: ' . $graph_width . 'px;">' . graph_agent_status (false, $graph_width, $graph_height, true, true) . '</div></div>'; -+ $tdata[0] = '<div id="outter_status_pie" style="height: ' . $graph_height . 'px">' . -+ '<div id="status_pie" style="margin: auto; width: ' . $graph_width . 'px;">' . -+ graph_agent_status(false, $graph_width, $graph_height, true, true) . -+ '</div></div>'; - $table_mbs->rowclass[] = ''; - $table_mbs->data[] = $tdata; - } - -- $output = '<fieldset class="databox tactical_set"> -- <legend>' . -- __('Monitors by status') . -- '</legend>' . -- html_print_table($table_mbs, true) . '</fieldset>'; -+ $output = ' -+ <fieldset class="databox tactical_set"> -+ <legend>' . -+ __('Monitors by status') . -+ '</legend>' . -+ html_print_table($table_mbs, true) . -+ '</fieldset>'; - - return $output; - } -@@ -3123,9 +3147,29 @@ - } - else { - -- $data[0] = grafico_modulo_sparse($content['id_agent_module'], $content['period'], -- false, $sizgraph_w, $sizgraph_h, '', '', false, true, true, -- $report["datetime"], '', 0, 0, true, true, ui_get_full_url(false) . '/'); -+ $data[0] = grafico_modulo_sparse( -+ $content['id_agent_module'], -+ $content['period'], -+ false, -+ $sizgraph_w, -+ $sizgraph_h, -+ '', -+ '', -+ false, -+ true, -+ true, -+ $report["datetime"], -+ '', -+ 0, -+ 0, -+ true, -+ true, -+ ui_get_full_url(false) . '/', -+ 1, -+ false, -+ '', -+ false, -+ true); - } - - array_push ($table->data, $data); -Index: include/auth/ldap.php -=================================================================== ---- include/auth/ldap.php (revision 10314) -+++ include/auth/ldap.php (working copy) -@@ -65,8 +65,11 @@ - $config["admin_can_make_admin"] = false; - - //Required and optional keys for this function to work --$req_keys = array ("ldap_server", "ldap_base_dn", "ldap_login_attr", "ldap_admin_group_name", "ldap_admin_group_attr", "ldap_admin_group_type", "ldap_user_filter", "ldap_user_attr"); --$opt_keys = array ("ldap_port", "ldap_start_tls", "ldap_version", "ldap_admin_dn", "ldap_admin_pwd"); -+$req_keys = array("ldap_server", "ldap_base_dn", "ldap_login_attr", -+ "ldap_admin_group_name", "ldap_admin_group_attr", -+ "ldap_admin_group_type", "ldap_user_filter", "ldap_user_attr"); -+$opt_keys = array("ldap_port", "ldap_start_tls", "ldap_version", -+ "ldap_admin_dn", "ldap_admin_pwd"); - - global $ldap_cache; //Needs to be globalized because config_process_config () function calls this file first and the variable would be local and subsequently lost - $ldap_cache = array (); -@@ -76,13 +79,15 @@ - //Put each required key in a variable. - foreach ($req_keys as $key) { - if (!isset ($config["auth"][$key])) { -- user_error ("Required key ".$key." not set", E_USER_ERROR); -+ user_error("Required key " . $key . " not set", E_USER_ERROR); - } - } - - // Convert group name to lower case to prevent problems --$config["auth"]["ldap_admin_group_attr"] = strtolower ($config["auth"]["ldap_admin_group_attr"]); --$config["auth"]["ldap_admin_group_type"] = strtolower ($config["auth"]["ldap_admin_group_type"]); -+$config["auth"]["ldap_admin_group_attr"] = -+ strtolower ($config["auth"]["ldap_admin_group_attr"]); -+$config["auth"]["ldap_admin_group_type"] = -+ strtolower ($config["auth"]["ldap_admin_group_type"]); - - foreach ($opt_keys as $key) { - if (!isset ($config["auth"][$key])) { -@@ -122,7 +127,7 @@ - return false; - } - global $config; -- -+ - $profile = db_get_value ("id_usuario", "tusuario_perfil", "id_usuario", $login); - - if ($profile === false && empty ($config["auth"]["create_user_undefined"])) { -@@ -311,7 +316,8 @@ - - $nick = false; - if (ldap_connect_bind ()) { -- $sr = @ldap_search ($ldap_cache["ds"], $config["auth"]["ldap_base_dn"], "(&(".$config["auth"]["ldap_login_attr"]."=".$login.")".$config["auth"]["ldap_user_filter"].")", array_values ($config["auth"]["ldap_user_attr"])); -+ $sr = @ldap_search ($ldap_cache["ds"], -+ io_safe_output($config["auth"]["ldap_base_dn"]), "(&(".io_safe_output($config["auth"]["ldap_login_attr"])."=".$login.")".io_safe_output($config["auth"]["ldap_user_filter"]).")", array_values ($config["auth"]["ldap_user_attr"])); - - if (!$sr) { - $ldap_cache["error"] .= 'Error searching LDAP server: ' . ldap_error ($ldap_cache["ds"]); -@@ -364,7 +370,7 @@ - return $ret; - } - -- $r = @ldap_bind ($ds, $config["auth"]["ldap_login_attr"]."=".$login.",".$config["auth"]["ldap_base_dn"], $password); -+ $r = @ldap_bind ($ds, io_safe_output($config["auth"]["ldap_login_attr"])."=".$login.",".io_safe_output($config["auth"]["ldap_base_dn"]), $password); - if (!$r) { - $ldap_cache["error"] .= 'Invalid login'; - } -@@ -393,7 +399,8 @@ - $time = get_system_time (); - if (ldap_connect_bind ()) { - -- $sr = ldap_search ($ldap_cache["ds"], $config["auth"]["ldap_base_dn"], "(&(".$config["auth"]["ldap_login_attr"]."=".$login.")".$config["auth"]["ldap_user_filter"].")", array_values ($config["auth"]["ldap_user_attr"])); -+ $sr = ldap_search ($ldap_cache["ds"], -+ io_safe_output($config["auth"]["ldap_base_dn"]), "(&(".io_safe_output($config["auth"]["ldap_login_attr"])."=".$login.")".io_safe_output($config["auth"]["ldap_user_filter"]).")", array_values ($config["auth"]["ldap_user_attr"])); - - if (!$sr) { - $ldap_cache["error"] .= 'Error searching LDAP server (load_user): ' . ldap_error( $ldap_cache["ds"] ); -@@ -497,7 +504,7 @@ - $time = get_system_time (); - - if (ldap_connect_bind ()) { -- $sr = @ldap_search ($ldap_cache["ds"], $config["auth"]["ldap_base_dn"], $config["auth"]["ldap_user_filter"], array_values ($config["auth"]["ldap_user_attr"])); -+ $sr = @ldap_search ($ldap_cache["ds"], io_safe_output($config["auth"]["ldap_base_dn"]), io_safe_output($config["auth"]["ldap_user_filter"]), array_values ($config["auth"]["ldap_user_attr"])); - if (!$sr) { - $ldap_cache["error"] .= 'Error searching LDAP server (get_users): ' . ldap_error( $ldap_cache["ds"] ); - } -Index: include/auth/mysql.php -=================================================================== ---- include/auth/mysql.php (revision 10314) -+++ include/auth/mysql.php (working copy) -@@ -512,7 +512,11 @@ - } - } - -- if (strlen($password) == 0 || !@ldap_bind ($ds, $config["ldap_login_attr"]."=".$login.",".$config["ldap_base_dn"], $password)) { -+ if (strlen($password) == 0 || -+ !@ldap_bind($ds, -+ io_safe_output($config["ldap_login_attr"]) . "=" . $login . "," . io_safe_output($config["ldap_base_dn"]), -+ $password)) { -+ - $config["auth_error"] = 'User not found in database or incorrect password'; - @ldap_close ($ds); - -Index: include/functions_networkmap.php -=================================================================== ---- include/functions_networkmap.php (revision 10314) -+++ include/functions_networkmap.php (working copy) -@@ -233,7 +233,8 @@ - $simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0, - $zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0, - $id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true, -- $relative = false, $text_filter = '', $l2_network = false, $ip_mask = null) { -+ $relative = false, $text_filter = '', $l2_network = false, $ip_mask = null, -+ $dont_show_subgroups = false) { - - global $config; - -@@ -262,7 +263,20 @@ - } - - if ($group >= 1) { -- $filter['id_grupo'] = $group; -+ if ($dont_show_subgroups) -+ $filter['id_grupo'] = $group; -+ else { -+ $childrens = groups_get_childrens($group, null, true); -+ if (!empty($childrens)) { -+ $childrens = array_keys($childrens); -+ -+ $filter['id_grupo'] = $childrens; -+ $filter['id_grupo'][] = $group; -+ } -+ else { -+ $filter['id_grupo'] = $group; -+ } -+ } - - //Order by id_parent ascendant for to avoid the bugs - //because the first agents to process in the next -@@ -589,7 +603,13 @@ - } - - // Generate a dot graph definition for graphviz with groups --function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0, $zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0, $modwithalerts = 0, $module_group = 0, $hidepolicymodules = 0, $depth = 'all', $id_networkmap = 0, $dont_show_subgroups = 0, $text_filter = '') { -+function networkmap_generate_dot_groups ($pandora_name, $group = 0, -+ $simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0, -+ $zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0, -+ $modwithalerts = 0, $module_group = 0, $hidepolicymodules = 0, -+ $depth = 'all', $id_networkmap = 0, $dont_show_subgroups = 0, -+ $text_filter = '') { -+ - global $config; - - $parents = array(); -@@ -682,7 +702,8 @@ - // Get agents data - $agents = agents_get_agents ($filter, - array ('id_grupo, nombre, id_os, id_agente, -- normal_count, warning_count, critical_count, unknown_count, total_count, notinit_count')); -+ normal_count, warning_count, critical_count, -+ unknown_count, total_count, notinit_count')); - - if ($agents === false) - $agents = array(); -@@ -1427,7 +1448,9 @@ - $values['show_groups'] = $show_groups; - $values['show_modules'] = $show_modules; - -- return @db_process_sql_insert ('tnetwork_map', $values); -+ $values['server_name'] = ""; -+ -+ return @db_process_sql_insert('tnetwork_map', $values); - } - - /** -Index: include/javascript/introjs.css -=================================================================== ---- include/javascript/introjs.css (revision 0) -+++ include/javascript/introjs.css (revision 10417) -@@ -0,0 +1,276 @@ -+.introjs-overlay { -+ position: absolute; -+ z-index: 999999; -+ background-color: #000; -+ opacity: 0; -+ background: -moz-radial-gradient(center,ellipse cover,rgba(0,0,0,0.4) 0,rgba(0,0,0,0.9) 100%); -+ background: -webkit-gradient(radial,center center,0px,center center,100%,color-stop(0%,rgba(0,0,0,0.4)),color-stop(100%,rgba(0,0,0,0.9))); -+ background: -webkit-radial-gradient(center,ellipse cover,rgba(0,0,0,0.4) 0,rgba(0,0,0,0.9) 100%); -+ background: -o-radial-gradient(center,ellipse cover,rgba(0,0,0,0.4) 0,rgba(0,0,0,0.9) 100%); -+ background: -ms-radial-gradient(center,ellipse cover,rgba(0,0,0,0.4) 0,rgba(0,0,0,0.9) 100%); -+ background: radial-gradient(center,ellipse cover,rgba(0,0,0,0.4) 0,rgba(0,0,0,0.9) 100%); -+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#66000000',endColorstr='#e6000000',GradientType=1); -+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; -+ filter: alpha(opacity=50); -+ -webkit-transition: all 0.3s ease-out; -+ -moz-transition: all 0.3s ease-out; -+ -ms-transition: all 0.3s ease-out; -+ -o-transition: all 0.3s ease-out; -+ transition: all 0.3s ease-out; -+} -+ -+.introjs-fixParent { -+ z-index: auto !important; -+ opacity: 1.0 !important; -+} -+ -+.introjs-showElement, -+tr.introjs-showElement > td, -+tr.introjs-showElement > th { -+ z-index: 9999999 !important; -+} -+ -+.introjs-relativePosition, -+tr.introjs-showElement > td, -+tr.introjs-showElement > th { -+ position: relative; -+} -+ -+.introjs-helperLayer { -+ position: absolute; -+ z-index: 9999998; -+ background-color: #FFF; -+ background-color: rgba(255,255,255,.9); -+ border: 1px solid #777; -+ border: 1px solid rgba(0,0,0,.5); -+ border-radius: 4px; -+ box-shadow: 0 2px 15px rgba(0,0,0,.4); -+ -webkit-transition: all 0.3s ease-out; -+ -moz-transition: all 0.3s ease-out; -+ -ms-transition: all 0.3s ease-out; -+ -o-transition: all 0.3s ease-out; -+ transition: all 0.3s ease-out; -+} -+ -+.introjs-helperNumberLayer { -+ position: absolute; -+ top: -16px; -+ left: -16px; -+ z-index: 9999999999 !important; -+ padding: 2px; -+ font-family: Arial, verdana, tahoma; -+ font-size: 13px; -+ font-weight: bold; -+ color: white; -+ text-align: center; -+ text-shadow: 1px 1px 1px rgba(0,0,0,.3); -+ background: #ff3019; /* Old browsers */ -+ background: -webkit-linear-gradient(top, #ff3019 0%, #cf0404 100%); /* Chrome10+,Safari5.1+ */ -+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ff3019), color-stop(100%, #cf0404)); /* Chrome,Safari4+ */ -+ background: -moz-linear-gradient(top, #ff3019 0%, #cf0404 100%); /* FF3.6+ */ -+ background: -ms-linear-gradient(top, #ff3019 0%, #cf0404 100%); /* IE10+ */ -+ background: -o-linear-gradient(top, #ff3019 0%, #cf0404 100%); /* Opera 11.10+ */ -+ background: linear-gradient(to bottom, #ff3019 0%, #cf0404 100%); /* W3C */ -+ width: 20px; -+ height:20px; -+ line-height: 20px; -+ border: 3px solid white; -+ border-radius: 50%; -+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3019', endColorstr='#cf0404', GradientType=0); /* IE6-9 */ -+ filter: progid:DXImageTransform.Microsoft.Shadow(direction=135, strength=2, color=ff0000); /* IE10 text shadows */ -+ box-shadow: 0 2px 5px rgba(0,0,0,.4); -+} -+ -+.introjs-arrow { -+ border: 5px solid white; -+ content:''; -+ position: absolute; -+} -+.introjs-arrow.top { -+ top: -10px; -+ border-top-color:transparent; -+ border-right-color:transparent; -+ border-bottom-color:white; -+ border-left-color:transparent; -+} -+.introjs-arrow.top-right { -+ top: -10px; -+ right: 10px; -+ border-top-color:transparent; -+ border-right-color:transparent; -+ border-bottom-color:white; -+ border-left-color:transparent; -+} -+.introjs-arrow.top-middle { -+ top: -10px; -+ left: 50%; -+ margin-left: -5px; -+ border-top-color:transparent; -+ border-right-color:transparent; -+ border-bottom-color:white; -+ border-left-color:transparent; -+} -+.introjs-arrow.right { -+ right: -10px; -+ top: 10px; -+ border-top-color:transparent; -+ border-right-color:transparent; -+ border-bottom-color:transparent; -+ border-left-color:white; -+} -+.introjs-arrow.bottom { -+ bottom: -10px; -+ border-top-color:white; -+ border-right-color:transparent; -+ border-bottom-color:transparent; -+ border-left-color:transparent; -+} -+.introjs-arrow.left { -+ left: -10px; -+ top: 10px; -+ border-top-color:transparent; -+ border-right-color:white; -+ border-bottom-color:transparent; -+ border-left-color:transparent; -+} -+ -+.introjs-tooltip { -+ position: absolute; -+ padding: 10px; -+ background-color: white; -+ min-width: 200px; -+ max-width: 300px; -+ border-radius: 3px; -+ box-shadow: 0 1px 10px rgba(0,0,0,.4); -+ -webkit-transition: opacity 0.1s ease-out; -+ -moz-transition: opacity 0.1s ease-out; -+ -ms-transition: opacity 0.1s ease-out; -+ -o-transition: opacity 0.1s ease-out; -+ transition: opacity 0.1s ease-out; -+} -+ -+.introjs-tooltipbuttons { -+ text-align: right; -+} -+ -+/* -+ Buttons style by http://nicolasgallagher.com/lab/css3-github-buttons/ -+ Changed by Afshin Mehrabani -+*/ -+.introjs-button { -+ position: relative; -+ overflow: visible; -+ display: inline-block; -+ padding: 0.3em 0.8em; -+ border: 1px solid #d4d4d4; -+ margin: 0; -+ text-decoration: none; -+ text-shadow: 1px 1px 0 #fff; -+ font: 11px/normal sans-serif; -+ color: #333; -+ white-space: nowrap; -+ cursor: pointer; -+ outline: none; -+ background-color: #ececec; -+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f4f4f4), to(#ececec)); -+ background-image: -moz-linear-gradient(#f4f4f4, #ececec); -+ background-image: -o-linear-gradient(#f4f4f4, #ececec); -+ background-image: linear-gradient(#f4f4f4, #ececec); -+ -webkit-background-clip: padding; -+ -moz-background-clip: padding; -+ -o-background-clip: padding-box; -+ /*background-clip: padding-box;*/ /* commented out due to Opera 11.10 bug */ -+ -webkit-border-radius: 0.2em; -+ -moz-border-radius: 0.2em; -+ border-radius: 0.2em; -+ /* IE hacks */ -+ zoom: 1; -+ *display: inline; -+ margin-top: 10px; -+} -+ -+.introjs-button:hover { -+ border-color: #bcbcbc; -+ text-decoration: none; -+ box-shadow: 0px 1px 1px #e3e3e3; -+} -+ -+.introjs-button:focus, -+.introjs-button:active { -+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ececec), to(#f4f4f4)); -+ background-image: -moz-linear-gradient(#ececec, #f4f4f4); -+ background-image: -o-linear-gradient(#ececec, #f4f4f4); -+ background-image: linear-gradient(#ececec, #f4f4f4); -+} -+ -+/* overrides extra padding on button elements in Firefox */ -+.introjs-button::-moz-focus-inner { -+ padding: 0; -+ border: 0; -+} -+ -+.introjs-skipbutton { -+ margin-right: 5px; -+ color: #7a7a7a; -+} -+ -+.introjs-prevbutton { -+ -webkit-border-radius: 0.2em 0 0 0.2em; -+ -moz-border-radius: 0.2em 0 0 0.2em; -+ border-radius: 0.2em 0 0 0.2em; -+ border-right: none; -+} -+ -+.introjs-nextbutton { -+ -webkit-border-radius: 0 0.2em 0.2em 0; -+ -moz-border-radius: 0 0.2em 0.2em 0; -+ border-radius: 0 0.2em 0.2em 0; -+} -+ -+.introjs-disabled, .introjs-disabled:hover, .introjs-disabled:focus { -+ color: #9a9a9a; -+ border-color: #d4d4d4; -+ box-shadow: none; -+ cursor: default; -+ background-color: #f4f4f4; -+ background-image: none; -+ text-decoration: none; -+} -+ -+.introjs-bullets { -+ text-align: center; -+} -+.introjs-bullets ul { -+ clear: both; -+ margin: 15px auto 0; -+ padding: 0; -+ display: inline-block; -+} -+.introjs-bullets ul li { -+ list-style: none; -+ float: left; -+ margin: 0 2px; -+} -+.introjs-bullets ul li a { -+ display: block; -+ width: 6px; -+ height: 6px; -+ background: #ccc; -+ border-radius: 10px; -+ -moz-border-radius: 10px; -+ -webkit-border-radius: 10px; -+ text-decoration: none; -+} -+.introjs-bullets ul li a:hover { -+ background: #999; -+} -+.introjs-bullets ul li a.active { -+ background: #999; -+} -+.introjsFloatingElement { -+ position: absolute; -+ height: 0; -+ width: 0; -+ left: 50%; -+ top: 50%; -+} -Index: include/javascript/intro.js -=================================================================== ---- include/javascript/intro.js (revision 0) -+++ include/javascript/intro.js (revision 10417) -@@ -0,0 +1,1049 @@ -+/** -+ * Intro.js v0.9.0 -+ * https://github.com/usablica/intro.js -+ * MIT licensed -+ * -+ * Copyright (C) 2013 usabli.ca - A weekend project by Afshin Mehrabani (@afshinmeh) -+ */ -+ -+(function (root, factory) { -+ if (typeof exports === 'object') { -+ // CommonJS -+ factory(exports); -+ } else if (typeof define === 'function' && define.amd) { -+ // AMD. Register as an anonymous module. -+ define(['exports'], factory); -+ } else { -+ // Browser globals -+ factory(root); -+ } -+} (this, function (exports) { -+ //Default config/variables -+ var VERSION = '0.9.0'; -+ -+ /** -+ * IntroJs main class -+ * -+ * @class IntroJs -+ */ -+ function IntroJs(obj) { -+ this._targetElement = obj; -+ -+ this._options = { -+ /* Next button label in tooltip box */ -+ nextLabel: 'Next →', -+ /* Previous button label in tooltip box */ -+ prevLabel: '← Back', -+ /* Skip button label in tooltip box */ -+ skipLabel: 'Skip', -+ /* Done button label in tooltip box */ -+ doneLabel: 'Done', -+ /* Default tooltip box position */ -+ tooltipPosition: 'bottom', -+ /* Next CSS class for tooltip boxes */ -+ tooltipClass: '', -+ /* Close introduction when pressing Escape button? */ -+ exitOnEsc: true, -+ /* Close introduction when clicking on overlay layer? */ -+ exitOnOverlayClick: true, -+ /* Show step numbers in introduction? */ -+ showStepNumbers: true, -+ /* Let user use keyboard to navigate the tour? */ -+ keyboardNavigation: true, -+ /* Show tour control buttons? */ -+ showButtons: true, -+ /* Show tour bullets? */ -+ showBullets: true, -+ /* Scroll to highlighted element? */ -+ scrollToElement: true, -+ /* Set the overlay opacity */ -+ overlayOpacity: 0.8 -+ }; -+ } -+ -+ /** -+ * Initiate a new introduction/guide from an element in the page -+ * -+ * @api private -+ * @method _introForElement -+ * @param {Object} targetElm -+ * @returns {Boolean} Success or not? -+ */ -+ function _introForElement(targetElm) { -+ var introItems = [], -+ self = this; -+ -+ if (this._options.steps) { -+ //use steps passed programmatically -+ var allIntroSteps = []; -+ -+ for (var i = 0, stepsLength = this._options.steps.length; i < stepsLength; i++) { -+ var currentItem = _cloneObject(this._options.steps[i]); -+ //set the step -+ currentItem.step = introItems.length + 1; -+ //use querySelector function only when developer used CSS selector -+ if (typeof(currentItem.element) === 'string') { -+ //grab the element with given selector from the page -+ currentItem.element = document.querySelector(currentItem.element); -+ } -+ -+ //intro without element -+ if (typeof(currentItem.element) === 'undefined' || currentItem.element == null) { -+ var floatingElementQuery = document.querySelector(".introjsFloatingElement"); -+ -+ if (floatingElementQuery == null) { -+ floatingElementQuery = document.createElement('div'); -+ floatingElementQuery.className = 'introjsFloatingElement'; -+ -+ document.body.appendChild(floatingElementQuery); -+ } -+ -+ currentItem.element = floatingElementQuery; -+ currentItem.position = 'floating'; -+ } -+ -+ if (currentItem.element != null) { -+ introItems.push(currentItem); -+ } -+ } -+ -+ } else { -+ //use steps from data-* annotations -+ var allIntroSteps = targetElm.querySelectorAll('*[data-intro]'); -+ //if there's no element to intro -+ if (allIntroSteps.length < 1) { -+ return false; -+ } -+ -+ //first add intro items with data-step -+ for (var i = 0, elmsLength = allIntroSteps.length; i < elmsLength; i++) { -+ var currentElement = allIntroSteps[i]; -+ var step = parseInt(currentElement.getAttribute('data-step'), 10); -+ -+ if (step > 0) { -+ introItems[step - 1] = { -+ element: currentElement, -+ intro: currentElement.getAttribute('data-intro'), -+ step: parseInt(currentElement.getAttribute('data-step'), 10), -+ tooltipClass: currentElement.getAttribute('data-tooltipClass'), -+ position: currentElement.getAttribute('data-position') || this._options.tooltipPosition -+ }; -+ } -+ } -+ -+ //next add intro items without data-step -+ //todo: we need a cleanup here, two loops are redundant -+ var nextStep = 0; -+ for (var i = 0, elmsLength = allIntroSteps.length; i < elmsLength; i++) { -+ var currentElement = allIntroSteps[i]; -+ -+ if (currentElement.getAttribute('data-step') == null) { -+ -+ while (true) { -+ if (typeof introItems[nextStep] == 'undefined') { -+ break; -+ } else { -+ nextStep++; -+ } -+ } -+ -+ introItems[nextStep] = { -+ element: currentElement, -+ intro: currentElement.getAttribute('data-intro'), -+ step: nextStep + 1, -+ tooltipClass: currentElement.getAttribute('data-tooltipClass'), -+ position: currentElement.getAttribute('data-position') || this._options.tooltipPosition -+ }; -+ } -+ } -+ } -+ -+ //removing undefined/null elements -+ var tempIntroItems = []; -+ for (var z = 0; z < introItems.length; z++) { -+ introItems[z] && tempIntroItems.push(introItems[z]); // copy non-empty values to the end of the array -+ } -+ -+ introItems = tempIntroItems; -+ -+ //Ok, sort all items with given steps -+ introItems.sort(function (a, b) { -+ return a.step - b.step; -+ }); -+ -+ //set it to the introJs object -+ self._introItems = introItems; -+ -+ //add overlay layer to the page -+ if(_addOverlayLayer.call(self, targetElm)) { -+ //then, start the show -+ _nextStep.call(self); -+ -+ var skipButton = targetElm.querySelector('.introjs-skipbutton'), -+ nextStepButton = targetElm.querySelector('.introjs-nextbutton'); -+ -+ self._onKeyDown = function(e) { -+ if (e.keyCode === 27 && self._options.exitOnEsc == true) { -+ propagate_exit = true; -+ -+ //check if any callback is defined -+ if (self._introExitCallback != undefined) { -+ propagate_exit = self._introExitCallback.call(self); -+ if (typeof(propagate_exit) == "undefined") -+ propagate_exit = true; -+ } -+ -+ //escape key pressed, exit the intro -+ if (propagate_exit) -+ _exitIntro.call(self, targetElm); -+ -+ } else if(e.keyCode === 37) { -+ //left arrow -+ _previousStep.call(self); -+ } else if (e.keyCode === 39 || e.keyCode === 13) { -+ //right arrow or enter -+ _nextStep.call(self); -+ //prevent default behaviour on hitting Enter, to prevent steps being skipped in some browsers -+ if(e.preventDefault) { -+ e.preventDefault(); -+ } else { -+ e.returnValue = false; -+ } -+ } -+ }; -+ -+ self._onResize = function(e) { -+ _setHelperLayerPosition.call(self, document.querySelector('.introjs-helperLayer')); -+ }; -+ -+ if (window.addEventListener) { -+ if (this._options.keyboardNavigation) { -+ window.addEventListener('keydown', self._onKeyDown, true); -+ } -+ //for window resize -+ window.addEventListener("resize", self._onResize, true); -+ } else if (document.attachEvent) { //IE -+ if (this._options.keyboardNavigation) { -+ document.attachEvent('onkeydown', self._onKeyDown); -+ } -+ //for window resize -+ document.attachEvent("onresize", self._onResize); -+ } -+ } -+ return false; -+ } -+ -+ /* -+ * makes a copy of the object -+ * @api private -+ * @method _cloneObject -+ */ -+ function _cloneObject(object) { -+ if (object == null || typeof (object) != 'object' || typeof (object.nodeType) != 'undefined') { -+ return object; -+ } -+ var temp = {}; -+ for (var key in object) { -+ temp[key] = _cloneObject(object[key]); -+ } -+ return temp; -+ } -+ /** -+ * Go to specific step of introduction -+ * -+ * @api private -+ * @method _goToStep -+ */ -+ function _goToStep(step) { -+ //because steps starts with zero -+ this._currentStep = step - 2; -+ if (typeof (this._introItems) !== 'undefined') { -+ _nextStep.call(this); -+ } -+ } -+ -+ /** -+ * Go to next step on intro -+ * -+ * @api private -+ * @method _nextStep -+ */ -+ function _nextStep() { -+ this._direction = 'forward'; -+ -+ if (typeof (this._currentStep) === 'undefined') { -+ this._currentStep = 0; -+ } else { -+ ++this._currentStep; -+ } -+ -+ if ((this._introItems.length) <= this._currentStep) { -+ //end of the intro -+ //check if any callback is defined -+ if (typeof (this._introCompleteCallback) === 'function') { -+ this._introCompleteCallback.call(this); -+ } -+ _exitIntro.call(this, this._targetElement); -+ return; -+ } -+ -+ var nextStep = this._introItems[this._currentStep]; -+ if (typeof (this._introBeforeChangeCallback) !== 'undefined') { -+ this._introBeforeChangeCallback.call(this, nextStep.element); -+ } -+ -+ _showElement.call(this, nextStep); -+ } -+ -+ /** -+ * Go to previous step on intro -+ * -+ * @api private -+ * @method _nextStep -+ */ -+ function _previousStep() { -+ this._direction = 'backward'; -+ -+ if (this._currentStep === 0) { -+ return false; -+ } -+ -+ var nextStep = this._introItems[--this._currentStep]; -+ if (typeof (this._introBeforeChangeCallback) !== 'undefined') { -+ this._introBeforeChangeCallback.call(this, nextStep.element); -+ } -+ -+ _showElement.call(this, nextStep); -+ } -+ -+ /** -+ * Exit from intro -+ * -+ * @api private -+ * @method _exitIntro -+ * @param {Object} targetElement -+ */ -+ function _exitIntro(targetElement) { -+ //remove overlay layer from the page -+ var overlayLayer = targetElement.querySelector('.introjs-overlay'); -+ -+ //return if intro already completed or skipped -+ if (overlayLayer == null) { -+ return; -+ } -+ -+ //for fade-out animation -+ overlayLayer.style.opacity = 0; -+ setTimeout(function () { -+ if (overlayLayer.parentNode) { -+ overlayLayer.parentNode.removeChild(overlayLayer); -+ } -+ }, 500); -+ -+ //remove all helper layers -+ var helperLayer = targetElement.querySelector('.introjs-helperLayer'); -+ if (helperLayer) { -+ helperLayer.parentNode.removeChild(helperLayer); -+ } -+ -+ //remove intro floating element -+ var floatingElement = document.querySelector('.introjsFloatingElement'); -+ if (floatingElement) { -+ floatingElement.parentNode.removeChild(floatingElement); -+ } -+ -+ //remove `introjs-showElement` class from the element -+ var showElement = document.querySelector('.introjs-showElement'); -+ if (showElement) { -+ showElement.className = showElement.className.replace(/introjs-[a-zA-Z]+/g, '').replace(/^\s+|\s+$/g, ''); // This is a manual trim. -+ } -+ -+ //remove `introjs-fixParent` class from the elements -+ var fixParents = document.querySelectorAll('.introjs-fixParent'); -+ if (fixParents && fixParents.length > 0) { -+ for (var i = fixParents.length - 1; i >= 0; i--) { -+ fixParents[i].className = fixParents[i].className.replace(/introjs-fixParent/g, '').replace(/^\s+|\s+$/g, ''); -+ }; -+ } -+ -+ //clean listeners -+ if (window.removeEventListener) { -+ window.removeEventListener('keydown', this._onKeyDown, true); -+ } else if (document.detachEvent) { //IE -+ document.detachEvent('onkeydown', this._onKeyDown); -+ } -+ -+ //set the step to zero -+ this._currentStep = undefined; -+ } -+ -+ /** -+ * Render tooltip box in the page -+ * -+ * @api private -+ * @method _placeTooltip -+ * @param {Object} targetElement -+ * @param {Object} tooltipLayer -+ * @param {Object} arrowLayer -+ */ -+ function _placeTooltip(targetElement, tooltipLayer, arrowLayer, helperNumberLayer) { -+ var tooltipCssClass = '', -+ currentStepObj, -+ tooltipOffset, -+ targetElementOffset; -+ -+ //reset the old style -+ tooltipLayer.style.top = null; -+ tooltipLayer.style.right = null; -+ tooltipLayer.style.bottom = null; -+ tooltipLayer.style.left = null; -+ tooltipLayer.style.marginLeft = null; -+ tooltipLayer.style.marginTop = null; -+ -+ arrowLayer.style.display = 'inherit'; -+ -+ if (typeof(helperNumberLayer) != 'undefined' && helperNumberLayer != null) { -+ helperNumberLayer.style.top = null; -+ helperNumberLayer.style.left = null; -+ } -+ -+ //prevent error when `this._currentStep` is undefined -+ if (!this._introItems[this._currentStep]) return; -+ -+ //if we have a custom css class for each step -+ currentStepObj = this._introItems[this._currentStep]; -+ if (typeof (currentStepObj.tooltipClass) === 'string') { -+ tooltipCssClass = currentStepObj.tooltipClass; -+ } else { -+ tooltipCssClass = this._options.tooltipClass; -+ } -+ -+ tooltipLayer.className = ('introjs-tooltip ' + tooltipCssClass).replace(/^\s+|\s+$/g, ''); -+ -+ //custom css class for tooltip boxes -+ var tooltipCssClass = this._options.tooltipClass; -+ -+ currentTooltipPosition = this._introItems[this._currentStep].position; -+ switch (currentTooltipPosition) { -+ case 'top': -+ tooltipLayer.style.left = '15px'; -+ tooltipLayer.style.top = '-' + (_getOffset(tooltipLayer).height + 10) + 'px'; -+ arrowLayer.className = 'introjs-arrow bottom'; -+ break; -+ case 'right': -+ tooltipLayer.style.left = (_getOffset(targetElement).width + 20) + 'px'; -+ arrowLayer.className = 'introjs-arrow left'; -+ break; -+ case 'left': -+ if (this._options.showStepNumbers == true) { -+ tooltipLayer.style.top = '15px'; -+ } -+ tooltipLayer.style.right = (_getOffset(targetElement).width + 20) + 'px'; -+ arrowLayer.className = 'introjs-arrow right'; -+ break; -+ case 'floating': -+ arrowLayer.style.display = 'none'; -+ -+ //we have to adjust the top and left of layer manually for intro items without element -+ tooltipOffset = _getOffset(tooltipLayer); -+ -+ tooltipLayer.style.left = '50%'; -+ tooltipLayer.style.top = '50%'; -+ tooltipLayer.style.marginLeft = '-' + (tooltipOffset.width / 2) + 'px'; -+ tooltipLayer.style.marginTop = '-' + (tooltipOffset.height / 2) + 'px'; -+ -+ if (typeof(helperNumberLayer) != 'undefined' && helperNumberLayer != null) { -+ helperNumberLayer.style.left = '-' + ((tooltipOffset.width / 2) + 18) + 'px'; -+ helperNumberLayer.style.top = '-' + ((tooltipOffset.height / 2) + 18) + 'px'; -+ } -+ -+ break; -+ case 'bottom-right-aligned': -+ arrowLayer.className = 'introjs-arrow top-right'; -+ tooltipLayer.style.right = '0px'; -+ tooltipLayer.style.bottom = '-' + (_getOffset(tooltipLayer).height + 10) + 'px'; -+ break; -+ case 'bottom-middle-aligned': -+ targetElementOffset = _getOffset(targetElement); -+ tooltipOffset = _getOffset(tooltipLayer); -+ -+ arrowLayer.className = 'introjs-arrow top-middle'; -+ tooltipLayer.style.left = (targetElementOffset.width / 2 - tooltipOffset.width / 2) + 'px'; -+ tooltipLayer.style.bottom = '-' + (tooltipOffset.height + 10) + 'px'; -+ break; -+ case 'bottom-left-aligned': -+ // Bottom-left-aligned is the same as the default bottom -+ case 'bottom': -+ // Bottom going to follow the default behavior -+ default: -+ tooltipLayer.style.bottom = '-' + (_getOffset(tooltipLayer).height + 10) + 'px'; -+ arrowLayer.className = 'introjs-arrow top'; -+ break; -+ } -+ } -+ -+ /** -+ * Update the position of the helper layer on the screen -+ * -+ * @api private -+ * @method _setHelperLayerPosition -+ * @param {Object} helperLayer -+ */ -+ function _setHelperLayerPosition(helperLayer) { -+ if (helperLayer) { -+ //prevent error when `this._currentStep` in undefined -+ if (!this._introItems[this._currentStep]) return; -+ -+ var currentElement = this._introItems[this._currentStep], -+ elementPosition = _getOffset(currentElement.element), -+ widthHeightPadding = 10; -+ -+ if (currentElement.position == 'floating') { -+ widthHeightPadding = 0; -+ } -+ -+ //set new position to helper layer -+ helperLayer.setAttribute('style', 'width: ' + (elementPosition.width + widthHeightPadding) + 'px; ' + -+ 'height:' + (elementPosition.height + widthHeightPadding) + 'px; ' + -+ 'top:' + (elementPosition.top - 5) + 'px;' + -+ 'left: ' + (elementPosition.left - 5) + 'px;'); -+ } -+ } -+ -+ /** -+ * Show an element on the page -+ * -+ * @api private -+ * @method _showElement -+ * @param {Object} targetElement -+ */ -+ function _showElement(targetElement) { -+ -+ if (typeof (this._introChangeCallback) !== 'undefined') { -+ this._introChangeCallback.call(this, targetElement.element); -+ } -+ -+ var self = this, -+ oldHelperLayer = document.querySelector('.introjs-helperLayer'), -+ elementPosition = _getOffset(targetElement.element); -+ -+ if (oldHelperLayer != null) { -+ var oldHelperNumberLayer = oldHelperLayer.querySelector('.introjs-helperNumberLayer'), -+ oldtooltipLayer = oldHelperLayer.querySelector('.introjs-tooltiptext'), -+ oldArrowLayer = oldHelperLayer.querySelector('.introjs-arrow'), -+ oldtooltipContainer = oldHelperLayer.querySelector('.introjs-tooltip'), -+ skipTooltipButton = oldHelperLayer.querySelector('.introjs-skipbutton'), -+ prevTooltipButton = oldHelperLayer.querySelector('.introjs-prevbutton'), -+ nextTooltipButton = oldHelperLayer.querySelector('.introjs-nextbutton'); -+ -+ //hide the tooltip -+ oldtooltipContainer.style.opacity = 0; -+ -+ if (oldHelperNumberLayer != null) { -+ var lastIntroItem = this._introItems[(targetElement.step - 2 >= 0 ? targetElement.step - 2 : 0)]; -+ -+ if (lastIntroItem != null && (this._direction == 'forward' && lastIntroItem.position == 'floating') || (this._direction == 'backward' && targetElement.position == 'floating')) { -+ oldHelperNumberLayer.style.opacity = 0; -+ } -+ } -+ -+ //set new position to helper layer -+ _setHelperLayerPosition.call(self, oldHelperLayer); -+ -+ //remove `introjs-fixParent` class from the elements -+ var fixParents = document.querySelectorAll('.introjs-fixParent'); -+ if (fixParents && fixParents.length > 0) { -+ for (var i = fixParents.length - 1; i >= 0; i--) { -+ fixParents[i].className = fixParents[i].className.replace(/introjs-fixParent/g, '').replace(/^\s+|\s+$/g, ''); -+ }; -+ } -+ -+ //remove old classes -+ var oldShowElement = document.querySelector('.introjs-showElement'); -+ oldShowElement.className = oldShowElement.className.replace(/introjs-[a-zA-Z]+/g, '').replace(/^\s+|\s+$/g, ''); -+ //we should wait until the CSS3 transition is competed (it's 0.3 sec) to prevent incorrect `height` and `width` calculation -+ if (self._lastShowElementTimer) { -+ clearTimeout(self._lastShowElementTimer); -+ } -+ self._lastShowElementTimer = setTimeout(function() { -+ //set current step to the label -+ if (oldHelperNumberLayer != null) { -+ oldHelperNumberLayer.innerHTML = targetElement.step; -+ } -+ //set current tooltip text -+ oldtooltipLayer.innerHTML = targetElement.intro; -+ //set the tooltip position -+ _placeTooltip.call(self, targetElement.element, oldtooltipContainer, oldArrowLayer, oldHelperNumberLayer); -+ -+ //change active bullet -+ oldHelperLayer.querySelector('.introjs-bullets li > a.active').className = ''; -+ oldHelperLayer.querySelector('.introjs-bullets li > a[data-stepnumber="' + targetElement.step + '"]').className = 'active'; -+ -+ //show the tooltip -+ oldtooltipContainer.style.opacity = 1; -+ if (oldHelperNumberLayer) oldHelperNumberLayer.style.opacity = 1; -+ }, 350); -+ -+ } else { -+ var helperLayer = document.createElement('div'), -+ arrowLayer = document.createElement('div'), -+ tooltipLayer = document.createElement('div'), -+ tooltipTextLayer = document.createElement('div'), -+ bulletsLayer = document.createElement('div'), -+ buttonsLayer = document.createElement('div'); -+ -+ helperLayer.className = 'introjs-helperLayer'; -+ -+ //set new position to helper layer -+ _setHelperLayerPosition.call(self, helperLayer); -+ -+ //add helper layer to target element -+ this._targetElement.appendChild(helperLayer); -+ -+ arrowLayer.className = 'introjs-arrow'; -+ -+ tooltipTextLayer.className = 'introjs-tooltiptext'; -+ tooltipTextLayer.innerHTML = targetElement.intro; -+ -+ bulletsLayer.className = 'introjs-bullets'; -+ -+ if (this._options.showBullets === false) { -+ bulletsLayer.style.display = 'none'; -+ } -+ -+ var ulContainer = document.createElement('ul'); -+ -+ for (var i = 0, stepsLength = this._introItems.length; i < stepsLength; i++) { -+ var innerLi = document.createElement('li'); -+ var anchorLink = document.createElement('a'); -+ -+ anchorLink.onclick = function() { -+ self.goToStep(this.getAttribute('data-stepnumber')); -+ }; -+ -+ if (i === (targetElement.step-1)) anchorLink.className = "active"; -+ -+ anchorLink.href = 'javascript:void(0);'; -+ anchorLink.innerHTML = " "; -+ anchorLink.setAttribute('data-stepnumber', this._introItems[i].step); -+ -+ innerLi.appendChild(anchorLink); -+ ulContainer.appendChild(innerLi); -+ } -+ -+ bulletsLayer.appendChild(ulContainer); -+ -+ buttonsLayer.className = 'introjs-tooltipbuttons'; -+ if (this._options.showButtons === false) { -+ buttonsLayer.style.display = 'none'; -+ } -+ -+ tooltipLayer.className = 'introjs-tooltip'; -+ tooltipLayer.appendChild(tooltipTextLayer); -+ tooltipLayer.appendChild(bulletsLayer); -+ -+ //add helper layer number -+ if (this._options.showStepNumbers == true) { -+ var helperNumberLayer = document.createElement('span'); -+ helperNumberLayer.className = 'introjs-helperNumberLayer'; -+ helperNumberLayer.innerHTML = targetElement.step; -+ helperLayer.appendChild(helperNumberLayer); -+ } -+ tooltipLayer.appendChild(arrowLayer); -+ helperLayer.appendChild(tooltipLayer); -+ -+ //next button -+ var nextTooltipButton = document.createElement('a'); -+ -+ nextTooltipButton.onclick = function() { -+ if (self._introItems.length - 1 != self._currentStep) { -+ _nextStep.call(self); -+ } -+ }; -+ -+ nextTooltipButton.href = 'javascript:void(0);'; -+ nextTooltipButton.innerHTML = this._options.nextLabel; -+ -+ //previous button -+ var prevTooltipButton = document.createElement('a'); -+ -+ prevTooltipButton.onclick = function() { -+ if (self._currentStep != 0) { -+ _previousStep.call(self); -+ } -+ }; -+ -+ prevTooltipButton.href = 'javascript:void(0);'; -+ prevTooltipButton.innerHTML = this._options.prevLabel; -+ -+ //skip button -+ var skipTooltipButton = document.createElement('a'); -+ skipTooltipButton.className = 'introjs-button introjs-skipbutton'; -+ skipTooltipButton.href = 'javascript:void(0);'; -+ skipTooltipButton.innerHTML = this._options.skipLabel; -+ -+ skipTooltipButton.onclick = function() { -+ propagate_exit = true; -+ -+ if (self._introItems.length - 1 == self._currentStep && typeof (self._introCompleteCallback) === 'function') { -+ propagate_exit = self._introCompleteCallback.call(self); -+ if (typeof(propagate_exit) == "undefined") -+ propagate_exit = true; -+ } -+ -+ if (self._introItems.length - 1 != self._currentStep && typeof (self._introExitCallback) === 'function') { -+ propagate_exit = self._introExitCallback.call(self); -+ if (typeof(propagate_exit) == "undefined") -+ propagate_exit = true; -+ } -+ -+ if (propagate_exit) -+ _exitIntro.call(self, self._targetElement); -+ }; -+ -+ buttonsLayer.appendChild(skipTooltipButton); -+ -+ //in order to prevent displaying next/previous button always -+ if (this._introItems.length > 1) { -+ buttonsLayer.appendChild(prevTooltipButton); -+ buttonsLayer.appendChild(nextTooltipButton); -+ } -+ -+ tooltipLayer.appendChild(buttonsLayer); -+ -+ //set proper position -+ _placeTooltip.call(self, targetElement.element, tooltipLayer, arrowLayer, helperNumberLayer); -+ } -+ -+ if (this._currentStep == 0 && this._introItems.length > 1) { -+ prevTooltipButton.className = 'introjs-button introjs-prevbutton introjs-disabled'; -+ nextTooltipButton.className = 'introjs-button introjs-nextbutton'; -+ skipTooltipButton.innerHTML = this._options.skipLabel; -+ } else if (this._introItems.length - 1 == this._currentStep || this._introItems.length == 1) { -+ skipTooltipButton.innerHTML = this._options.doneLabel; -+ prevTooltipButton.className = 'introjs-button introjs-prevbutton'; -+ nextTooltipButton.className = 'introjs-button introjs-nextbutton introjs-disabled'; -+ } else { -+ prevTooltipButton.className = 'introjs-button introjs-prevbutton'; -+ nextTooltipButton.className = 'introjs-button introjs-nextbutton'; -+ skipTooltipButton.innerHTML = this._options.skipLabel; -+ } -+ -+ //Set focus on "next" button, so that hitting Enter always moves you onto the next step -+ nextTooltipButton.focus(); -+ -+ //add target element position style -+ targetElement.element.className += ' introjs-showElement'; -+ -+ var currentElementPosition = _getPropValue(targetElement.element, 'position'); -+ if (currentElementPosition !== 'absolute' && -+ currentElementPosition !== 'relative') { -+ //change to new intro item -+ targetElement.element.className += ' introjs-relativePosition'; -+ } -+ -+ var parentElm = targetElement.element.parentNode; -+ while (parentElm != null) { -+ if (parentElm.tagName.toLowerCase() === 'body') break; -+ -+ //fix The Stacking Contenxt problem. -+ //More detail: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Understanding_z_index/The_stacking_context -+ var zIndex = _getPropValue(parentElm, 'z-index'); -+ var opacity = parseFloat(_getPropValue(parentElm, 'opacity')); -+ var transform = _getPropValue(parentElm, 'transform') || _getPropValue(parentElm, '-webkit-transform') || _getPropValue(parentElm, '-moz-transform') || _getPropValue(parentElm, '-ms-transform') || _getPropValue(parentElm, '-o-transform'); -+ if (/[0-9]+/.test(zIndex) || opacity < 1 || transform !== 'none') { -+ parentElm.className += ' introjs-fixParent'; -+ } -+ -+ parentElm = parentElm.parentNode; -+ } -+ -+ if (!_elementInViewport(targetElement.element) && this._options.scrollToElement === true) { -+ var rect = targetElement.element.getBoundingClientRect(), -+ winHeight=_getWinSize().height, -+ top = rect.bottom - (rect.bottom - rect.top), -+ bottom = rect.bottom - winHeight; -+ -+ //Scroll up -+ if (top < 0 || targetElement.element.clientHeight > winHeight) { -+ window.scrollBy(0, top - 30); // 30px padding from edge to look nice -+ -+ //Scroll down -+ } else { -+ window.scrollBy(0, bottom + 100); // 70px + 30px padding from edge to look nice -+ } -+ } -+ -+ if (typeof (this._introAfterChangeCallback) !== 'undefined') { -+ this._introAfterChangeCallback.call(this, targetElement.element); -+ } -+ } -+ -+ /** -+ * Get an element CSS property on the page -+ * Thanks to JavaScript Kit: http://www.javascriptkit.com/dhtmltutors/dhtmlcascade4.shtml -+ * -+ * @api private -+ * @method _getPropValue -+ * @param {Object} element -+ * @param {String} propName -+ * @returns Element's property value -+ */ -+ function _getPropValue (element, propName) { -+ var propValue = ''; -+ if (element.currentStyle) { //IE -+ propValue = element.currentStyle[propName]; -+ } else if (document.defaultView && document.defaultView.getComputedStyle) { //Others -+ propValue = document.defaultView.getComputedStyle(element, null).getPropertyValue(propName); -+ } -+ -+ //Prevent exception in IE -+ if (propValue && propValue.toLowerCase) { -+ return propValue.toLowerCase(); -+ } else { -+ return propValue; -+ } -+ } -+ -+ /** -+ * Provides a cross-browser way to get the screen dimensions -+ * via: http://stackoverflow.com/questions/5864467/internet-explorer-innerheight -+ * -+ * @api private -+ * @method _getWinSize -+ * @returns {Object} width and height attributes -+ */ -+ function _getWinSize() { -+ if (window.innerWidth != undefined) { -+ return { width: window.innerWidth, height: window.innerHeight }; -+ } else { -+ var D = document.documentElement; -+ return { width: D.clientWidth, height: D.clientHeight }; -+ } -+ } -+ -+ /** -+ * Add overlay layer to the page -+ * http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport -+ * -+ * @api private -+ * @method _elementInViewport -+ * @param {Object} el -+ */ -+ function _elementInViewport(el) { -+ var rect = el.getBoundingClientRect(); -+ -+ return ( -+ rect.top >= 0 && -+ rect.left >= 0 && -+ (rect.bottom+80) <= window.innerHeight && // add 80 to get the text right -+ rect.right <= window.innerWidth -+ ); -+ } -+ -+ /** -+ * Add overlay layer to the page -+ * -+ * @api private -+ * @method _addOverlayLayer -+ * @param {Object} targetElm -+ */ -+ function _addOverlayLayer(targetElm) { -+ var overlayLayer = document.createElement('div'), -+ styleText = '', -+ self = this; -+ -+ //set css class name -+ overlayLayer.className = 'introjs-overlay'; -+ -+ //check if the target element is body, we should calculate the size of overlay layer in a better way -+ if (targetElm.tagName.toLowerCase() === 'body') { -+ styleText += 'top: 0;bottom: 0; left: 0;right: 0;position: fixed;'; -+ overlayLayer.setAttribute('style', styleText); -+ } else { -+ //set overlay layer position -+ var elementPosition = _getOffset(targetElm); -+ if (elementPosition) { -+ styleText += 'width: ' + elementPosition.width + 'px; height:' + elementPosition.height + 'px; top:' + elementPosition.top + 'px;left: ' + elementPosition.left + 'px;'; -+ overlayLayer.setAttribute('style', styleText); -+ } -+ } -+ -+ targetElm.appendChild(overlayLayer); -+ -+ overlayLayer.onclick = function() { -+ if (self._options.exitOnOverlayClick == true) { -+ _exitIntro.call(self, targetElm); -+ -+ //check if any callback is defined -+ if (self._introExitCallback != undefined) { -+ self._introExitCallback.call(self); -+ } -+ } -+ }; -+ -+ setTimeout(function() { -+ styleText += 'opacity: ' + self._options.overlayOpacity.toString() + ';'; -+ overlayLayer.setAttribute('style', styleText); -+ }, 10); -+ -+ return true; -+ } -+ -+ /** -+ * Get an element position on the page -+ * Thanks to `meouw`: http://stackoverflow.com/a/442474/375966 -+ * -+ * @api private -+ * @method _getOffset -+ * @param {Object} element -+ * @returns Element's position info -+ */ -+ function _getOffset(element) { -+ var elementPosition = {}; -+ -+ //set width -+ elementPosition.width = element.offsetWidth; -+ -+ //set height -+ elementPosition.height = element.offsetHeight; -+ -+ //calculate element top and left -+ var _x = 0; -+ var _y = 0; -+ while (element && !isNaN(element.offsetLeft) && !isNaN(element.offsetTop)) { -+ _x += element.offsetLeft; -+ _y += element.offsetTop; -+ element = element.offsetParent; -+ } -+ //set top -+ elementPosition.top = _y; -+ //set left -+ elementPosition.left = _x; -+ -+ return elementPosition; -+ } -+ -+ /** -+ * Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1 -+ * via: http://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically -+ * -+ * @param obj1 -+ * @param obj2 -+ * @returns obj3 a new object based on obj1 and obj2 -+ */ -+ function _mergeOptions(obj1,obj2) { -+ var obj3 = {}; -+ for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; } -+ for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; } -+ return obj3; -+ } -+ -+ var introJs = function (targetElm) { -+ if (typeof (targetElm) === 'object') { -+ //Ok, create a new instance -+ return new IntroJs(targetElm); -+ -+ } else if (typeof (targetElm) === 'string') { -+ //select the target element with query selector -+ var targetElement = document.querySelector(targetElm); -+ -+ if (targetElement) { -+ return new IntroJs(targetElement); -+ } else { -+ throw new Error('There is no element with given selector.'); -+ } -+ } else { -+ return new IntroJs(document.body); -+ } -+ }; -+ -+ /** -+ * Current IntroJs version -+ * -+ * @property version -+ * @type String -+ */ -+ introJs.version = VERSION; -+ -+ //Prototype -+ introJs.fn = IntroJs.prototype = { -+ clone: function () { -+ return new IntroJs(this); -+ }, -+ setOption: function(option, value) { -+ this._options[option] = value; -+ return this; -+ }, -+ setOptions: function(options) { -+ this._options = _mergeOptions(this._options, options); -+ return this; -+ }, -+ start: function () { -+ _introForElement.call(this, this._targetElement); -+ return this; -+ }, -+ goToStep: function(step) { -+ _goToStep.call(this, step); -+ return this; -+ }, -+ nextStep: function() { -+ _nextStep.call(this); -+ return this; -+ }, -+ previousStep: function() { -+ _previousStep.call(this); -+ return this; -+ }, -+ exit: function() { -+ _exitIntro.call(this, this._targetElement); -+ }, -+ refresh: function() { -+ _setHelperLayerPosition.call(this, document.querySelector('.introjs-helperLayer')); -+ return this; -+ }, -+ onbeforechange: function(providedCallback) { -+ if (typeof (providedCallback) === 'function') { -+ this._introBeforeChangeCallback = providedCallback; -+ } else { -+ throw new Error('Provided callback for onbeforechange was not a function'); -+ } -+ return this; -+ }, -+ onchange: function(providedCallback) { -+ if (typeof (providedCallback) === 'function') { -+ this._introChangeCallback = providedCallback; -+ } else { -+ throw new Error('Provided callback for onchange was not a function.'); -+ } -+ return this; -+ }, -+ onafterchange: function(providedCallback) { -+ if (typeof (providedCallback) === 'function') { -+ this._introAfterChangeCallback = providedCallback; -+ } else { -+ throw new Error('Provided callback for onafterchange was not a function'); -+ } -+ return this; -+ }, -+ oncomplete: function(providedCallback) { -+ if (typeof (providedCallback) === 'function') { -+ this._introCompleteCallback = providedCallback; -+ } else { -+ throw new Error('Provided callback for oncomplete was not a function.'); -+ } -+ return this; -+ }, -+ onexit: function(providedCallback) { -+ if (typeof (providedCallback) === 'function') { -+ this._introExitCallback = providedCallback; -+ } else { -+ throw new Error('Provided callback for onexit was not a function.'); -+ } -+ return this; -+ } -+ }; -+ -+ exports.introJs = introJs; -+ return introJs; -+})); -Index: include/javascript/clippy.js -=================================================================== ---- include/javascript/clippy.js (revision 0) -+++ include/javascript/clippy.js (revision 10417) -@@ -0,0 +1,8 @@ -+function clippy_set_help(help_section) { -+ document.cookie = 'clippy=' + help_section; -+} -+ -+function clippy_go_link_show_help(link, help_section) { -+ document.cookie = 'clippy=' + help_section; -+ window.location.href = link; -+} -\ No newline at end of file -Index: include/functions_servers.php -=================================================================== ---- include/functions_servers.php (revision 10314) -+++ include/functions_servers.php (working copy) -@@ -79,7 +79,9 @@ - $data["avg_interval_remote_modules"] = array(); - $data["avg_interval_local_modules"] = 0; - $data["local_modules_rate"] = 0; -+ $data["network_modules_rate"] = 0; - -+ - if ($config["realtimestats"] == 1) { - $counts = db_get_all_rows_sql ("SELECT tagente_modulo.id_modulo, COUNT(tagente_modulo.id_agente_modulo) modules - FROM tagente_modulo, tagente_estado, tagente -@@ -195,6 +197,8 @@ - $interval_avgs_agents = array(); - } - -+ $interval_avgs = array(); -+ - // Merge with the previous calculated array - foreach($interval_avgs_agents as $iaagents) { - if(!isset($interval_avgs[$iaagents['id_modulo']]['modules'])) { -Index: include/functions_treeview.php -=================================================================== ---- include/functions_treeview.php (revision 10314) -+++ include/functions_treeview.php (working copy) -@@ -468,11 +468,19 @@ - echo '<table class="databox" style="width:98%">'; - echo '<tr><td style="width:50%" valign="top">'; - -+ -+ - if (! defined ('METACONSOLE')) { -+ - $list = treeview_getData ($type); -+ - } - else { -- $servers = db_get_all_rows_sql ("SELECT * FROM tmetaconsole_setup WHERE disabled = 0"); -+ $servers = db_get_all_rows_sql (" -+ SELECT * -+ FROM tmetaconsole_setup -+ WHERE disabled = 0"); -+ - if ($servers === false) { - $servers = array(); - } -@@ -502,6 +510,8 @@ - metaconsole_restore_db(); - } - -+ -+ - if ($list === false) { - ui_print_error_message(__('There aren\'t agents in this agrupation')); - echo '</td></tr>'; -@@ -543,19 +553,25 @@ - else { - $id = $item['_id_']; - } -- -+ - echo "<a onfocus='JavaScript: this.blur()' href='javascript: loadSubTree(\"" . $type . "\",\"" . $id . "\", " . $lessBranchs . ", \"\", \"\")'>"; - - echo $img . $item['_iconImg_'] ." " . __($item['_name_']) . ' ('; - -- $counts_info = array('total_count' => $item['_num_ok_'] + $item['_num_critical_'] + $item['_num_warning_'] + $item['_num_unknown_'], -- 'normal_count' => $item['_num_ok_'], -- 'critical_count' => $item['_num_critical_'], -- 'warning_count' => $item['_num_warning_'], -- 'unknown_count' => $item['_num_unknown_']); -- -+ $counts_info = array( -+ 'total_count' => $item['_num_ok_'] + -+ $item['_num_critical_'] + -+ $item['_num_warning_'] + -+ $item['_num_unknown_'], -+ 'normal_count' => $item['_num_ok_'], -+ 'critical_count' => $item['_num_critical_'], -+ 'warning_count' => $item['_num_warning_'], -+ 'unknown_count' => $item['_num_unknown_']); -+ -+ - reporting_tiny_stats($counts_info, false, $type); - -+ - echo ') '. "</a>"; - - echo "<div hiddenDiv='1' loadDiv='0' style='margin: 0px; padding: 0px;' class='tree_view' id='tree_div_" . $type . "_" . $id . "'></div>"; -@@ -581,7 +597,11 @@ - $avariableGroups = users_get_groups (); - - //Get all groups with agents -- $full_groups = db_get_all_rows_sql("SELECT DISTINCT id_grupo FROM tagente WHERE total_count > 0"); -+ $full_groups = db_get_all_rows_sql(" -+ SELECT DISTINCT id_grupo -+ FROM tagente -+ WHERE total_count > 0"); -+ - if ($full_groups === false) { - return array (); - } -@@ -607,9 +627,12 @@ - switch ($select_status) { - case NORMAL: - foreach ($avariableGroups as $group_name) { -- $id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"'); -+ $id_group = db_get_value_sql(' -+ SELECT id_grupo -+ FROM tgrupo -+ WHERE nombre ="' . $group_name . '"'); - -- $num_ok = groups_agent_ok($id_group); -+ $num_ok = groups_agent_ok($id_group); - - if ($num_ok <= 0) - unset($avariableGroups[$id_group]); -@@ -619,7 +642,10 @@ - break; - case WARNING: - foreach ($avariableGroups as $group_name) { -- $id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"'); -+ $id_group = db_get_value_sql(' -+ SELECT id_grupo -+ FROM tgrupo -+ WHERE nombre ="' . $group_name . '"'); - - $num_warning = groups_agent_warning($id_group); - -@@ -629,7 +655,10 @@ - break; - case CRITICAL: - foreach ($avariableGroups as $group_name) { -- $id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"'); -+ $id_group = db_get_value_sql(' -+ SELECT id_grupo -+ FROM tgrupo -+ WHERE nombre ="' . $group_name . '"'); - - $num_critical = groups_agent_critical($id_group); - -@@ -639,7 +668,10 @@ - break; - case UNKNOWN: - foreach ($avariableGroups as $group_name) { -- $id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"'); -+ $id_group = db_get_value_sql(' -+ SELECT id_grupo -+ FROM tgrupo -+ WHERE nombre ="' . $group_name . '"'); - - $num_unknown = groups_agent_unknown($id_group); - -@@ -656,17 +688,42 @@ - } - - if ($search_free != '') { -- $sql_search = " AND id_grupo IN (SELECT id_grupo FROM tagente -- WHERE tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; -+ switch ($config['dbtype']) { -+ case "mysql": -+ $sql_search = " AND id_grupo IN ( -+ SELECT id_grupo -+ FROM tagente -+ WHERE tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; -+ break; -+ case "postgresql": -+ $sql_search = " AND id_grupo IN ( -+ SELECT id_grupo -+ FROM tagente -+ WHERE tagente.nombre LIKE '%$search_free%')"; -+ break; -+ case "oracle": -+ $sql_search = " AND id_grupo IN ( -+ SELECT id_grupo -+ FROM tagente -+ WHERE tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; -+ break; -+ } - } - else { - $sql_search =''; - } - -+ $order_collate = ""; -+ switch ($config['dbtype']) { -+ case "mysql": -+ $order_collate = "COLLATE utf8_general_ci"; -+ break; -+ } -+ - switch ($type) { -- case 'os': -+ case 'os': - $sql = agents_get_agents(array ( -- 'order' => 'nombre COLLATE utf8_general_ci ASC', -+ 'order' => 'nombre ' . $order_collate . ' ASC', - 'disabled' => 0, - 'status' => $select_status, - 'search' => $sql_search), -@@ -676,7 +733,9 @@ - false, - true); - -- $sql_os = sprintf("SELECT * FROM tconfig_os WHERE id_os IN (%s)", $sql); -+ $sql_os = sprintf("SELECT * -+ FROM tconfig_os -+ WHERE id_os IN (%s)", $sql); - - $list = db_get_all_rows_sql($sql_os); - -@@ -692,17 +751,31 @@ - - switch ($config["dbtype"]) { - case "mysql": -+ $list = db_get_all_rows_sql(" -+ SELECT * -+ FROM tgrupo -+ WHERE nombre IN (" . $stringAvariableGroups . ") $sql_search -+ ORDER BY nombre COLLATE utf8_general_ci ASC"); -+ break; - case "postgresql": -- $list = db_get_all_rows_sql("SELECT * FROM tgrupo WHERE nombre IN (" . $stringAvariableGroups . ") $sql_search ORDER BY nombre COLLATE utf8_general_ci ASC"); -+ $list = db_get_all_rows_sql(" -+ SELECT * -+ FROM tgrupo -+ WHERE nombre IN (" . $stringAvariableGroups . ") $sql_search -+ ORDER BY nombre ASC"); - break; - case "oracle": -- $list = db_get_all_rows_sql("SELECT * FROM tgrupo WHERE dbms_lob.substr(nombre,4000,1) IN (" . $stringAvariableGroups . ") ORDER BY nombre COLLATE utf8_general_ci ASC"); -+ $list = db_get_all_rows_sql(" -+ SELECT * -+ FROM tgrupo -+ WHERE dbms_lob.substr(nombre,4000,1) IN (" . $stringAvariableGroups . ") -+ ORDER BY nombre COLLATE utf8_general_ci ASC"); - break; - } - break; - case 'module_group': - $sql = agents_get_agents(array ( -- 'order' => 'nombre COLLATE utf8_general_ci ASC', -+ 'order' => 'nombre ' . $order_collate . ' ASC', - 'disabled' => 0, - 'status' => $select_status, - 'search' => $sql_search), -@@ -714,8 +787,13 @@ - // Skip agents without modules - $sql .= ' AND tagente.total_count>0'; - -- $sql_module_groups = sprintf("SELECT * FROM tmodule_group -- WHERE id_mg IN (SELECT id_module_group FROM tagente_modulo WHERE id_agente IN (%s))", $sql); -+ $sql_module_groups = sprintf(" -+ SELECT * -+ FROM tmodule_group -+ WHERE id_mg IN ( -+ SELECT id_module_group -+ FROM tagente_modulo -+ WHERE id_agente IN (%s))", $sql); - - - $list = db_get_all_rows_sql($sql_module_groups); -@@ -734,7 +812,8 @@ - $groups = implode(',',$groups_id); - - if ($search_free != '') { -- $sql = "SELECT DISTINCT tpolicies.id, tpolicies.name -+ $sql = " -+ SELECT DISTINCT tpolicies.id, tpolicies.name - FROM tpolicies, tpolicy_modules, - tagente_estado, tagente, tagente_modulo - WHERE -@@ -749,7 +828,7 @@ - tagente.nombre LIKE '%$search_free%' AND - tagente.disabled = 0 AND - tagente_modulo.disabled = 0 -- ORDER BY tpolicies.name COLLATE utf8_general_ci ASC"; -+ ORDER BY tpolicies.name COLLATE utf8_general_ci ASC"; - - $list = db_get_all_rows_sql($sql); - -@@ -825,7 +904,7 @@ - tagente.id_grupo IN ($groups) AND - tagente.disabled = 0 AND - tagente_modulo.disabled = 0 -- ORDER BY tpolicies.name COLLATE utf8_general_ci ASC"); -+ ORDER BY tpolicies.name ' . $order_collate . ' ASC"); - - $element = 0; - switch ($select_status) { -@@ -889,8 +968,28 @@ - } - - if ($search_free != '') { -- $sql_search = " AND t1.id_agente IN (SELECT id_agente FROM tagente -- WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; -+ switch ($config['dbtype']) { -+ case "mysql": -+ $sql_search = " AND t1.id_agente IN ( -+ SELECT id_agente -+ FROM tagente -+ WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; -+ break; -+ case "postgresql": -+ $sql_search = " AND t1.id_agente IN ( -+ SELECT id_agente -+ FROM tagente -+ WHERE nombre LIKE '%$search_free%')"; -+ break; -+ case "oracle": -+ $sql_search = " AND t1.id_agente IN ( -+ SELECT id_agente -+ FROM tagente -+ WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; -+ break; -+ } -+ -+ - } - else { - $sql_search = ''; -@@ -899,7 +998,8 @@ - if ($select_status != -1) - $sql_search .= " AND estado = " . $select_status . " "; - -- $sql_search .= tags_get_acl_tags($config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1'); -+ $sql_search .= tags_get_acl_tags( -+ $config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1'); - - switch ($config["dbtype"]) { - case "mysql": -@@ -915,7 +1015,7 @@ - $sql_search.' - GROUP BY t1.nombre ORDER BY t1.nombre'); - break; -- case "oracle": -+ case "oracle": - $list = db_get_all_rows_sql(' - SELECT dbms_lob.substr(t1.nombre,4000,1) as nombre - FROM tagente_modulo t1, tagente t2, -@@ -950,15 +1050,16 @@ - $search_sql = sprintf(" AND tagente.nombre COLLATE utf8_general_ci LIKE '%%%s%%'", $search_free); - } - -- $sql = "SELECT DISTINCT ttag.name -- FROM ttag, ttag_module, tagente, tagente_modulo -- WHERE ttag.id_tag = ttag_module.id_tag -+ $sql = " -+ SELECT DISTINCT ttag.name -+ FROM ttag, ttag_module, tagente, tagente_modulo -+ WHERE ttag.id_tag = ttag_module.id_tag - AND tagente.id_agente = tagente_modulo.id_agente - AND tagente.disabled = 0 - AND ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo" . - $search_sql . -- $user_tags_sql . -- " ORDER BY ttag.name COLLATE utf8_general_ci ASC"; -+ $user_tags_sql . " -+ ORDER BY ttag.name ' . $order_collate . ' ASC"; - - $list = db_get_all_rows_sql($sql); - break; -@@ -1054,6 +1155,13 @@ - return false; - } - -+ $order_collate = ""; -+ switch ($config['dbtype']) { -+ case "mysql": -+ $order_collate = "COLLATE utf8_general_ci"; -+ break; -+ } -+ - //TODO CHANGE POLICY ACL FOR TAG ACL - $extra_sql = ''; - if ($extra_sql != '') { -@@ -1062,7 +1170,18 @@ - $groups_sql = implode(', ', $avariableGroupsIds); - - if ($search_free != '') { -- $search_sql = " AND tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%'"; -+ switch ($config['dbtype']) { -+ case "mysql": -+ $search_sql = " AND tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%'"; -+ break; -+ case "postgresql": -+ $search_sql = " AND tagente.nombre LIKE '%$search_free%'"; -+ break; -+ case "oracle": -+ $search_sql = " AND tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%'"; -+ break; -+ } -+ - } - else { - $search_sql = ''; -@@ -1078,14 +1197,14 @@ - } - } - -- $sql = agents_get_agents(array ( -+ $sql = agents_get_agents(array ( - 'id_grupo' => $id, - 'disabled' => 0, - 'status' => $statusSel, - 'search' => $search_sql), - array ('*'), - 'AR', -- array('field' => 'nombre COLLATE utf8_general_ci', 'order' => ' ASC'), -+ array('field' => 'nombre ' . $order_collate, 'order' => ' ASC'), - true); - break; - case 'os': -@@ -1097,7 +1216,7 @@ - 'search' => $search_sql), - array ('*'), - 'AR', -- array('field' => 'nombre COLLATE utf8_general_ci', 'order' => ' ASC'), -+ array('field' => 'nombre ' . $order_collate, 'order' => ' ASC'), - true); - break; - case 'module_group': -@@ -1117,7 +1236,7 @@ - FROM tagente_modulo - WHERE id_module_group = ' . $id . ')'; - -- $sql .= 'ORDER BY nombre COLLATE utf8_general_ci ASC'; -+ $sql .= 'ORDER BY nombre ' . $order_collate . ' ASC'; - - break; - case 'policies': -@@ -1144,7 +1263,7 @@ - AND tagente_estado.utimestamp != 0 - AND tagente_modulo.id_policy_module != 0 - AND tpolicy_modules.id_policy = ' . $id . ' -- group by tagente.id_agente -+ GROUP BY tagente.id_agente - having COUNT(*) > 0)'; - } - else if ($statusSel == 0) { -@@ -1152,11 +1271,12 @@ - // If status filter is NORMAL add void agents - $sql .= " UNION SELECT * FROM tagente - WHERE tagente.disabled = 0 -- AND tagente.id_agente NOT IN (SELECT tagente_estado.id_agente -+ AND tagente.id_agente NOT IN ( -+ SELECT tagente_estado.id_agente - FROM tagente_estado)"; - } - -- $sql .= 'ORDER BY nombre COLLATE utf8_general_ci ASC'; -+ $sql .= 'ORDER BY nombre ' . $order_collate . ' ASC'; - - break; - case 'module': -@@ -1188,7 +1308,7 @@ - ) - ', $name); - -- $sql .= 'ORDER BY nombre COLLATE utf8_general_ci ASC'; -+ $sql .= 'ORDER BY nombre ' . $order_collate . ' ASC'; - - break; - case 'tag': -@@ -1219,7 +1339,8 @@ - - $sql .= ' AND tagente.disabled = 0'. $search_sql; - -- $sql .= ' GROUP BY tagente.id_agente ORDER BY tagente.nombre COLLATE utf8_general_ci ASC'; -+ $sql .= ' GROUP BY tagente.id_agente -+ ORDER BY tagente.nombre ' . $order_collate . ' ASC'; - - break; - } -@@ -1234,25 +1355,36 @@ - // Get SQL for the second tree branch - function treeview_getSecondBranchSQL ($fatherType, $id, $id_father) { - global $config; -+ -+ $order_collate = ""; -+ switch ($config['dbtype']) { -+ case "mysql": -+ $order_collate = "COLLATE utf8_general_ci"; -+ break; -+ } -+ - switch ($fatherType) { - case 'group': - $sql = 'SELECT * - FROM tagente_modulo AS t1 -- INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo -+ INNER JOIN tagente_estado AS t2 -+ ON t1.id_agente_modulo = t2.id_agente_modulo - WHERE t1.id_agente = ' . $id; - $sql .= tags_get_acl_tags($config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1'); - break; - case 'os': - $sql = 'SELECT * - FROM tagente_modulo AS t1 -- INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo -+ INNER JOIN tagente_estado AS t2 -+ ON t1.id_agente_modulo = t2.id_agente_modulo - WHERE t1.id_agente = ' . $id; - $sql .= tags_get_acl_tags($config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1'); - break; - case 'module_group': - $sql = 'SELECT * - FROM tagente_modulo AS t1 -- INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo -+ INNER JOIN tagente_estado AS t2 -+ ON t1.id_agente_modulo = t2.id_agente_modulo - WHERE t1.id_agente = ' . $id . ' AND id_module_group = ' . $id_father; - $sql .= tags_get_acl_tags($config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1'); - break; -@@ -1275,8 +1407,10 @@ - $symbols = ' !"#$%&\'()*+,./:;<=>?@[\\]^{|}~'; - $name = $id_father; - for ($i = 0; $i < strlen($symbols); $i++) { -- $name = str_replace('_articapandora_'.ord(substr($symbols, $i, 1)).'_pandoraartica_', substr($symbols, $i, 1), $name); -- } -+ $name = str_replace('_articapandora_' . -+ ord(substr($symbols, $i, 1)) .'_pandoraartica_', -+ substr($symbols, $i, 1), $name); -+ } - switch ($config["dbtype"]) { - case "mysql": - $sql = 'SELECT * -@@ -1315,8 +1449,9 @@ - break; - } - -- // This line checks for initializated modules or (non-initialized) asyncronous modules -- $sql .= ' AND disabled = 0 AND (utimestamp > 0 OR id_tipo_modulo IN (21,22,23)) ORDER BY nombre COLLATE utf8_general_ci ASC'; -+ // This line checks for initializated modules or (non-initialized) asyncronous modules -+ $sql .= ' AND disabled = 0 AND (utimestamp > 0 OR id_tipo_modulo IN (21,22,23)) -+ ORDER BY nombre ' . $order_collate . ' ASC'; - return $sql; - } - ?> -Index: include/functions_config.php -=================================================================== ---- include/functions_config.php (revision 10314) -+++ include/functions_config.php (working copy) -@@ -182,6 +182,8 @@ - $error_update[] = __('Command Snapshot'); - if (!config_update_value ('server_log_dir', get_parameter('server_log_dir'))) - $error_update[] = __('Server logs directory'); -+ if (!config_update_value ('tutorial_mode', get_parameter('tutorial_mode'))) -+ $error_update[] = __('Tutorial mode'); - break; - case 'enterprise': - if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { -@@ -433,6 +435,10 @@ - $error_update[] = __('Default icon in GIS'); - if (!config_update_value ('autohidden_menu', get_parameter('autohidden_menu'))) - $error_update[] = __('Autohidden menu'); -+ if (!config_update_value ('fixed_header', get_parameter('fixed_header'))) -+ $error_update[] = __('Fixed header'); -+ if (!config_update_value ('fixed_menu', get_parameter('fixed_menu'))) -+ $error_update[] = __('Fixed menu'); - if (!config_update_value ('paginate_module', get_parameter('paginate_module'))) - $error_update[] = __('Paginate module'); - if (!config_update_value ('graphviz_bin_dir', get_parameter('graphviz_bin_dir'))) -@@ -781,17 +787,31 @@ - // config_update_value ('autoupdate', true); - // } - -- require_once ($config["homedir"]."/include/auth/mysql.php"); -+ require_once ($config["homedir"] . "/include/auth/mysql.php"); - -- // Next is the directory where "/attachment" directory is placed, to upload files stores. -- // This MUST be writtable by http server user, and should be in pandora root. -- // By default, Pandora adds /attachment to this, so by default is the pandora console home dir -+ -+ // Next is the directory where "/attachment" directory is placed, -+ // to upload files stores. This MUST be writtable by http server -+ // user, and should be in pandora root. By default, Pandora adds -+ // /attachment to this, so by default is the pandora console home -+ // dir. - if (!isset ($config['attachment_store'])) { -- config_update_value ( 'attachment_store', $config['homedir'].'/attachment'); -+ config_update_value('attachment_store', -+ $config['homedir'] . '/attachment'); - } -+ else { -+ //Fixed when the user moves the pandora console to another dir -+ //after the first uses. -+ if (!is_dir($config['attachment_store'])) { -+ config_update_value('attachment_store', -+ $config['homedir'] . '/attachment'); -+ } -+ } - -+ - if (!isset ($config['fontpath'])) { -- config_update_value ( 'fontpath', $config['homedir'].'/include/fonts/smallfont.ttf'); -+ config_update_value('fontpath', -+ $config['homedir'] . '/include/fonts/smallfont.ttf'); - } - - if (!isset ($config['style'])) { -@@ -869,7 +889,7 @@ - if (!isset ($config['netflow_nfexpire'])) { - config_update_value ( 'netflow_nfexpire', '/usr/bin/nfexpire'); - } -- -+ - if (!isset ($config['netflow_max_resolution'])) { - config_update_value ( 'netflow_max_resolution', '50'); - } -@@ -877,7 +897,7 @@ - if (!isset ($config['netflow_disable_custom_lvfilters'])) { - config_update_value ( 'netflow_disable_custom_lvfilters', 0); - } -- -+ - if (!isset ($config['netflow_max_lifetime'])) { - config_update_value ( 'netflow_max_lifetime', '5'); - } -@@ -919,13 +939,14 @@ - } - - if (!isset ($config['ldap_base_dn'])) { -- config_update_value ( 'ldap_base_dn', 'ou=People,dc=edu,dc=example,dc=org'); -+ config_update_value('ldap_base_dn', -+ 'ou=People,dc=edu,dc=example,dc=org'); - } - - if (!isset ($config['ldap_login_attr'])) { - config_update_value ( 'ldap_login_attr', 'uid'); - } -- -+ - if (!isset ($config['fallback_local_auth'])) { - config_update_value ( 'fallback_local_auth', '0'); - } -@@ -1030,11 +1051,11 @@ - config_update_value( 'api_password', ''); - } - -- if(defined('METACONSOLE')) { -+ if (defined('METACONSOLE')) { - // Customizable sections (Metaconsole) - enterprise_include_once ('include/functions_enterprise.php'); - $customizable_sections = enterprise_hook('enterprise_get_customizable_sections'); -- -+ - if($customizable_sections != ENTERPRISE_NOT_HOOK) { - foreach($customizable_sections as $k => $v) { - if (!isset ($config[$k])) { -@@ -1050,7 +1071,7 @@ - - if (!isset ($config['relative_path']) && (isset ($_POST['nick']) - || isset ($config['id_user'])) && isset($config['enterprise_installed'])) { -- -+ - $isFunctionSkins = enterprise_include_once ('include/functions_skins.php'); - if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { - -@@ -1153,7 +1174,8 @@ - } - - if (!isset($config['custom_report_front_logo'])) { -- config_update_value ('custom_report_front_logo', 'images/pandora_logo_white.jpg'); -+ config_update_value ('custom_report_front_logo', -+ 'images/pandora_logo_white.jpg'); - } - - if (!isset($config['custom_report_front_header'])) { -@@ -1161,7 +1183,8 @@ - } - - if (!isset($config['custom_report_front_firstpage'])) { -- config_update_value ('custom_report_front_firstpage', "<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="" . ui_get_full_url(false, false, false, false) . "/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>"); -+ config_update_value ('custom_report_front_firstpage', -+ "<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="" . ui_get_full_url(false, false, false, false) . "/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>"); - } - - if (!isset($config['custom_report_front_footer'])) { -@@ -1176,6 +1199,10 @@ - config_update_value ('networkmap_max_width', 900); - } - -+ if (!isset($config['tutorial_mode'])) { -+ config_update_value ('tutorial_mode', 'full'); -+ } -+ - /* Finally, check if any value was overwritten in a form */ - config_update_config(); - } -@@ -1312,7 +1339,7 @@ - $config["alert_cnt"]++; - $_SESSION["alert_msg"] .= ui_print_info_message( - array('title' => __("New update of Pandora Console"), -- 'message' => __('There is a new update please go to menu Administration and into extensions <a style="font-weight:bold;" href="index.php?sec=gsetup&sec2=godmode/update_manager_xxx/update_manager_xxx&tab=online">go to Update Manager</a> for more details.'), -+ 'message' => __('There is a new update please go to menu Administration and into extensions <a style="font-weight:bold;" href="index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online">go to Update Manager</a> for more details.'), - 'no_close' => true, 'force_style' => 'color: #000000 !important'), '', true); - } - } -Index: include/help/clippy/godmode_agentes_modificar_agente.php -=================================================================== ---- include/help/clippy/godmode_agentes_modificar_agente.php (revision 0) -+++ include/help/clippy/godmode_agentes_modificar_agente.php (revision 10417) -@@ -0,0 +1,71 @@ -+<?php -+ -+// Pandora FMS - http://pandorafms.com -+// ================================================== -+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas -+// Please see http://pandorafms.org for full contribution list -+ -+// This program is free software; you can redistribute it and/or -+// modify it under the terms of the GNU Lesser General Public License -+// as published by the Free Software Foundation; version 2 -+ -+// This program is distributed in the hope that it will be useful, -+// 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. -+ -+/** -+ * @package Include -+ * @subpackage Clippy -+ */ -+ -+function clippy_start_page() { -+ -+ $helps = array(); -+ -+ //================================================================== -+ //Help tour about the monitoring with a ping (step 1) -+ //------------------------------------------------------------------ -+ $helps['monitoring_server_step_1'] = array(); -+ $helps['monitoring_server_step_1']['steps'] = array(); -+ $helps['monitoring_server_step_1']['steps'][] = array( -+ 'element'=> '#clippy', -+ 'intro' => __('I show how to monitoring a server.') -+ ); -+ $helps['monitoring_server_step_1']['steps'][] = array( -+ 'element'=> 'input[name="search"]', -+ 'intro' => __('Please type a agent to save the modules for monitoring a server.') -+ ); -+ $helps['monitoring_server_step_1']['steps'][] = array( -+ 'element'=> 'input[name="srcbutton"]', -+ 'intro' => __('Maybe if you typped correctly the name, you can see the agent.') -+ ); -+ $helps['monitoring_server_step_1']['conf'] = array(); -+ $helps['monitoring_server_step_1']['conf']['showBullets'] = 0; -+ $helps['monitoring_server_step_1']['conf']['showStepNumbers'] = 1; -+ $helps['monitoring_server_step_1']['conf']['next_help'] = 'monitoring_server_step_2'; -+ //================================================================== -+ -+ -+ //================================================================== -+ //Help tour about the monitoring with a ping (step 2) -+ //------------------------------------------------------------------ -+ $helps['monitoring_server_step_2'] = array(); -+ $helps['monitoring_server_step_2']['steps'] = array(); -+ $helps['monitoring_server_step_2']['steps'][] = array( -+ 'element'=> '#clippy', -+ 'intro' => __('Please choose the agent that you have searched.') -+ ); -+ $helps['monitoring_server_step_2']['steps'][] = array( -+ 'element'=> '#agent_list', -+ 'intro' => __('Choose the agent, please click in the name.') -+ ); -+ $helps['monitoring_server_step_2']['conf'] = array(); -+ $helps['monitoring_server_step_2']['conf']['showBullets'] = 0; -+ $helps['monitoring_server_step_2']['conf']['showStepNumbers'] = 0; -+ $helps['monitoring_server_step_2']['conf']['next_help'] = 'monitoring_server_step_3'; -+ //================================================================== -+ -+ clippy_write_javascript_helps_steps($helps, false); -+} -+?> -\ No newline at end of file -Index: include/help/clippy/homepage.php -=================================================================== ---- include/help/clippy/homepage.php (revision 0) -+++ include/help/clippy/homepage.php (revision 10417) -@@ -0,0 +1,105 @@ -+<?php -+ -+// Pandora FMS - http://pandorafms.com -+// ================================================== -+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas -+// Please see http://pandorafms.org for full contribution list -+ -+// This program is free software; you can redistribute it and/or -+// modify it under the terms of the GNU Lesser General Public License -+// as published by the Free Software Foundation; version 2 -+ -+// This program is distributed in the hope that it will be useful, -+// 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. -+ -+/** -+ * @package Include -+ * @subpackage Clippy -+ */ -+ -+function clippy_start_page_homepage() { -+ global $config; -+ -+ $clippy_is_annoying = (int)get_cookie('clippy_is_annoying', 0); -+ -+ clippy_clean_help(); -+ -+ $helps = array(); -+ -+ //================================================================== -+ //Help tour with the some task for to help the user. -+ //------------------------------------------------------------------ -+ $helps['homepage'] = array(); -+ $helps['homepage']['steps'] = array(); -+ $helps['homepage']['steps'][] = array( -+ 'element'=> '#clippy', -+ 'intro' => __('Could I help you?<br/><br/>I am Pandorin, the annoying clippy for Pandora. You could follow my advices for to make common and basic tasks in Pandora.') . -+ '<div style="position:relative;"> -+ <div id="pandorin" style="display: block; position: absolute; left: -100px; top: 20px;">' . -+ html_print_image('images/pandorin.png', true) . -+ '</div> -+ </div>' -+ ); -+ $helps['homepage']['steps'][] = array( -+ 'element'=> '#clippy', -+ 'intro' => __('What task do you want to do?') . '<br/><br/>' . -+ '<ul style="text-align: left; margin-left: 3px; list-style-type: disc;">' . -+ '<li>' . -+ "<a href='javascript: clippy_go_link_show_help(\"index.php?sec=gagente&sec2=godmode/agentes/modificar_agente\", \"monitoring_server_step_1\");'>" . -+ //'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&clippy=monitoring_server">' . -+ __('Monitoring a server Linux/Windows with a pandora agent') . -+ '</a>' . -+ '</li>' . -+ '<li>' . __('Monitoring a switch with remote SNMP') . '</li>' . -+ '<li>' . __('Monitoring a Windows server with remote WMI ') . '</li>' . -+ '</ul>' . -+ '<div style="text-align: left;">'. -+ html_print_checkbox_extended -+ ('clippy_is_annoying', 1, $clippy_is_annoying, false, -+ 'set_clippy_annoying()', '', true) . -+ __('Please the clippy is annoying, I don\'t want see.') . -+ '</div>' -+ ); -+ $helps['homepage']['conf'] = array(); -+ $helps['homepage']['conf']['showBullets'] = 0; -+ $helps['homepage']['conf']['showStepNumbers'] = 0; -+ $helps['homepage']['conf']['name_obj_tour'] = 'intro_homepage'; -+ $helps['homepage']['conf']['other_js'] = " -+ function show_clippy() { -+ intro_homepage.start(); -+ } -+ -+ function set_clippy_annoying() { -+ checked = $('input[name=\'clippy_is_annoying\']').is(':checked'); -+ intro_homepage.exit(); -+ -+ if (checked) { -+ document.cookie = 'clippy_is_annoying=1'; -+ } -+ else { -+ document.cookie = 'clippy_is_annoying=0'; -+ } -+ } -+ "; -+ if ($config['logged']) { -+ $helps['homepage']['conf']['autostart'] = true; -+ } -+ else { -+ $helps['homepage']['conf']['autostart'] = false; -+ } -+ -+ if ($config["tutorial_mode"] == 'on_demand') { -+ $helps['homepage']['conf']['autostart'] = false; -+ } -+ -+ if ($clippy_is_annoying === 1) { -+ $helps['homepage']['conf']['autostart'] = false; -+ } -+ -+ //================================================================== -+ -+ clippy_write_javascript_helps_steps($helps); -+} -+?> -\ No newline at end of file -Index: include/help/clippy/godmode_agentes_configurar_agente.php -=================================================================== ---- include/help/clippy/godmode_agentes_configurar_agente.php (revision 0) -+++ include/help/clippy/godmode_agentes_configurar_agente.php (revision 10417) -@@ -0,0 +1,126 @@ -+<?php -+ -+// Pandora FMS - http://pandorafms.com -+// ================================================== -+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas -+// Please see http://pandorafms.org for full contribution list -+ -+// This program is free software; you can redistribute it and/or -+// modify it under the terms of the GNU Lesser General Public License -+// as published by the Free Software Foundation; version 2 -+ -+// This program is distributed in the hope that it will be useful, -+// 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. -+ -+/** -+ * @package Include -+ * @subpackage Clippy -+ */ -+ -+function clippy_start_page() { -+ $helps = array(); -+ -+ //================================================================== -+ //Help tour about the monitoring with a ping (step 3) -+ //------------------------------------------------------------------ -+ $helps['monitoring_server_step_3'] = array(); -+ $helps['monitoring_server_step_3']['steps'] = array(); -+ $helps['monitoring_server_step_3']['steps'][] = array( -+ 'element'=> '#clippy', -+ 'intro' => __('Now you must go to modules, don\'t worry I teach you.') -+ ); -+ $helps['monitoring_server_step_3']['steps'][] = array( -+ 'element'=> "img[alt='Modules']", -+ 'intro' => __('Please click in this tab.') -+ ); -+ $helps['monitoring_server_step_3']['conf'] = array(); -+ $helps['monitoring_server_step_3']['conf']['showBullets'] = 0; -+ $helps['monitoring_server_step_3']['conf']['showStepNumbers'] = 0; -+ $helps['monitoring_server_step_3']['conf']['next_help'] = 'monitoring_server_step_4'; -+ //================================================================== -+ -+ -+ //================================================================== -+ //Help tour about the monitoring with a ping (step 4) -+ //------------------------------------------------------------------ -+ $helps['monitoring_server_step_4'] = array(); -+ $helps['monitoring_server_step_4']['steps'] = array(); -+ $helps['monitoring_server_step_4']['steps'][] = array( -+ 'element'=> '#clippy', -+ 'intro' => __('Now you must create the module, don\'t worry I teach you.') -+ ); -+ $helps['monitoring_server_step_4']['steps'][] = array( -+ 'element'=> "#moduletype", -+ 'intro' => __('Choose the network server module.') -+ ); -+ $helps['monitoring_server_step_4']['steps'][] = array( -+ 'element'=> "input[name='updbutton']", -+ 'intro' => __('And click in this button.') -+ ); -+ $helps['monitoring_server_step_4']['conf'] = array(); -+ $helps['monitoring_server_step_4']['conf']['showBullets'] = 0; -+ $helps['monitoring_server_step_4']['conf']['showStepNumbers'] = 0; -+ $helps['monitoring_server_step_4']['conf']['next_help'] = 'monitoring_server_step_5'; -+ //================================================================== -+ -+ -+ //================================================================== -+ //Help tour about the monitoring with a ping (step 5) -+ //------------------------------------------------------------------ -+ $helps['monitoring_server_step_5'] = array(); -+ $helps['monitoring_server_step_5']['steps'] = array(); -+ $helps['monitoring_server_step_5']['steps'][] = array( -+ 'element'=> '#clippy', -+ 'intro' => __('Now you must create the module, don\'t worry I teach you.') -+ ); -+ $helps['monitoring_server_step_5']['steps'][] = array( -+ 'element'=> '#clippy', -+ 'intro' => __('We are going to fill the form.') -+ ); -+ $helps['monitoring_server_step_5']['steps'][] = array( -+ 'element'=> "#network_component_group", -+ 'intro' => __('Please choose the Network Management.') -+ ); -+ $helps['monitoring_server_step_5']['steps'][] = array( -+ 'element'=> "#network_component", -+ 'intro' => __('And choose the component with the name "Host Alive".') -+ ); -+ $helps['monitoring_server_step_5']['steps'][] = array( -+ 'element'=> "input[name='name']", -+ 'intro' => __('You can change the name.') -+ ); -+ $helps['monitoring_server_step_5']['steps'][] = array( -+ 'element'=> "input[name='ip_target']", -+ 'intro' => __('Check if this IP is the address of your machine.') -+ ); -+ $helps['monitoring_server_step_5']['steps'][] = array( -+ 'element'=> "input[name='crtbutton']", -+ 'intro' => __('And only to finish it is clicking this button.') -+ ); -+ $helps['monitoring_server_step_5']['conf'] = array(); -+ $helps['monitoring_server_step_5']['conf']['showBullets'] = 0; -+ $helps['monitoring_server_step_5']['conf']['showStepNumbers'] = 0; -+ $helps['monitoring_server_step_5']['conf']['next_help'] = 'monitoring_server_step_6'; -+ //================================================================== -+ -+ -+ //================================================================== -+ //Help tour about the monitoring with a ping (step 6) -+ //------------------------------------------------------------------ -+ $helps['monitoring_server_step_6'] = array(); -+ $helps['monitoring_server_step_6']['steps'] = array(); -+ $helps['monitoring_server_step_6']['steps'][] = array( -+ 'element'=> '#clippy', -+ 'intro' => __('Now, your module is just created.<br/> And the status color is <b>blue</b>.<br/>This meaning of blue status is the module is not executed for first time.<br/>In the next seconds if there is not a problem, the status color will change to red or green.') -+ ); -+ $helps['monitoring_server_step_6']['conf'] = array(); -+ $helps['monitoring_server_step_6']['conf']['showBullets'] = 0; -+ $helps['monitoring_server_step_6']['conf']['showStepNumbers'] = 0; -+ //================================================================== -+ -+ -+ clippy_write_javascript_helps_steps($helps, false); -+} -+?> -\ No newline at end of file -Index: include/help/clippy/module_unknow.php -=================================================================== ---- include/help/clippy/module_unknow.php (revision 0) -+++ include/help/clippy/module_unknow.php (revision 10417) -@@ -0,0 +1,55 @@ -+<?php -+ -+// Pandora FMS - http://pandorafms.com -+// ================================================== -+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas -+// Please see http://pandorafms.org for full contribution list -+ -+// This program is free software; you can redistribute it and/or -+// modify it under the terms of the GNU Lesser General Public License -+// as published by the Free Software Foundation; version 2 -+ -+// This program is distributed in the hope that it will be useful, -+// 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. -+ -+/** -+ * @package Include -+ * @subpackage Clippy -+ */ -+ -+function clippy_module_unknow() { -+ $helps = array(); -+ -+ //================================================================== -+ //Help tour about the monitoring with a ping (step 3) -+ //------------------------------------------------------------------ -+ $helps['module_unknow'] = array(); -+ $helps['module_unknow']['steps'] = array(); -+ $helps['module_unknow']['steps'][] = array( -+ 'element'=> '{clippy}', //The template to replace with the autogenerate id -+ 'intro' => '<table>' . -+ '<tr>' . -+ '<td class="context_help_title">' . -+ __('You have unknown modules in this agent.') . -+ '</td>' . -+ '</tr>' . -+ '<tr>' . -+ '<td class="context_help_body">' . -+ __('Unknown modules are modules which receive data normally at least in one occassion, but at this time are not receving data. Please check our troubleshoot help page to help you determine why you have unknown modules.') . -+ ui_print_help_icon ('context_module_unknow', true, '', 'images/help_w.png') . -+ '</td>' . -+ '</tr>' . -+ '</table>' -+ ); -+ $helps['module_unknow']['conf'] = array(); -+ $helps['module_unknow']['conf']['autostart'] = false; -+ $helps['module_unknow']['conf']['showBullets'] = 0; -+ $helps['module_unknow']['conf']['showStepNumbers'] = 0; -+ $helps['module_unknow']['conf']['name_obj_tour'] = '{clippy_obj}'; -+ //================================================================== -+ -+ clippy_write_javascript_helps_steps($helps, true); -+} -+?> -\ No newline at end of file -Index: include/help/en/help_context_module_unknow.php -=================================================================== ---- include/help/en/help_context_module_unknow.php (revision 0) -+++ include/help/en/help_context_module_unknow.php (revision 10417) -@@ -0,0 +1,24 @@ -+<?php -+/** -+ * @package Include/help/en -+ */ -+?> -+<h1>Unknown modules in Pandora</h1> -+<p> -+You may have unknown modules for many reasons. Unknown module is a special status for a module/monitor which means “I dont have recent data for this monitor and I should have data”. A monitor goes to unknown status when doesnt receive nothing in at least its interval (for example, 300 seconds) multiplied by two, in this case, if you doesn't receive nothing in ten minutes, monitor goes to unknown. -+</p> -+<p> -+These are a few cases where you can get unknown modules: -+</p> -+<ul style="list-style-type: disc; margin-left: 30px;"> -+ <li>Your pandora server is down. Restart it, dont forget to check /var/log/pandora/pandora_server.log to see why was down.</li> -+ <li>Your tentacle server is down, and cannot get data from your Pandora FMS agents installed in your remote servers.</li> -+ <li>You have a network problem between your agents and your server.</li> -+ <li>Your pandora fms agent is stopped and is not sending information to your server.</li> -+ <li>Your network is down, or the remote device you are trying to ask is down or changed it's IP address (for example for numerical SNMP remote queries).</li> -+ <li>Your agent is reporting a badly synchronized date. Means reports a timedate in the past and that messup everything.</li> -+ <li>The script / module before works now doesn't, that can be because something is happing in the agent, check it out.</li> -+</ul> -+<p> -+Sometimes UNKNOWN status can be useful to monitor, so you can setup alerts on UNKNOWN status to warn you about that. -+</p> -\ No newline at end of file -Index: include/help/en/help_snmp_alert_field1.php -=================================================================== ---- include/help/en/help_snmp_alert_field1.php (revision 10314) -+++ include/help/en/help_snmp_alert_field1.php (working copy) -@@ -14,10 +14,10 @@ - <br><br> - You can use these macros in FieldX (1-10) of any alert - <br><br> --<b>_DATA_</b>: Full trap<br> --<b>_AGENT_</b>: Agent name<br> --<b>_IP_</b>: IP Address<br> --<b>_TIMESTAMP_</b>: Trap date<br> --<b>_SNMP_OID_</b>: Trap OID<br> --<b>_SNMP_VALUE_</b>: Trap OID value<br> -+<b>_data_</b>: Full trap<br> -+<b>_agent_</b>: Agent name<br> -+<b>_address_</b>: IP Address<br> -+<b>_timestamp_</b>: Trap date<br> -+<b>_snmp_oid_</b>: Trap OID<br> -+<b>_snmp_value_</b>: Trap OID value<br> - </p> -Index: include/help/es/help_snmp_alert_field1.php -=================================================================== ---- include/help/es/help_snmp_alert_field1.php (revision 10314) -+++ include/help/es/help_snmp_alert_field1.php (working copy) -@@ -14,10 +14,10 @@ - <br><br> - Puede usar esas macros en los campos FieldX (1-10) de cualquier alerta. - <br><br> --<b>_DATA_</b>: Trap entero <br> --<b>_AGENT_</b>: Nombre del Agente <br> --<b>_IP_</b>: Dirección IP<br> --<b>_TIMESTAMP_</b>: Fecha trap<br> --<b>_SNMP_OID_</b>: OID del trap<br> --<b>_SNMP_VALUE_</b>: Valor del OID del trap<br> -+<b>_data_</b>: Trap entero <br> -+<b>_agent_</b>: Nombre del Agente <br> -+<b>_address_</b>: Dirección IP<br> -+<b>_timestamp_</b>: Fecha trap<br> -+<b>_snmp_oid_</b>: OID del trap<br> -+<b>_snmp_value_</b>: Valor del OID del trap<br> - </p> -Index: include/help/ja/help_snmp_alert_field1.php -=================================================================== ---- include/help/ja/help_snmp_alert_field1.php (revision 10314) -+++ include/help/ja/help_snmp_alert_field1.php (working copy) -@@ -7,10 +7,17 @@ - <p> - - データフィールドがある場合、アラートでそれを利用する必要があります。この目的のために、特別な _snmp_fX_ というマクロを利用できます。これらのマクロは、SNMP トラップアラート以外では無効です。 -- -+<br><br> - メッセージを生成するには、フィールド1に次のような設定をします。 -- --Chassis Alert: _snmp_f2_ in device _snmp_f1_ -- --これらのマクロは、任意のアラートのフィールドX (1 から 10) で利用できます。 -+<br><br> -+ Chassis Alert: _snmp_f2_ in device _snmp_f1_ -+<br><br> -+任意のアラートのフィールドX (1 から 10) で以下のマクロを利用できます。 -+<br><br> -+<b>_data_</b>: トラップ全体<br> -+<b>_agent_</b>: エージェント名<br> -+<b>_address_</b>: IP アドレス<br> -+<b>_timestamp_</b>: トラップのタイムスタンプ<br> -+<b>_snmp_oid_</b>: トラップの OID<br> -+<b>_snmp_value_</b>: トラップ OID の値<br> - </p> -Index: include/config_process.php -=================================================================== ---- include/config_process.php (revision 10314) -+++ include/config_process.php (working copy) -@@ -247,4 +247,30 @@ - // cases (reverse proxy, others ports...). - //====================================================================== - $config["homeurl"] = ui_get_full_url(false); -+ -+ -+//====================================================================== -+// Get the version of DB manager -+//====================================================================== -+switch ($config["dbtype"]) { -+ case "mysql": -+ if (!isset($config['quote_string'])) { -+ $config['db_quote_string'] = "\""; -+ } -+ break; -+ case "postgresql": -+ if (!isset($config['dbversion'])) { -+ $result = db_get_sql("select version();"); -+ $result_chunks = explode(" ", $result); -+ -+ $config['dbversion'] = $result_chunks[1]; -+ } -+ if (!isset($config['quote_string'])) { -+ $config['db_quote_string'] = "'"; -+ } -+ break; -+ case "oracle": -+ break; -+} -+//====================================================================== - ?> -Index: include/functions_db.php -=================================================================== ---- include/functions_db.php (revision 10314) -+++ include/functions_db.php (working copy) -@@ -65,7 +65,8 @@ - if ($return === false) { - if ($critical) { - $login_screen = 'error_authconfig'; -- require($config['homeurl'] . '/general/error_screen.php'); -+ -+ require($config['homedir'] . '/general/error_screen.php'); - exit; - } - else if ($error == 0) { -@@ -108,6 +109,22 @@ - } - } - -+function db_encapsule_fields_with_same_name_to_instructions($field) { -+ global $config; -+ -+ switch ($config["dbtype"]) { -+ case "mysql": -+ return mysql_encapsule_fields_with_same_name_to_instructions($field); -+ break; -+ case "postgresql": -+ return postgresql_encapsule_fields_with_same_name_to_instructions($field); -+ break; -+ case "oracle": -+ return oracle_encapsule_fields_with_same_name_to_instructions($field); -+ break; -+ } -+} -+ - /** - * Adds an audit log entry (new function in 3.0) - * -Index: include/functions_extensions.php -=================================================================== ---- include/functions_extensions.php (revision 10314) -+++ include/functions_extensions.php (working copy) -@@ -99,11 +99,11 @@ - $dir = ENTERPRISE_DIR.'/'.EXTENSIONS_DIR; - - if (file_exists ($dir)) -- $handle = @opendir ($dir); -+ $handle = @opendir ($dir); - - if (empty ($handle)) - return; -- -+ - $file = readdir ($handle); - $extensions = array (); - $ignores = array ('.', '..'); -@@ -117,6 +117,10 @@ - $file = readdir ($handle); - continue; - } -+ -+ if ($file == "update_manager.php") -+ continue; -+ - $extension['file'] = $file; - $extension['operation_menu'] = ''; - $extension['godmode_menu'] = ''; -Index: ChangeLog -=================================================================== ---- ChangeLog (revision 10314) -+++ ChangeLog (working copy) -@@ -1,3 +1,425 @@ -+2014-08-14 Koichiro Kikuchi <koichiro@rworks.jp> -+ -+ * pandora_console_install: Refactored code and added "fakeroot" -+ installation support. -+ -+2014-08-13 Junichi Satoh <junichi@rworks.jp> -+ -+ * pandoradb.sql: Fixed sql error with MySQL 5.6 when NO_ZERO_DATE -+ SQL mode is enabled. -+ -+2014-08-13 Junichi Satoh <junichi@rworks.jp> -+ -+ * mobile/operation/events.php: Improved to show event comment. -+ -+2014-08-12 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * index.php, operation/agentes/ver_agente.php, -+ operation/agentes/estado_monitores.php, general/header.php, -+ include/functions_clippy.php, include/functions_ui.php, -+ include/help/en/help_context_module_unknow.php, -+ include/help/clippy/module_unknow.php, include/styles/pandora.css, -+ include/javascript/intro.js: added first version of context help -+ interactive. -+ -+2014-08-12 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/functions_modules.php: killed some unicorns and magic -+ numbers into the function "modules_get_status". -+ -+2014-08-12 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * images/clippy_icon.png, images/pandorin.png, -+ include/help/clippy/homepage.php, general/header.php: yes there is -+ a octopus another time in Pandora. -+ -+2014-08-12 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/functions_clippy.php, -+ include/help/clippy/godmode_agentes_modificar_agente.php, -+ include/help/clippy/godmode_agentes_configurar_agente.php: fixed the -+ execution of help tour when never it started. Sorry the clippy is -+ less annoying. -+ -+2014-08-12 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/functions_clippy.php: changed to modal version. -+ -+ * include/javascript/intro.js: added feature to avoid the exit, and -+ the pull request to original repository is solicited too -+ (https://github.com/usablica/intro.js/pull/311). -+ -+2014-08-12 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * general/header.php, godmode/setup/setup_general.php, -+ include/functions_clippy.php, include/functions_config.php, -+ include/help/clippy/homepage.php: wip in the clippy. -+ -+2014-08-12 Sancho Lerena <slerena@artica.es> -+ -+ * pandoradb_data.sql: No more "welcome to Pandora FMS 5.0" -+ removed version code to allow the same text for next releases -+ :-) -+ -+2014-08-11 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/help/clippy/godmode_agentes_modificar_agente.php, -+ include/help/clippy/homepage.php, -+ include/help/clippy/godmode_agentes_configurar_agente.php, -+ include/functions_clippy.php: wip in the clippy. -+ -+2014-08-11 Vanessa Gil <vanessa.gil@artica.es> -+ -+ * godmode/agentes/agent_template.php: Fixed bug in FF -+ threshold to apply a template module. Ticket #871. -+ -+2014-08-11 Vanessa Gil <vanessa.gil@artica.es> -+ -+ * godmode/agentes/agent_conf_gis.php: Altitude coordinate by -+ default. Fixed bug #766. -+ -+2014-08-08 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/functions.php, -+ include/help/clippy/godmode_agentes_modificar_agente.php, -+ include/help/clippy/homepage.php, -+ include/help/clippy/godmode_agentes_configurar_agente.php, -+ include/javascript/intro.js, -+ include/javascript/introjs.css, -+ include/javascript/clippy.js, -+ include/functions_ui.php, -+ include/functions_clippy.php, -+ index.php, -+ general/header.php: first version of the new feature a annoying -+ clippy such as the lovely micro$oft mascot. -+ -+2014-08-07 Alejandro Gallardo <alejandro.gallardo@artica.es> -+ -+ * pandoradb.sql, -+ extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql, -+ extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql, -+ extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql: -+ Modified the decimal precision of the column "post_process" -+ for the table 'tagente_modulo' (Ticket #1124). -+ -+2014-08-06 Sancho Lerena <slerena@artica.es> -+ -+ * extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql, -+ pandoradb.sql: Fixed bug introduced in commit 9604 -+ altering tagente_modulo.post_process double precission -+ making conversion from bytes to megabytes impossible -+ (0,00000095367432). Pending to fix also the interface for -+ module creation/edition which also fails. This is critical -+ for SP1 release :( -+ -+2014-08-05 Alejandro Gallardo <alejandro.gallardo@artica.es> -+ -+ * general/main_menu.php: Improved the submenus state -+ persistence functionality. -+ -+2014-08-05 Alejandro Gallardo <alejandro.gallardo@artica.es> -+ -+ * general/main_menu.php: Fixed the menu position when -+ it's fixed and the header's not. -+ -+ * include/functions_graph.php, -+ include/graphs/pandora.d3.js: Added colors to the elements -+ depending on their status on the functions 'sunburst' and -+ 'graph_monitor_wheel'. -+ -+ * include/styles/pandora.css: Fixed the z-index of the -+ shortcut bar. -+ -+2014-08-04 Alejandro Gallardo <alejandro.gallardo@artica.es> -+ -+ * general/header.php: Now the header can be configured -+ to be fixed at the top. -+ -+ * general/main_menu.php: Now the menu can be configured -+ to be fixed at the left. -+ -+ * godmode/setup/setup_visuals.php, -+ include/functions_config.php: Added new options to -+ enable the fixed header and menu. -+ -+ * include/styles/menu.css, -+ include/styles/pandora.css: Changes on the menu styles. -+ -+ -+2014-08-04 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/functions_config.php, -+ include/functions_update_manager.php: some fixes into the update -+ manager. -+ -+2014-08-04 Alejandro Gallardo <alejandro.gallardo@artica.es> -+ -+ * general/main_menu.php: Now the submenus opened by the -+ user remain opened when navigating through Pandora FMS. -+ -+2014-08-04 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/config_process.php: added global config var for the -+ quote strings (for example, PostgreSQL). -+ -+2014-08-03 Junichi Satoh <junichi@rworks.jp> -+ -+ * include/functions_ui.php: Fixed that the fast forward and the going -+ to the last of pagination doesn't work in the modal window for module -+ data display. -+ And fixed incorrect offset calculation for the fast forward. -+ -+2014-08-02 Junichi Satoh <junichi@rworks.jp> -+ -+ * operation/agentes/estado_monitores.php: Fixed that module data -+ display does not work correctly when time range mode is selected -+ and paginated. -+ -+2014-08-02 Junichi Satoh <junichi@rworks.jp> -+ -+ * operation/agentes/estado_agente.php: Fixed sql error. -+ -+2014-08-01 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * godmode/agentes/planned_downtime.editor.php: fixed the acl. -+ -+ MERGED FROM THE BRANCH 5.0 -+ -+2014-07-31 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/functions_networkmap.php, include/functions_graph.php, -+ include/db/postgresql.php, include/db/oracle.php, -+ include/functions_api.php, extensions/agents_alerts.php, -+ operation/search_main.php, operation/search_agents.getdata.php, -+ operation/agentes/status_monitor.php, -+ operation/agentes/networkmap.topology.php, -+ operation/agentes/ver_agente.php, -+ operation/search_modules.getdata.php, operation/search_results.php, -+ operation/events/events_list.php, -+ godmode/alerts/alert_list.builder.php, -+ godmode/alerts/configure_alert_template.php, -+ godmode/modules/manage_network_components_form.php, -+ godmode/reporting/reporting_builder.php, -+ godmode/reporting/map_builder.php: tiny fixes for the improve the -+ support of postgreSQL databases. -+ -+2014-07-30 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/ajax/module.php: tiny fixes for the improve the support of -+ postgreSQL databases. -+ -+2014-07-30 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * godmode/servers/manage_recontask.php, -+ godmode/servers/manage_recontask_form.php, -+ include/functions_treeview.php, include/ajax/module.php, -+ include/functions_reporting.php, include/db/postgresql.php, -+ include/functions_servers.php, operation/agentes/estado_agente.php, -+ operation/tree.php: tiny fixes for the improve -+ the support of postgreSQL databases. -+ -+2014-07-29 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/functions_graph.php, include/functions_reporting.php, -+ operation/agentes/estado_monitores.php: tiny fixes for the improve -+ the support of postgreSQL databases. -+ -+2014-07-29 Junichi Satoh <junichi@rworks.jp> -+ -+ * include/functions_events.php: Fixed a bug that event's comment -+ is not shown when it includes newline. -+ -+2014-07-28 Junichi Satoh <junichi@rworks.jp> -+ -+ * operation/agentes/estado_agente.php: Fixed sql error. -+ -+2014-07-24 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * operation/snmpconsole/snmp_view.php, -+ operation/events/events_list.php, operation/incidents/incident.php, -+ extensions/files_repo.php, -+ extensions/files_repo/sql/files_repo.postgreSQL.sql, -+ extensions/files_repo/functions_files_repo.php, -+ extensions/files_repo/files_repo_list.php, -+ godmode/agentes/modificar_agente.php, -+ godmode/snmpconsole/snmp_alert.php, godmode/db/db_info.php, -+ include/functions_graph.php, include/functions_db.php, -+ include/db/postgresql.php, include/db/oracle.php, -+ include/db/mysql.php, include/functions_update_manager.php, -+ include/functions_events.php, include/graphs/functions_flot.php, -+ include/graphs/fgraph.php: tiny fixes for the improve the support of -+ postgreSQL databases. -+ -+2014-07-23 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * extensions/module_groups.php, extensions/agents_alerts.php, -+ include/functions_agents.php, operation/agentes/exportdata.php: tiny -+ fixes for the improve the support of postgreSQL databases. -+ -+ * include/functions_db.php: fix blank screen when the connection -+ fail, now it shows the error message again. -+ -+2014-07-23 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/config_process.php, operation/agentes/status_monitor.php, -+ operation/agentes/estado_generalagente.php, -+ operation/agentes/estado_agente.php: tiny fixes for the improve the -+ support of postgreSQL databases. -+ -+2014-07-23 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/functions_servers.php, include/functions_reporting.php: -+ tiny fixes for the improve the support of postgreSQL databases. -+ -+2014-07-23 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * operation/agentes/estado_generalagente.php: fixed the show the -+ agent access box when the agent is new without data. -+ -+ INCIDENT: #1078 -+ -+2014-07-23 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * godmode/agentes/agent_wizard.snmp_explorer.php, -+ godmode/agentes/module_manager_editor_plugin.php: some fixes for -+ the snmp version 3. -+ -+2014-07-22 Juan Manuel Ramon <juanmanuel.ramon@artica.es> -+ -+ * include/ajax/events.php: Fixed custom fields view in -+ metaconsole event extended view. -+ -+ This is my last commit for Pandora guys! Bye ;-) -+ -+2014-07-22 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * godmode/agentes/agent_wizard.snmp_explorer.php, -+ include/functions.php: some fixes for the snmp v3. -+ -+2014-07-22 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * godmode/agentes/agent_manager.php: fixed to show the QR code image -+ in the creation of a new agent. -+ -+2014-07-21 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * pandoradb.postgreSQL.sql: fixed the SQL. -+ -+2014-07-18 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/functions_graph.php, include/functions_reporting.php: -+ fixed to show the unknown graph in simple graph. -+ -+ INCIDENT: #1035 -+ -+2014-07-17 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/auth/ldap.php, include/auth/mysql.php: fixed the -+ parameters with white spaces. -+ -+ INCIDENT: #1063 -+ -+2014-07-17 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/functions_groups.php: added parameter to avoid the check -+ the propagation in the function "groups_get_childrens". -+ -+ * include/functions_networkmap.php, -+ operation/agentes/networkmap.php, -+ operation/agentes/networkmap.topology.php: added feature to show the -+ agents in subgroups (or not). -+ -+ INCIDENT: #1018 -+ -+2014-07-14 Vanessa Gil <vanessa.gil@artica.es> -+ -+ * godmode/admin_access_log.php -+ include/functions.php: Added export to csv. -+ -+ * godmode/audit_log_csv.php: Added file. -+ -+2014-07-10 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/functions_api.php: fixed the call "set_update_agent" -+ because before the call get the id_server but this data never -+ was translated to name_server. And added id_server into the call -+ "get_pandora_servers" in the last position. -+ -+2014-07-10 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/functions_api.php: restored the parameter name server in -+ the api call "set_new_agent", thanks KOSAKA. -+ -+2014-07-10 Junichi Satoh <junichi@rworks.jp> -+ -+ * include/help/ja/help_snmp_alert_field1.php: Updated help. -+ -+2014-07-09 Mario Pulido <mario.pulido@artica.es> -+ -+ * include/help/ja/help_snmp_alert_field1.php: Added macros snmp alert help -+ -+2014-07-09 Junichi Satoh <junichi@rworks.jp> -+ -+ * include/help/ja/help_snmp_alert_field1.php: Updated help. -+ -+2014-07-09 Junichi Satoh <junichi@rworks.jp> -+ -+ * include/functions_events.php, operation/events/events.php, -+ operation/events/events_list.php: Replaced json_encode() -+ with io_json_mb_encode() to avoid invalid encoding with multi-byte -+ characters. -+ -+2014-07-08 Mario Pulido <mario.pulido@artica.es> -+ -+ * include/help/en/help_snmp_alert_field1.php, -+ include/help/es/help_snmp_alert_field1.php: Change macros snmp alert help -+ -+2014-07-08 Hirofumi Kosaka <kosaka@rworks.jp> -+ -+ * include/functions_api.php: Fixed that 'set enable_module' -+ had not worked. -+ -+ MERGED FROM BRANCH 5.0 -+ -+2014-07-07 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/functions_visual_map.php: show in the tooltip of -+ "static graph" the last value of module. -+ -+ INCIDENT: #1014 -+ -+2014-07-07 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * godmode/setup/license.php: fixed the white screen. -+ -+ INCIDENT: #996 -+ -+2014-07-07 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * operation/agentes/alerts_status.php: fixed the pagination with -+ the column sorted. -+ -+ INCIDENT: #977 -+ -+2014-07-04 Alejandro Gallardo <alejandro.gallardo@artica.es> -+ -+ * index.php: Now the shortcut bar isn't loaded while -+ the pandora console is in fullscreen mode. -+ -+2014-07-04 Ramon Novoa <rnovoa@artica.es> -+ -+ * include/functions_graph.php: When drawing charts, propagate the last value -+ in the database instead of the value of the last interval (which is the -+ average value for that interval). -+ -+ * operation/agentes/estado_monitores.php: Show events for boolean modules by default. -+ -+2014-07-04 Miguel de Dios <miguel.dedios@artica.es> -+ -+ * include/functions_config.php, include/functions_extensions.php: -+ fixed the show old update manager and set the correct link in the -+ header warning message to update manager. -+ - 2014-06-30 Koichiro KIKUCHI <koichiro@rworks.jp> - - * operation/agentes/estado_monitores.php, -Index: pandoradb.sql -=================================================================== ---- pandoradb.sql (revision 10314) -+++ pandoradb.sql (working copy) -@@ -203,7 +203,7 @@ - `plugin_pass` text, - `plugin_parameter` text, - `id_plugin` int(10) default '0', -- `post_process` double default NULL, -+ `post_process` double(18,15) default 0, - `prediction_module` bigint(14) default '0', - `max_timeout` int(4) unsigned default '0', - `max_retries` int(4) unsigned default '0', -@@ -490,7 +490,7 @@ - CREATE TABLE IF NOT EXISTS `talert_special_days` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_group` INT(10) NOT NULL DEFAULT 0, -- `date` date NOT NULL DEFAULT '0000-00-00', -+ `date` date NOT NULL DEFAULT '1970-01-01', - `same_day` enum('monday','tuesday','wednesday','thursday','friday','saturday','sunday') NOT NULL DEFAULT 'sunday', - `description` text, - PRIMARY KEY (`id`) -Index: pandoradb.postgreSQL.sql -=================================================================== ---- pandoradb.postgreSQL.sql (revision 10314) -+++ pandoradb.postgreSQL.sql (working copy) -@@ -26,7 +26,8 @@ - - --\c "pandora" - --CREATE OR REPLACE LANGUAGE plpgsql; -+-- For previous PostgreSQL version 9.0 -+CREATE LANGUAGE plpgsql; - - CREATE OR REPLACE FUNCTION unix_timestamp(TIMESTAMP without time zone = CURRENT_TIMESTAMP) RETURNS double precision AS 'SELECT ceil(date_part(''epoch'', $1)); ' LANGUAGE SQL; - -@@ -240,10 +241,10 @@ - "disabled_types_event" TEXT default '', - "module_macros" TEXT default '', - "min_ff_event_normal" INTEGER default 0, -- "min_ff_event_warning" INTEGER default 0, -- "min_ff_event_critical" INTEGER default 0, -- "each_ff" SMALLINT default 0, -- "ff_timeout" INTEGER unsigned default 0 -+ "min_ff_event_warning" INTEGER default 0, -+ "min_ff_event_critical" INTEGER default 0, -+ "each_ff" SMALLINT default 0, -+ "ff_timeout" INTEGER default 0 - ); - CREATE INDEX "tagente_modulo_id_agente_idx" ON "tagente_modulo"("id_agente"); - CREATE INDEX "tagente_modulo_id_tipo_modulo_idx" ON "tagente_modulo"("id_tipo_modulo"); -@@ -1595,7 +1596,7 @@ - -- ----------------------------------------------------- - -- Table `tevent_response` - -- ----------------------------------------------------- --CREATE TABLE IF NOT EXISTS "tevent_response" ( -+CREATE TABLE "tevent_response" ( - "id" SERIAL NOT NULL PRIMARY KEY, - "name" varchar(600) NOT NULL default '', - "description" TEXT, -@@ -1611,7 +1612,7 @@ - -- --------------------------------------------------------------------- - -- Table "tcategory" - -- --------------------------------------------------------------------- --CREATE TABLE IF NOT EXISTS "tcategory" ( -+CREATE TABLE "tcategory" ( - "id" SERIAL NOT NULL PRIMARY KEY, - "name" varchar(600) NOT NULL default '' - ); -Index: pandora_console_install -=================================================================== ---- pandora_console_install (revision 10314) -+++ pandora_console_install (working copy) -@@ -11,92 +11,103 @@ - - PI_VERSION=4.0 - FORCE=0 -+DESTDIR="" - LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"` - MODE=$1 - -+# -+# set_global_vars -+# Check platform and set DISTRO, OS_VERSION, WWWUSER, WWWGROUP, WWWROOT, -+# PANDORA_HOME and PANDORA_HOME_GROUP. -+# -+set_global_vars () { -+ DISTRO="GENERIC" - --get_distro () { -- -- OS_NAME=`uname -s` -- -- # Get Linux Distro type and version -- if [ -f "/etc/SuSE-release" ] -- then -- OS_VERSION=`cat /etc/SuSE-release | grep VERSION | cut -f 3 -d " "` -- LINUX_DISTRO=SUSE -- else -- if [ -f "/etc/lsb-release" ] && [ ! -f "/etc/redhat-release" ] -+ case `uname -s` in -+ Linux) -+ # Get Linux Distro type and version -+ if [ -f "/etc/SuSE-release" ] - then -+ OS_VERSION=`cat /etc/SuSE-release | grep VERSION | cut -f 3 -d " "` -+ DISTRO=SUSE -+ elif [ -f "/etc/lsb-release" ] && [ ! -f "/etc/redhat-release" ] -+ then - OS_VERSION=`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -f 2 -d "="` -- LINUX_DISTRO=UBUNTU -+ DISTRO=UBUNTU - OS_VERSION="UBUNTU $OS_VERSION" -- else -- if [ -f "/etc/debian_version" ] -- then -- OS_VERSION=`cat /etc/debian_version` -- OS_VERSION="DEBIAN $OS_VERSION" -- LINUX_DISTRO=DEBIAN -- else -- if [ -f "/etc/fedora-release" ] -- then -- OS_VERSION=`cat /etc/fedora-release | cut -f 4 -d " "` -- OS_VERSION="FEDORA $OS_VERSION" -- LINUX_DISTRO=FEDORA -- else -- if [ -f "/etc/redhat-release" ] -- then -- LINUX_DISTRO=RHEL_CENTOS -- else -- if [ "$OS_NAME" = "FreeBSD" ] -- then -- LINUX_DISTRO=FreeBSD -- else -- if [ "$OS_NAME" = "NetBSD" ] -- then -- LINUX_DISTRO=NetBSD -- else -- LINUX_DISTRO=GENERIC -- fi -- fi -- OS_VERSION=`uname -r` -- fi -- fi -- fi -+ elif [ -f "/etc/debian_version" ] -+ then -+ OS_VERSION=`cat /etc/debian_version` -+ OS_VERSION="DEBIAN $OS_VERSION" -+ DISTRO=DEBIAN -+ elif [ -f "/etc/fedora-release" ] -+ then -+ OS_VERSION=`cat /etc/fedora-release | cut -f 4 -d " "` -+ OS_VERSION="FEDORA $OS_VERSION" -+ DISTRO=FEDORA -+ elif [ -f "/etc/redhat-release" ] -+ then -+ DISTRO=RHEL_CENTOS - fi -+ case $DISTRO in -+ SUSE) -+ WWWUSER=wwwrun -+ WWWGROUP=www -+ PANDORA_HOME_GROUP=root -+ WWWROOT=/srv/www/htdocs -+ ;; -+ UBUNTU|DEBIAN) -+ WWWUSER=www-data -+ WWWGROUP=www-data -+ WWWROOT=/var/www -+ ;; -+ FEDORA|RHEL_CENTOS) -+ WWWUSER=apache -+ WWWGROUP=apache -+ WWWROOT=/var/www/html -+ ;; -+ esac -+ ;; -+ FreeBSD) -+ DISTRO=FreeBSD -+ WWWUSER=www -+ WWWGROUP=www -+ WWWROOT=/usr/local/www -+ -+ local apache -+ for apache in apache24 apache22 -+ do -+ [ ! -d $WWWROOT/$apache ] && continue -+ WWWROOT=$WWWROOT/$apache/data -+ break -+ done -+ ;; -+ NetBSD) -+ DISTRO=NetBSD -+ WWWUSER=www -+ WWWGROUP=www -+ WWWROOT=/usr/pkg/share/httpd/htdocs -+ ;; -+ esac -+ -+ # backward compatible defaults (Assuming SUSE) -+ if [ "$DISTRO" = GENERIC ] -+ then -+ WWWUSER=wwwrun -+ WWWGROUP=www -+ WWWROOT=/srv/www/htdocs -+ PANDORA_HOME_GROUP=root - fi -- echo $LINUX_DISTRO -+ # Use WWWGROUP as default for PANDORA_HOME_GROUP -+ : ${PANDORA_HOME_GROUP:=$WWWGROUP} -+ -+ OS_VERSION=`uname -r` -+ PANDORA_HOME="$WWWROOT/pandora_console" - } - - uninstall () { -- DISTRO=`get_distro` -+ set_global_vars - -- if [ "$DISTRO" = "UBUNTU" ] -- then -- PANDORA_HOME=/var/www/pandora_console -- else -- if [ "$DISTRO" = "RHEL_CENTOS" ] -- then -- PANDORA_HOME=/var/www/html/pandora_console -- else -- if [ "$DISTRO" = "FEDORA" ] -- then -- PANDORA_HOME=/var/www/html/pandora_console -- else -- if [ "$DISTRO" = "FreeBSD" ] -- then -- PANDORA_HOME="/usr/local/www/data/pandora_console /usr/local/www/apache24/data/pandora_console /usr/local/www/apache22/data/pandora_console" -- else -- if [ "$DISTRO" = "NetBSD" ] -- then -- PANDORA_HOME="/usr/pkg/share/httpd/htdocs/pandora_console" -- else -- PANDORA_HOME=/srv/www/htdocs/pandora_console -- fi -- fi -- fi -- fi -- fi -- - echo "Removing Pandora FMS Console" - rm -Rf $PANDORA_HOME - echo "You need to drop manually pandora database from your Database server" -@@ -104,81 +115,43 @@ - } - - install () { -+ set_global_vars - -- DISTRO=`get_distro` - OLDFILENAMETMP=`date +"%Y-%m-%d"` -- -- if [ "$DISTRO" = "UBUNTU" ] -- then -- PANDORA_HOME=/var/www/pandora_console -- PANDORA_CONF=$PANDORA_HOME/include/config.php -- else -- if [ "$DISTRO" = "RHEL_CENTOS" ] -- then -- PANDORA_HOME=/var/www/html/pandora_console -- PANDORA_CONF=$PANDORA_HOME/include/config.php -- else -- if [ "$DISTRO" = "FEDORA" ] -- then -- PANDORA_HOME=/var/www/html/pandora_console -- PANDORA_CONF=$PANDORA_HOME/include/config.php -- else -- if [ "$DISTRO" = "FreeBSD" ] -- then -- if [ -d /usr/local/www/apache24 ] -- then -- PANDORA_HOME=/usr/local/www/apache24/data/pandora_console -- else -- if [ -d /usr/local/www/apache22 ] -- then -- PANDORA_HOME=/usr/local/www/apache22/data/pandora_console -- else -- PANDORA_HOME=/usr/local/www/data/pandora_console -- fi -- fi -- PANDORA_CONF=$PANDORA_HOME/include/config.php -- else -- if [ "$DISTRO" = "NetBSD" ] -- then -- PANDORA_HOME=/usr/pkg/share/httpd/htdocs/pandora_console -- PANDORA_CONF=$PANDORA_HOME/include/config.php -- else -- PANDORA_HOME=/srv/www/htdocs/pandora_console -- PANDORA_CONF=$PANDORA_HOME/include/config.php -- fi -- fi -- fi -- fi -- fi -+ PANDORA_CONF=$PANDORA_HOME/include/config.php - - echo "Detecting operating system: $DISTRO" - -- if [ -f $PANDORA_HOME ] && [ "$FORCE" = "0" ] -+ if [ -f $DESTDIR$PANDORA_HOME ] && [ "$FORCE" = "0" ] - then - echo "Seems that default dir already exists. Please use --force to" -- echo "force installer to install on $PANDORA_HOME" -+ echo "force installer to install on $DESTDIR$PANDORA_HOME" - exit - else -- echo "Checking default dir $PANDORA_HOME..." -+ echo "Checking default dir $DESTDIR$PANDORA_HOME..." - fi - -- # Create directories -- echo "Creating Pandora FMS Console home directory at $PANDORA_HOME ..." -- mkdir -p $PANDORA_HOME 2> /dev/null -- -- # Copying Pandora FMS console -- echo "Copying Pandora FMS Console to $PANDORA_HOME.." -- cp -R * $PANDORA_HOME -- chmod -R u+rwX,g+rX,g-w,o-rwx $PANDORA_HOME -- -- -- # Creating 'pandora' user -+ # Check and create 'pandora' user if needed - id pandora 2> /dev/null - if [ $? -eq 0 ]; then - echo " " - echo "User pandora does exist, skipping this step" -+ elif [ "$DESTDIR" ] -+ then -+ # don't create user with "fakeroot" installation -+ echo "User 'pandora' does not exist. All chown operations may fail." -+ echo "You should manualy set proper ownership to $DESTDIR$PANDORA_HOME and $DESTDIR$PANDORA_SPOOL if it's required." -+ echo - else -- echo "Creating 'pandora' user" -+ echo "Are you sure we can create a standard 'pandora' user locally? [y/N]" -+ read AREYOUSURE -+ if [ "$AREYOUSURE" != "y" ] -+ then -+ echo "Please create the 'pandora' user manually according to your authentication scheme, then start again the installation" -+ echo "Aborting..." -+ exit 1 -+ fi -+ # creating user - if [ "$DISTRO" = "FreeBSD" ] - then - echo "pandora:41121:::::Pandora FMS:/home/pandora:/usr/sbin/nologin:" | adduser -f - -w no 2> /dev/null -@@ -190,46 +163,31 @@ - fi - fi - -- if [ ! -d /var/spool/pandora ] -- then -- mkdir -p /var/spool/pandora -- fi -+ # Create directories -+ echo "Creating Pandora FMS Console home directory at $DESTDIR$PANDORA_HOME ..." -+ mkdir -p $DESTDIR$PANDORA_HOME 2> /dev/null - -+ # Copying Pandora FMS console -+ echo "Copying Pandora FMS Console to $DESTDIR$PANDORA_HOME.." -+ cp -R * $DESTDIR$PANDORA_HOME -+ chmod -R u+rwX,g+rX,g-w,o-rwx $DESTDIR$PANDORA_HOME -+ -+ # prepare /var/spool/pandora/data_in and sub directories -+ for subdir in collections conf md5 netflow -+ do -+ [ ! -d $DESTDIR/var/spool/pandora/data_in/$subdir ] && mkdir -p $DESTDIR/var/spool/pandora/data_in/$subdir -+ done -+ - #Ownership -- if [ "$DISTRO" = "UBUNTU" ] -- then -- chown -R www-data:root $PANDORA_HOME -- chown -R pandora:www-data /var/spool/pandora/ -- else -- if [ "$DISTRO" = "RHEL_CENTOS" ] -- then -- chown -R apache:apache $PANDORA_HOME -- chown -R pandora:apache /var/spool/pandora/ -- else -- if [ "$DISTRO" = "FEDORA" ] -- then -- chown -R apache:apache $PANDORA_HOME -- chown -R pandora:apache /var/spool/pandora/ -- else -- if [ "$DISTRO" = "FreeBSD" -o "$DISTRO" = "NetBSD" ] -- then -- chown -R www:www $PANDORA_HOME -- chown -R pandora:www /var/spool/pandora/ -- else -- # Assuming SUSE -- chown -R wwwrun:root $PANDORA_HOME -- chown -R pandora:www /var/spool/pandora/ -- fi -- fi -- fi -- fi -+ chown -R $WWWUSER:$PANDORA_HOME_GROUP $DESTDIR$PANDORA_HOME 2> /dev/null -+ chown -R pandora:$WWWGROUP $DESTDIR/var/spool/pandora/ 2> /dev/null - - echo "Setting secure permissions for Pandora FMS spool dir..." -- chmod -R u+rwX,g+rwX,o-rwx /var/spool/pandora/ -+ chmod -R u+rwX,g+rwX,o-rwx $DESTDIR/var/spool/pandora/ - - echo "Done." - echo " " -- echo "You have your Pandora FMS console installed on $PANDORA_HOME." -+ echo "You have your Pandora FMS console installed on $DESTDIR$PANDORA_HOME." - echo " " - echo "Now you can setup your Pandora FMS console and install" - echo "database using a browser and point to: " -@@ -240,17 +198,40 @@ - } - - help () { -+ echo "Syntax": -+ echo -+ echo " ./pandora_console_install < --mode > [ --option ]" -+ echo " " -+ echo "Modes:" -+ echo - echo " --force-install To force installation if already installed on this system" - echo " --install To install Pandora FMS Console on this system" -- echo " " -+ echo " --uninstall To uninstall/remove Pandora FMS Console on this System" -+ echo -+ echo "Option:" -+ echo -+ echo " --destdir DIR Specify root directory for \"fakeroot\" installation" -+ echo - } - - # Script banner at start - echo " " --echo "Pandora FMS Console Installer $PI_VERSION (c) 2008-2011 ArticaST" -+echo "Pandora FMS Console Installer $PI_VERSION (c) 2008-2014 ArticaST" - echo "This program is licensed under GPL2 Terms. http://pandorafms.com" - echo " " - -+# parse option -+if [ "$2" = "--destdir" ] -+then -+ if [ -z "$3" ] -+ then -+ echo '"--datadir" option requires an argument' -+ help -+ exit 1 -+ fi -+ DESTDIR="$3" -+fi -+ - case "$MODE" in - - '--force-install') -Index: index.php -=================================================================== ---- index.php (revision 10314) -+++ index.php (working copy) -@@ -355,6 +355,7 @@ - * Load here, because if not, some extensions not load well, I don't why. - */ - -+$config['logged'] = false; - extensions_load_extensions ($config['extensions']); - if ($process_login) { - /* Call all extensions login function */ -@@ -376,6 +377,8 @@ - - //Set the initial global counter for chat. - users_get_last_global_counter('session'); -+ -+ $config['logged'] = true; - } - - //Get old parameters before navigation. -@@ -562,7 +565,9 @@ - require("general/logon_ok.php"); - } - } -- require("general/shortcut_bar.php"); -+ if ($config["pure"] == 0) { -+ require("general/shortcut_bar.php"); -+ } - } - - if ($config["pure"] == 0) { -@@ -583,6 +588,11 @@ - require ("general/footer.php"); - echo '</div>'; - } -+ -+/// Clippy function -+require_once('include/functions_clippy.php'); -+clippy_start($sec2); -+ - while (@ob_end_flush ()); - - db_print_database_debug (); -Index: extensions/agents_alerts.php -=================================================================== ---- extensions/agents_alerts.php (revision 10314) -+++ extensions/agents_alerts.php (working copy) -@@ -172,13 +172,18 @@ - echo "<th width='20px' style='vertical-align:top; padding-top: 35px;' rowspan='".($nagents+1)."'><a href='index.php?sec=extensions&sec2=extensions/agents_alerts&refr=0&hor_offset=".$new_hor_offset."&offset=".$offset."&group_id=".$group_id."'>".html_print_image("images/darrowleft.png",true, array('title' => __('Previous templates')))."</a> </th>"; - } - -+ $templates_raw = array(); - if (!empty($templates)) { - $sql = sprintf('SELECT id, name -- FROM talert_templates WHERE id IN (%s)',implode(',',array_keys($templates))); -+ FROM talert_templates -+ WHERE id IN (%s)',implode(',',array_keys($templates))); - - $templates_raw = db_get_all_rows_sql($sql); - } - -+ if (empty($templates_raw)) -+ $templates_raw = array(); -+ - $alerts = array(); - $ntemplates = 0; - foreach ($templates_raw as $temp) { -@@ -225,7 +230,7 @@ - if($anyfired) { - $cellstyle = 'background:'.COL_ALERTFIRED.';'; - } -- -+ - echo '<td style="text-align:center;'.$cellstyle.'"> '; - - $uniqid = uniqid(); -@@ -266,9 +271,12 @@ - $data[0] = modules_get_agentmodule_name ($alert['id_agent_module']); - - $actions = alerts_get_alert_agent_module_actions ($alert['id']); -- -- $actionDefault = db_get_value_sql("SELECT id_alert_action FROM talert_templates WHERE id = " . $alert['id_alert_template']); - -+ $actionDefault = db_get_value_sql(" -+ SELECT id_alert_action -+ FROM talert_templates -+ WHERE id = " . $alert['id_alert_template']); -+ - $actionText = ''; - - if (!empty($actions)) { -@@ -284,10 +292,13 @@ - } - else { - if (!empty($actionDefault)) { -- $actionText = db_get_sql ("SELECT name FROM talert_actions WHERE id = $actionDefault"). " <i>(".__("Default") . ")</i>"; -+ $actionText = db_get_sql ("SELECT name -+ FROM talert_actions -+ WHERE id = $actionDefault") . -+ " <i>(" . __("Default") . ")</i>"; - } - } -- -+ - $data[1] = $actionText; - $data[2] = ui_print_timestamp ($alert["last_fired"], true); - -Index: extensions/files_repo/sql/files_repo.postgreSQL.sql -=================================================================== ---- extensions/files_repo/sql/files_repo.postgreSQL.sql (revision 10314) -+++ extensions/files_repo/sql/files_repo.postgreSQL.sql (working copy) -@@ -1,2 +1,2 @@ --CREATE TABLE IF NOT EXISTS "tfiles_repo" ("id" SERIAL NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "description" VARCHAR(500) NULL default '', "hash" VARCHAR(8) NULL default ''); --CREATE TABLE IF NOT EXISTS "tfiles_repo_group" ("id" SERIAL NOT NULL PRIMARY KEY, "id_file" INTEGER NOT NULL REFERENCES tfiles_repo("id") ON DELETE CASCADE, "id_group" INTEGER NOT NULL); -+CREATE TABLE "tfiles_repo" ("id" SERIAL NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "description" VARCHAR(500) NULL default '', "hash" VARCHAR(8) NULL default ''); -+CREATE TABLE "tfiles_repo_group" ("id" SERIAL NOT NULL PRIMARY KEY, "id_file" INTEGER NOT NULL REFERENCES tfiles_repo("id") ON DELETE CASCADE, "id_group" INTEGER NOT NULL); -Index: extensions/files_repo/functions_files_repo.php -=================================================================== ---- extensions/files_repo/functions_files_repo.php (revision 10314) -+++ extensions/files_repo/functions_files_repo.php (working copy) -@@ -125,31 +125,33 @@ - - function files_repo_get_files ($filter = false, $count = false) { - global $config; -- -+ - // Don't use the realpath for the download links! - $files_repo_path = io_safe_output($config['attachment_store'])."/files_repo"; -- -- $sql = "SELECT * FROM tfiles_repo " . db_format_array_where_clause_sql($filter, "AND", "WHERE"); -+ -+ $sql = "SELECT * -+ FROM tfiles_repo -+ " . db_format_array_where_clause_sql($filter, "AND", "WHERE"); - $files = db_get_all_rows_sql($sql); -- -+ - if ($files === false) - $files = array(); -- -+ - $user_groups = files_repo_get_user_groups($config['id_user']); -- -+ - $files_data = array(); - foreach ($files as $file) { -- -+ - $file_groups = files_repo_get_file_groups($file['id']); - $permission = files_repo_check_file_acl ($file['id'], $config['id_user'], $file_groups, $user_groups); - if (!$permission) { - continue; - } -- -+ - $data = array(); - $data['name'] = $file['name']; - $data['description'] = $file['description']; -- $data['location'] = $files_repo_path."/".$file['id']."_".$data['name']; -+ $data['location'] = $files_repo_path . "/" . $file['id']."_".$data['name']; - // Size in bytes - $data['size'] = filesize($data['location']); - // Last modification time in unix timestamp -@@ -158,7 +160,7 @@ - $data['hash'] = $file['hash']; - $files_data[$file['id']] = $data; - } -- -+ - if ($count) { - $files_data = count($files_data); - } -Index: extensions/files_repo/files_repo_list.php -=================================================================== ---- extensions/files_repo/files_repo_list.php (revision 10314) -+++ extensions/files_repo/files_repo_list.php (working copy) -@@ -17,16 +17,19 @@ - - global $config; - --$full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/"; --require_once ($full_extensions_dir."files_repo/functions_files_repo.php"); -+$full_extensions_dir = $config['homedir'] . "/" . EXTENSIONS_DIR . "/"; -+require_once ($full_extensions_dir . -+ "files_repo/functions_files_repo.php"); - - $offset = (int) get_parameter('offset'); - $filter = array(); - $filter['limit'] = $config['block_size']; - $filter['offset'] = $offset; - $filter['order'] = array('field' => 'id', 'order' => 'DESC'); -+ - $files = files_repo_get_files($filter); - -+ - if (!empty($files)) { - - echo "<br>"; -Index: extensions/module_groups.php -=================================================================== ---- extensions/module_groups.php (revision 10314) -+++ extensions/module_groups.php (working copy) -@@ -141,7 +141,8 @@ - GROUP BY estado"; - break; - case "postgresql": -- $sql = "SELECT COUNT(id_agente) AS count, case utimestamp when 0 then 5 else estado end as estado -+ $sql = "SELECT COUNT(id_agente) AS count, -+ case utimestamp when 0 then 5 else estado end as estado - FROM tagente_estado - WHERE id_agente IN - (SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled = 0) -@@ -149,7 +150,7 @@ - (SELECT id_agente_modulo - FROM tagente_modulo - WHERE id_module_group = %d AND disabled = 0 AND delete_pending = 0) -- GROUP BY estado"; -+ GROUP BY estado, utimestamp"; - break; - case "oracle": - $sql = "SELECT COUNT(id_agente) AS count, case when utimestamp = 0 then 5 else estado end estado -@@ -185,7 +186,8 @@ - //Metaobject use in html_print_table - $table = null; - $table->align[0] = 'right'; //Align to right the first column. -- $table->style[0] = 'color: #ffffff; background-color: #778866; font-weight: bolder;'; -+ $table->style[0] = 'color: #ffffff; '. -+ 'background-color: #778866; font-weight: bolder;'; - $table->head = $head; - $table->width = '98%'; - -@@ -201,7 +203,7 @@ - - foreach ($modelGroups as $idModelGroup => $modelGroup) { - $fired = false; -- $query = sprintf($sql,$idAgentGroup, $idModelGroup); -+ $query = sprintf($sql, $idAgentGroup, $idModelGroup); - - $rowsDB = db_get_all_rows_sql ($query); - -Index: extensions/files_repo.php -=================================================================== ---- extensions/files_repo.php (revision 10314) -+++ extensions/files_repo.php (working copy) -@@ -18,12 +18,14 @@ - function pandora_files_repo_install () { - global $config; - -+ - if (isset($config['files_repo_installed'])) { - if ($config['files_repo_installed'] == 1) { - return; - } - } -- -+ -+ - $full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/"; - $full_sql_dir = $full_extensions_dir."files_repo/sql/"; - -@@ -40,6 +42,7 @@ - break; - } - -+ - foreach ($sentences as $sentence) { - if (trim ($sentence) == "") - continue; -@@ -61,22 +64,22 @@ - - switch ($config["dbtype"]) { - case "mysql": -- db_process_sql ('DROP TABLE `tfiles_repo_group`'); -- db_process_sql ('DROP TABLE `tfiles_repo`'); -- db_process_sql ('DELETE FROM `tconfig` -- WHERE `token` LIKE "files_repo_%"'); -+ db_process_sql('DROP TABLE `tfiles_repo_group`'); -+ db_process_sql('DROP TABLE `tfiles_repo`'); -+ db_process_sql('DELETE FROM `tconfig` -+ WHERE `token` LIKE "files_repo_%"'); - break; - case "postgresql": -- db_process_sql ('DROP TABLE `tfiles_repo_group`'); -- db_process_sql ('DROP TABLE `tfiles_repo`'); -- db_process_sql ('DELETE FROM "tconfig" -- WHERE "token" LIKE \'files_repo_%\''); -+ db_process_sql('DROP TABLE "tfiles_repo_group"'); -+ db_process_sql('DROP TABLE "tfiles_repo"'); -+ db_process_sql('DELETE FROM "tconfig" -+ WHERE "token" LIKE \'files_repo_%\''); - break; - case "oracle": -- db_process_sql ('DROP TABLE `tfiles_repo_group`'); -- db_process_sql ('DROP TABLE `tfiles_repo`'); -- db_process_sql ('DELETE FROM tconfig -- WHERE token LIKE \'files_repo_%\''); -+ db_process_sql('DROP TABLE "tfiles_repo_group"'); -+ db_process_sql('DROP TABLE "tfiles_repo"'); -+ db_process_sql('DELETE FROM tconfig -+ WHERE token LIKE \'files_repo_%\''); - break; - } - -@@ -86,11 +89,11 @@ - - function pandora_files_repo_godmode () { - global $config; -- -+ - if (!isset($config['files_repo_installed']) || !$config['files_repo_installed']) { - ui_print_error_message(__('Extension not installed')); - } -- -+ - // ACL Check - check_login (); - if (! check_acl ($config['id_user'], 0, "PM")) { -@@ -98,37 +101,41 @@ - require ("general/noaccess.php"); - return; - } -- -+ - // Header tabs - $godmode['text'] = '<a href="index.php?sec=gextensions&sec2=extensions/files_repo">' - . html_print_image ("images/setup.png", true, array ("title" => __('Administration view'))) - . "</a>"; - $godmode['godmode'] = 1; - $godmode['active'] = 1; -- -+ - $operation['text'] = '<a href="index.php?sec=extensions&sec2=extensions/files_repo">' - . html_print_image ("images/operation.png", true, array ("title" => __('Operation view'))) - . "</a>"; - $operation['operation'] = 1; -- -+ - $onheader = array('godmode' => $godmode, 'operation' => $operation); - // Header - ui_print_page_header (__("Files repository manager"), "images/extensions.png", false, "", true, $onheader); -- -+ - $full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/"; -- require_once ($full_extensions_dir."files_repo/functions_files_repo.php"); -- -+ require_once ($full_extensions_dir . "files_repo/functions_files_repo.php"); -+ - // Directory files_repo check - if (!files_repo_check_directory(true)) { - return; - } -- -+ -+ $server_content_length = 0; -+ if (isset($_SERVER['CONTENT_LENGTH'])) -+ $server_content_length = $_SERVER['CONTENT_LENGTH']; -+ - // Check for an anoying error that causes the $_POST and $_FILES arrays - // were empty if the file is larger than the post_max_size -- if (intval($_SERVER['CONTENT_LENGTH']) > 0 && empty($_POST)) { -+ if (intval($server_content_length) > 0 && empty($_POST)) { - ui_print_error_message(__('The file exceeds the maximum size')); - } -- -+ - // GET and POST parameters - $file_id = (int) get_parameter ("file_id"); - $add_file = (bool) get_parameter ("add_file"); -@@ -144,7 +151,7 @@ - $description = mb_substr($description, 0, 200, "UTF-8"); - } - $description = io_safe_input($description); -- -+ - if ($add_file) { - $result = files_repo_add_file("upfile", $description, $groups, $public); - } elseif ($update_file) { -@@ -163,7 +170,7 @@ - } - $file_id = 0; - } -- -+ - // FORM - require ($full_extensions_dir."files_repo/files_repo_form.php"); - if (!$file_id) { -@@ -175,7 +182,7 @@ - - function pandora_files_repo_operation () { - global $config; -- -+ - // Header tabs - $onheader = array(); - if (check_acl($config['id_user'], 0, "PM")) { -@@ -194,18 +201,19 @@ - } - // Header - ui_print_page_header (__("Files repository"), "images/extensions.png", false, "", false, $onheader); -- -+ - $full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/"; - require_once ($full_extensions_dir."files_repo/functions_files_repo.php"); -- -+ - // Directory files_repo check - if (!files_repo_check_directory(true)) { - return; - } -- -+ - // LIST - $full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/"; -- require ($full_extensions_dir."files_repo/files_repo_list.php"); -+ -+ require ($full_extensions_dir . "files_repo/files_repo_list.php"); - } - - extensions_add_operation_menu_option(__('Files repository'), null, null, "v1r1"); -Index: operation/incidents/incident.php -=================================================================== ---- operation/incidents/incident.php (revision 10314) -+++ operation/incidents/incident.php (working copy) -@@ -25,7 +25,8 @@ - } - - // Header --ui_print_page_header (__('Incident management'), "images/book_edit.png", false, "", false, ""); -+ui_print_page_header (__('Incident management'), -+ "images/book_edit.png", false, "", false, ""); - - // Take input parameters - -@@ -197,7 +198,7 @@ - ORDER BY actualizacion DESC OFFSET ".$offset." LIMIT ".$config["block_size"]; - $count_sql = "SELECT count(*) FROM tincidencia WHERE - id_grupo IN (".implode (",",array_keys ($groups)).")".$filter; -- breka; -+ break; - } - - $result = db_get_all_rows_sql ($sql); -@@ -250,11 +251,14 @@ - $agents_incidents = array(); - } - --foreach ($agents_incidents as $agent_incident){ -+$result_agent_incidents = array(); -+foreach ($agents_incidents as $agent_incident) { - $result_agent_incidents[$agent_incident['id_agente']] = $agent_incident['nombre']; - } - --html_print_select ($result_agent_incidents, "agent_search", $agent_search, 'javascript:this.form.submit();', __('All agents'), "", false, false, false, "w155"); -+html_print_select ($result_agent_incidents, "agent_search", -+ $agent_search, 'javascript:this.form.submit();', __('All agents'), -+ "", false, false, false, "w155"); - - echo '</td></tr><tr><td colspan=3>'; - -Index: operation/tree.php -=================================================================== ---- operation/tree.php (revision 10314) -+++ operation/tree.php (working copy) -@@ -72,7 +72,7 @@ - } - if ($printAlertsTable) { - $id_module = get_parameter('id_module'); -- -+ - if (defined ('METACONSOLE')) { - $server = metaconsole_get_connection ($server_name); - metaconsole_connect($server); -@@ -86,7 +86,7 @@ - } - if ($printModuleTable) { - $id_module = get_parameter('id_module'); -- -+ - if (defined ('METACONSOLE')) { - $server = metaconsole_get_connection ($server_name); - metaconsole_connect($server); -@@ -139,7 +139,8 @@ - } - $avariableGroups = users_get_groups(); - $avariableGroupsIds = array_keys($avariableGroups); -- $sql = treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel, $search_free); -+ $sql = treeview_getFirstBranchSQL ($type, $id, -+ $avariableGroupsIds, $statusSel, $search_free); - if ($sql === false) { - $server_rows = array (); - } -@@ -437,7 +438,7 @@ - "id=" . $row["id_agente_modulo"]; - } - echo "<a href='javascript: show_module_detail_dialog(" . $row["id_agente_modulo"] . ", ". $row['id_agente'].", \"" . $server_name . "\", 0, 86400)'>". html_print_image ("images/binary.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . "</a>"; -- -+ - echo " "; - - $nmodule_alerts = db_get_value_sql(sprintf("SELECT count(*) FROM talert_template_modules WHERE id_agent_module = %s", $row["id_agente_modulo"])); -@@ -525,35 +526,44 @@ - } - - $module_tab = array('text' => "<a href='index.php?extension_in_menu=estado&sec=estado&sec2=operation/tree&refr=0&sort_by=module'>" -- . html_print_image ("images/brick.png", true, array ("title" => __('Modules'))) . "</a>", 'active' => $activeTab == "module"); -+ . html_print_image("images/brick.png", -+ true, -+ array("title" => __('Modules'))) . "</a>", -+ 'active' => $activeTab == "module"); - - $tags_tab = array('text' => "<a href='index.php?&sec=monitoring&sec2=operation/tree&refr=0&sort_by=tag&pure=$pure'>" -- . html_print_image ("images/tag.png", true, array ("title" => __('Tags'))) . "</a>", 'active' => $activeTab == "tag"); -- -+ . html_print_image("images/tag.png", -+ true, -+ array("title" => __('Tags'))) . "</a>", -+ 'active' => $activeTab == "tag"); -+ - switch ($activeTab) { - case 'group': -- $order = __('groups'); -+ $order = __('groups'); - break; - case 'module_group': -- $order = __('module groups'); -+ $order = __('module groups'); - break; - case 'policies': -- $order = __('policies'); -+ $order = __('policies'); - break; - case 'module': -- $order = __('modules'); -+ $order = __('modules'); - break; - case 'os': -- $order = __('OS'); -+ $order = __('OS'); - break; - case 'tag': -- $order = __('tags'); -+ $order = __('tags'); - break; - } - - if (! defined ('METACONSOLE')) { - $onheader = array('tag' => $tags_tab, 'os' => $os_tab, 'group' => $group_tab, 'module_group' => $module_group_tab, 'policies' => $policies_tab, 'module' => $module_tab); -- ui_print_page_header (__('Tree view')." - ".__('Sort the agents by ') .$order, "images/extensions.png", false, "", false, $onheader); -+ ui_print_page_header( -+ __('Tree view') . " - " . __('Sort the agents by ') . $order, -+ "images/extensions.png", -+ false, "", false, $onheader); - } - else { - -@@ -569,7 +579,7 @@ - if ($config['enable_tags_tree']) { - $allowed_tabs[] = 'tag'; - } -- -+ - if (!in_array($activeTab, $allowed_tabs)) { - db_pandora_audit("HACK Attempt", - "Trying to access to not allowed tab on tree view"); -@@ -577,17 +587,19 @@ - exit; - } - // End of tab check -- -+ - $group_tab = array('text' => "<a href='index.php?sec=monitoring&sec2=operation/tree&refr=0&tab=group&pure=$pure'>" - . html_print_image ("images/group.png", true, array ("title" => __('Groups'))) . "</a>", - 'active' => $activeTab == "group"); - - $subsections['group'] = $group_tab; -- -- if($config['enable_tags_tree']) { -- $tags_tab = array('text' => "<a href='index.php?&sec=monitoring&sec2=operation/tree&refr=0&tab=tag&pure=$pure'>" -- . html_print_image ("images/tag.png", true, array ("title" => __('Tags'))) . "</a>", 'active' => $activeTab == "tag"); - -+ if ($config['enable_tags_tree']) { -+ $tags_tab = array( -+ 'text' => "<a href='index.php?&sec=monitoring&sec2=operation/tree&refr=0&tab=tag&pure=$pure'>" . -+ html_print_image ("images/tag.png", true, array ("title" => __('Tags'))) . "</a>", -+ 'active' => $activeTab == "tag"); -+ - $subsections['tag'] = $tags_tab; - } - -@@ -649,6 +661,7 @@ - - treeview_printTree($activeTab); - -+ - enterprise_hook('close_meta_frame'); - - ui_include_time_picker(); -@@ -672,10 +685,14 @@ - * id_father int use in js and ajax php, its useful when you have a two subtrees with same agent for diferent each one - */ - function loadSubTree(type, div_id, less_branchs, id_father, server_name) { -- hiddenDiv = $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv'); -- loadDiv = $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv'); -- pos = parseInt($('#tree_image'+id_father+'_'+type+'_'+div_id).attr('pos_tree')); -+ hiddenDiv = $('#tree_div' + id_father + '_' + type + '_' + div_id) -+ .attr('hiddenDiv'); -+ loadDiv = $('#tree_div' + id_father + '_' + type + '_' + div_id) -+ .attr('loadDiv'); - -+ pos = parseInt($('#tree_image' + id_father + '_' + type + '_' + div_id) -+ .attr('pos_tree')); -+ - //If has yet ajax request running - if (loadDiv == 2) - return; -@@ -683,8 +700,10 @@ - if (loadDiv == 0) { - - //Put an spinner to simulate loading process -- $('#tree_div'+id_father+'_'+type+'_'+div_id).html("<img style='padding-top:10px;padding-bottom:10px;padding-left:20px;' src=images/spinner.gif>"); -- $('#tree_div'+id_father+'_'+type+'_'+div_id).show('normal'); -+ $('#tree_div' + id_father + '_' + type + '_' + div_id) -+ .html("<img style='padding-top:10px;padding-bottom:10px;padding-left:20px;' src=images/spinner.gif>"); -+ $('#tree_div' + id_father + '_' + type + '_' + div_id) -+ .show('normal'); - - $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv', 2); - $.ajax({ -Index: operation/search_modules.getdata.php -=================================================================== ---- operation/search_modules.getdata.php (revision 10314) -+++ operation/search_modules.getdata.php (working copy) -@@ -108,7 +108,7 @@ - ) - ) - ) AND -- t1.nombre COLLATE utf8_general_ci LIKE \'%' . $stringSearchSQL . '%\' OR -+ t1.nombre LIKE \'%' . $stringSearchSQL . '%\' OR - t3.nombre LIKE \'%' . $stringSearchSQL . '%\''; - break; - case "oracle": -Index: operation/search_main.php -=================================================================== ---- operation/search_main.php (revision 10314) -+++ operation/search_main.php (working copy) -@@ -44,6 +44,7 @@ - $table->style[9] = 'font-weight: bold; text-align: center;'; - $table->style[10] = 'font-weight: bold; text-align: center;'; - $table->style[11] = 'font-weight: bold; text-align: center;'; -+$table->style[13] = 'font-weight: bold; text-align: center;'; - - $table->data[0][0] = html_print_image ("images/agent.png", true, array ("title" => __('Agents found'))); - $table->data[0][1] = "<a href='index.php?search_category=agents&keywords=".$keyword."&head_search_keywords=Search'>" . -Index: operation/events/events_list.php -=================================================================== ---- operation/events/events_list.php (revision 10314) -+++ operation/events/events_list.php (working copy) -@@ -52,7 +52,7 @@ - $event_filter['tag_with'] = base64_encode(io_safe_output($event_filter['tag_with'])); - $event_filter['tag_without'] = base64_encode(io_safe_output($event_filter['tag_without'])); - -- echo json_encode($event_filter); -+ echo io_json_mb_encode($event_filter); - } - - // Saves an event filter -@@ -69,8 +69,8 @@ - $values['event_view_hr'] = get_parameter('event_view_hr'); - $values['id_user_ack'] = get_parameter('id_user_ack'); - $values['group_rep'] = get_parameter('group_rep'); -- $values['tag_with'] = get_parameter('tag_with', json_encode(array())); -- $values['tag_without'] = get_parameter('tag_without', json_encode(array())); -+ $values['tag_with'] = get_parameter('tag_with', io_json_mb_encode(array())); -+ $values['tag_without'] = get_parameter('tag_without', io_json_mb_encode(array())); - $values['filter_only_alert'] = get_parameter('filter_only_alert'); - $values['id_group_filter'] = get_parameter('id_group_filter'); - -@@ -97,8 +97,8 @@ - $values['event_view_hr'] = get_parameter('event_view_hr'); - $values['id_user_ack'] = get_parameter('id_user_ack'); - $values['group_rep'] = get_parameter('group_rep'); -- $values['tag_with'] = get_parameter('tag_with', json_encode(array())); -- $values['tag_without'] = get_parameter('tag_without', json_encode(array())); -+ $values['tag_with'] = get_parameter('tag_with', io_json_mb_encode(array())); -+ $values['tag_without'] = get_parameter('tag_without', io_json_mb_encode(array())); - $values['filter_only_alert'] = get_parameter('filter_only_alert'); - $values['id_group_filter'] = get_parameter('id_group_filter'); - -@@ -116,7 +116,7 @@ - if ($get_event_filters) { - $event_filter = events_get_event_filter_select(); - -- echo json_encode($event_filter); -+ echo io_json_mb_encode($event_filter); - } - - return; -@@ -195,14 +195,14 @@ - $table->class = 'databox'; - $table->styleTable = 'font-weight: bold; color: #555; text-align:left;'; - $table->style[0] = 'width: 50%; width:50%;'; -- -+ - $data = array(); - $table->rowid[0] = 'update_save_selector'; - $data[0] = html_print_radio_button('filter_mode', 'new', '', true, true) . __('New filter') . '<br><br>'; - $data[1] = html_print_radio_button('filter_mode', 'update', '', false, true) . __('Update filter') . '<br><br>'; - $table->data[] = $data; - $table->rowclass[] = ''; -- -+ - $data = array(); - $table->rowid[1] = 'save_filter_row1'; - $data[0] = __('Filter name') . '<br>'; -@@ -212,7 +212,7 @@ - $data[1] .= html_print_select_groups($config["id_user"], "ER", users_can_manage_group_all(), 'id_group', $id_group, '', '', 0, true, false, false, 'w130'); - $table->data[] = $data; - $table->rowclass[] = ''; -- -+ - $data = array(); - $table->rowid[2] = 'save_filter_row2'; - $data[0] = html_print_submit_button (__('Save filter'), 'save_filter', false, 'class="sub upd"', true); -@@ -220,18 +220,18 @@ - $table->cellstyle[2][0] = 'text-align:right;'; - $table->data[] = $data; - $table->rowclass[] = ''; -- -+ - $data = array(); - $table->rowid[3] = 'update_filter_row1'; - $data[0] = __("Overwrite filter") . '<br>'; - # Fix : Only admin user can see filters of group ALL for update - $_filters_update = events_get_event_filter_select(false); -- -+ - $data[0] .= html_print_select ($_filters_update, "overwrite_filter", '', '', '', 0, true); - $data[1] = html_print_submit_button (__('Update filter'), 'update_filter', false, 'class="sub upd"', true); - $table->data[] = $data; - $table->rowclass[] = ''; -- -+ - html_print_table($table); - unset($table); - echo '</div>'; -@@ -340,7 +340,7 @@ - if ($open_filter) { - $events_filter .= html_print_input_hidden('open_filter', 'true', true); - } --else{ -+else { - $events_filter .= html_print_input_hidden('open_filter', 'false', true); - } - -@@ -414,8 +414,18 @@ - $table_advanced->rowclass[] = ''; - - $data = array(); --$data[0] = '<fieldset class="databox" style="width: 310px;"><legend>' . __('Events with following tags') . '</legend>' . html_print_table($tabletags_with, true) . '</fieldset>'; --$data[1] = '<fieldset class="databox" style="width: 310px;"><legend>' . __('Events without following tags') . '</legend>' . html_print_table($tabletags_without, true) . '</fieldset>'; -+$data[0] = '<fieldset class="databox" style="width: 310px;">' . -+ '<legend>' . -+ __('Events with following tags') . -+ '</legend>' . -+ html_print_table($tabletags_with, true) . -+ '</fieldset>'; -+$data[1] = '<fieldset class="databox" style="width: 310px;">' . -+ '<legend>' . -+ __('Events without following tags') . -+ '</legend>' . -+ html_print_table($tabletags_without, true) . -+ '</fieldset>'; - $table_advanced->data[] = $data; - $table_advanced->rowclass[] = ''; - -@@ -536,9 +546,15 @@ - - //Extract the events by filter (or not) from db - $result = db_get_all_rows_sql ($sql); -+ - } - else { -- $result = events_get_events_grouped($sql_post, $offset, $pagination, $meta, $history); -+ $result = events_get_events_grouped( -+ $sql_post, -+ $offset, -+ $pagination, -+ $meta, -+ $history); - } - - if (!empty($result)) { -Index: operation/events/events.php -=================================================================== ---- operation/events/events.php (revision 10314) -+++ operation/events/events.php (working copy) -@@ -172,7 +172,7 @@ - $return = array('fired' => 0); - } - -- echo json_encode($return); -+ echo io_json_mb_encode($return); - } - - return; -Index: operation/search_agents.getdata.php -=================================================================== ---- operation/search_agents.getdata.php (revision 10314) -+++ operation/search_agents.getdata.php (working copy) -@@ -173,7 +173,7 @@ - AND ( - t1.nombre LIKE '%%" . $stringSearchSQL . "%%' OR - t2.nombre LIKE '%%" . $stringSearchSQL . "%%' OR -- t1.direction LIKE '%%" . $stringSearchSQL . "%%' -+ t1.direccion LIKE '%%" . $stringSearchSQL . "%%' - ) - "; - break; -Index: operation/search_results.php -=================================================================== ---- operation/search_results.php (revision 10314) -+++ operation/search_results.php (working copy) -@@ -58,7 +58,9 @@ - - if ($searchMain) { - $main_tab = array('text' => "<a href='index.php?search_category=main&keywords=".$config['search_keywords']."&head_search_keywords=Search'>" -- . html_print_image ("images/zoom_mc.png", true, array ("title" => __('Global search'))) . "</a>", 'active' => $searchTab == "main"); -+ . html_print_image ("images/zoom_mc.png", true, -+ array ("title" => __('Global search'))) . "</a>", -+ 'active' => $searchTab == "main"); - } - else { - $main_tab = ''; -@@ -66,7 +68,9 @@ - - if ($searchAgents) { - $agents_tab = array('text' => "<a href='index.php?search_category=agents&keywords=".$config['search_keywords']."&head_search_keywords=Search'>" -- . html_print_image ("images/op_monitoring.png", true, array ("title" => __('Agents'))) . "</a>", 'active' => $searchTab == "agents"); -+ . html_print_image ("images/op_monitoring.png", true, -+ array ("title" => __('Agents'))) . "</a>", -+ 'active' => $searchTab == "agents"); - } - else { - $agents_tab = ''; -@@ -74,7 +78,9 @@ - - if ($searchUsers) { - $users_tab = array('text' => "<a href='index.php?search_category=users&keywords=".$config['search_keywords']."&head_search_keywords=Search'>" -- . html_print_image ("images/op_workspace.png", true, array ("title" => __('Users'))) . "</a>", 'active' => $searchTab == "users"); -+ . html_print_image ("images/op_workspace.png", true, -+ array ("title" => __('Users'))) . "</a>", -+ 'active' => $searchTab == "users"); - } - else { - $users_tab = ''; -@@ -82,7 +88,9 @@ - - if ($searchAlerts) { - $alerts_tab = array('text' => "<a href='index.php?search_category=alerts&keywords=".$config['search_keywords']."&head_search_keywords=Search'>" -- . html_print_image ("images/op_alerts.png", true, array ("title" => __('Alerts'))) . "</a>", 'active' => $searchTab == "alerts"); -+ . html_print_image ("images/op_alerts.png", true, -+ array ("title" => __('Alerts'))) . "</a>", -+ 'active' => $searchTab == "alerts"); - } - else { - $alerts_tab = ''; -@@ -90,7 +98,9 @@ - - if ($searchGraphs) { - $graphs_tab = array('text' => "<a href='index.php?search_category=graphs&keywords=".$config['search_keywords']."&head_search_keywords=Search'>" -- . html_print_image ("images/chart.png", true, array ("title" => __('Graphs'))) . "</a>", 'active' => $searchTab == "graphs"); -+ . html_print_image ("images/chart.png", true, -+ array ("title" => __('Graphs'))) . "</a>", -+ 'active' => $searchTab == "graphs"); - } - else { - $graphs_tab = ''; -@@ -98,7 +108,9 @@ - - if ($searchReports) { - $reports_tab = array('text' => "<a href='index.php?search_category=reports&keywords=".$config['search_keywords']."&head_search_keywords=Search'>" -- . html_print_image ("images/op_reporting.png", true, array ("title" => __('Reports'))) . "</a>", 'active' => $searchTab == "reports"); -+ . html_print_image ("images/op_reporting.png", true, -+ array ("title" => __('Reports'))) . "</a>", -+ 'active' => $searchTab == "reports"); - } - else { - $reports_tab = ''; -@@ -106,7 +118,9 @@ - - if ($searchMaps) { - $maps_tab = array('text' => "<a href='index.php?search_category=maps&keywords=".$config['search_keywords']."&head_search_keywords=Search'>" -- . html_print_image ("images/visual_console.png", true, array ("title" => __('Maps'))) . "</a>", 'active' => $searchTab == "maps"); -+ . html_print_image ("images/visual_console.png", true, -+ array ("title" => __('Maps'))) . "</a>", -+ 'active' => $searchTab == "maps"); - } - else { - $maps_tab = ''; -@@ -114,7 +128,9 @@ - - if ($searchModules) { - $modules_tab = array('text' => "<a href='index.php?search_category=modules&keywords=".$config['search_keywords']."&head_search_keywords=Search'>" -- . html_print_image ("images/brick.png", true, array ("title" => __('Modules'))) . "</a>", 'active' => $searchTab == "modules"); -+ . html_print_image ("images/brick.png", true, -+ array ("title" => __('Modules'))) . "</a>", -+ 'active' => $searchTab == "modules"); - } - else { - $modules_tab = ''; -@@ -135,6 +151,7 @@ - switch ($searchTab) { - case 'main': - $only_count = true; -+ - require_once('search_agents.getdata.php'); - require_once('search_agents.php'); - require_once('search_users.getdata.php'); -Index: operation/agentes/status_monitor.php -=================================================================== ---- operation/agentes/status_monitor.php (revision 10314) -+++ operation/agentes/status_monitor.php (working copy) -@@ -14,8 +14,6 @@ - // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - // GNU General Public License for more details. - -- -- - // Load global vars - global $config; - -@@ -45,6 +43,8 @@ - ui_meta_print_header(__("Monitor view")); - } - -+ -+ - $ag_freestring = get_parameter ('ag_freestring'); - $ag_modulename = (string) get_parameter ('ag_modulename'); - if (!defined('METACONSOLE')) { -@@ -101,9 +101,13 @@ - - $sql_conditions = " AND tagente_modulo.disabled = 0 AND tagente.disabled = 0"; - -+if (is_numeric($ag_group)) { -+ $id_ag_group = 0; -+} -+else { -+ $id_ag_group = db_get_value('id_grupo', 'tgrupo', 'nombre', $ag_group); -+} - --$id_ag_group = db_get_value('id_grupo', 'tgrupo', 'nombre', $ag_group); -- - // Agent group selector - if (!defined('METACONSOLE')) { - if ($ag_group > 0 && check_acl ($config["id_user"], $ag_group, "AR")) { -@@ -123,6 +127,7 @@ - $sql_conditions_group = " AND tagente.id_grupo IN (".$user_groups.")"; - } - } -+ - // Module group - if (defined('METACONSOLE')) { - if ($modulegroup != '-1') -@@ -198,7 +203,7 @@ - WHERE ttag_module.id_tag IN (SELECT id_tag FROM ttag where name LIKE '%" . $tag_filter . "%') - )"; - } -- else{ -+ else { - $sql_conditions .= " AND tagente_modulo.id_agente_modulo IN ( - SELECT ttag_module.id_agente_modulo - FROM ttag_module -@@ -310,7 +315,9 @@ - if (defined('METACONSOLE')) { - - // For each server defined and not disabled: -- $servers = db_get_all_rows_sql ("SELECT * FROM tmetaconsole_setup WHERE disabled = 0"); -+ $servers = db_get_all_rows_sql ("SELECT * -+ FROM tmetaconsole_setup -+ WHERE disabled = 0"); - - if ($servers === false) - $servers = array(); -@@ -727,8 +734,15 @@ - LIMIT ".$offset.",".$limit_sql; - break; - case "postgresql": -+ if (strstr($config['dbversion'], "8.4") !== false) { -+ $string_agg = "array_to_string(array_agg(ttag.name), ',')"; -+ } -+ else { -+ $string_agg = "STRING_AGG(ttag.name, ',')"; -+ } -+ - $sql = "SELECT -- (SELECT STRING_AGG(ttag.name, ',') -+ (SELECT " . $string_agg . " - FROM ttag - WHERE ttag.id_tag IN ( - SELECT ttag_module.id_tag -@@ -760,7 +774,10 @@ - tagente_modulo.critical_instructions, - tagente_modulo.warning_instructions, - tagente_modulo.unknown_instructions, -- tagente_estado.utimestamp AS utimestamp".$sql_form . $sql_conditions_all." LIMIT " . $limit_sql . " OFFSET " . $offset; -+ tagente_estado.utimestamp AS utimestamp" . -+ $sql_from . -+ $sql_conditions_all . -+ " LIMIT " . $limit_sql . " OFFSET " . $offset; - break; - case "oracle": - $set = array(); -@@ -799,7 +816,9 @@ - tagente_modulo.critical_instructions, - tagente_modulo.warning_instructions, - tagente_modulo.unknown_instructions, -- tagente_estado.utimestamp AS utimestamp" . $sql_form . $sql_conditions_all; -+ tagente_estado.utimestamp AS utimestamp" . -+ $sql_from . -+ $sql_conditions_all; - $sql = oracle_recode_query ($sql, $set); - break; - } -Index: operation/agentes/alerts_status.php -=================================================================== ---- operation/agentes/alerts_status.php (revision 10314) -+++ operation/agentes/alerts_status.php (working copy) -@@ -258,7 +258,8 @@ - - - $alerts = array(); --$options_simple = array('offset' => $offset_simple, 'limit' => $config['block_size'], 'order' => $order); -+$options_simple = array('offset' => $offset_simple, -+ 'limit' => $config['block_size'], 'order' => $order); - - $filter_alert = array(); - if($filter_standby == 'standby_on') { -@@ -322,11 +323,11 @@ - } - - if ($tab != null) { -- $url = $url.'&tab='.$tab; -+ $url = $url.'&tab=' . $tab; - } - - if ($pure) { -- $url .= '&pure='.$pure; -+ $url .= '&pure=' . $pure; - } - - // Filter form -@@ -345,13 +346,17 @@ - if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - if ($print_agent) { - if (!defined('METACONSOLE')) { -- $table->head[0] = "<span title='" . __('Policy') . "'>" . __('P.') . "</span>"; -+ $table->head[0] = "<span title='" . __('Policy') . "'>" . -+ __('P.') . "</span>"; - } - -- $table->head[1] = "<span title='" . __('Standby') . "'>" . __('S.') . "</span>"; -+ $table->head[1] = "<span title='" . __('Standby') . "'>" . -+ __('S.') . "</span>"; - - if (!defined('METACONSOLE')) { -- $table->head[2] = "<span title='" . __('Force execution') . "'>" . __('F.') . "</span>"; -+ $table->head[2] = -+ "<span title='" . __('Force execution') . "'>" . -+ __('F.') . "</span>"; - } - - $table->head[3] = __('Agent'); -@@ -481,6 +486,12 @@ - } - } - -+ -+if ($sortField) { -+ $url .= '&sort_field=' . $sortField; -+ $url .= '&sort=' . $sort; -+} -+ - $table->data = array (); - - $rowPair = true; -@@ -496,9 +507,10 @@ - } - - if (!empty ($table->data)) { -- echo '<form method="post" action="'.$url.'">'; -+ echo '<form method="post" action="' . $url . '">'; - -- ui_pagination ($countAlertsSimple, $url, $offset_simple, 0, false, 'offset_simple'); -+ ui_pagination ($countAlertsSimple, $url, $offset_simple, 0, false, -+ 'offset_simple'); - html_print_table ($table); - - if (!defined('METACONSOLE')) { -Index: operation/agentes/estado_generalagente.php -=================================================================== ---- operation/agentes/estado_generalagente.php (revision 10314) -+++ operation/agentes/estado_generalagente.php (working copy) -@@ -255,7 +255,7 @@ - else { - $data[1] = __('Enabled'); - } -- -+ - $table_data->data[] = $data; - } - -@@ -323,7 +323,7 @@ - WHERE estado IN (0,1) - AND id_agent=$id_agente - ORDER BY actualizacion DESC"); -- -+ - if ($last_incident != false) { - - $table_incident->id = 'agent_incident_main'; -@@ -333,10 +333,10 @@ - $table_incident->class = 'databox'; - $table_incident->style[0] = 'width: 30%;'; - $table_incident->style[1] = 'width: 70%;'; -- -+ - $table_incident->head[0] = ' <span>' . '<a href="index.php?sec=incidencias&sec2=operation/incidents/incident_detail&id='.$last_incident["id_incidencia"].'">' .__('Active incident on this agent') .'</a>'. '</span>'; - $table_incident->head_colspan[0] = 2; -- -+ - $data = array(); - $data[0] = '<b>' . __('Author') . '</b>'; - $data[1] = $last_incident["id_creator"]; -@@ -391,20 +391,20 @@ - $table_interface->head_colspan = array(); - $table_interface->head_colspan[0] = 4; - $table_interface->data = array(); -- -+ - foreach ($modules as $key => $module) { -- -+ - // Trying to get the interface name from the module name - if (preg_match ("/_(.+)$/", (string)$module['nombre'], $matches)) { - if ($matches[1]) { - $interface_name = $matches[1]; -- -+ - $module_id = $module['id_agente_modulo']; - $db_status = modules_get_agentmodule_status($module_id); - $module_value = modules_get_last_value ($module_id); - modules_get_status($module_id, $db_status, $module_value, $status, $title); - $status = ui_print_status_image($status, $title, true); -- -+ - $ip_target = "--"; - // Trying to get something like an IP from the description - if (preg_match ("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", (string)$module['descripcion'], $matches) || -@@ -421,7 +421,7 @@ - $description = $matches[0]; - } - } -- -+ - $data = array(); - $data[0] = "<strong>" . $interface_name . "</strong>"; - $data[1] = $status; -@@ -432,7 +432,7 @@ - } - } - unset($modules); -- -+ - // This javascript piece of code is used to make expandible the body of the table - ?> - <script type="text/javascript"> -@@ -477,7 +477,11 @@ - '</fieldset>'; - - // ACCESS RATE GRAPH --if ($config["agentaccess"]) { -+$access_agent = db_get_value_sql("SELECT COUNT(id_agent) -+ FROM tagent_access -+ WHERE id_agent = " . $id_agente); -+ -+if ($config["agentaccess"] && $access_agent > 0) { - $data[0] .= '<fieldset class="databox" style="position: static;"> - <legend style="text-align:left; color: #666;">' . - __('Agent access rate (24h)') . -Index: operation/agentes/networkmap.topology.php -=================================================================== ---- operation/agentes/networkmap.topology.php (revision 10314) -+++ operation/agentes/networkmap.topology.php (working copy) -@@ -39,7 +39,7 @@ - $graph = networkmap_generate_dot(__('Pandora FMS'), $group, $simple, - $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, - $pure, $id_networkmap, $show_snmp_modules, true, true, -- $text_filter, $l2_network); -+ $text_filter, $l2_network, null, $dont_show_subgroups); - - if ($graph === false) { - ui_print_error_message (__('Map could not be generated')); -@@ -79,9 +79,18 @@ - } - else { - fwrite ($fh, $graph); -- $graphviz_path = ($config['graphviz_bin_dir']) ? io_safe_output($config['graphviz_bin_dir']."/") : ""; -- $cmd = escapeshellarg($graphviz_path.$filter) . " -Tcmapx " . escapeshellarg("-o$filename_map") . " -Tpng ". escapeshellarg("-o$filename_img") . " " . escapeshellarg($filename_dot); -+ -+ $graphviz_path = (isset($config['graphviz_bin_dir'])) ? -+ io_safe_output($config['graphviz_bin_dir'] . "/") -+ : -+ ""; -+ -+ $cmd = escapeshellarg($graphviz_path . $filter) . -+ " -Tcmapx " . escapeshellarg("-o$filename_map") . -+ " -Tpng ". escapeshellarg("-o$filename_img") . -+ " " . escapeshellarg($filename_dot); - $result = system ($cmd); -+ - fclose ($fh); - unlink ($filename_dot); - //~ html_debug_print($cmd); -Index: operation/agentes/estado_agente.php -=================================================================== ---- operation/agentes/estado_agente.php (revision 10314) -+++ operation/agentes/estado_agente.php (working copy) -@@ -223,18 +223,31 @@ - $selectLastContactDown = ''; - $order = null; - -+ -+$order_collation = ""; -+switch ($config["dbtype"]) { -+ case "mysql": -+ $order_collation = " COLLATE utf8_general_ci"; -+ break; -+ case "postgresql": -+ case "oracle": -+ $order_collation = ""; -+ break; -+} -+ -+ - switch ($sortField) { - case 'name': - switch ($sort) { - case 'up': - $selectNameUp = $selected; -- $order = array('field' => 'nombre COLLATE utf8_general_ci', -- 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); -+ $order = array('field' => 'nombre' . $order_collation, -+ 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); - break; - case 'down': - $selectNameDown = $selected; -- $order = array('field' => 'nombre COLLATE utf8_general_ci', -- 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); -+ $order = array('field' => 'nombre' . $order_collation, -+ 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); - break; - } - break; -@@ -243,12 +256,12 @@ - case 'up': - $selectOsUp = $selected; - $order = array('field' => 'id_os', -- 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); -+ 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); - break; - case 'down': - $selectOsDown = $selected; - $order = array('field' => 'id_os', -- 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); -+ 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); - break; - } - break; -@@ -257,12 +270,12 @@ - case 'up': - $selectIntervalUp = $selected; - $order = array('field' => 'intervalo', -- 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); -+ 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); - break; - case 'down': - $selectIntervalDown = $selected; - $order = array('field' => 'intervalo', -- 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); -+ 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); - break; - } - break; -@@ -271,12 +284,12 @@ - case 'up': - $selectGroupUp = $selected; - $order = array('field' => 'id_grupo', -- 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); -+ 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); - break; - case 'down': - $selectGroupDown = $selected; - $order = array('field' => 'id_grupo', -- 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); -+ 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); - break; - } - break; -@@ -285,12 +298,12 @@ - case 'up': - $selectLastContactUp = $selected; - $order = array('field' => 'ultimo_contacto', -- 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); -+ 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); - break; - case 'down': - $selectLastContactDown = $selected; - $order = array('field' => 'ultimo_contacto', -- 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); -+ 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); - break; - } - break; -@@ -305,15 +318,15 @@ - $selectGroupDown = ''; - $selectLastContactUp = ''; - $selectLastContactDown = ''; -- $order = array('field' => 'nombre COLLATE utf8_general_ci', -- 'field2' => 'nombre COLLATE utf8_general_ci', -+ $order = array('field' => 'nombre' . $order_collation, -+ 'field2' => 'nombre' . $order_collation, - 'order' => 'ASC'); - break; - } - - $search_sql = ''; - if ($search != "") { -- $search_sql = " AND ( nombre COLLATE utf8_general_ci LIKE '%$search%' OR direccion LIKE '%$search%' OR comentarios LIKE '%$search%') "; -+ $search_sql = " AND ( nombre " . $order_collation . " LIKE '%$search%' OR direccion LIKE '%$search%' OR comentarios LIKE '%$search%') "; - } - - // Show only selected groups -@@ -340,8 +353,9 @@ - array ('COUNT(*) as total'), 'AR', false); - $total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0; - -+ - $agents = agents_get_agents(array ( -- 'order' => 'nombre COLLATE utf8_general_ci ASC', -+ 'order' => 'nombre ' . $order_collation . ' ASC', - 'id_grupo' => $groups, - 'disabled' => 0, - 'status' => $status, -@@ -354,7 +368,7 @@ - 'id_os', - 'ultimo_contacto', - 'intervalo', -- 'comentarios description', -+ 'comentarios description', - 'quiet', - 'normal_count', - 'warning_count', -Index: operation/agentes/exportdata.php -=================================================================== ---- operation/agentes/exportdata.php (revision 10314) -+++ operation/agentes/exportdata.php (working copy) -@@ -40,10 +40,13 @@ - - switch ($config["dbtype"]) { - case "mysql": -- case "postgresql": - $agents = agents_get_agents( - array('nombre LIKE "' . $agentName . '"'), array ('id_agente')); - break; -+ case "postgresql": -+ $agents = agents_get_agents( -+ array('nombre LIKE \'' . $agentName . '\''), array ('id_agente')); -+ break; - case "oracle": - $agents = agents_get_agents( - array('nombre LIKE \'%' . $agentName . '%\''), array ('id_agente')); -@@ -198,7 +201,7 @@ - $table->data[0][0] = '<b>'.__('Group').'</b>'; - - $groups = users_get_groups ($config['id_user'], "RR", users_can_manage_group_all()); -- -+ - $table->data[0][1] = html_print_select_groups($config['id_user'], - "RR", users_can_manage_group_all(), "group", $group, '', '', 0, true, false, true, - 'w130', false); -Index: operation/agentes/estado_monitores.php -=================================================================== ---- operation/agentes/estado_monitores.php (revision 10314) -+++ operation/agentes/estado_monitores.php (working copy) -@@ -102,6 +102,7 @@ - include_once($config['homedir'] . "/include/functions_modules.php"); - include_once($config['homedir'] . "/include/functions_servers.php"); - include_once($config['homedir'] . "/include/functions_tags.php"); -+include_once($config['homedir'] . "/include/functions_clippy.php"); - - $id_agent = get_parameter('id_agente'); - $url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agent; -@@ -232,7 +233,6 @@ - //Count monitors/modules - switch ($config["dbtype"]) { - case "mysql": -- case "postgresql": - $sql = sprintf(" - SELECT COUNT(*) - FROM tagente_estado, -@@ -246,8 +246,29 @@ - AND %s %s - AND tagente_estado.estado != %d - ORDER BY tagente_modulo.id_module_group , %s %s", -- $id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']); -+ $id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']); - break; -+ case "postgresql": -+ $sql = sprintf(" -+ SELECT COUNT(DISTINCT tagente_modulo.id_module_group) -+ FROM tagente_estado, -+ (SELECT * -+ FROM tagente_modulo -+ WHERE id_agente = %d AND nombre LIKE '%s' -+ AND delete_pending = 0 -+ AND disabled = 0) tagente_modulo -+ LEFT JOIN tmodule_group -+ ON tagente_modulo.id_module_group = tmodule_group.id_mg -+ WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo -+ AND %s %s -+ AND tagente_estado.estado != %d -+ GROUP BY tagente_modulo.id_module_group, -+ tagente_modulo.nombre -+ ORDER BY tagente_modulo.id_module_group , %s %s", -+ $id_agente, $status_text_monitor_sql, $status_filter_sql, -+ $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], -+ $order['order']); -+ break; - case "oracle": - $sql = sprintf (" - SELECT COUNT(*)" . -@@ -265,15 +286,18 @@ - ", $id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']); - break; - } --$count_modules = db_get_all_rows_sql ($sql); --$count_modules = reset($count_modules[0]); - -+$count_modules = db_get_all_rows_sql($sql); -+if (isset($count_modules[0])) -+ $count_modules = reset($count_modules[0]); -+else -+ $count_modules = 0; - -+ - //Get monitors/modules - // Get all module from agent - switch ($config["dbtype"]) { - case "mysql": -- case "postgresql": - $sql = sprintf(" - SELECT * - FROM tagente_estado, -@@ -287,8 +311,24 @@ - AND %s %s - AND tagente_estado.estado != %d - ORDER BY tagente_modulo.id_module_group , %s %s", -- $id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']); -+ $id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']); - break; -+ case "postgresql": -+ $sql = sprintf(" -+ SELECT * -+ FROM tagente_estado, -+ (SELECT * -+ FROM tagente_modulo -+ WHERE id_agente = %d AND nombre LIKE '%s' AND delete_pending = 0 -+ AND disabled = 0) tagente_modulo -+ LEFT JOIN tmodule_group -+ ON tagente_modulo.id_module_group = tmodule_group.id_mg -+ WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo -+ AND %s %s -+ AND tagente_estado.estado != %d -+ ORDER BY tagente_modulo.id_module_group , %s %s", -+ $id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']); -+ break; - // If Dbms is Oracle then field_list in sql statement has to be recoded. See oracle_list_all_field_table() - case "oracle": - $fields_tagente_estado = oracle_list_all_field_table('tagente_estado', 'string'); -@@ -374,6 +414,8 @@ - $id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo', - 'nombre', 'web_content_string'); - -+$show_context_help_first_time = false; -+ - foreach ($modules as $module) { - //The code add the row of 1 cell with title of group for to be more organice the list. - -@@ -509,7 +551,15 @@ - modules_get_status($module['id_agente_modulo'], $module['estado'], - $module_value, $status, $title); - -+ - $data[5] = ui_print_status_image($status, $title, true); -+ if (!$show_context_help_first_time) { -+ $show_context_help_first_time = true; -+ -+ if ($module['estado'] == AGENT_MODULE_STATUS_UNKNOWN) { -+ $data[5] .= clippy_context_help("module_unknow"); -+ } -+ } - - - if ($module["id_tipo_modulo"] == 24) { -@@ -633,7 +683,13 @@ - $url = 'include/procesos.php?agente='.$module["id_agente_modulo"]; - $win_handle=dechex(crc32($module["id_agente_modulo"].$module["nombre"])); - -- $link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$module["id_agente_modulo"]."&label=".rawurlencode(urlencode(base64_encode($module["nombre"])))."&refresh=600','day_".$win_handle."')"; -+ # Show events for boolean modules by default. -+ if ($graph_type == 'boolean') { -+ $draw_events = 1; -+ } else { -+ $draw_events = 0; -+ } -+ $link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$module["id_agente_modulo"]."&label=".rawurlencode(urlencode(base64_encode($module["nombre"])))."&refresh=600&draw_events=$draw_events','day_".$win_handle."')"; - - $data[8] .= '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a> '; - $server_name = ''; -@@ -736,7 +792,7 @@ - - var server_name = ''; - var extra_parameters = ''; -- if (period == -1) { -+ if ($('input[name=selection_mode]:checked').val()) { - - period = $('#period').val(); - -Index: operation/agentes/ver_agente.php -=================================================================== ---- operation/agentes/ver_agente.php (revision 10314) -+++ operation/agentes/ver_agente.php (working copy) -@@ -48,7 +48,7 @@ - $recursion = (int) get_parameter ('recursion', 0); - $custom_condition = get_parameter('custom_condition', ''); - $privilege = (string) get_parameter ('privilege', "AR"); -- -+ - // Is is possible add keys prefix to avoid auto sorting in js object conversion - $keys_prefix = (string) get_parameter ('keys_prefix', ''); - $status_agents = (int)get_parameter('status_agents', AGENT_STATUS_ALL); -@@ -142,7 +142,7 @@ - - $groups = users_get_groups ($config["id_user"], "AW", false); - $group_id_list = ($groups ? join(",",array_keys($groups)):"0"); -- -+ - $sql = 'SELECT DISTINCT(t1.nombre) as name - FROM tagente t1, tagente_modulo t2 - WHERE t1.id_agente = t2.id_agente -@@ -156,7 +156,7 @@ - WHERE t3.id_agente = t4.id_agente AND t1.nombre = t3.nombre - AND t4.nombre IN (\'' . implode('\',\'', $nameModules) . '\')) = '.count($nameModules); - } -- -+ - $sql .= ' ORDER BY t1.nombre'; - - $nameAgents = db_get_all_rows_sql($sql); -@@ -468,17 +468,17 @@ - - echo '<strong>'.__('Last contact').':</strong> '.human_time_comparation($agent['ultimo_contacto']).'<br />'; - echo '<strong>'.__('Last remote contact').':</strong> '.human_time_comparation($agent['ultimo_contacto_remoto']).'<br />'; -- -+ - # Fix : Only show agents with module with tags of user profile - $_user_tags = tags_get_user_tags($config['id_user'], 'RR'); -- -+ - $_sql_post = ''; - if ($_user_tags !== false) { -- -+ - $_tags = implode(',', array_keys($_user_tags)); -- -+ - $_sql_post .= ' AND tagente_modulo.id_agente_modulo IN (SELECT a.id_agente_modulo FROM tagente_modulo a, ttag_module b WHERE a.id_agente_modulo=b.id_agente_modulo AND b.id_tag IN (' . $_tags . ')) '; -- -+ - } - - $sql = sprintf ('SELECT tagente_modulo.descripcion, -@@ -488,9 +488,9 @@ - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.disabled = 0 - AND tagente_estado.estado = 1', $id_agent); -- -+ - $sql .= $_sql_post; -- -+ - if ($metaconsole) { - if (metaconsole_connect($server) != NOERR) { - return; -@@ -624,7 +624,7 @@ - if ($modulegroup === false) { - echo __('None').'<br />'; - } -- else{ -+ else { - echo $modulegroup.'<br />'; - } - echo '<strong>'.__('Agent').':</strong> '; -Index: operation/agentes/networkmap.php -=================================================================== ---- operation/agentes/networkmap.php (revision 10314) -+++ operation/agentes/networkmap.php (working copy) -@@ -230,14 +230,14 @@ - $buttons['addmap'] = array('active' => $activeTab == false, - 'text' => '<a href="index.php?sec=network&sec2=operation/agentes/networkmap&add_networkmap=1&tab='.$activeTab.'&pure='.$pure.'">' . - html_print_image("images/add_mc.png", true, array ("title" => __('Add map'))) .'</a>'); -- -+ - if (!$nomaps && $id_networkmap != 0) { - $buttons['deletemap'] = array('active' => $activeTab == false, - 'text' => '<a href="index.php?sec=network&sec2=operation/agentes/networkmap&id_networkmap='.$id_networkmap.'&delete_networkmap=1&tab='.$activeTab.'&pure='.$pure.'">' . - html_print_image("images/delete_mc.png", true, array ("title" => __('Delete map'))) .'</a>'); -- -+ - $buttons['savemap'] = array('active' => $activeTab == false, -- 'text' => '<a href="index.php?sec=network&' . -+ 'text' => '<a href="index.php?sec=network&' . - 'sec2=operation/agentes/networkmap&' . - 'id_networkmap=' . $id_networkmap . '&' . - 'save_networkmap=1&' . -@@ -320,7 +320,7 @@ - - - unset($table); --$table->width = '95%'; -+$table->width = '98%'; - $table->class = 'databox'; - $table->data = array(); - $table->data[0][] = __('Name:') . ' ' . -@@ -329,7 +329,9 @@ - html_print_select_groups(false, 'AR', false, 'group', $group, '', 'All', 0, true); - if ($activeTab == 'groups' || $activeTab == 'policies') { - $table->data[0][] = __('Module group') . ' ' . -- html_print_select_from_sql ('SELECT id_mg, name FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true); -+ html_print_select_from_sql (' -+ SELECT id_mg, name -+ FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true); - } - - if ($activeTab == 'topology') { -@@ -411,7 +413,7 @@ - - $table->data[2][] = __('Free text for search (*):') . ' ' . - html_print_input_text('text_filter', $text_filter, '', 30, 100, true); --if ($activeTab == 'groups') { -+if (($activeTab == 'groups') || ($activeTab == 'topology')) { - $table->data[2][] = __('Don\'t show subgroups:') . - ui_print_help_tip(__('Only run with it is filter for any group'), true) . - ' ' . -Index: operation/snmpconsole/snmp_view.php -=================================================================== ---- operation/snmpconsole/snmp_view.php (revision 10314) -+++ operation/snmpconsole/snmp_view.php (working copy) -@@ -48,7 +48,8 @@ - foreach ($user_groups as $id=>$name) { - if ($i == 0) { - $str_user_groups .= $id; -- } else { -+ } -+ else { - $str_user_groups .= ','.$id; - } - $i++; -@@ -336,8 +337,11 @@ - $table->data[4][2] = html_print_select ($trap_types, 'trap_type', $trap_type, 'this.form.submit();', '', '', true, false, false); - - $table->data[3][3] = '<strong>'.__('Group by OID/IP').'</strong>'; --$table->data[3][4] .= __('Yes').' '.html_print_radio_button ('group_by', 1, '', $group_by, true).' '; --$table->data[3][4] .= __('No').' '.html_print_radio_button ('group_by', 0, '', $group_by, true); -+$table->data[3][4] = __('Yes') . ' '. -+ html_print_radio_button ('group_by', 1, '', $group_by, true) . -+ ' '; -+$table->data[3][4] .= __('No') . ' ' . -+ html_print_radio_button ('group_by', 0, '', $group_by, true); - - $filter = '<form method="POST" action="index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&refr='.((int)get_parameter('refr', 0)).'&pure='.$config["pure"].'&tab='.$tab.'">'; - $filter .= html_print_table($table, true); -Index: images/pandorin.png -=================================================================== -Cannot display: file marked as a binary type. -svn:mime-type = application/octet-stream -Index: images/pandorin.png -=================================================================== ---- images/pandorin.png (revision 10314) -+++ images/pandorin.png (working copy) - -Property changes on: images/pandorin.png -___________________________________________________________________ -Added: svn:mime-type -## -0,0 +1 ## -+application/octet-stream -\ No newline at end of property -Index: images/clippy_icon.png -=================================================================== -Cannot display: file marked as a binary type. -svn:mime-type = application/octet-stream -Index: images/clippy_icon.png -=================================================================== ---- images/clippy_icon.png (revision 10314) -+++ images/clippy_icon.png (working copy) - -Property changes on: images/clippy_icon.png -___________________________________________________________________ -Added: svn:mime-type -## -0,0 +1 ## -+application/octet-stream -\ No newline at end of property -Index: extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql -=================================================================== ---- extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql (revision 10314) -+++ extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql (working copy) -@@ -190,3 +190,9 @@ - -- Table trecon_script - -- --------------------------------------------------------------------- - DELETE FROM "trecon_script" WHERE "id_recon_script"=1; -+ -+/* 2014/08/07 */ -+-- --------------------------------------------------------------------- -+-- Table `tagente_modulo` -+-- --------------------------------------------------------------------- -+ALTER TABLE "tagente_modulo" MODIFY COLUMN "post_process" NUMERIC(18,15) default 0; -\ No newline at end of file -Index: extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql -=================================================================== ---- extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql (revision 10314) -+++ extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql (working copy) -@@ -48,8 +48,6 @@ - -- --------------------------------------------------------------------- - -- Table `tagente_modulo` - -- --------------------------------------------------------------------- --ALTER TABLE `tagente_modulo` MODIFY COLUMN `post_process` DOUBLE DEFAULT NULL; --/* 2014/05/21 */ - ALTER TABLE `tagente_modulo` ADD COLUMN `min_ff_event_normal` int(4) unsigned default '0'; - ALTER TABLE `tagente_modulo` ADD COLUMN `min_ff_event_warning` int(4) unsigned default '0'; - ALTER TABLE `tagente_modulo` ADD COLUMN `min_ff_event_critical` int(4) unsigned default '0'; -@@ -230,3 +228,9 @@ - -- Table `trecon_script` - -- --------------------------------------------------------------------- - DELETE FROM `trecon_script` WHERE id_recon_script=1; -+ -+/* 2014/08/07 */ -+-- --------------------------------------------------------------------- -+-- Table `tagente_modulo` -+-- --------------------------------------------------------------------- -+ALTER TABLE tagente_modulo MODIFY COLUMN `post_process` double(18,15) default 0; -\ No newline at end of file -Index: extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql -=================================================================== ---- extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql (revision 10314) -+++ extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql (working copy) -@@ -216,3 +216,9 @@ - -- Table trecon_script - -- --------------------------------------------------------------------- - DELETE FROM trecon_script WHERE id_recon_script=1; -+ -+/* 2014/08/07 */ -+-- --------------------------------------------------------------------- -+-- Table `tagente_modulo` -+-- --------------------------------------------------------------------- -+ALTER TABLE tagente_modulo MODIFY COLUMN post_process NUMBER(18,15) default 0; -\ No newline at end of file -Index: mobile/operation/events.php -=================================================================== ---- mobile/operation/events.php (revision 10314) -+++ mobile/operation/events.php (working copy) -@@ -261,6 +261,25 @@ - if (empty($event["tags"])) { - $event["tags"] = '<i>'.__('N/A').'</i>'; - } -+ -+ $event_comments = db_get_value('user_comment', 'tevento', 'id_evento', $id_event); -+ $event_comments_array = array(); -+ $event_comments_array = json_decode($event_comments, true); -+ // Support for new format only. -+ if (empty($event_comments_array)) { -+ $comment = '<i>'.__('N/A').'</i>'; -+ } else { -+ $comment = ''; -+ $event_comments_array = array_reverse($event_comments_array); -+ foreach($event_comments_array as $c) { -+ $comment .= date ($system->getConfig("date_format"), $c['utimestamp']) . ' (' . $c['id_user'] . ')'; -+ $c['comment'] = io_safe_output($c['comment']); -+ $c['comment'] = str_replace("\n", "<br>", $c['comment']); -+ $comment .= '<br>' . $c['comment'] . '<br>'; -+ } -+ } -+ -+ $event["comments"] = $comment; - - echo json_encode(array('correct' => 1, 'event' => $event)); - } -@@ -486,6 +505,10 @@ - <th><?php echo __('Tags');?></th> - <td class="cell_event_tags"></td> - </tr> -+ <tr class="event_comments"> -+ <th><?php echo __('Comments');?></th> -+ <td class="cell_event_comments"></td> -+ </tr> - </tbody> - </table> - <?php -@@ -828,6 +851,9 @@ - .html(event[\"group\"]); - $(\"#detail_event_dialog .cell_event_tags\") - .html(event[\"tags\"]); -+ $(\"#detail_event_dialog .cell_event_comments\") -+ -+.html(event[\"comments\"]); - $(\"#detail_event_dialog .cell_agent\") - .html(event[\"agent\"]); - -Index: general/main_menu.php -=================================================================== ---- general/main_menu.php (revision 10314) -+++ general/main_menu.php (working copy) -@@ -62,74 +62,163 @@ - /* <![CDATA[ */ - - var autohidden_menu = <?php echo $autohidden_menu; ?>; -+var fixed_menu = <?php echo json_encode((bool)$config['fixed_menu']); ?>; -+var fixed_header = <?php echo json_encode((bool)$config['fixed_header']); ?>; -+var id_user = "<?php echo $config['id_user']; ?>"; -+var cookie_name = id_user + '-pandora_menu_state'; -+var cookie_name_encoded = btoa(cookie_name); - -+var menuState = $.cookie(cookie_name_encoded); -+if (!menuState) { -+ menuState = {}; -+} -+else { -+ menuState = JSON.parse(menuState); -+ open_submenus(); -+} -+ -+function open_submenus () { -+ $.each(menuState, function (index, value) { -+ if (value) -+ $('div.menu>ul>li#' + index + '>ul').show(); -+ }); -+ $('div.menu>ul>li.selected>ul').removeClass('invisible'); -+} -+ -+ -+function close_submenus () { -+ $.each(menuState, function (index, value) { -+ if (value) -+ $('div.menu>ul>li#' + index + '>ul').hide(); -+ }); -+ $('div.menu>ul>li.selected>ul').addClass('invisible'); -+} -+ - $(document).ready( function() { -- $("img.toggle").click (function () { -- $(this).siblings ("ul").toggle (); -+ -+ $("img.toggle").click (function (e) { - //In case the links gets activated, we don't want to follow link -- return false; -+ e.preventDefault(); -+ -+ var menuItem = $(this).parent(); -+ var submenu = menuItem.children("ul"); -+ -+ if (submenu.is(":visible")) { -+ submenu.slideUp(); -+ -+ if (typeof menuState[menuItem.attr('id')] != 'undefined') -+ delete menuState[menuItem.attr('id')]; -+ } -+ else { -+ submenu.slideDown(); -+ -+ menuState[menuItem.attr('id')] = 1; -+ } -+ -+ $.cookie(cookie_name_encoded, JSON.stringify(menuState), {expires: 7}); - }); - -- $('#menu_container').hover (handlerIn, handlerOut); -- var openTime = 0; -- var handsIn = 0; -- -- function handlerIn() { -- handsIn = 1; -- if(openTime == 0) { -- show_menu(); -- openTime = new Date().getTime(); -- -- // Close in 1 second if is not closed manually -- setTimeout(function() { -- if(openTime > 0 && handsIn == 0) { -- hide_menu(); -- openTime = 0; -+ if (fixed_menu) { -+ $('div#menu') -+ .css('position', 'fixed') -+ .css('z-index', '9000') -+ .css('left', '0') -+ .css('top', $('div#head').innerHeight() + 'px') -+ .css('height', '100%') -+ .css('overflow', 'hidden') -+ .hover(function (e) { -+ if (!autohidden_menu) { -+ $(this).css('overflow', 'auto').children('div').css('width', 'auto'); - } -- }, 1000); -+ }, function (e) { -+ if (!autohidden_menu) { -+ $(this).css('overflow', 'hidden').children('div').css('width', '100%'); -+ } -+ }) -+ .children('div') -+ .css('margin-bottom', $('div#head').innerHeight() + 'px'); -+ -+ if (!fixed_header) { -+ $(window).scroll(function () { -+ if ($(this).scrollTop() <= $('div#head').innerHeight()) { -+ $('div#menu').css('top', $('div#head').innerHeight() - $(this).scrollTop() + 'px' ); -+ } else { -+ $('div#menu').css('top', '0'); -+ } -+ }); - } - } -- -- function handlerOut() { -- handsIn = 0; -- var openedTime = new Date().getTime() - openTime; -+ -+ if (autohidden_menu) { -+ -+ $('#menu_container').hover (handlerIn, handlerOut); -+ var openTime = 0; -+ var handsIn = 0; -+ -+ $('#main').css('margin-left', '50px'); -+ hide_menu_pretty(); - -- if(openedTime > 1000) { -- hide_menu(); -- openTime = 0; -+ function handlerIn() { -+ handsIn = 1; -+ if (openTime == 0) { -+ show_menu(); -+ openTime = new Date().getTime(); -+ -+ // Close in 1 second if is not closed manually -+ setTimeout(function() { -+ if(openTime > 0 && handsIn == 0) { -+ hide_menu(); -+ openTime = 0; -+ } -+ }, 1000); -+ } - } -+ -+ function handlerOut() { -+ handsIn = 0; -+ var openedTime = new Date().getTime() - openTime; -+ -+ if (openedTime > 1000) { -+ hide_menu(); -+ openTime = 0; -+ } -+ } -+ -+ function show_menu () { -+ $('#menu_container').animate({"left": "+=80px"}, 200, function () { -+ if (fixed_menu) { -+ $('#menu_container').parent().css('overflow', 'auto'); -+ } -+ }); -+ show_menu_pretty(); -+ } -+ -+ function show_menu_pretty() { -+ open_submenus(); -+ $('div.menu ul li').css('background-position', ''); -+ $('ul.submenu li a, li.menu_icon a, li.links a, div.menu>ul>li>img.toggle').show(); -+ $('.titop').css('color', 'white'); -+ $('.bg3').css('color', 'white'); -+ $('.bg4').css('color', 'white'); -+ } -+ -+ function hide_menu () { -+ if (fixed_menu) { -+ $('#menu_container').parent().css('overflow', 'hidden'); -+ } -+ $('#menu_container').animate({"left": "-=80px"}, 100); -+ hide_menu_pretty(); -+ } -+ -+ function hide_menu_pretty() { -+ close_submenus(); -+ $('div.menu li').css('background-position', '85px 5px'); -+ $('ul.submenu li a, li.menu_icon a, li.links a, div.menu>ul>li>img.toggle').hide(); -+ $('.titop').css('color', $('.titop').css('background-color')); -+ $('.bg3').css('color', $('.bg3').css('background-color')); -+ $('.bg4').css('color', $('.bg4').css('background-color')); -+ } - } -- -- function show_menu () { -- $('#menu_container').animate({"left": "+=140px"}, 200); -- show_menu_pretty(); -- } -- -- function show_menu_pretty() { -- $('div.menu ul li').css('background-position', ''); -- $('ul.submenu li a, li.menu_icon a, li.links a').css('visibility', ''); -- $('.titop').css('color', 'white'); -- $('.bg3').css('color', 'white'); -- $('.bg4').css('color', 'white'); -- } -- -- function hide_menu () { -- $('#menu_container').animate({"left": "-=140px"}, 100); -- hide_menu_pretty(); -- } -- -- function hide_menu_pretty() { -- $('div.menu li').css('background-position', '140px 3px'); -- $('ul.submenu li a, li.menu_icon a, li.links a').css('visibility', 'hidden'); -- $('.titop').css('color', $('.titop').css('background-color')); -- $('.bg3').css('color', $('.bg3').css('background-color')); -- $('.bg4').css('color', $('.bg4').css('background-color')); -- } -- -- if (autohidden_menu) { -- $('#main').css('margin-left', '40px'); -- hide_menu_pretty(); -- } - }); - /* ]]> */ - </script> -Index: general/header.php -=================================================================== ---- general/header.php (revision 10314) -+++ general/header.php (working copy) -@@ -58,10 +58,16 @@ - $table->cellspacing = 0; - $table->head = array (); - $table->data = array (); -- $table->style[0] = $table->style[1] = $table->style[3] = -- $table->style[4] = $table->style[5] = -- $table->style[6] = $table->style[8] = -- $table->style[9] = $table->style['qr'] = -+ $table->style[0] = -+ $table->style['clippy'] = -+ $table->style[1] = -+ $table->style[3] = -+ $table->style[4] = -+ $table->style[5] = -+ $table->style[6] = -+ $table->style[8] = -+ $table->style[9] = -+ $table->style['qr'] = - 'width: 22px; text-align:center; height: 22px; padding-right: 9px;'; - $table->style[7] = 'width: 20px; padding-right: 9px;'; - $table->style['searchbar'] = 'width: 180px; min-width: 180px;'; -@@ -122,11 +128,26 @@ - </script> - <?php - -- $table->data[0][0] = $servers_link_open . $servers_check_img . $servers_link_close; -+ if ($config['tutorial_mode'] !== 'expert') { -+ $table->data[0]['clippy'] = -+ '<a href="javascript: show_clippy();">' . -+ html_print_image( -+ "images/clippy_icon.png", -+ true, -+ array("id" => 'clippy', -+ "class" => 'clippy', -+ "alt" => __('Clippy'), -+ 'title' => __('Clippy'))) . -+ '</a>'; -+ } - - -+ $table->data[0][0] = $servers_link_open . -+ $servers_check_img . $servers_link_close; - - -+ -+ - //======= Autorefresh code ============================= - $autorefresh_txt = ''; - $autorefresh_additional = ''; -@@ -303,8 +324,19 @@ - - <script type="text/javascript"> - /* <![CDATA[ */ -+ -+ var fixed_header = <?php echo json_encode((bool)$config['fixed_header']); ?>; -+ - var new_chat = <?php echo (int)$_SESSION['new_chat'];?>; - $(document).ready (function () { -+ -+ if (fixed_header) { -+ $('div#head').addClass('fixed_header'); -+ $('div#page') -+ .css('padding-top', $('div#head').innerHeight() + 'px') -+ .css('position', 'relative'); -+ } -+ - check_new_chats_icon('icon_new_messages_chat'); - - /* Temporal fix to hide graphics when ui_dialog are displayed */ -Index: godmode/audit_log_csv.php -=================================================================== ---- godmode/audit_log_csv.php (revision 0) -+++ godmode/audit_log_csv.php (revision 10417) -@@ -0,0 +1,137 @@ -+<?php -+// ______ __ _______ _______ _______ -+//| __ \.---.-.-----.--| |.-----.----.---.-. | ___| | | __| -+//| __/| _ | | _ || _ | _| _ | | ___| |__ | -+//|___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| -+// -+// ============================================================================ -+// Copyright (c) 2007-2010 Artica Soluciones Tecnologicas, http://www.artica.es -+// This code is NOT free software. This code is NOT licenced under GPL2 licence -+// You cannnot redistribute it without written permission of copyright holder. -+// ============================================================================ -+ -+if (file_exists("../../../include/config.php")) -+ require ("../../../include/config.php"); -+else { -+ //TODO FIX AND SET AS RELATIVE DIRECTORY -+ if (file_exists("/var/www/pandora_console/include/config.php")) -+ require ("/var/www/pandora_console/include/config.php"); -+ if (file_exists("/srv/www/htdocs/pandora_console/include/config.php")) -+ require ("/srv/www/htdocs/pandora_console/include/config.php"); -+} -+ -+global $config; -+ -+require_once ($config["homedir"]."/include/functions.php"); -+require_once ($config["homedir"]."/include/functions_db.php"); -+require_once ($config["homedir"]."/enterprise/include/functions_reporting_csv.php"); -+require_once ($config["homedir"]."/include/auth/mysql.php"); -+ -+error_reporting(E_ALL); -+ini_set("display_errors", 1); -+ -+if (! isset ($_SESSION["id_usuario"])) { -+ session_start (); -+ session_write_close (); -+} -+ -+ -+// Login check -+if (!isset($_SESSION["id_usuario"])) { -+ $config['id_user'] = null; -+} -+else { -+ $config['id_user'] = $_SESSION["id_usuario"]; -+} -+ -+if (!check_login()) { -+ db_pandora_audit("ACL Violation", "Trying to access graph builder"); -+ include ($config["homedir"]."/general/noaccess.php"); -+ return; -+} -+ -+if (! check_acl ($config['id_user'], 0, "PM")) { -+ db_pandora_audit( "ACL Violation", -+ "Trying to access event viewer"); -+ require ("general/noaccess.php"); -+ exit; -+} -+ -+$tipo_log = get_parameter ("tipo_log", 'all'); -+$user_filter = get_parameter('user_filter', 'all'); -+$filter_text = get_parameter('filter_text', ''); -+$filter_hours_old = get_parameter('filter_hours_old', 24); -+$filter_ip = get_parameter('filter_ip', ''); -+ -+$filter = 'WHERE 1 = 1'; -+ -+if ($tipo_log != 'all') { -+ $filter .= " AND accion = '$tipo_log'"; -+} -+switch ($config['dbtype']) { -+ case "mysql": -+ if ($user_filter != 'all') { -+ $filter .= sprintf(' AND id_usuario = "%s"', $user_filter); -+ } -+ -+ $filter .= ' AND (accion LIKE "%' . $filter_text . '%" OR descripcion LIKE "%' . $filter_text . '%")'; -+ -+ if ($filter_ip != '') { -+ $filter .= sprintf(' AND ip_origen LIKE "%s"', $filter_ip); -+ } -+ break; -+ case "postgresql": -+ case "oracle": -+ if ($user_filter != 'all') { -+ $filter .= sprintf(' AND id_usuario = \'%s\'', $user_filter); -+ } -+ -+ $filter .= ' AND (accion LIKE \'%' . $filter_text . '%\' OR descripcion LIKE \'%' . $filter_text . '%\')'; -+ -+ if ($filter_ip != '') { -+ $filter .= sprintf(' AND ip_origen LIKE \'%s\'', $filter_ip); -+ } -+ break; -+} -+ -+if ($filter_hours_old != 0) { -+ switch ($config["dbtype"]) { -+ case "mysql": -+ $filter .= ' AND fecha >= DATE_ADD(NOW(), INTERVAL -' . $filter_hours_old . ' HOUR)'; -+ break; -+ case "postgresql": -+ $filter .= ' AND fecha >= NOW() - INTERVAL \'' . $filter_hours_old . ' HOUR \''; -+ break; -+ case "oracle": -+ $filter .= ' AND fecha >= (SYSTIMESTAMP - INTERVAL \'' . $filter_hours_old . '\' HOUR)'; -+ break; -+ } -+} -+ -+switch ($config["dbtype"]) { -+ case "mysql": -+ $sql = sprintf ("SELECT * -+ FROM tsesion -+ %s -+ ORDER BY fecha DESC", $filter); -+ break; -+ case "postgresql": -+ $sql = sprintf ("SELECT * -+ FROM tsesion -+ %s -+ ORDER BY fecha DESC", $filter); -+ break; -+ case "oracle": -+ $sql = sprintf ("SELECT * -+ FROM tsesion -+ %s -+ ORDER BY fecha DESC", $filter); -+ $result = oracle_recode_query ($sql, $set); -+ break; -+} -+ -+$result = db_get_all_rows_sql ($sql); -+ -+print_audit_csv ($result); -+ -+?> -Index: godmode/admin_access_logs.php -=================================================================== ---- godmode/admin_access_logs.php (revision 10314) -+++ godmode/admin_access_logs.php (working copy) -@@ -295,6 +295,13 @@ - - html_print_table ($table); - -+echo '<div style="width: '.$table->width.'" class="action-buttons">'; -+echo '<a href="' . -+ ui_get_full_url(false, false, false, false) . 'godmode/audit_log_csv.php?tipo_log='.$tipo_log.'&user_filter='.$user_filter.'&filter_text='.$filter_text.'&filter_hours_old='.$filter_hours_old.'&filter_ip='.$filter_ip.'"'. -+ 'target="_new">' . -+ html_print_button (__('Export to CSV '), 'export_csv', false, '', 'class=sub next', true, false). '</a>'; -+echo '</div>'; -+ - if ($enterprise_include !== ENTERPRISE_NOT_HOOK) { - enterprise_hook('enterpriseAuditFooter'); - } -Index: godmode/db/db_info.php -=================================================================== ---- godmode/db/db_info.php (revision 10314) -+++ godmode/db/db_info.php (working copy) -@@ -79,7 +79,7 @@ - - foreach ($count as $agent_id => $value) { - $data = array (); -- -+ - //First row is a link to the agent - $data[0] = '<strong><a href="index.php?sec=gagente&sec2=operation/agentes/ver_agente&id_agente='.$agent_id.'">'.$agents[$agent_id].'</a></strong>'; - //Second row is a number of modules for the agent -Index: godmode/agentes/agent_template.php -=================================================================== ---- godmode/agentes/agent_template.php (revision 10314) -+++ godmode/agentes/agent_template.php (working copy) -@@ -96,7 +96,12 @@ - 'warning_instructions' => $row2['warning_instructions'], - 'unknown_instructions' => $row2['unknown_instructions'], - 'id_category' => $row2['id_category'], -- 'module_macros' => $row2['module_macros'] -+ 'module_macros' => $row2['module_macros'], -+ 'each_ff' => $row2['each_ff'], -+ 'min_ff_event' => $row2['min_ff_event'], -+ 'min_ff_event_normal' => $row2['min_ff_event_normal'], -+ 'min_ff_event_warning' => $row2['min_ff_event_warning'], -+ 'min_ff_event_critical' => $row2['min_ff_event_critical'] - ); - - $name = $row2["name"]; -Index: godmode/agentes/module_manager_editor_plugin.php -=================================================================== ---- godmode/agentes/module_manager_editor_plugin.php (revision 10314) -+++ godmode/agentes/module_manager_editor_plugin.php (working copy) -@@ -84,7 +84,12 @@ - if (!empty($m['help'])) { - $data[0] .= ui_print_help_tip ($m['help'], true); - } -- if($m['hide']) { -+ -+ $m_hide = false; -+ if (isset($m['hide'])) -+ $m_hide = $m['hide']; -+ -+ if ($m_hide) { - $data[1] = html_print_input_password($m['macro'], $m['value'], '', 100, 255, true); - } - else { -Index: godmode/agentes/agent_conf_gis.php -=================================================================== ---- godmode/agentes/agent_conf_gis.php (revision 10314) -+++ godmode/agentes/agent_conf_gis.php (working copy) -@@ -118,9 +118,7 @@ - //Validate altitude - if ((jQuery.trim(altitude).length == 0) || - isNaN(parseFloat(altitude))) { -- $('input[name=altitude]').css('background', '#cc0000'); -- -- valid = false; -+ $('input[name=altitude]').val(1); - } - - if (valid) return true; -Index: godmode/agentes/agent_wizard.snmp_explorer.php -=================================================================== ---- godmode/agentes/agent_wizard.snmp_explorer.php (revision 10314) -+++ godmode/agentes/agent_wizard.snmp_explorer.php (working copy) -@@ -50,65 +50,74 @@ - // Get the plugin - $plugin = db_get_row_sql('SELECT * FROM tplugin WHERE execute LIKE "%/snmp_remote.pl"'); - --if(empty($plugin)) { -+if (empty($plugin)) { - ui_print_info_message(array('message' => __('The SNMP remote plugin doesnt seem to be installed') . '. ' . __('It is necessary to use some features') . '.<br><br>' . __('Please, install the SNMP remote plugin (The name of the plugin must be snmp_remote.pl)'), 'no_close' => true)); - } - - // Define STATIC SNMP data - $static_snmp_descriptions = array( -- 'Load-1' => 'Load Average (Last minute)', -- 'Load-5' => 'Load Average (Last 5 minutes)', -- 'Load-15' => 'Load Average (Last 5 minutes)', -- 'memTotalSwap' => 'Total Swap Size configured for the host', -- 'memAvailSwap' => 'Available Swap Space on the host', -- 'memTotalReal' => 'Total Real/Physical Memory Size on the host', -- 'memAvailReal' => 'Available Real/Physical Memory Space on the host', -- 'memTotalFree' => 'Total Available Memory on the host', -- //'memShared' => 'Total Shared Memory', -- 'memCached' => 'Total Cached Memory', -- 'memBuffer' => 'Total Buffered Memory', -- 'ssSwapIn' => 'Amount of memory swapped in from disk (kB/s)', -- 'ssSwapOut' => 'Amount of memory swapped to disk (kB/s)', -- 'ssIORawSent' => 'Number of blocks sent to a block device', -- 'ssIORawReceived' => 'Number of blocks received from a block device', -- 'ssRawInterrupts' => 'Number of interrupts processed', -- 'ssRawContexts' => 'Number of context switches', -- 'ssCpuRawUser' => 'user CPU time', -- 'ssCpuRawSystem' => 'system CPU time', -- 'ssCpuRawIdle' => 'idle CPU time' -- ); -- -+ 'Load-1' => 'Load Average (Last minute)', -+ 'Load-5' => 'Load Average (Last 5 minutes)', -+ 'Load-15' => 'Load Average (Last 5 minutes)', -+ 'memTotalSwap' => 'Total Swap Size configured for the host', -+ 'memAvailSwap' => 'Available Swap Space on the host', -+ 'memTotalReal' => 'Total Real/Physical Memory Size on the host', -+ 'memAvailReal' => 'Available Real/Physical Memory Space on the host', -+ 'memTotalFree' => 'Total Available Memory on the host', -+ //'memShared' => 'Total Shared Memory', -+ 'memCached' => 'Total Cached Memory', -+ 'memBuffer' => 'Total Buffered Memory', -+ 'ssSwapIn' => 'Amount of memory swapped in from disk (kB/s)', -+ 'ssSwapOut' => 'Amount of memory swapped to disk (kB/s)', -+ 'ssIORawSent' => 'Number of blocks sent to a block device', -+ 'ssIORawReceived' => 'Number of blocks received from a block device', -+ 'ssRawInterrupts' => 'Number of interrupts processed', -+ 'ssRawContexts' => 'Number of context switches', -+ 'ssCpuRawUser' => 'user CPU time', -+ 'ssCpuRawSystem' => 'system CPU time', -+ 'ssCpuRawIdle' => 'idle CPU time' -+ ); -+ - $static_snmp_oids = array( -- 'Load-1' => '.1.3.6.1.4.1.2021.10.1.5.1', -- 'Load-5' => '.1.3.6.1.4.1.2021.10.1.5.2', -- 'Load-15' => '.1.3.6.1.4.1.2021.10.1.5.3', -- 'memTotalSwap' => '.1.3.6.1.4.1.2021.4.3.0', -- 'memAvailSwap' => '.1.3.6.1.4.1.2021.4.4.0', -- 'memTotalReal' => '.1.3.6.1.4.1.2021.4.5.0', -- 'memAvailReal' => '.1.3.6.1.4.1.2021.4.6.0', -- 'memTotalFree' => '.1.3.6.1.4.1.2021.4.11.0', -- //'memShared' => '.1.3.6.1.4.1.2021.4.13', -- 'memCached' => '.1.3.6.1.4.1.2021.4.15.0', -- 'memBuffer' => '.1.3.6.1.4.1.2021.4.14.0', -- 'ssSwapIn' => '.1.3.6.1.4.1.2021.11.3.0', -- 'ssSwapOut' => '.1.3.6.1.4.1.2021.11.4.0', -- 'ssIORawSent' => '.1.3.6.1.4.1.2021.11.57.0', -- 'ssIORawReceived' => '.1.3.6.1.4.1.2021.11.58.0', -- 'ssRawInterrupts' => '.1.3.6.1.4.1.2021.11.59.0', -- 'ssRawContexts' => '.1.3.6.1.4.1.2021.11.60.0', -- 'ssCpuRawUser' => '.1.3.6.1.4.1.2021.11.50.0', -- 'ssCpuRawSystem' => '.1.3.6.1.4.1.2021.11.52.0', -- 'ssCpuRawIdle' => '.1.3.6.1.4.1.2021.11.53.0' -- ); -+ 'Load-1' => '.1.3.6.1.4.1.2021.10.1.5.1', -+ 'Load-5' => '.1.3.6.1.4.1.2021.10.1.5.2', -+ 'Load-15' => '.1.3.6.1.4.1.2021.10.1.5.3', -+ 'memTotalSwap' => '.1.3.6.1.4.1.2021.4.3.0', -+ 'memAvailSwap' => '.1.3.6.1.4.1.2021.4.4.0', -+ 'memTotalReal' => '.1.3.6.1.4.1.2021.4.5.0', -+ 'memAvailReal' => '.1.3.6.1.4.1.2021.4.6.0', -+ 'memTotalFree' => '.1.3.6.1.4.1.2021.4.11.0', -+ //'memShared' => '.1.3.6.1.4.1.2021.4.13', -+ 'memCached' => '.1.3.6.1.4.1.2021.4.15.0', -+ 'memBuffer' => '.1.3.6.1.4.1.2021.4.14.0', -+ 'ssSwapIn' => '.1.3.6.1.4.1.2021.11.3.0', -+ 'ssSwapOut' => '.1.3.6.1.4.1.2021.11.4.0', -+ 'ssIORawSent' => '.1.3.6.1.4.1.2021.11.57.0', -+ 'ssIORawReceived' => '.1.3.6.1.4.1.2021.11.58.0', -+ 'ssRawInterrupts' => '.1.3.6.1.4.1.2021.11.59.0', -+ 'ssRawContexts' => '.1.3.6.1.4.1.2021.11.60.0', -+ 'ssCpuRawUser' => '.1.3.6.1.4.1.2021.11.50.0', -+ 'ssCpuRawSystem' => '.1.3.6.1.4.1.2021.11.52.0', -+ 'ssCpuRawIdle' => '.1.3.6.1.4.1.2021.11.53.0' -+ ); - - // Using plugin --if(!empty($plugin)) { -+if (!empty($plugin)) { - $static_snmp_descriptions['avgCpuLoad'] = 'Average of CPUs Load (%)'; - $static_snmp_descriptions['memoryUse'] = 'Memory use (%)'; - } - - $fail = false; - -+$devices = array(); -+$processes = array(); -+$disks = array(); -+$temperatures = array(); -+ -+$arrow = false; -+ -+$other_snmp_data = array(); -+ - if ($snmpwalk) { - // OID Used is for DISKS - $snmpis = get_snmpwalk($ip_target, $snmp_version, $snmp_community, $snmp3_auth_user, -@@ -120,7 +129,6 @@ - $snmpis = array(); - } - else { -- $disks = array(); - // We get here only the interface part of the MIB, not full mib - foreach($snmpis as $key => $snmp) { - -@@ -136,14 +144,14 @@ - - if (array_key_exists(1,$data)) { - $disks[$data[1]] = $data[1]; -- -+ - } - else { - $disks[$data[0]] = $data[0]; -- -- } -+ -+ } - } -- -+ - // OID Used is for PROCESSES - $snmpis = get_snmpwalk($ip_target, $snmp_version, $snmp_community, $snmp3_auth_user, - $snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass, -@@ -152,8 +160,8 @@ - if ($snmpis === false) { - $snmpis = array(); - } -- -- $processes = array(); -+ -+ - // We get here only the interface part of the MIB, not full mib - foreach($snmpis as $key => $snmp) { - -@@ -168,12 +176,12 @@ - - if (array_key_exists(1,$data)) { - $process_name = str_replace ( "\"" , "" , $data[1]); -- -+ - } - else { - $process_name = str_replace ( "\"" , "" , $data[0]); -- -- } -+ -+ } - - $processes[$process_name] = $process_name; - } -@@ -191,7 +199,7 @@ - $snmpis = array(); - } - -- $temperatures = array(); -+ - // We get here only the interface part of the MIB, not full mib - foreach($snmpis as $key => $snmp) { - -@@ -208,11 +216,11 @@ - if ($keydata2[0] == 'lmTempSensorsDevice') { - if (array_key_exists(1,$data)) { - $temperatures[$keydata2[1]] = $data[1]; -- -+ - } - else { - $temperatures[$keydata2[1]] = $data[0]; -- -+ - } - } - } -@@ -229,7 +237,7 @@ - $snmpis = array(); - } - -- $devices = array(); -+ - // We get here only the interface part of the MIB, not full mib - foreach($snmpis as $key => $snmp) { - -@@ -262,8 +270,15 @@ - - // Other SNMP Data - $arrow = true; -- foreach ($static_snmp_oids as $key=>$oid) { -- $result = snmpget($ip_target, $snmp_community, $oid); -+ -+ foreach ($static_snmp_oids as $key => $oid) { -+ if ($snmp_version == 3) { -+ $result = false; //It is statics oids. -+ } -+ else { -+ $result = snmpget($ip_target, $snmp_community, $oid); -+ } -+ - if ($result != false) { - $other_snmp_data[$key] = $static_snmp_descriptions[$key]; - } -@@ -318,7 +333,7 @@ - ui_print_error_message (__('No agent selected or the agent does not exist')); - } - else { -- -+ - // Common values - $common_values = array(); - -@@ -341,33 +356,33 @@ - - // DEVICES - $devices_prefix_oids = array( -- 'diskIONRead' => '.1.3.6.1.4.1.2021.13.15.1.1.3.', -- 'diskIONWritten' => '.1.3.6.1.4.1.2021.13.15.1.1.4.', -- 'diskIONReads' => '.1.3.6.1.4.1.2021.13.15.1.1.5.', -- 'diskIONWrites' => '.1.3.6.1.4.1.2021.13.15.1.1.6.' -- ); -- -+ 'diskIONRead' => '.1.3.6.1.4.1.2021.13.15.1.1.3.', -+ 'diskIONWritten' => '.1.3.6.1.4.1.2021.13.15.1.1.4.', -+ 'diskIONReads' => '.1.3.6.1.4.1.2021.13.15.1.1.5.', -+ 'diskIONWrites' => '.1.3.6.1.4.1.2021.13.15.1.1.6.' -+ ); -+ - $devices_prefix_descriptions = array( -- 'diskIONRead' => 'The number of bytes read from this device since boot', -- 'diskIONWritten' => 'The number of bytes written to this device since boot', -- 'diskIONReads' => 'The number of read accesses from this device since boot', -- 'diskIONWrites' => 'The number of write accesses from this device since boot' -- ); -- -+ 'diskIONRead' => 'The number of bytes read from this device since boot', -+ 'diskIONWritten' => 'The number of bytes written to this device since boot', -+ 'diskIONReads' => 'The number of read accesses from this device since boot', -+ 'diskIONWrites' => 'The number of write accesses from this device since boot' -+ ); -+ - $results = array(); - - foreach ($devices as $device) { - $module_values = $common_values; -- -+ - // Split module data to get type, name, etc - $device_exploded = explode($separator, $device); - $device_name = $device_exploded[0]; - - $name_exploded = explode('-', $device_name); - $name = ltrim(html_entity_decode($name_exploded[1])); -- -+ - $device_type = $device_exploded[1]; -- -+ - // Delete type from device id - unset($device_exploded[0]); - unset($device_exploded[1]); -@@ -376,10 +391,11 @@ - $device_id = implode($separator, $device_exploded); - - $module_values['descripcion'] = $devices_prefix_descriptions[$device_type]; -- -+ - if (($name == 'Bytes read') || ($name == 'Bytes written')) { - $module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp_inc'); -- } else { -+ } -+ else { - $module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp'); - } - -@@ -398,7 +414,7 @@ - - foreach ($temperatures as $temperature) { - $module_values = $common_values; -- -+ - // Split module data to get type, name, etc - $temperature_exploded = explode($separator, $temperature); - $temperature_name = $temperature_exploded[0]; -@@ -434,14 +450,14 @@ - - $module_values['descripcion'] = $static_snmp_descriptions[$snmpdata_name]; - $module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp'); -- -+ - //Average use of CPUs is a plugin module - switch ($snmpdata_name) { - case 'avgCpuLoad': - case 'memoryUse': - $module_values['id_modulo'] = MODULE_PLUGIN; - $module_values['id_plugin'] = $plugin['id']; -- -+ - $macros = json_decode($plugin['macros'], true); - - foreach($macros as $k => $macro) { -@@ -464,6 +480,33 @@ - $macros[$k]['value'] = '-m memuse'; - break; - } -+ -+ if ($snmp_version == '3') { -+ $macros[$k]['value'] .= " -v3 "; -+ switch ($snmp3_security_level) { -+ case "authNoPriv": -+ $macros[$k]['value'] .= -+ ' -u ' . $snmp3_auth_user . -+ ' -A ' . $snmp3_auth_pass . -+ ' -l ' . $snmp3_security_level . -+ ' -a ' . $snmp3_auth_method; -+ break; -+ case "noAuthNoPriv": -+ $macros[$k]['value'] .= -+ ' -u ' . $snmp3_auth_user . -+ ' -l ' . $snmp3_security_level; -+ break; -+ default: -+ $macros[$k]['value'] .= -+ ' -u ' . $snmp3_auth_user . -+ ' -A ' . $snmp3_auth_pass . -+ ' -l ' . $snmp3_security_level . -+ ' -a ' . $snmp3_auth_method . -+ ' -x ' . $snmp3_privacy_method . -+ ' -X ' . $snmp3_privacy_pass; -+ break; -+ } -+ } - break; - } - } -@@ -497,7 +540,7 @@ - - $macros = json_decode($plugin['macros'], true); - -- foreach($macros as $k => $macro) { -+ foreach ($macros as $k => $macro) { - switch($macro['macro']) { - case '_field1_': - // Field 1 is the IP Address -@@ -510,6 +553,33 @@ - case '_field3_': - // Field 3 is the plugin parameters - $macros[$k]['value'] = io_safe_input('-m process -p "' . $process . '"'); -+ -+ if ($snmp_version == '3') { -+ $macros[$k]['value'] .= " -v3 "; -+ switch ($snmp3_security_level) { -+ case "authNoPriv": -+ $macros[$k]['value'] .= -+ ' -u ' . $snmp3_auth_user . -+ ' -A ' . $snmp3_auth_pass . -+ ' -l ' . $snmp3_security_level . -+ ' -a ' . $snmp3_auth_method; -+ break; -+ case "noAuthNoPriv": -+ $macros[$k]['value'] .= -+ ' -u ' . $snmp3_auth_user . -+ ' -l ' . $snmp3_security_level; -+ break; -+ default: -+ $macros[$k]['value'] .= -+ ' -u ' . $snmp3_auth_user . -+ ' -A ' . $snmp3_auth_pass . -+ ' -l ' . $snmp3_security_level . -+ ' -a ' . $snmp3_auth_method . -+ ' -x ' . $snmp3_privacy_method . -+ ' -X ' . $snmp3_privacy_pass; -+ break; -+ } -+ } - break; - } - } -@@ -519,7 +589,7 @@ - unset($module_values['snmp_community']); //snmp_community - unset($module_values['ip_target']); //ip_target - unset($module_values['tcp_send']); //snmp_version -- -+ - $result = modules_create_agent_module ($id_agent, io_safe_input($process), $module_values); - - $results[$result][] = $process; -@@ -537,7 +607,7 @@ - - $macros = json_decode($plugin['macros'], true); - -- foreach($macros as $k => $macro) { -+ foreach ($macros as $k => $macro) { - switch($macro['macro']) { - case '_field1_': - // Field 1 is the IP Address -@@ -550,7 +620,33 @@ - case '_field3_': - // Field 3 is the plugin parameters - $macros[$k]['value'] = io_safe_input('-m diskuse -d "' . io_safe_output($disk) . '"'); -- break; -+ -+ if ($snmp_version == '3') { -+ $macros[$k]['value'] .= " -v3 "; -+ switch ($snmp3_security_level) { -+ case "authNoPriv": -+ $macros[$k]['value'] .= -+ ' -u ' . $snmp3_auth_user . -+ ' -A ' . $snmp3_auth_pass . -+ ' -l ' . $snmp3_security_level . -+ ' -a ' . $snmp3_auth_method; -+ break; -+ case "noAuthNoPriv": -+ $macros[$k]['value'] .= -+ ' -u ' . $snmp3_auth_user . -+ ' -l ' . $snmp3_security_level; -+ break; -+ default: -+ $macros[$k]['value'] .= -+ ' -u ' . $snmp3_auth_user . -+ ' -A ' . $snmp3_auth_pass . -+ ' -l ' . $snmp3_security_level . -+ ' -a ' . $snmp3_auth_method . -+ ' -x ' . $snmp3_privacy_method . -+ ' -X ' . $snmp3_privacy_pass; -+ break; -+ } -+ } - } - } - -@@ -559,34 +655,46 @@ - unset($module_values['snmp_community']); //snmp_community - unset($module_values['ip_target']); //ip_target - unset($module_values['tcp_send']); //snmp_version -- -- $result = modules_create_agent_module ($id_agent, io_safe_input($disk), $module_values); - -+ $result = modules_create_agent_module($id_agent, io_safe_input($disk), $module_values); -+ - $results[$result][] = $disk; - } -- -+ - $success_message = ''; - $error_message = ''; -- -- if (count($results[NOERR]) > 0) { -- $success_message .= sprintf(__('%s modules created succesfully'), count($results[NOERR])) . '<br>'; -+ -+ if (isset($results[NOERR])) { -+ if (count($results[NOERR]) > 0) { -+ $success_message .= sprintf(__('%s modules created succesfully'), count($results[NOERR])) . '<br>'; -+ } - } -- if (count($results[ERR_GENERIC]) > 0) { -- $error_message .= sprintf(__('Error creating %s modules') . ': <br> * ' . implode('<br> * ', $results[ERR_GENERIC]), count($results[ERR_GENERIC])) . '<br>'; -+ if (isset($results[ERR_GENERIC])) { -+ if (count($results[ERR_GENERIC]) > 0) { -+ $error_message .= sprintf(__('Error creating %s modules') . ': <br> * ' . implode('<br> * ', $results[ERR_GENERIC]), count($results[ERR_GENERIC])) . '<br>'; -+ } - } -- if (count($results[ERR_EXIST]) > 0) { -- $error_message .= sprintf(__('%s modules already exist') . ': <br> * ' . implode('<br> * ', $results[ERR_EXIST]), count($results[ERR_EXIST])) . '<br>'; -+ if (isset($results[ERR_DB])) { -+ if (count($results[ERR_DB]) > 0) { -+ $error_message .= sprintf(__('Error creating %s modules') . ': <br> * ' . implode('<br> * ', $results[ERR_DB]), count($results[ERR_DB])) . '<br>'; -+ } - } -+ if (isset($results[ERR_EXIST])) { -+ if (count($results[ERR_EXIST]) > 0) { -+ $error_message .= sprintf(__('%s modules already exist') . ': <br> * ' . implode('<br> * ', $results[ERR_EXIST]), count($results[ERR_EXIST])) . '<br>'; -+ } -+ } - - if (!empty($error_message)) { - ui_print_error_message($error_message); -- } else { -+ } -+ else { - if (empty($success_message)) { - $success_message .= sprintf(__('Modules created succesfully')) . '<br>'; - } - ui_print_success_message($success_message); - } -- } -+ } - } - - echo '<span id ="none_text" style="display: none;">' . __('None') . '</span>'; -@@ -697,17 +805,17 @@ - $table->data[1][0] .= html_print_select ($modes, - 'snmp_wizard_modes', '', '', '', '', true, false, false); - $table->cellstyle[1][0] = 'vertical-align: middle;'; -- -+ - $table->colspan[1][0] = 2; - $table->data[1][2] = '<b>'.__('Modules').'</b>'; - $table->cellstyle[1][2] = 'vertical-align: middle;'; -- -+ - // Devices list -- $table->data[2][0] .= '<div class="wizard_mode_form wizard_mode_devices">'; -+ $table->data[2][0] = '<div class="wizard_mode_form wizard_mode_devices">'; - $table->data[2][0] .= html_print_select ($devices, 'devices', '', '', - '', '', true, true, true, '', false, 'width: 300px;'); - $table->data[2][0] .= '</div>'; -- -+ - // If SNMP remote plugin is not installed, show an advice - if(empty($plugin)) { - // Processes list -@@ -747,7 +855,7 @@ - $table->data[2][0] .= '</div>'; - - $table->cellstyle[2][0] = 'vertical-align: top; text-align: center;'; -- -+ - // Devices arrow - $table->data[2][1] = '<div class="wizard_mode_form wizard_mode_devices wizard_mode_devices_arrow clickable">' . html_print_image('images/darrowright.png', true, array('title' => __('Add to modules list'))) . '</div>'; - // Processes arrow -@@ -761,15 +869,15 @@ - $table->data[2][1] .= '<div class="wizard_mode_form wizard_mode_snmpdata wizard_mode_snmpdata_arrow clickable">' . html_print_image('images/darrowright.png', true, array('title' => __('Add to modules list'))) . '</div>'; - } - $table->data[2][1] .= '<br><br><div class="wizard_mode_delete_arrow clickable">' . html_print_image('images/cross.png', true, array('title' => __('Remove from modules list'))) . '</div>'; -- $table->cellstyle[2][1] .= 'vertical-align: middle; text-align: center;'; -- -+ $table->cellstyle[2][1] = 'vertical-align: middle; text-align: center;'; -+ - $table->data[2][2] = html_print_select (array (), 'module[]', 0, false, '', 0, true, true, true, '', false, 'width:300px; height: 100%;'); - $table->data[2][2] .= html_print_input_hidden('agent', $id_agent, true); - $table->cellstyle[2][2] = 'vertical-align: top; text-align: center;'; -- -+ - html_print_table($table); - -- echo "<div style='text-align:right; width:".$table->width."'>"; -+ echo "<div style='text-align:right; width:" . $table->width . "'>"; - html_print_submit_button(__('Create modules'), 'create_modules_btn', false, array('class' => 'sub add')); - echo "</div>"; - unset($table); -@@ -778,7 +886,7 @@ - echo "</form>"; - echo '</div>'; - } -- -+ - ui_require_jquery_file ('pandora.controls'); - ui_require_jquery_file ('ajaxqueue'); - ui_require_jquery_file ('bgiframe'); -Index: godmode/agentes/planned_downtime.editor.php -=================================================================== ---- godmode/agentes/planned_downtime.editor.php (revision 10314) -+++ godmode/agentes/planned_downtime.editor.php (working copy) -@@ -1,5 +1,4 @@ - <?php -- - // Pandora FMS - http://pandorafms.com - // ================================================== - // Copyright (c) 2005-2010 Artica Soluciones Tecnologicas -@@ -18,6 +17,7 @@ - - check_login(); - -+ - if (! check_acl ($config['id_user'], 0, "AW")) { - db_pandora_audit("ACL Violation", - "Trying to access downtime scheduler"); -@@ -25,6 +25,7 @@ - return; - } - -+ - require_once ('include/functions_users.php'); - - // Header -@@ -36,10 +37,7 @@ - true, - ""); - --// Load global vars --global $config; - --check_login(); - - //Initialize data - $id_agent = get_parameter ("id_agent"); -@@ -153,7 +151,7 @@ - $datetime_from = strtotime ($once_date_from . ' ' . $once_time_from); - $datetime_to = strtotime ($once_date_to . ' ' . $once_time_to); - $now = strtotime(date(DATE_FORMAT). ' ' . date(TIME_FORMAT)); -- -+ - if ($datetime_from < $now) { - ui_print_error_message(__('Not created. Error inserting data. Start time must be higher than the current time' )); - } -Index: godmode/agentes/modificar_agente.php -=================================================================== ---- godmode/agentes/modificar_agente.php (revision 10314) -+++ godmode/agentes/modificar_agente.php (working copy) -@@ -161,6 +161,17 @@ - echo "</div>"; - - -+$order_collation = ""; -+switch ($config["dbtype"]) { -+ case "mysql": -+ $order_collation = "COLLATE utf8_general_ci"; -+ break; -+ case "postgresql": -+ case "oracle": -+ $order_collation = ""; -+ break; -+} -+ - $selected = 'border: 1px solid black;'; - $selectNameUp = ''; - $selectNameDown = ''; -@@ -173,14 +184,14 @@ - switch ($sort) { - case 'up': - $selectNameUp = $selected; -- $order = array('field' => 'nombre COLLATE utf8_general_ci', -- 'field2' => 'nombre COLLATE utf8_general_ci', -+ $order = array('field' => 'nombre ' . $order_collation, -+ 'field2' => 'nombre ' . $order_collation, - 'order' => 'ASC'); - break; - case 'down': - $selectNameDown = $selected; -- $order = array('field' => 'nombre COLLATE utf8_general_ci', -- 'field2' => 'nombre COLLATE utf8_general_ci', -+ $order = array('field' => 'nombre ' . $order_collation, -+ 'field2' => 'nombre ' . $order_collation, - 'order' => 'DESC'); - break; - } -@@ -190,13 +201,13 @@ - case 'up': - $selectOsUp = $selected; - $order = array('field' => 'id_os', -- 'field2' => 'nombre COLLATE utf8_general_ci', -+ 'field2' => 'nombre ' . $order_collation, - 'order' => 'ASC'); - break; - case 'down': - $selectOsDown = $selected; - $order = array('field' => 'id_os', -- 'field2' => 'nombre COLLATE utf8_general_ci', -+ 'field2' => 'nombre ' . $order_collation, - 'order' => 'DESC'); - break; - } -@@ -206,13 +217,13 @@ - case 'up': - $selectGroupUp = $selected; - $order = array('field' => 'id_grupo', -- 'field2' => 'nombre COLLATE utf8_general_ci', -+ 'field2' => 'nombre ' . $order_collation, - 'order' => 'ASC'); - break; - case 'down': - $selectGroupDown = $selected; - $order = array('field' => 'id_grupo', -- 'field2' => 'nombre COLLATE utf8_general_ci', -+ 'field2' => 'nombre ' . $order_collation, - 'order' => 'DESC'); - break; - } -@@ -224,13 +235,16 @@ - $selectOsDown = ''; - $selectGroupUp = ''; - $selectGroupDown = ''; -- $order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); -+ $order = array('field' => 'nombre ' . $order_collation, -+ 'field2' => 'nombre ' . $order_collation, -+ 'order' => 'ASC'); - break; - } - - $search_sql = ''; - if ($search != "") { -- $search_sql = " AND ( nombre COLLATE utf8_general_ci LIKE '%$search%' OR direccion LIKE '%$search%') "; -+ $search_sql = " AND ( nombre " . $order_collation . " -+ LIKE '%$search%' OR direccion LIKE '%$search%') "; - } - - // Show only selected groups -Index: godmode/agentes/agent_manager.php -=================================================================== ---- godmode/agentes/agent_manager.php (revision 10314) -+++ godmode/agentes/agent_manager.php (working copy) -@@ -159,7 +159,8 @@ - - $table->data[0][1] .= " <b>" . __("ID") . "</b> $id_agente "; - $table->data[0][1] .= ' <a href="index.php?sec=gagente&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'">'; -- $table->data[0][1] .= html_print_image ("images/zoom.png", true, array ("border" => 0, "title" => __('Agent detail'))); -+ $table->data[0][1] .= html_print_image ("images/zoom.png", -+ true, array ("border" => 0, "title" => __('Agent detail'))); - $table->data[0][1] .= '</a>'; - } - -@@ -215,9 +216,14 @@ - </style> - <?php - $table->rowspan[1][2] = 7; --$table->data[1][2] = -- "<a id='qr_code_agent_view' href='javascript: show_dialog_qrcode(null, \"" . -- ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agente) . "\" );'></a>"; -+if ($id_agente) { -+ $table->data[1][2] = -+ "<a id='qr_code_agent_view' href='javascript: show_dialog_qrcode(null, \"" . -+ ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agente) . "\" );'></a>"; -+} -+else { -+ $table->data[1][2] = __("Only it is show when<br />the agent is saved."); -+} - - $groups = users_get_groups ($config["id_user"], "AR",false); - $agents = agents_get_group_agents (array_keys ($groups)); -Index: godmode/servers/manage_recontask.php -=================================================================== ---- godmode/servers/manage_recontask.php (revision 10314) -+++ godmode/servers/manage_recontask.php (working copy) -@@ -204,6 +204,7 @@ - if (($id_recon_script == 'NULL') && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network)) - { - $result = db_process_sql_insert('trecon_task', $values); -+ - $reason = __("Network provided is not correct"); - } - elseif ($id_recon_script != 'NULL') { -@@ -215,9 +216,10 @@ - $result = false; - } - } -- else -+ else { - $result = false; -- -+ } -+ - if ($result !== false) { - ui_print_success_message(__('Successfully created recon task')); - } -Index: godmode/servers/manage_recontask_form.php -=================================================================== ---- godmode/servers/manage_recontask_form.php (revision 10314) -+++ godmode/servers/manage_recontask_form.php (working copy) -@@ -54,7 +54,7 @@ - echo io_json_mb_encode($macros); - return; - } -- -+ - return; - } - -@@ -261,7 +261,7 @@ - - - $explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id_recon_script); -- -+ - $table->data[12][0] = "<b>" . __('Explanation') . "</b>"; - $table->data[12][1] = "<span id='spinner_layour' style='display: none;'>" . html_print_image ("images/spinner.gif", true) . - "</span>" . html_print_textarea('explanation', 4, 60, $explanation, 'style="width: 388px;"', true); -Index: godmode/alerts/configure_alert_template.php -=================================================================== ---- godmode/alerts/configure_alert_template.php (revision 10314) -+++ godmode/alerts/configure_alert_template.php (working copy) -@@ -394,11 +394,15 @@ - } - if ($result) { - //db_pandora_audit("Command management", "Create alert command " . $result, false, false, json_encode($values)); -- db_pandora_audit("Template alert management", "Create alert template #" . $result, false, false, json_encode($values)); -+ db_pandora_audit("Template alert management", -+ "Create alert template #" . $result, false, false, -+ json_encode($values)); - } - else { - //db_pandora_audit("Command management", "Fail try to create alert command", false, false, json_encode($values)); -- db_pandora_audit("Template alert management", "Fail try to create alert template", false, false, json_encode($values)); -+ db_pandora_audit("Template alert management", -+ "Fail try to create alert template", false, false, -+ json_encode($values)); - } - - ui_print_result_message ($result, -@@ -455,7 +459,7 @@ - for ($i = 1; $i <= 10; $i++) { - $fields_recovery[$i] = $template['field'.$i.'_recovery']; - } -- -+ - $default_action = $template['id_alert_action']; - $priority = $template['priority']; - $id_group = $template['id_group']; -@@ -474,6 +478,10 @@ - $table->size[2] = '20%'; - - if ($step == 2) { -+ -+ if (!isset($show_matches)) -+ $show_matches = false; -+ - /* Firing conditions and events */ - $table->colspan = array (); - $table->colspan[4][1] = 3; -@@ -493,7 +501,7 @@ - $table->data[0][1] .= html_print_checkbox ('saturday', 1, $saturday, true); - $table->data[0][1] .= __('Sun'); - $table->data[0][1] .= html_print_checkbox ('sunday', 1, $sunday, true); -- -+ - $table->data[0][2] = __('Use special days list'); - $table->data[0][3] = html_print_checkbox ('special_day', 1, $special_day, true); - -@@ -512,11 +520,11 @@ - '', false, true); - - $table->data[3][0] = __('Min. number of alerts'); -- $table->data[3][1] = html_print_input_text ('min_alerts', $min_alerts, '', -- 5, 7, true); -+ $table->data[3][1] = html_print_input_text ('min_alerts', -+ $min_alerts, '', 5, 7, true); - $table->data[3][2] = __('Max. number of alerts'); -- $table->data[3][3] = html_print_input_text ('max_alerts', $max_alerts, '', -- 5, 7, true); -+ $table->data[3][3] = html_print_input_text ('max_alerts', -+ $max_alerts, '', 5, 7, true); - - $table->data[4][0] = __('Default action'); - $usr_groups = implode(',', array_keys(users_get_groups($config['id_user'], 'LM', true))); -@@ -529,7 +537,8 @@ - ORDER BY name', $usr_groups); - break; - case "oracle": -- $sql_query = sprintf('SELECT id, dbms_lob.substr(name,4000,1) as nombre -+ $sql_query = sprintf('SELECT id, -+ dbms_lob.substr(name,4000,1) AS nombre - FROM talert_actions - WHERE id_group IN (%s) - ORDER BY dbms_lob.substr(name,4000,1)', $usr_groups); -@@ -543,13 +552,15 @@ - $table->data[5][0] = __('Condition type'); - $table->data[5][1] = html_print_select (alerts_get_alert_templates_types (), 'type', - $type, '', __('Select'), 0, true, false, false); -- $table->data[5][1] .= '<span id="matches_value" '.($show_matches ? '' : 'style="display: none"').'>'; -+ $table->data[5][1] .= '<span id="matches_value" ' . -+ ($show_matches ? '' : 'style="display: none"').'>'; - $table->data[5][1] .= ' '.html_print_checkbox ('matches_value', 1, $matches, true); -- $table->data[5][1] .= html_print_label (__('Trigger when matches the value'), -+ $table->data[5][1] .= html_print_label( -+ __('Trigger when matches the value'), - 'checkbox-matches_value', true); - $table->data[5][1] .= '</span>'; - $table->colspan[5][1] = 3; -- -+ - $table->data['value'][0] = __('Value'); - $table->data['value'][1] = html_print_input_text ('value', $value, '', - 35, 255, true); -@@ -566,17 +577,20 @@ - 'width' => '20px')); - $table->data['value'][1] .= '</span>'; - $table->colspan['value'][1] = 3; -- -+ - //Min first, then max, that's more logical - $table->data['min'][0] = __('Min.'); -- $table->data['min'][1] = html_print_input_text ('min', $min, '', 5, 255, true); -+ $table->data['min'][1] = html_print_input_text ('min', $min, '', 5, -+ 255, true); - $table->colspan['min'][1] = 3; -- -+ - $table->data['max'][0] = __('Max.'); -- $table->data['max'][1] = html_print_input_text ('max', $max, '', 5, 255, true); -+ $table->data['max'][1] = html_print_input_text ('max', $max, '', 5, -+ 255, true); - $table->colspan['max'][1] = 3; -- -- $table->data['example'][1] = ui_print_alert_template_example ($id, true, false); -+ -+ $table->data['example'][1] = ui_print_alert_template_example($id, -+ true, false); - $table->colspan['example'][1] = 4; - } - else if ($step == 3) { -@@ -585,7 +599,7 @@ - $table->style[2] = 'font-weight: bold; vertical-align: top'; - $table->size = array (); - $table->size[0] = '20%'; -- -+ - /* Alert recover */ - if (! $recovery_notify) { - $table->cellstyle['label_fields'][2] = 'display:none;'; -@@ -610,7 +624,7 @@ - $table->data['label_fields'][0] = ''; - $table->data['label_fields'][1] = __('Firing fields'); - $table->data['label_fields'][2] = __('Recovery fields'); -- -+ - for ($i = 1; $i <= 10; $i++) { - if (isset($template[$name])) { - $value = $template[$name]; -@@ -621,8 +635,9 @@ - - //$table->rowclass['field'.$i] = 'row_field'; - -- $table->data['field'.$i][0] = sprintf(__('Field %s'), $i) . ui_print_help_icon ('alert_macros', true); -- $table->data['field'.$i][1] = html_print_textarea ('field'.$i, 1, 1, isset($fields[$i]) ? $fields[$i] : '', 'style="min-height:40px;" class="fields"', true); -+ $table->data['field'.$i][0] = sprintf(__('Field %s'), $i) . -+ ui_print_help_icon ('alert_macros', true); -+ $table->data['field'.$i][1] = html_print_textarea('field'.$i, 1, 1, isset($fields[$i]) ? $fields[$i] : '', 'style="min-height:40px;" class="fields"', true); - // Recovery - $table->data['field'.$i][2] = html_print_textarea ('field'.$i.'_recovery', 1, 1, isset($fields_recovery[$i]) ? $fields_recovery[$i] : '', 'style="min-height:40px" class="fields"', true); - } -Index: godmode/alerts/alert_list.builder.php -=================================================================== ---- godmode/alerts/alert_list.builder.php (revision 10314) -+++ godmode/alerts/alert_list.builder.php (working copy) -@@ -80,7 +80,7 @@ - $own_info = get_user_info ($config['id_user']); - if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) - $templates = alerts_get_alert_templates (false, array ('id', 'name')); --else{ -+else { - $usr_groups = users_get_groups($config['id_user'], 'LW', true); - $filter_groups = ''; - $filter_groups = implode(',', array_keys($usr_groups)); -@@ -107,13 +107,17 @@ - $actions = db_get_all_rows_sql($sql); - } - $table->data[2][1] = '<div class="actions_container">'; --$table->data[2][1] .= html_print_select(index_array ($actions, 'id', 'name'),'action_select','','',__('Default action'),'0',true, '', true, '', false, 'width: 250px;'); -+$table->data[2][1] .= html_print_select( -+ index_array($actions, 'id', 'name'), 'action_select', '', '', -+ __('Default action'), '0', true, '', true, '', false, -+ 'width: 250px;'); - $table->data[2][1] .= '<span id="advanced_action" class="advanced_actions invisible"><br>'; - $table->data[2][1] .= __('Number of alerts match from').' '; - $table->data[2][1] .= html_print_input_text ('fires_min', '', '', 4, 10, true); --$table->data[2][1] .= ' '.__('to').' '; -+$table->data[2][1] .= ' ' . __('to') . ' '; - $table->data[2][1] .= html_print_input_text ('fires_max', '', '', 4, 10, true); --$table->data[2][1] .= ui_print_help_icon ("alert-matches", true, ui_get_full_url(false, false, false, false)); -+$table->data[2][1] .= ui_print_help_icon ("alert-matches", true, -+ ui_get_full_url(false, false, false, false)); - $table->data[2][1] .= '</span>'; - $table->data[2][1] .= '</div>'; - if (check_acl ($config['id_user'], 0, "LM")) { -Index: godmode/snmpconsole/snmp_alert.php -=================================================================== ---- godmode/snmpconsole/snmp_alert.php (revision 10314) -+++ godmode/snmpconsole/snmp_alert.php (working copy) -@@ -476,10 +476,11 @@ - $user_groups = users_get_groups($config['id_user'],"AR", true); - $str_user_groups = ''; - $i = 0; --foreach ($user_groups as $id=>$name) { -+foreach ($user_groups as $id => $name) { - if ($i == 0) { - $str_user_groups .= $id; -- } else { -+ } -+ else { - $str_user_groups .= ','.$id; - } - $i++; -@@ -895,6 +896,7 @@ - $where_sql .= ' AND `priority` = ' . $priority_filter; - } - -+ $where_sql = ""; - if (!empty($free_search)) { - $where_sql .= " AND (`single_value` LIKE '%" . $free_search . "%' - OR `_snmp_f10_` LIKE '%" . $free_search . "%' -@@ -914,7 +916,8 @@ - } - - $count = db_get_value_sql("SELECT COUNT(*) -- FROM talert_snmp WHERE id_group IN ($str_user_groups) " . $where_sql); -+ FROM talert_snmp WHERE id_group IN ($str_user_groups) " . -+ $where_sql); - - $result = array(); - -Index: godmode/setup/setup_general.php -=================================================================== ---- godmode/setup/setup_general.php (revision 10314) -+++ godmode/setup/setup_general.php (working copy) -@@ -252,6 +252,17 @@ - $table->data[32][0] = __('Server logs directory') . ui_print_help_tip (__("Directory where the server logs are stored."), true); - $table->data[32][1] = html_print_input_text ('server_log_dir', $config["server_log_dir"], '', 50, 255, true); - -+$modes_tutorial = array( -+ 'full' => __('Full mode'), -+ 'on_demand' => __('On demand'), -+ 'expert' => __('Expert') -+ ); -+$table->data['tutorial_mode'][0] = __('Tutorial mode') . -+ ui_print_help_tip (__("Configuration of our clippy, 'full mode' show the icon in the header and the contextual helps and it is noise, 'on demand' it is equal to full but it is not noise and 'expert' the icons in the header and the context is not."), true); -+$table->data['tutorial_mode'][1] = -+ html_print_select($modes_tutorial, 'tutorial_mode', -+ $config["tutorial_mode"], '', '', 0, true); -+ - echo '<form id="form_setup" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=general&pure='.$config['pure'].'">'; - - echo "<fieldset>"; -Index: godmode/setup/license.php -=================================================================== ---- godmode/setup/license.php (revision 10314) -+++ godmode/setup/license.php (working copy) -@@ -47,7 +47,8 @@ - } - - echo '<script type="text/javascript">'; --print_js_var_enteprise(); -+if (enterprise_installed()) -+ print_js_var_enteprise(); - echo '</script>'; - - echo '<form method="post">'; -@@ -71,11 +72,13 @@ - $table->data[4][1] = html_print_input_text('expires', $license['license_mode'], '', 10, 255, true, true); - - html_print_table ($table); --echo '<div class="action-buttons" style="width: '.$table->width.'">'; --html_print_input_hidden ('update_settings', 1); --html_print_submit_button (__('Validate'), 'update_button', false, 'class="sub upd"'); --html_print_button(__('Request new license'), '', false, 'generate_request_code()', 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub next"'); --echo '</div>'; -+if (enterprise_installed()) { -+ echo '<div class="action-buttons" style="width: '.$table->width.'">'; -+ html_print_input_hidden ('update_settings', 1); -+ html_print_submit_button (__('Validate'), 'update_button', false, 'class="sub upd"'); -+ html_print_button(__('Request new license'), '', false, 'generate_request_code()', 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub next"'); -+ echo '</div>'; -+} - echo '</form>'; - echo '<div id="code_license_dialog" style="display: none; text-align: left;" title="' . __('Request new license') . '">'; - echo '<div id="logo">'; -Index: godmode/setup/setup_visuals.php -=================================================================== ---- godmode/setup/setup_visuals.php (revision 10314) -+++ godmode/setup/setup_visuals.php (working copy) -@@ -399,6 +399,16 @@ - - $row++; - -+$table->data[$row][0] = __('Fixed header'); -+$table->data[$row][1] = html_print_checkbox('fixed_header', 1, $config['fixed_header'], true); -+ -+$row++; -+ -+$table->data[$row][0] = __('Fixed menu'); -+$table->data[$row][1] = html_print_checkbox('fixed_menu', 1, $config['fixed_menu'], true); -+ -+$row++; -+ - echo '<form id="form_setup" method="post">'; - html_print_input_hidden ('update_config', 1); - html_print_table ($table); -Index: godmode/modules/manage_network_components_form.php -=================================================================== ---- godmode/modules/manage_network_components_form.php (revision 10314) -+++ godmode/modules/manage_network_components_form.php (working copy) -@@ -489,7 +489,7 @@ - $("input[name=snmp_community]").css({backgroundColor: '#ddd'}); - $("input[name=snmp_community]").attr("disabled",true); - } -- else{ -+ else { - $("input[name=snmp3_auth_user]").val(""); - $("input[name=snmp3_auth_user]").css({backgroundColor: '#ddd'}); - $("input[name=snmp3_auth_user]").attr("disabled", true); -Index: godmode/reporting/reporting_builder.php -=================================================================== ---- godmode/reporting/reporting_builder.php (revision 10314) -+++ godmode/reporting/reporting_builder.php (working copy) -@@ -66,12 +66,12 @@ - 'args' => serialize ($parameters), - 'scheduled' => $scheduled, - 'flag_delete' => 1); -- -+ - $result = db_process_sql_insert('tuser_task_scheduled', $values); - - ui_print_result_message ($result, -- __('Your report has been planned, and the system will email you a PDF with the report as soon as its finished'), -- __('An error has ocurred')); -+ __('Your report has been planned, and the system will email you a PDF with the report as soon as its finished'), -+ __('An error has ocurred')); - echo '<br>'; - } - -@@ -451,10 +451,13 @@ - $data[2] = '<a href="' . $config['homeurl'] . 'index.php?sec=reporting&sec2=operation/reporting/reporting_viewer&id='.$report['id_report'].'&pure='.$pure.'">' . - html_print_image("images/html.png", true, array('title' => __('HTML view'))) . '</a>'; - $data[3] = '<a href="'. ui_get_full_url(false, false, false, false) . 'ajax.php?page=' . $config['homedir'] . '/operation/reporting/reporting_xml&id='.$report['id_report'].'">' . html_print_image("images/xml.png", true, array('title' => __('Export to XML'))) . '</a>'; //I chose ajax.php because it's supposed to give XML anyway -- } else { -- $data[2] = html_print_image("images/html_disabled.png", true); -- $data[3] = html_print_image("images/xml_disabled.png", true); - } -+ else { -+ $data[2] = html_print_image( -+ "images/html_disabled.png", true); -+ $data[3] = html_print_image( -+ "images/xml_disabled.png", true); -+ } - - - //Calculate dinamically the number of the column -@@ -475,7 +478,8 @@ - $next++; - - -- $data[$next] = ui_print_group_icon($report['id_group'], true, "groups_small", '', !defined('METACONSOLE')); -+ $data[$next] = ui_print_group_icon( -+ $report['id_group'], true, "groups_small", '', !defined('METACONSOLE')); - $next++; - } - -@@ -801,7 +805,7 @@ - else - $values['id_agent_module'] = get_parameter('id_agent_module'); - -- $values['only_display_wrong'] = get_parameter('checkbox_only_display_wrong'); -+ $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); -@@ -814,7 +818,7 @@ - $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'] = get_parameter('exception_condition'); -+ $values['exception_condition'] = (int)get_parameter('exception_condition', 0); - $values['exception_condition_value'] = get_parameter('exception_condition_value'); - $values['show_graph'] = get_parameter('combo_graph_options'); - $values['id_module_group'] = get_parameter('combo_modulegroup'); -@@ -916,7 +920,7 @@ - if ($good_format) { - $resultOperationDB = db_process_sql_update('treport_content', $values, array('id_rc' => $idItem)); - } -- else{ -+ else { - $resultOperationDB = false; - } - break; -@@ -926,6 +930,7 @@ - $values['type'] = get_parameter('type', null); - $values['name'] = (string) get_parameter('name'); - $values['description'] = get_parameter('description'); -+ - // 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']) { -@@ -1007,15 +1012,15 @@ - switch ($config['dbtype']) { - case "mysql": - case "postgresql": -- $values['only_display_wrong'] = get_parameter('checkbox_only_display_wrong'); -+ $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; -+ else { -+ $values['only_display_wrong'] = $only_display_wrong_tmp; - } - break; - } -@@ -1040,7 +1045,7 @@ - $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'] = get_parameter('radiobutton_exception_condition'); -+ $values['exception_condition'] = (int)get_parameter('radiobutton_exception_condition', 0); - $values['exception_condition_value'] = get_parameter('exception_condition_value'); - $values['show_graph'] = get_parameter('combo_graph_options'); - $values['id_module_group'] = get_parameter('combo_modulegroup'); -@@ -1391,11 +1396,17 @@ - default: - switch ($config["dbtype"]) { - case "mysql": -- $oldOrder = db_get_value_sql('SELECT `order` FROM treport_content WHERE id_rc = ' . $idItem); -+ $oldOrder = db_get_value_sql(' -+ SELECT `order` -+ FROM treport_content -+ WHERE id_rc = ' . $idItem); - break; - case "postgresql": - case "oracle": -- $oldOrder = db_get_value_sql('SELECT "order" FROM treport_content WHERE id_rc = ' . $idItem); -+ $oldOrder = db_get_value_sql(' -+ SELECT "order" -+ FROM treport_content -+ WHERE id_rc = ' . $idItem); - break; - } - //db_get_value_filter('order', 'treport_content', array('id_rc' => $idItem)); -@@ -1413,17 +1424,20 @@ - case "mysql": - $resultOperationDB = db_process_sql_update('treport_content', - array('`order`' => $oldOrder), -- array('`order`' => $newOrder, 'id_report' => $idReport)); -+ array('`order`' => $newOrder, -+ 'id_report' => $idReport)); - break; - case "postgresql": - $resultOperationDB = db_process_sql_update('treport_content', - array('"order"' => $oldOrder), -- array('"order"' => $newOrder, 'id_report' => $idReport)); -+ array('"order"' => $newOrder, -+ 'id_report' => $idReport)); - break; - case "oracle": - $resultOperationDB = db_process_sql_update('treport_content', - array('"order"' => $oldOrder), -- array('"order"' => $newOrder, 'id_report' => $idReport), -+ array('"order"' => $newOrder, -+ 'id_report' => $idReport), - 'AND', false); - break; - } -@@ -1505,7 +1519,7 @@ - $resultOperationDB = $result; - } - } -- -+ - $buttons = array( - 'list_reports' => array('active' => false, - 'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure.'">' . -@@ -1545,15 +1559,21 @@ - // Page header for metaconsole - if ($enterpriseEnable and defined('METACONSOLE')) { - // Bread crumbs -- ui_meta_add_breadcrumb(array('link' => 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure, 'text' => __('Reporting'))); -+ ui_meta_add_breadcrumb( -+ array('link' => -+ 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure=' . $pure, -+ 'text' => __('Reporting'))); - - ui_meta_print_page_header($nav_bar); - - // Print header - ui_meta_print_header(__('Reporting'). $textReportName, "", $buttons); - } --else -- ui_print_page_header(__('Reporting') . $textReportName, "images/op_reporting.png", false, "reporting_" . $activeTab . "_tab", false, $buttons); -+else { -+ ui_print_page_header(__('Reporting') . $textReportName, -+ "images/op_reporting.png", false, -+ "reporting_" . $activeTab . "_tab", false, $buttons); -+} - - enterprise_hook('open_meta_frame'); - -@@ -1563,13 +1583,16 @@ - - switch ($activeTab) { - case 'main': -- require_once($config['homedir'] . '/godmode/reporting/reporting_builder.main.php'); -+ require_once($config['homedir'] . -+ '/godmode/reporting/reporting_builder.main.php'); - break; - case 'list_items': -- require_once($config['homedir'] . '/godmode/reporting/reporting_builder.list_items.php'); -+ require_once($config['homedir'] . -+ '/godmode/reporting/reporting_builder.list_items.php'); - break; - case 'item_editor': -- require_once($config['homedir'] . '/godmode/reporting/reporting_builder.item_editor.php'); -+ require_once($config['homedir'] . -+ '/godmode/reporting/reporting_builder.item_editor.php'); - break; - default: - reporting_enterprise_select_tab($activeTab); -Index: godmode/reporting/map_builder.php -=================================================================== ---- godmode/reporting/map_builder.php (revision 10314) -+++ godmode/reporting/map_builder.php (working copy) -@@ -125,7 +125,7 @@ - ui_print_error_message(__('Not copied. Error copying data')); - } - } -- else{ -+ else { - // If the array is empty the copy is completed - ui_print_success_message(__('Successfully copied')); - db_clean_cache(); |