From 01e3cbafac46b7b8c291b3afef349774479c079d Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 4 Feb 2013 17:38:02 +0000 Subject: [PATCH] 2013-02-04 Miguel de Dios * godmode/modules/manage_network_components.php: cleaned source code style. * operation/netflow/nf_live_view.php: fixed the lost to simplified the filter. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7579 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 8 ++ .../modules/manage_network_components.php | 50 +++++++------ .../operation/netflow/nf_live_view.php | 75 ++++++++++++++----- 3 files changed, 93 insertions(+), 40 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index ea2133aa67..26b7857465 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2013-02-04 Miguel de Dios + + * godmode/modules/manage_network_components.php: cleaned source code + style. + + * operation/netflow/nf_live_view.php: fixed the lost to simplified + the filter. + 2013-02-04 Miguel de Dios * include/functions_ui.php: fixed the javascript of function diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index daddc52ab4..de55957dbc 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -59,13 +59,13 @@ $plugin_parameter = (string) get_parameter ('plugin_parameter'); $macros = (string) get_parameter ('macros'); -if(!empty($macros)) { +if (!empty($macros)) { $macros = json_decode(base64_decode($macros), true); - + foreach($macros as $k => $m) { $macros[$k]['value'] = get_parameter($m['macro'], ''); } - + $macros = json_encode($macros); } @@ -94,7 +94,7 @@ $id_category = (int) get_parameter('id_category'); $id_tag_selected = (array) get_parameter('id_tag_selected'); $pure = get_parameter('pure', 0); -if(count($id_tag_selected) == 1 && empty($id_tag_selected[0])) { +if (count($id_tag_selected) == 1 && empty($id_tag_selected[0])) { $tags = ''; } else { @@ -123,7 +123,8 @@ if ($duplicate_network_component) { $id = network_components_duplicate_network_component ($source_id); ui_print_result_message ($id, - __('Successfully created from %s', network_components_get_name ($source_id)), + __('Successfully created from %s', + network_components_get_name ($source_id)), __('Could not be created')); //List unset for jump the bug in the pagination (TODO) that the make another @@ -135,11 +136,12 @@ if ($duplicate_network_component) { } if ($create_component) { - + $custom_string_1 = ''; $custom_string_2 = ''; $custom_string_3 = ''; - $name_check = db_get_value ('name', 'tnetwork_component', 'name', $name); + $name_check = db_get_value ('name', 'tnetwork_component', 'name', + $name); if ($type >= 15 && $type <= 18) { // New support for snmp v3 $tcp_send = $snmp_version; @@ -149,10 +151,11 @@ if ($create_component) { $custom_string_1 = $snmp3_privacy_method; $custom_string_2 = $snmp3_privacy_pass; $custom_string_3 = $snmp3_security_level; - $name_check = db_get_value ('name', 'tnetwork_component', 'name', $name); + $name_check = db_get_value ('name', 'tnetwork_component', + 'name', $name); } - - + + if ($name && !$name_check) { $id = network_components_create_network_component ($name, $type, $id_group, @@ -286,7 +289,7 @@ if ($update_component) { include_once ('godmode/modules/manage_network_components_form.php'); return; } - + db_pandora_audit("Module management", "Update network component #$id"); ui_print_success_message (__('Updated successfully')); @@ -413,26 +416,28 @@ if ($component_groups === false) $component_groups = array(); foreach ($component_groups as $component_group_key => $component_group_val) { - $num_components = db_get_num_rows('SELECT id_nc - FROM tnetwork_component - WHERE id_group = ' . $component_group_key); - + $num_components = db_get_num_rows( + 'SELECT id_nc + FROM tnetwork_component + WHERE id_group = ' . $component_group_key); + $childs = component_groups_get_childrens($component_group_key); $num_components_childs = 0; if ($childs !== false) { - + foreach ($childs as $child) { - $num_components_childs += db_get_num_rows('SELECT id - FROM tlocal_component - WHERE id_network_component_group = ' . $child['id_sg']); + $num_components_childs += db_get_num_rows( + 'SELECT id + FROM tlocal_component + WHERE id_network_component_group = ' . $child['id_sg']); } - } - + } + // Only show component groups with local components if ($num_components == 0 && $num_components_childs == 0) unset($component_groups[$component_group_key]); @@ -513,7 +518,8 @@ foreach ($components as $component) { } if (isset($data)) { - echo "
"; + echo ""; html_print_input_hidden('multiple_delete', 1); html_print_table ($table); echo "
"; diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 514be4fd56..2d2ba02b6e 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -150,6 +150,11 @@ else if ($update != '' && check_acl ($config["id_user"], 0, "AW")) { // The filter name will not be needed anymore $filter['id_name'] = ''; +$netflow_disable_custom_lvfilters = false; +if (isset($config['netflow_disable_custom_lvfilters'])) { + $netflow_disable_custom_lvfilters = $config['netflow_disable_custom_lvfilters']; +} + echo ''; if (defined ('METACONSOLE')) { @@ -252,11 +257,17 @@ echo '"; echo ""; - echo "" . ''.__('Filter').'' . ""; - echo "" . - __('Normal') . ' ' . html_print_radio_button_extended ('filter_type', 0, '', $filter_type, false, 'displayNormalFilter();', 'style="margin-right: 40px;"', true) . - __('Advanced') . ' ' . html_print_radio_button_extended ('filter_type', 1, '', $filter_type, false, 'displayAdvancedFilter();', 'style="margin-right: 40px;"', true) . - ""; + if ($netflow_disable_custom_lvfilters) { + echo ""; + echo ""; + } + else { + echo "" . ''.__('Filter').'' . ""; + echo "" . + __('Normal') . ' ' . html_print_radio_button_extended ('filter_type', 0, '', $filter_type, false, 'displayNormalFilter();', 'style="margin-right: 40px;"', true) . + __('Advanced') . ' ' . html_print_radio_button_extended ('filter_type', 1, '', $filter_type, false, 'displayAdvancedFilter();', 'style="margin-right: 40px;"', true) . + ""; + } echo "" . ''.__('Load filter').'' . ""; $user_groups = users_get_groups ($config['id_user'], "AR", $own_info['is_admin'], true); @@ -267,20 +278,44 @@ echo '"; - echo "" . __('Dst Ip'). ui_print_help_tip (__("Destination IP. A comma separated list of destination ip. If we leave the field blank, will show all ip. Example filter by ip:
25.46.157.214,160.253.135.249"), true) . ""; - echo "" . html_print_input_text ('ip_dst', $filter['ip_dst'], false, 30, 80, true) . ""; + if ($netflow_disable_custom_lvfilters) { + echo ""; + echo ""; + } + else { + echo "" . __('Dst Ip'). ui_print_help_tip (__("Destination IP. A comma separated list of destination ip. If we leave the field blank, will show all ip. Example filter by ip:
25.46.157.214,160.253.135.249"), true) . ""; + echo "" . html_print_input_text ('ip_dst', $filter['ip_dst'], false, 30, 80, true) . ""; + } - echo "" . __('Src Ip'). ui_print_help_tip (__("Source IP. A comma separated list of source ip. If we leave the field blank, will show all ip. Example filter by ip:
25.46.157.214,160.253.135.249"), true) . ""; - echo "" . html_print_input_text ('ip_src', $filter['ip_src'], false, 30, 80, true) . ""; + if ($netflow_disable_custom_lvfilters) { + echo ""; + echo ""; + } + else { + echo "" . __('Src Ip'). ui_print_help_tip (__("Source IP. A comma separated list of source ip. If we leave the field blank, will show all ip. Example filter by ip:
25.46.157.214,160.253.135.249"), true) . ""; + echo "" . html_print_input_text ('ip_src', $filter['ip_src'], false, 30, 80, true) . ""; + } echo ""; echo ""; - echo "" . __('Dst Port'). ui_print_help_tip (__("Destination port. A comma separated list of destination ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22:
80,22"), true) . ""; - echo "" . html_print_input_text ('dst_port', $filter['dst_port'], false, 30, 80, true) . ""; - - echo "" . __('Src Port'). ui_print_help_tip (__("Source port. A comma separated list of source ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22:
80,22"), true) . ""; - echo "" . html_print_input_text ('src_port', $filter['src_port'], false, 30, 80, true) . ""; + if ($netflow_disable_custom_lvfilters) { + echo ""; + echo ""; + } + else { + echo "" . __('Dst Port'). ui_print_help_tip (__("Destination port. A comma separated list of destination ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22:
80,22"), true) . ""; + echo "" . html_print_input_text ('dst_port', $filter['dst_port'], false, 30, 80, true) . ""; + } + + if ($netflow_disable_custom_lvfilters) { + echo ""; + echo ""; + } + else { + echo "" . __('Src Port'). ui_print_help_tip (__("Source port. A comma separated list of source ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22:
80,22"), true) . ""; + echo "" . html_print_input_text ('src_port', $filter['src_port'], false, 30, 80, true) . ""; + } echo ""; echo ""; @@ -310,11 +345,15 @@ echo '"; } + html_print_submit_button (__('Draw'), 'draw_button', false, 'class="sub upd"'); - if (check_acl ($config["id_user"], 0, "AW")) { - html_print_submit_button (__('Save as new filter'), 'save_button', false, 'class="sub upd" onClick="return defineFilterName();"'); - - html_print_submit_button (__('Update current filter'), 'update_button', false, 'class="sub upd"'); + + if (!$netflow_disable_custom_lvfilters) { + if (check_acl ($config["id_user"], 0, "AW")) { + html_print_submit_button (__('Save as new filter'), 'save_button', false, 'class="sub upd" onClick="return defineFilterName();"'); + + html_print_submit_button (__('Update current filter'), 'update_button', false, 'class="sub upd"'); + } } if (defined ('METACONSOLE')) {