"%$name")); $values = array( 'name' => ($check ? "($sql) $name" : $name), 'type' => $activeTab, 'layout' => $layout, 'nooverlap' => $nooverlap, 'simple' => $simple, 'regenerate' => $regen, 'font_size' => $font_size, 'store_group' => $store_group, 'id_group' => $group, 'id_module_group' => $module_group, 'depth' => $depth, 'only_modules_with_alerts' => $modwithalerts, 'hide_policy_modules' => $hidepolicymodules, 'zoom' => $zoom, 'distance_nodes' => $ranksep, 'text_filter' => $text_filter, 'dont_show_subgroups' => $dont_show_subgroups, 'center' => $center, 'show_snmp_modules' => $show_snmp_modules, 'l2_network' => $l2_network ); $id_networkmap = networkmap_create_networkmap($values); $message = ui_print_result_message ($id_networkmap, __('Network map created successfully'), __('Could not create network map'), '', true); // Exit when the networkmap was not created if ($id_networkmap === false) { return; } } // Action in existing networkmap else if ($delete_networkmap || $save_networkmap || $update_networkmap) { // ACL for the network map // if (!isset($networkmap_read)) // $networkmap_read = check_acl ($config['id_user'], $store_group, "MR"); if (!isset($networkmap_write)) $networkmap_write = check_acl ($config['id_user'], $store_group, "MW"); if (!isset($networkmap_manage)) $networkmap_manage = check_acl ($config['id_user'], $store_group, "MM"); if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit("ACL Violation", "Trying to accessnode graph builder"); require ("general/noaccess.php"); exit; } // Actions // // Not used now. The new behaviour is delete the map posting to the list. if ($delete_networkmap) { $result = networkmap_delete_networkmap($id_networkmap); $message = ui_print_result_message ($result, __('Network map deleted successfully'), __('Could not delete network map'), '', true); return; } // Save updates the db data, update only updates the view. if ($save_networkmap || $update_networkmap) { // Load variables $layout = (string) get_parameter ('layout', 'radial'); $depth = (string) get_parameter ('depth', 'all'); $nooverlap = (bool) get_parameter ('nooverlap', 0); $modwithalerts = (int) get_parameter ('modwithalerts', 0); $hidepolicymodules = (int) get_parameter ('hidepolicymodules', 0); $zoom = (float) get_parameter ('zoom', 1); $ranksep = (float) get_parameter ('ranksep', 2.5); $simple = (int) get_parameter ('simple', 0); $regen = (int) get_parameter ('regen', 0); $show_snmp_modules = (int) get_parameter ('show_snmp_modules', 0); $font_size = (int) get_parameter ('font_size', 12); $text_filter = get_parameter ('text_filter', ''); $dont_show_subgroups = (bool)get_parameter ('dont_show_subgroups', 0); $store_group = (int) get_parameter ('store_group', 0); $group = (int) get_parameter ('group', 0); $module_group = (int) get_parameter ('module_group', 0); $center = (int) get_parameter ('center', 0); $name = (string) get_parameter ('name', $activeTab); $l2_network = (int) get_parameter ('l2_network', 0); if ($save_networkmap) { // ACL for the new network map $networkmap_read_new = check_acl ($config['id_user'], $store_group, "MR"); $networkmap_write_new = check_acl ($config['id_user'], $store_group, "MW"); $networkmap_manage_new = check_acl ($config['id_user'], $store_group, "MM"); if (!$networkmap_write_new && !$networkmap_manage_new) { db_pandora_audit("ACL Violation", "Trying to accessnode graph builder"); require ("general/noaccess.php"); exit; } $result = networkmap_update_networkmap($id_networkmap, array('name' => $name, 'type' => $activeTab, 'layout' => $layout, 'nooverlap' => $nooverlap, 'simple' => $simple, 'regenerate' => $regen, 'font_size' => $font_size, 'store_group' => $store_group, 'id_group' => $group, 'id_module_group' => $module_group, 'depth' => $depth, 'only_modules_with_alerts' => $modwithalerts, 'hide_policy_modules' => $hidepolicymodules, 'zoom' => $zoom, 'distance_nodes' => $ranksep, 'text_filter' => $text_filter, 'dont_show_subgroups' => $dont_show_subgroups, 'center' => $center, 'show_snmp_modules' => (int)$show_snmp_modules, 'l2_network' => (int)$l2_network)); $message = ui_print_result_message ($result, __('Network map saved successfully'), __('Could not save network map'), '', true); if ($result) { // Save the new ACL permisison $networkmap_read = $networkmap_read_new; $networkmap_write = $networkmap_write_new; $networkmap_manage = $networkmap_manage_new; } } } } if (!$update_networkmap && !$save_networkmap) { $networkmap_data = networkmap_get_networkmap($id_networkmap); if (empty($networkmap_data)) { ui_print_error_message(__('There was an error loading the network map')); return; } // Load variables $layout = $networkmap_data['layout']; $depth = $networkmap_data['depth']; $nooverlap = (bool)$networkmap_data['nooverlap']; $modwithalerts = $networkmap_data['only_modules_with_alerts']; $hidepolicymodules = $networkmap_data['hide_policy_modules']; $zoom = $networkmap_data['zoom']; $ranksep = $networkmap_data['distance_nodes']; $simple = $networkmap_data['simple']; $regen = $networkmap_data['regenerate']; $show_snmp_modules = $networkmap_data['show_snmp_modules']; $font_size = $networkmap_data['font_size']; $text_filter = $networkmap_data['text_filter']; $dont_show_subgroups = $networkmap_data['dont_show_subgroups']; $store_group = $networkmap_data['store_group']; $group = $networkmap_data['id_group']; $module_group = $networkmap_data['id_module_group']; $center = $networkmap_data['center']; $name = io_safe_output($networkmap_data['name']); $activeTab = $networkmap_data['type']; $l2_network = $networkmap_data['l2_network']; } if ($recenter_networkmap) { $center = (int) get_parameter ('center', 0); } /* Main code */ $qs = http_build_query(array( "sec" => "network", "sec2" => "operation/agentes/networkmap_list" )); $href = "index.php?$qs"; $buttons['list'] = array('active' => false, 'text' => "" . html_print_image("images/list.png", true, array ("title" => __('List'))) .""); if ($pure == 1) { $qs = http_build_query(array( "sec" => "network", "sec2" => "operation/agentes/networkmap", "id_networkmap" => $id_networkmap, "tab" => $activeTab )); $href = "index.php?$qs"; $buttons['screen'] = array('active' => false, 'text' => "" . html_print_image("images/normal_screen.png", true, array ('title' => __('Normal screen'))) .""); } else { $qs = http_build_query(array( "sec" => "network", "sec2" => "operation/agentes/networkmap", "id_networkmap" => $id_networkmap, "tab" => $activeTab, "pure" => 1 )); $href = "index.php?$qs"; $buttons['screen'] = array('active' => false, 'text' => "" . html_print_image("images/full_screen.png", true, array ('title' => __('Full screen'))) .""); } if ($networkmap_write || $networkmap_manage) { $qs = http_build_query(array( "sec" => "network", "sec2" => "operation/agentes/networkmap_list", "id_networkmap" => $id_networkmap, "delete_networkmap" => 1 )); $href = "index.php?$qs"; $buttons['deletemap'] = array('active' => false, 'text' => "" . html_print_image("images/delete_mc.png", true, array ("title" => __('Delete map'))) .""); $qs = http_build_query(array( "sec" => "network", "sec2" => "operation/agentes/networkmap", "id_networkmap" => $id_networkmap, "save_networkmap" => 1, "tab" => $activeTab, "name" => $name, "store_group" => $store_group, "group" => $group, "layout" => $layout, "nooverlap" => $nooverlap, "simple" => $simple, "regen" => $regen, "zoom" => $zoom, "ranksep" => $ranksep, "font_size" => $font_size, "depth" => $depth, "modwithalerts" => $modwithalerts, "text_filter" => $text_filter, "dont_show_subgroups" => $dont_show_subgroups, "hidepolicymodules" => $hidepolicymodules, "module_group" => $module_group, "hidden_options" => (int)$hidden_options, "show_snmp_modules" => (int)$show_snmp_modules, "l2_network" => (int)$l2_network, "pure" => $pure )); $href = "index.php?$qs"; $buttons['savemap'] = array('active' => false, 'text' => "" . html_print_image("images/save_mc.png", true, array ("title" => __('Save map'))) .''); } // Disabled. It's a waste of resources to check the ACL of every networkmap // for only provide a shorthand feature. // $combolist = '
'; // $networkmaps = networkmap_get_networkmaps('','', true, $strict_user); // if (empty($networkmaps)) // $networkmaps = array(); // $combolist .= html_print_select($networkmaps, 'id_networkmap', $id_networkmap, // 'onchange:this.form.submit()', '', 0, true, false, false, // '', false, 'margin-top:4px; margin-left:3px; width:150px;'); // $combolist .= html_print_input_hidden('hidden_options',$hidden_options, true); // $combolist .= '
'; // $buttons['combolist'] = $combolist; $title = ''; $icon = "images/op_network.png"; switch ($activeTab) { case 'topology': $title = __('Topology view'); $icon = "images/op_network.png"; break; case 'groups': $title = __('Groups view'); $icon = "images/group.png"; break; case 'policies': $title = __('Policies view'); $icon = "images/policies_mc.png"; break; case 'dynamic': $title = __('Dynamic view'); $icon = "images/dynamic_network_icon.png"; break; case 'radial_dynamic': $title = __('Radial dynamic view'); $icon = "images/radial_dynamic_network_icon.png"; break; } if (!empty($name)) { $title .= " » ". mb_substr($name, 0, 25); } ui_print_page_header (__('Network map') . " - " . $title, $icon, false, "network_map", false, $buttons); if ((tags_has_user_acl_tags()) && (!$strict_user)) { ui_print_tags_warning(); } if ($delete_networkmap || $add_networkmap || $save_networkmap) { echo $message; } // CONFIGURATION FORM // Layout selection $layout_array = array ( 'circular' => 'circular', 'radial' => 'radial', 'spring1' => 'spring 1', 'spring2' => 'spring 2', 'flat' => 'flat'); $options_form = '
'; // Fill an array with the form inputs $form_elems = array(); // Name $element = __('Name') . ' ' . html_print_input_text ('name', io_safe_output($name), '', 25, 50, true); if ($activeTab == 'groups') $element .= clippy_context_help("topology_group"); $form_elems[] = $element; // Store group $form_elems[] = __('Store group') . ' ' . html_print_select_groups(false, 'AR', false, 'store_group', $store_group, '', 'All', 0, true); // Group $form_elems[] = __('Group') . ' ' . html_print_select_groups(false, 'AR', false, 'group', $group, '', 'All', 0, true); // Free text if ($activeTab != 'radial_dynamic') { $form_elems[] = __('Free text for search (*):') . ' ' . html_print_input_text('text_filter', $text_filter, '', 25, 100, true); } // Module group if ($activeTab == 'groups' || $activeTab == 'policies' || $activeTab == 'radial_dynamic') { $form_elems[] = __('Module group') . ' ' . html_print_select_from_sql (' SELECT id_mg, name FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true); } // Layout if ($activeTab != 'dynamic' && $activeTab != 'radial_dynamic') { $form_elems[] = __('Layout') . ' ' . html_print_select ($layout_array, 'layout', $layout, '', '', '', true); } // Depth if ($activeTab == 'groups') { $depth_levels = array( 'all' => __('All'), 'agent' => __('Agents'), 'group' => __('Groups')); $form_elems[] = __('Depth') . ' ' . html_print_select ($depth_levels, 'depth', $depth, '', '', '', true, false, false); } // Interfaces if ($activeTab == 'topology') { $form_elems[] = __('Show interfaces') . ' ' . html_print_checkbox ('show_snmp_modules', '1', $show_snmp_modules, true); } // No overlap if ($activeTab != 'dynamic' && $activeTab != 'radial_dynamic') { $form_elems[] = __('No Overlap') . ' ' . html_print_checkbox ('nooverlap', '1', $nooverlap, true); } // Modules with alerts if (($activeTab == 'groups' || $activeTab == 'policies') && $depth == 'all') { $form_elems[] = __('Only modules with alerts') . ' ' . html_print_checkbox ('modwithalerts', '1', $modwithalerts, true); } // Hide policy modules if ($activeTab == 'groups') { if ($config['enterprise_installed']) { $form_elems[] = __('Hide policy modules') . ' ' . html_print_checkbox ('hidepolicymodules', '1', $hidepolicymodules, true); } } // Simple if ($activeTab != 'dynamic' && $activeTab != 'radial_dynamic') { $form_elems[] = __('Simple') . ' ' . html_print_checkbox ('simple', '1', $simple, true); } // Regenerate if ($activeTab != 'dynamic' && $activeTab != 'radial_dynamic') { $form_elems[] = __('Regenerate') . ' ' . html_print_checkbox ('regen', '1', $regen, true); } // Zoom if ($pure == "1") { $zoom_array = array ( '1' => 'x1', '1.2' => 'x2', '1.6' => 'x3', '2' => 'x4', '2.5' => 'x5', '5' => 'x10', ); $form_elems[] = __('Zoom') . ' ' . html_print_select ($zoom_array, 'zoom', $zoom, '', '', '', true, false, false, false); } // Font if ($activeTab != 'dynamic' && $activeTab != 'radial_dynamic') { $form_elems[] = __('Font') . ' ' . html_print_input_text ('font_size', $font_size, $alt = 'Font size (in pt)', 2, 4, true); } // Don't show subgroups if (($activeTab == 'groups') || ($activeTab == 'topology')) { $form_elems[] = __('Don\'t show subgroups:') . ui_print_help_tip(__('Only run with it is filter for any group'), true) . ' ' . html_print_checkbox ('dont_show_subgroups', '1', $dont_show_subgroups, true); } // L2 network if ($activeTab == 'topology') { $form_elems[] = __('L2 network interfaces') . ' ' . html_print_checkbox ('l2_network', '1', $l2_network, true); } // Distance between nodes if ($nooverlap == 1) { $form_elems[] = __('Distance between nodes') . ' ' . html_print_input_text ('ranksep', $ranksep, __('Separation between elements in the map (in Non-overlap mode)'), 3, 4, true); } unset($table); $table->width = '100%'; $table->class = 'databox filters'; $table->data = array(); $max_col = 4; $col = 0; $row = 0; foreach ($form_elems as $key => $element) { if ($col >= $max_col) { $col = 0; $row++; } $table->size[] = "25%"; $table->data[$row][$col] = $element; $col++; } $options_form .= html_print_input_hidden('update_networkmap',1, true) . html_print_input_hidden('hidden_options',0, true); $options_form .= html_print_table ($table, true); $options_form .= "
" . html_print_submit_button (__('Refresh'), "updbutton", false, 'class="sub next"', true) . "
"; $options_form .= '
'; ui_toggle($options_form, __('Map options'), '', $hidden_options); switch ($activeTab) { case 'groups': require_once('operation/agentes/networkmap.groups.php'); break; case 'policies': require_once(ENTERPRISE_DIR . '/operation/policies/networkmap.policies.php'); break; case 'dynamic': require_once('operation/agentes/networkmap.dinamic.php'); break; case 'radial_dynamic': require_once('operation/agentes/networkmap.dinamic.php'); break; default: case 'topology': require_once('operation/agentes/networkmap.topology.php'); break; } ?>