diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e8163c4524..7569533f8c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2014-06-02 Alejandro Gallardo + + * godmode/setup/setup_visuals.php, + include/functions_config.php: Added a new config token + to hold a custom path for the graphviz binaries. + + * include/functions_networkmap.php: Minor fixes on the + functions "networkmap_create_module_node" and + "networkmap_open_graph". + + * operation/agentes/networkmap.groups.php, + operation/agentes/networkmap.topology.php: Modified to + support the custom graphviz directory, blanks in paths, etc. + 2014-06-02 Ramon Novoa * godmode/setup/license.php: Added to repository. License configuration diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 8fba17390d..5eed8c7824 100644 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -382,7 +382,10 @@ $table->data[$row][1] .= __('No') . ' ' . $row++; +$table->data[$row][0] = __('Custom graphviz directory') . ui_print_help_tip (__("Custom directory where the graphviz binaries are stored."), true); +$table->data[$row][1] = html_print_input_text ('graphviz_bin_dir', $config["graphviz_bin_dir"], '', 50, 255, true); +$row++; echo '
'; html_print_input_hidden ('update_config', 1); diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 8261bedea6..265bf328a6 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -432,7 +432,9 @@ function config_update_config () { $error_update[] = __('Autohidden 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'))) + $error_update[] = __('Custom graphviz directory'); + $interval_values = get_parameter ('interval_values'); // Add new interval value if is provided diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 5347d56963..daf84e87ba 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -1183,7 +1183,7 @@ function networkmap_create_module_node ($module, $simple = 0, $font_size = 10, $ 'width=0.20, ' . 'height=0.20, ' . 'label="", ' . - 'tooltip="' . $url_tooltip . + 'tooltip="' . $url_tooltip . '"' . '];'; } return $node; @@ -1278,7 +1278,7 @@ function networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, $ranksep, $fo $size = $size_x . ',' . $size_y; // BEWARE: graphwiz DONT use single ('), you need double (") - $head = "graph networkmap { bgcolor=\"transparent\", labeljust=l; margin=0; "; + $head = "graph networkmap { bgcolor=\"transparent\"; labeljust=l; margin=0; "; if ($nooverlap != '') { $head .= "overlap=\"$overlap\";"; $head .= "ranksep=\"$ranksep\";"; diff --git a/pandora_console/include/graphs/functions_d3.php b/pandora_console/include/graphs/functions_d3.php index 6288b1b987..135c88ff1e 100644 --- a/pandora_console/include/graphs/functions_d3.php +++ b/pandora_console/include/graphs/functions_d3.php @@ -117,4 +117,4 @@ function d3_tree_map_graph ($data, $width = 700, $height = 700, $return = false) return $output; } -?> \ No newline at end of file +?> diff --git a/pandora_console/operation/agentes/networkmap.groups.php b/pandora_console/operation/agentes/networkmap.groups.php index 1ad7e06922..d86929bdb2 100644 --- a/pandora_console/operation/agentes/networkmap.groups.php +++ b/pandora_console/operation/agentes/networkmap.groups.php @@ -47,11 +47,9 @@ 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 = io_safe_output($config["attachment_store"]) . "/networkmap_" . $filter; +$filename_img = io_safe_output($config["attachment_store"]) . "/networkmap_" . $filter . "_" . $font_size; +$filename_dot = io_safe_output($config["attachment_store"]) . "/networkmap_" . $filter; if ($simple) { $filename_map .= "_simple"; $filename_img .= "_simple"; @@ -77,8 +75,8 @@ else { } else { fwrite ($fh, $graph); - $cmd = "$filter -Tcmapx -o" . $filename_map . " -Tpng " . - "-o" . $filename_img . " " . $filename_dot; + $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); $result = system ($cmd); fclose ($fh); unlink ($filename_dot); @@ -96,8 +94,8 @@ if ($result !== false) { return; } echo "
"; - html_print_image ($filename_img, false, - array ("alt" => __('Network map'), "usemap" => "#networkmap")); + $image_url = str_replace(realpath(io_safe_output($config['homedir'])), "", realpath($filename_img)); + html_print_image ($image_url, false, array ("alt" => __('Network map'), "usemap" => "#networkmap")); echo "
"; require ($filename_map); } diff --git a/pandora_console/operation/agentes/networkmap.topology.php b/pandora_console/operation/agentes/networkmap.topology.php index 92c6c9c4f7..c2badc0a43 100644 --- a/pandora_console/operation/agentes/networkmap.topology.php +++ b/pandora_console/operation/agentes/networkmap.topology.php @@ -49,12 +49,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; +// If image was generated just a few minutes ago, then don't regenerate +// (it takes long) unless regen checkbox is set +$filename_map = io_safe_output($config["attachment_store"]) . "/networkmap_" . $filter; +$filename_img = io_safe_output($config["attachment_store"]) . "/networkmap_" . $filter . "_" . $font_size; +$filename_dot = io_safe_output($config["attachment_store"]) . "/networkmap_" . $filter; if ($simple) { $filename_map .= "_simple"; $filename_img .= "_simple"; @@ -71,7 +70,6 @@ $filename_dot .= "_" . $id_networkmap . ".dot"; if ($regen != 1 && file_exists ($filename_img) && filemtime ($filename_img) > get_system_time () - SECONDS_5MINUTES) { - $result = true; } else { @@ -81,10 +79,11 @@ else { } else { fwrite ($fh, $graph); - $cmd = "$filter -Tcmapx -o".$filename_map." -Tpng -o".$filename_img." ".$filename_dot; + $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); $result = system ($cmd); fclose ($fh); - //unlink ($filename_dot); + unlink ($filename_dot); } } @@ -99,7 +98,8 @@ if ($result !== false) { return; } echo "
"; - html_print_image ($filename_img, false, array ("alt" => __('Network map'), "usemap" => "#networkmap")); + $image_url = str_replace(realpath(io_safe_output($config['homedir'])), "", realpath($filename_img)); + html_print_image ($image_url, false, array ("alt" => __('Network map'), "usemap" => "#networkmap")); echo "
"; require ($filename_map); }