From 804b132fb71cce25fbe0508602449e3211a3291b Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 28 Jan 2013 11:50:30 +0000 Subject: [PATCH] 2013-01-28 Miguel de Dios * include/functions_networkmap.php, operation/agentes/networkmap.topology.php, operation/agentes/networkmap.groups.php: fixed the lost parameter in the generation of networkmap with a text filter. Fixes: #3602233 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7532 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 ++++++ .../include/functions_networkmap.php | 16 ++++++++++- .../operation/agentes/networkmap.groups.php | 28 ++++++++++++------- .../operation/agentes/networkmap.topology.php | 13 ++++++--- 4 files changed, 51 insertions(+), 15 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index bef957ed74..8a84c43fc2 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2013-01-28 Miguel de Dios + + * include/functions_networkmap.php, + operation/agentes/networkmap.topology.php, + operation/agentes/networkmap.groups.php: fixed the lost parameter + in the generation of networkmap with a text filter. + + Fixes: #3602233 + 2013-01-28 Miguel de Dios * godmode/agentes/module_manager.php: fixed the PHP notices in the diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index e83c92d01b..b8c32cf072 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -202,7 +202,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, } // 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) { +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(); @@ -211,6 +211,20 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $filter = array (); $filter['disabled'] = 0; + if (!empty($text_filter)) { + switch ($config['dbtype']) { + case "mysql": + case "postgresql": + $filter[] = + '(nombre COLLATE utf8_general_ci LIKE "%' . $text_filter . '%")'; + break; + case "oracle": + $filter[] = + '(upper(nombre) LIKE upper("%' . $text_filter . '%"))'; + break; + } + } + // Get groups data if ($group > 0) { $groups = array(); diff --git a/pandora_console/operation/agentes/networkmap.groups.php b/pandora_console/operation/agentes/networkmap.groups.php index e925e7f58f..7f73c01f39 100644 --- a/pandora_console/operation/agentes/networkmap.groups.php +++ b/pandora_console/operation/agentes/networkmap.groups.php @@ -32,7 +32,10 @@ require_once ('include/functions_networkmap.php'); $filter = networkmap_get_filter ($layout); // Generate dot file -$graph = networkmap_generate_dot_groups (__('Pandora FMS'), $group, $simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, $pure, $modwithalerts, $module_group, $hidepolicymodules, $depth, $id_networkmap, $dont_show_subgroups); +$graph = networkmap_generate_dot_groups (__('Pandora FMS'), $group, + $simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, + $regen, $pure, $modwithalerts, $module_group, $hidepolicymodules, + $depth, $id_networkmap, $dont_show_subgroups, $text_filter); if ($graph === false) { ui_print_error_message (__('Map could not be generated')); @@ -41,10 +44,13 @@ if ($graph === false) { } // Generate image and map -// If image was generated just a few minutes ago, then don't regenerate (it takes long) unless regen checkbox is set -$filename_map = safe_url_extraclean ($config["attachment_store"])."/networkmap_".$filter; -$filename_img = "attachment/networkmap_".$filter."_".$font_size; -$filename_dot = safe_url_extraclean ($config["attachment_store"])."/networkmap_".$filter; +// If image was generated just a few minutes ago, then don't regenerate +// (it takes long) unless regen checkbox is set +$filename_map = safe_url_extraclean($config["attachment_store"]) . + "/networkmap_" . $filter; +$filename_img = "attachment/networkmap_" . $filter . "_" . $font_size; +$filename_dot = safe_url_extraclean($config["attachment_store"]) . + "/networkmap_" . $filter; if ($simple) { $filename_map .= "_simple"; $filename_img .= "_simple"; @@ -55,9 +61,9 @@ if ($nooverlap) { $filename_img .= "_nooverlap"; $filename_dot .= "_nooverlap"; } -$filename_map .= "_".$id_networkmap.".map"; -$filename_img .= "_".$id_networkmap.".png"; -$filename_dot .= "_".$id_networkmap.".dot"; +$filename_map .= "_" . $id_networkmap . ".map"; +$filename_img .= "_" . $id_networkmap . ".png"; +$filename_dot .= "_" . $id_networkmap . ".dot"; if ($regen != 1 && file_exists ($filename_img) && filemtime ($filename_img) > get_system_time () - SECONDS_5MINUTES) { @@ -70,7 +76,8 @@ else { } else { fwrite ($fh, $graph); - $cmd = "$filter -Tcmapx -o".$filename_map." -Tpng -o".$filename_img." ".$filename_dot; + $cmd = "$filter -Tcmapx -o" . $filename_map . " -Tpng " . + "-o" . $filename_img . " " . $filename_dot; $result = system ($cmd); fclose ($fh); unlink ($filename_dot); @@ -87,7 +94,8 @@ if ($result !== false) { return; } - html_print_image ($filename_img, false, array ("alt" => __('Network map'), "usemap" => "#networkmap")); + html_print_image ($filename_img, false, + array ("alt" => __('Network map'), "usemap" => "#networkmap")); require ($filename_map); } else { diff --git a/pandora_console/operation/agentes/networkmap.topology.php b/pandora_console/operation/agentes/networkmap.topology.php index 65f7a7893b..de9a523fa4 100644 --- a/pandora_console/operation/agentes/networkmap.topology.php +++ b/pandora_console/operation/agentes/networkmap.topology.php @@ -32,7 +32,10 @@ require_once ('include/functions_networkmap.php'); $filter = networkmap_get_filter ($layout); // Generate dot file -$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); +$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); if ($graph === false) { ui_print_error_message (__('Map could not be generated')); @@ -43,9 +46,11 @@ if ($graph === false) { // Generate image and map // If image was generated just a few minutes ago, then don't regenerate (it takes long) unless regen checkbox is set -$filename_map = safe_url_extraclean ($config["attachment_store"])."/networkmap_".$filter; -$filename_img = "attachment/networkmap_".$filter."_".$font_size; -$filename_dot = safe_url_extraclean ($config["attachment_store"])."/networkmap_".$filter; +$filename_map = safe_url_extraclean($config["attachment_store"]) . + "/networkmap_" . $filter; +$filename_img = "attachment/networkmap_" . $filter . "_" . $font_size; +$filename_dot = safe_url_extraclean($config["attachment_store"]) . + "/networkmap_" . $filter; if ($simple) { $filename_map .= "_simple"; $filename_img .= "_simple";