From 4c7486f4d65a60bc10d495c4a30aaf22351dc53d Mon Sep 17 00:00:00 2001 From: vgilc Date: Fri, 23 Dec 2011 08:37:36 +0000 Subject: [PATCH] 2011-12-21 Vanessa Gil * godmode/netflow/nf_manage.php godmode/netflow/nf_edit.php include/functions_netflow.php: changed netflow setup. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5302 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/godmode/netflow/nf_edit.php | 2 +- pandora_console/godmode/netflow/nf_manage.php | 165 ++++-------------- .../godmode/netflow/nf_option_form.php | 4 +- pandora_console/include/functions_graph.php | 36 +--- pandora_console/include/functions_netflow.php | 24 ++- pandora_console/index.php | 2 +- 6 files changed, 67 insertions(+), 166 deletions(-) diff --git a/pandora_console/godmode/netflow/nf_edit.php b/pandora_console/godmode/netflow/nf_edit.php index 3c16c0635b..970c99fc86 100644 --- a/pandora_console/godmode/netflow/nf_edit.php +++ b/pandora_console/godmode/netflow/nf_edit.php @@ -90,7 +90,7 @@ $filter['limit'] = (int) $config['block_size']; $filters = db_get_all_rows_filter ('tnetflow_filter', $filter); if ($filters === false) - $filter = array (); + $filters = array (); $table->width = '70%'; $table->head = array (); diff --git a/pandora_console/godmode/netflow/nf_manage.php b/pandora_console/godmode/netflow/nf_manage.php index 5f5f783471..f173e54fb9 100644 --- a/pandora_console/godmode/netflow/nf_manage.php +++ b/pandora_console/godmode/netflow/nf_manage.php @@ -17,163 +17,66 @@ global $config; +//include_once("include/functions_graph.php"); include_once("include/functions_ui.php"); -include_once("include/functions_db.php"); -include_once("include/functions_netflow.php"); -include_once("include/functions_html.php"); +//ui_require_javascript_file ('calendar'); check_login (); -if (! check_acl ($config["id_user"], 0, "IW")) { +if (! check_acl ($config["id_user"], 0, "IR")) { db_pandora_audit("ACL Violation", "Trying to access event viewer"); require ("general/noaccess.php"); return; } -/* -$buttons ['view']= '' - . html_print_image ("images/lupa.png", true, array ("title" => __('View'))) - . ''; - -$buttons['edit'] = '' - . html_print_image ("images/edit.png", true, array ("title" => __('Filter list'))) - . ''; - -$buttons['add'] = '' - . html_print_image ("images/add.png", true, array ("title" => __('Add filter'))) - . ''; - -*/ //Header -ui_print_page_header (__('Netflow Manager'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons); +ui_print_page_header (__('Netflow Manager'), "images/networkmap/so_cisco_new.png", false, "", true); -$delete = (bool) get_parameter ('delete'); -$multiple_delete = (bool)get_parameter('multiple_delete', 0); -$id = (int) get_parameter ('id'); +$update = (bool) get_parameter ("update"); -if ($delete) { - $result = db_process_sql_delete ('tnetflow_options', - array ('id_option' => $id)); - - if ($result !== false) $result = true; - else $result = false; - - ui_print_result_message ($result, - __('Successfully deleted'), - __('Not deleted. Error deleting data')); +if ($update) { + + $config['netflow_path'] = (string)get_parameter('netflow_path'); + + if (db_get_value('token', 'tconfig', 'token', 'netflow_path') === false) { + config_create_value('netflow_path', $config['netflow_path']); + } else { + db_process_sql_update ('tconfig', + array ('value' => $config['netflow_path']), + array ('token' => 'netflow_path')); + } } +$table->width = '70%'; +$table->border = 0; +$table->cellspacing = 3; +$table->cellpadding = 5; +$table->class = "databox_color"; +$table->style[0] = 'vertical-align: top;'; -if ($multiple_delete) { - $ids = (array)get_parameter('delete_multiple', array()); - - db_process_sql_begin(); - - foreach ($ids as $id) { - $result = db_process_sql_delete ('tnetflow_options', - array ('id_option' => $id)); - - if ($result === false) { - db_process_sql_rollback(); - break; - } - } - - if ($result !== false) { - db_process_sql_commit(); - } - - if ($result !== false) $result = true; - else $result = false; - - ui_print_result_message ($result, - __('Successfully deleted'), - __('Not deleted. Error deleting data')); -} - -$filter = array (); - -$filter['offset'] = (int) get_parameter ('offset'); -$filter['limit'] = (int) $config['block_size']; - -$options = db_get_all_rows_filter ('tnetflow_options', $filter); - -if ($options === false) - $filter = array (); - -$table->width = '80%'; -$table->head = array (); -$table->head[0] = __('Options name'); -$table->head[1] = __('Description'); -$table->head[2] = __('Action') . - html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();'); - -$table->style = array (); -$table->style[0] = 'font-weight: bold'; -$table->align = array (); -$table->align[2] = 'center'; -$table->size = array (); -$table->size[0] = '50%'; -$table->size[1] = '40%'; -$table->size[2] = '50px'; $table->data = array (); - -$total_options = db_get_all_rows_filter ('tnetflow_options', false, 'COUNT(*) AS total'); -$total_options = $total_options[0]['total']; - -ui_pagination ($total_options, $url); - - foreach ($options as $option) { - - $data = array (); - - $data[0] = ''.$option['id_name'].''; +$table->data[0][0] = ''.__('Path').''. ui_print_help_tip (__("Read input from a sequence of files in the same directory."), true); +$table->data[0][1] = html_print_input_text ('netflow_path', $config['netflow_path'], false, 50, 200, true); - $data[1] = $option['description']; +echo '
'; + +html_print_table ($table); + +// Update button +echo '
'; + html_print_input_hidden ('update', 1); + html_print_submit_button (__('Update'), 'upd_button', false, 'class="sub upd"'); +echo '
'; - $data[2] = "" . - html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "" . - html_print_checkbox_extended ('delete_multiple[]', $option['id_option'], false, false, '', 'class="check_delete"', true); - - array_push ($table->data, $data); -} - -if(isset($data)) { - echo "
"; - html_print_input_hidden('multiple_delete', 1); - html_print_table ($table); - echo "
"; - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); - echo "
"; - echo "
"; -}else { - echo "
".__('There are no defined filters')."
"; -} - -echo '
'; - echo "
"; - html_print_submit_button (__('Create option'), 'crt', false, 'class="sub wand"'); - echo "
"; - echo "
"; - ?> diff --git a/pandora_console/godmode/netflow/nf_option_form.php b/pandora_console/godmode/netflow/nf_option_form.php index 5e293fe930..1fdecece3e 100644 --- a/pandora_console/godmode/netflow/nf_option_form.php +++ b/pandora_console/godmode/netflow/nf_option_form.php @@ -19,8 +19,8 @@ global $config; include_once("include/functions_ui.php"); include_once("include/functions_netflow.php"); -include_once ("/include/functions_users.php"); -include_once ("/include/functions_groups.php"); +include_once ("include/functions_users.php"); +include_once ("include/functions_groups.php"); check_login (); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 842ae6f808..adda0e2634 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2029,7 +2029,12 @@ echo"

