From 14f5937b2f9f8ca50f37db57e17fd5ab55c50be4 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 17 Apr 2012 13:08:08 +0000 Subject: [PATCH] 2012-04-17 Miguel de Dios * include/functions_html.php, extensions/net_tools.php: cleaned source code style. * include/functions_networkmap.php: into the functions "networkmap_generate_dot" and "networkmap_create_agent_node" added new parameter $relative for set the url of icons as relative. It is used in networmap enterprise. * include/functions_ui.php: fixed into the function "ui_print_message" lost the javascript code when the first messages are without close button. And into the function "ui_print_os_icon" added new parameter $relative for set the url of icons as relative. It is used in networmap enterprise. Merged from the branch "pandora_4.0". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6000 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 18 +++++ pandora_console/extensions/net_tools.php | 80 +++++++++---------- pandora_console/include/functions_html.php | 6 +- .../include/functions_networkmap.php | 54 ++++++++----- pandora_console/include/functions_ui.php | 10 +-- 5 files changed, 97 insertions(+), 71 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 848fca889a..b501ac76ad 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,21 @@ +2012-04-17 Miguel de Dios + + * include/functions_html.php, extensions/net_tools.php: cleaned + source code style. + + * include/functions_networkmap.php: into the functions + "networkmap_generate_dot" and "networkmap_create_agent_node" + added new parameter $relative for set the url of icons as relative. + It is used in networmap enterprise. + + * include/functions_ui.php: fixed into the function + "ui_print_message" lost the javascript code when the first messages + are without close button. And into the function "ui_print_os_icon" + added new parameter $relative for set the url of icons as relative. + It is used in networmap enterprise. + + Merged from the branch "pandora_4.0". + 2012-04-17 Vanessa Gil * godmode/reporting/reporting_builder.item_editor.php: Fixed diff --git a/pandora_console/extensions/net_tools.php b/pandora_console/extensions/net_tools.php index 633e36ab28..c44720a171 100644 --- a/pandora_console/extensions/net_tools.php +++ b/pandora_console/extensions/net_tools.php @@ -25,47 +25,45 @@ function main_net_tools () { echo "

The agent hasn't got IP

"; return; } - echo "
"; - echo "
"; - echo ""; - echo "
"; - echo __("Operation"); - echo ""; - echo ""; - echo ""; - echo __("SNMP Community"); - echo ""; - echo ""; - echo ""; - echo ""; - echo "
"; - echo "
"; - - - $operation = get_parameter ("operation",0); - $community = get_parameter ("community","public"); - - switch($operation){ - - case 1: - if (!file_exists('/usr/sbin/traceroute')) { - ui_print_error_message(__('Traceroute executable does not exist.')); - } - else { - echo "

".__("Traceroute to "). $ip. "

"; - echo "
";
-	                echo system ("/usr/sbin/traceroute $ip");
-	                echo "
"; - } - break; - - case 2: + echo "
"; + echo "
"; + echo ""; + echo "
"; + echo __("Operation"); + echo ""; + echo ""; + echo ""; + echo __("SNMP Community"); + echo ""; + echo ""; + echo ""; + echo ""; + echo "
"; + echo "
"; + + + $operation = get_parameter ("operation",0); + $community = get_parameter ("community","public"); + + switch($operation) { + case 1: + if (!file_exists('/usr/sbin/traceroute')) { + ui_print_error_message(__('Traceroute executable does not exist.')); + } + else { + echo "

".__("Traceroute to "). $ip. "

"; + echo "
";
+				echo system ("/usr/sbin/traceroute $ip");
+				echo "
"; + } + break; + case 2: ob_start(); system('whereis ping'); $output = ob_get_clean(); diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index be4c68b536..06b5676f8d 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1194,14 +1194,14 @@ function html_print_checkbox ($name, $value, $checked = false, $return = false, */ function html_print_image ($src, $return = false, $options = false, $return_src = false, $relative = false) { global $config; - + /* Checks if user's skin is available */ $isFunctionSkins = enterprise_include_once ('include/functions_skins.php'); - + if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { $skin_path = enterprise_hook('skins_get_image_path',array($src)); if ($skin_path) - $src = $skin_path; + $src = $skin_path; } if (!$relative) { diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 6b278a925f..7cee3b0db3 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -44,10 +44,12 @@ function networkmap_is_descendant ($node, $ascendant, $parents) { // Generate a dot graph definition for graphviz function networkmap_generate_dot ($pandora_name, $group = 0, $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) { + $regen = 1, $pure = 0, $id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true, + $relative = false) { + $parents = array(); $orphans = array(); - + $filter = array (); $filter['disabled'] = 0; if ($group >= 1) { @@ -84,7 +86,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_ } $node_count = 1; - + foreach ($agents as $agent) { // Save node parent information to define edges later if ($agent['id_parent'] != "0") { @@ -95,9 +97,9 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_ } $agent['id_node'] = $node_count; - + $agent['type'] = 'agent'; - + // Add node $nodes[$node_count] = $agent; @@ -108,15 +110,15 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_ foreach ($modules as $key => $module) { $node_count ++; $agent_module = modules_get_agentmodule($key); - + $alerts_module = db_get_sql('SELECT count(*) as num FROM talert_template_modules WHERE id_agent_module = '.$key); - + // Save node parent information to define edges later $parents[$node_count] = $agent_module['parent'] = $agent['id_node']; - + $agent_module['id_node'] = $node_count; - + $agent_module['type'] = 'module'; // Add node $nodes[$node_count] = $agent_module; @@ -133,10 +135,10 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_ unset ($nodes[$node_id]); continue; } - + switch($node['type']){ case 'agent': - $graph .= networkmap_create_agent_node ($node , $simple, $font_size, $cut_names)."\n\t\t"; + $graph .= networkmap_create_agent_node ($node , $simple, $font_size, $cut_names, $relative)."\n\t\t"; break; case 'module': $graph .= networkmap_create_module_node ($node , $simple, $font_size)."\n\t\t"; @@ -158,7 +160,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_ if (count ($orphans) || empty ($nodes)) { $graph .= networkmap_create_pandora_node ($pandora_name, $font_size, $simple); } - + // Define edges for orphan nodes foreach (array_keys($orphans) as $node) { $graph .= networkmap_create_edge ('0', $node, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap); @@ -173,10 +175,10 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_ // 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) { global $config; - + $parents = array(); $orphans = array(); - + $filter = array (); $filter['disabled'] = 0; @@ -212,13 +214,13 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $node_count ++; $group2['type'] = 'group'; $group2['id_node'] = $node_count; - + // Add node $nodes_groups[$group2['id_grupo']] = $group2; } $node_count = 0; - + foreach ($nodes_groups as $node_group) { $node_count++; @@ -408,11 +410,11 @@ function networkmap_create_group_node ($group, $simple = 0, $font_size = 10) { } // Returns a node definition -function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cut_names = true) { +function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cut_names = true, $relative = false) { global $config; $status = agents_get_status($agent['id_agente']); - + // Set node status switch($status) { case 0: @@ -431,18 +433,26 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu $status_color = '#BBBBBB'; // Unknown monitor break; } - + // Short name $name = io_safe_output($agent["nombre"]); if ((strlen ($name) > 16) && ($cut_names)) { $name = substr ($name, 0, 16) . '...'; } - + if ($simple == 0){ // Set node icon - $img_node = ui_print_os_icon ($agent['id_os'], false, true, true, true, true); + $img_node = ui_print_os_icon ($agent['id_os'], false, true, true, true, true, $relative); + $img_node = str_replace($config['homeurl'] . '/', '', $img_node); - $node = $agent['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.40, height=0.40, label=< + if ($relative) { + $img_node = html_print_image($img_node, true, false, false, true); + } + else { + $img_node = html_print_image($img_node, true, false, false, false); + } + + $node = $agent['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.40, height=0.40, label=<
' . html_print_image($img_node, true, false, false, true) . '
' . $img_node . '
'.$name.'
>, shape="doublecircle", URL="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'", tooltip="ajax.php?page=operation/agentes/ver_agente&get_agent_status_tooltip=1&id_agent='.$agent['id_agente'].'"];'; diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 6d3e250639..aa993a7966 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -220,7 +220,7 @@ function ui_print_message ($message, $class = '', $attributes = '', $return = fa '; - if ($first_execution) { + if (($first_execution) && (!$no_close_bool)) { $first_execution = false; $output .= ' @@ -501,7 +501,7 @@ function ui_print_group_icon_path ($id_group, $return = false, $path = "images/g * * @return string HTML with icon of the OS */ -function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin = true, $networkmap = false, $only_src = false) { +function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin = true, $networkmap = false, $only_src = false, $relative = false) { $subfolter = 'os_icons'; if ($networkmap) { $subfolter = 'networkmap'; @@ -511,7 +511,7 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin = $os_name = get_os_name ($id_os); if (empty ($icon)) { if ($only_src) { - $output = html_print_image("images/".$subfolter."/unknown.png", false, false, true); + $output = html_print_image("images/".$subfolter."/unknown.png", false, false, true, $relative); } else { return "-"; @@ -520,10 +520,10 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin = if ($apply_skin) { if ($only_src) { - $output = html_print_image("images/".$subfolter."/".$icon, true, false, true); + $output = html_print_image("images/".$subfolter."/".$icon, true, false, true, $relative); } else { - $output = html_print_image("images/".$subfolter."/".$icon, true, array("alt" => $os_name, "title" => $os_name)); + $output = html_print_image("images/".$subfolter."/".$icon, true, array("alt" => $os_name, "title" => $os_name), false, $relative); } } else