Gráfica de área

"; } $color = array(); - $flash_chart = ''; + + $flash_chart = $config['flash_charts']; + if ($only_image) { + $flash_chart = false; + } + return area_graph($flash_chart, $chart, $width, $height, $color, $aggs, $long_index, "images/image_problem.opaque.png", "", "", $homeurl, $config['homedir'] . "/images/logo_vertical_water.png", @@ -2193,35 +2198,6 @@ function grafico_netflow_aggregate_pie ($data) { $config['fontpath'], $config['font_size']); } -/** - * Print a pie graph with netflow total - */ - -function grafico_netflow_total_pie ($data) { - global $config; - global $graphic_type; - echo"

Gráfica totalizada

"; - - $i = 0; - $agg = ''; - $values = array(); - while (isset ($data[$i])) { - $agg = $data[$i]['agg']; - if ($data[$i]['unit'] == 'G') { - $data[$i]['data'] = $data[$i]['data'] * 1024; - } - if (isset($values[$agg])){ - $values[$agg] = $data[$i]['data']; - } else { - $values[$agg] += $data[$i]['data']; - } - $i++; - } - return pie3d_graph($config['flash_charts'], $values, 320, 200, - __('Other'), '', $config['homedir'] . "/images/logo_vertical_water.png", - $config['fontpath'], $config['font_size']); -} - /** * Draw a graph of Module string data of agent diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 3c62a06182..04d4622287 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -249,7 +249,29 @@ function netflow_show_table_values($data, $date_limit, $date_time){ $coordx = array(); $coordy = array(); - +//añadido +/* + $max_values = 10; + + if(count($data) > $max_values) { + $chart_data_trunc = array(); + $n = 1; + foreach($chart_data as $key => $value) { + if($n < $max_values) { + $chart_data_trunc[$key] = $value; + } + else { + if (!isset($chart_data_trunc[$others_str])) { + $chart_data_trunc[$others_str] = 0; + } + $chart_data_trunc[$others_str] += $value; + } + $n++; + } + $chart_data = $chart_data_trunc; + } +*/ +//fin añadido while (isset ($data[$j])) { $date = $data[$j]['date']; $time = $data[$j]['time']; diff --git a/pandora_console/index.php b/pandora_console/index.php index 05e50b03cd..671fe7b289 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -21,7 +21,7 @@ if (function_exists ('mb_internal_encoding')) { // Set to 1 to do not check for installer or config file (for development!). // Activate gives more error information, not useful for production sites -$develop_bypass = 0; +$develop_bypass = 1; if ($develop_bypass != 1) { // If no config file, automatically try to install