From f545851b20edeb1a411e326972bc2ab40133742d Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 2 Oct 2012 11:11:58 +0000 Subject: [PATCH] 2012-10-02 Ramon Novoa * include/functions_api.php, include/functions_netflow.php, operation/netflow/nf_reporting.php, operation/netflow/nf_view.php: Added XML netflow reports and many changes to enable metaconsole integration. * extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql, extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql, extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql: Updated migration scripts. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7025 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 13 + .../pandoradb_migrate_4.0.x_to_5.0.mysql.sql | 6 +- .../pandoradb_migrate_4.0.x_to_5.0.oracle.sql | 5 + ...doradb_migrate_4.0.x_to_5.0.postgreSQL.sql | 4 + pandora_console/include/functions_api.php | 57 +++++ pandora_console/include/functions_netflow.php | 232 ++++++++++++++++-- .../operation/netflow/nf_reporting.php | 16 +- pandora_console/operation/netflow/nf_view.php | 73 ++++-- 8 files changed, 345 insertions(+), 61 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 2acd8d6c1c..915d221483 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2012-10-02 Ramon Novoa + + * include/functions_api.php, + include/functions_netflow.php, + operation/netflow/nf_reporting.php, + operation/netflow/nf_view.php: Added XML netflow reports and many + changes to enable metaconsole integration. + + * extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql, + extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql, + extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql: Updated + migration scripts. + 2012-10-02 Dario Rodriguez * godmode/setup/setup_visuals.php diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql index e3b6b77d9d..e33e132ac8 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql @@ -148,8 +148,8 @@ ALTER TABLE `tagente_modulo` ADD COLUMN `quiet` tinyint(1) NOT NULL DEFAULT '0'; ALTER TABLE `tagente_modulo` ADD COLUMN `critical_instructions` TEXT NOT NULL DEFAULT ''; ALTER TABLE `tagente_modulo` ADD COLUMN `warning_instructions` TEXT NOT NULL DEFAULT ''; ALTER TABLE `tagente_modulo` ADD COLUMN `unknown_instructions` TEXT NOT NULL DEFAULT ''; -ALTER TABLE `tagente_modulo` ADD COLUMN `critical_inverse` tinyint(1) NOT NULL DEFAULT '0'; -ALTER TABLE `tagente_modulo` ADD COLUMN `warning_inverse` tinyint(1) NOT NULL DEFAULT '0'; +ALTER TABLE `tagente_modulo` ADD COLUMN `critical_inverse` tinyint(1) unsigned default '0'; +ALTER TABLE `tagente_modulo` ADD COLUMN `warning_inverse` tinyint(1) unsigned default '0'; ------------------------------------------------------------------------ -- Table `tnetwork_component` @@ -162,6 +162,8 @@ ALTER TABLE tnetwork_component ADD `macros` text; ALTER TABLE tnetwork_component ADD `critical_instructions` TEXT NOT NULL default ''; ALTER TABLE tnetwork_component ADD `warning_instructions` TEXT NOT NULL default ''; ALTER TABLE tnetwork_component ADD `unknown_instructions` TEXT NOT NULL default ''; +ALTER TABLE `tnetwork_component` ADD COLUMN `critical_inverse` tinyint(1) unsigned default '0'; +ALTER TABLE `tnetwork_component` ADD COLUMN `warning_inverse` tinyint(1) unsigned default '0'; ------------------------------------------------------------------------ -- Table `tgraph_source` Alter table to allow negative values in weight diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql index 7076ccab39..e9f9b07e9f 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql @@ -322,6 +322,8 @@ ALTER TABLE tlayout_data ADD (enable_link NUMBER(5, 0) NOT NULL default 1); ALTER TABLE tagente_modulo ADD (critical_instructions VARCHAR2(255) default ''); ALTER TABLE tagente_modulo ADD (warning_instructions VARCHAR2(255) default ''); ALTER TABLE tagente_modulo ADD (unknown_instructions VARCHAR2(255) default ''); +ALTER TABLE tagente_modulo ADD (critical_inverse NUMBER(1, 0) default 0 NOT NULL); +ALTER TABLE tagente_modulo ADD (warning_inverse NUMBER(1, 0) default 0 NOT NULL); -- ----------------------------------------------------- -- Table `tnetwork_component` @@ -329,6 +331,9 @@ ALTER TABLE tagente_modulo ADD (unknown_instructions VARCHAR2(255) default ''); ALTER TABLE tnetwork_component ADD (critical_instructions VARCHAR2(255) default ''); ALTER TABLE tnetwork_component ADD (warning_instructions VARCHAR2(255) default ''); ALTER TABLE tnetwork_component ADD (unknown_instructions VARCHAR2(255) default ''); +ALTER TABLE tnetwork_component ADD (critical_inverse NUMBER(1, 0) default 0 NOT NULL); +ALTER TABLE tnetwork_component ADD (warning_inverse NUMBER(1, 0) default 0 NOT NULL); +evento ------------------------------------------------------------------------ -- Table `tnetwork_map` diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql index 9d83112bc1..4fa7255ceb 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql @@ -171,6 +171,8 @@ ALTER TABLE "tagente_modulo" ADD COLUMN "macros" TEXT default ''; ALTER TABLE "tagente_modulo" ADD COLUMN "critical_instructions" text default ''; ALTER TABLE "tagente_modulo" ADD COLUMN "warning_instructions" text default ''; ALTER TABLE "tagente_modulo" ADD COLUMN "unknown_instructions" text default ''; +ALTER TABLE "tagente_modulo" ADD COLUMN "critical_inverse" SMALLINT NOT NULL default 0; +ALTER TABLE "tagente_modulo" ADD COLUMN "warning_inverse" SMALLINT NOT NULL default 0; -- ----------------------------------------------------- -- Table `tevent_filter` @@ -321,6 +323,8 @@ ALTER TABLE "tlayout_data" ADD COLUMN "enable_link" SMALLINT NOT NULL default 1; ALTER TABLE "tnetwork_component" ADD COLUMN "critical_instructions" text default ''; ALTER TABLE "tnetwork_component" ADD COLUMN "warning_instructions" text default ''; ALTER TABLE "tnetwork_component" ADD COLUMN "unknown_instructions" text default ''; +ALTER TABLE "tnetwork_component" ADD COLUMN "critical_inverse" SMALLINT NOT NULL default 0; +ALTER TABLE "tnetwork_component" ADD COLUMN "warning_inverse" SMALLINT NOT NULL default 0; ------------------------------------------------------------------------ -- Table `tnetwork_map` diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index e8ded7d3b3..d75eb3bd55 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -27,6 +27,7 @@ include_once($config['homedir'] . "/include/functions_graph.php"); include_once($config['homedir'] . "/include/functions_events.php"); include_once($config['homedir'] . "/include/functions_groups.php"); include_once($config['homedir'] . "/include/functions_network_components.php"); +include_once($config['homedir'] . "/include/functions_netflow.php"); enterprise_include_once ('include/functions_local_components.php'); /** @@ -141,6 +142,9 @@ function returnData($returnType, $data, $separator = ';') { break; } break; + case 'json': + echo json_encode ($data); + break; } } @@ -5540,4 +5544,57 @@ function api_get_tactical_view($trash1, $trash2, $trash3, $returnType) { return; } + +// http://localhost/pandora_console/include/api.php?op=get&op2=netflow_get_data&other=1348562410|1348648810|base64_encode(json_encode($filter))|_1_1234|none|50|bytes&other_mode=url_encode_separator_|&apipass=pandora&user=pandora&pass=pandora' +function api_get_netflow_get_data ($discard_1, $discard_2, $params) { + + // Parse function parameters + $start_date = $params['data'][0]; + $end_date = $params['data'][1]; + $filter = json_decode (base64_decode ($params['data'][2]), true); + $unique_id = $params['data'][3]; + $aggregate = $params['data'][4]; + $max = $params['data'][5]; + $unit = $params['data'][6]; + + // Get netflow data + $data = netflow_get_data ($start_date, $end_date, $filter, $unique_id, $aggregate, $max, $unit); + + returnData('json', $data); + return; +} + +// http://localhost/pandora_console/include/api.php?op=get&op2=netflow_get_stats&other=1348562410|1348648810|base64_encode(json_encode($filter))|none|50|bytes&other_mode=url_encode_separator_|&apipass=pandora&user=pandora&pass=pandora' +function api_get_netflow_get_stats ($discard_1, $discard_2, $params) { + + // Parse function parameters + $start_date = $params['data'][0]; + $end_date = $params['data'][1]; + $filter = json_decode (base64_decode ($params['data'][2]), true); + $aggregate = $params['data'][3]; + $max = $params['data'][4]; + $unit = $params['data'][5]; + + // Get netflow data + $data = netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max_aggregates, $unit); + + returnData('json', $data); + return; +} + +// http://localhost/pandora_console/include/api.php?op=get&op2=netflow_get_summary&other=1348562410|1348648810|_base64_encode(json_encode($filter))|_1_1234&other_mode=url_encode_separator_|&apipass=pandora&user=pandora&pass=pandora' +function api_get_netflow_get_summary ($discard_1, $discard_2, $params) { + + // Parse function parameters + $start_date = $params['data'][0]; + $end_date = $params['data'][1]; + $filter = json_decode (base64_decode ($params['data'][2]), true); + $unique_id = $params['data'][3]; + + // Get netflow data + $data = netflow_get_summary ($start_date, $end_date, $filter, $unique_id); + returnData('json', $data); + return; +} + ?> diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 8015d7b888..24d6e41dcb 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -15,8 +15,8 @@ // GNU General Public License for more details. -include_once("include/functions_users.php"); -include_once("include/functions_io.php"); +include_once($config['homedir'] . "/include/functions_users.php"); +include_once($config['homedir'] . "/include/functions_io.php"); // Date format for nfdump $nfdump_date_format = 'Y/m/d.H:i:s'; @@ -355,7 +355,7 @@ function netflow_is_net ($address) { * * @param string start_date Period start date. * @param string end_date Period end date. - * @param string command Command used to retrieve netflow data. + * @param string filter Netflow filter. * @param string unique_id A unique number that is used to generate a cache file. * @param string aggregate Aggregate field. * @param int max Maximum number of aggregates. @@ -364,10 +364,13 @@ function netflow_is_net ($address) { * @return An array with netflow stats. * */ -function netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggregate, $max, $unit) { +function netflow_get_data ($start_date, $end_date, $filter, $unique_id, $aggregate, $max, $unit) { global $nfdump_date_format; global $config; - + + // Get the command to call nfdump + $command = netflow_get_command ($filter); + // Suppress the header line and the statistics at the bottom $command .= ' -q'; @@ -424,16 +427,20 @@ function netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggreg * * @param string start_date Period start date. * @param string end_date Period end date. - * @param string command Command used to retrieve netflow data. + * @param string filter Netflow filter. * @param string aggregate Aggregate field. * @param int max Maximum number of aggregates. * @param string unit Unit to show. * * @return An array with netflow stats. */ -function netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max, $unit) { +function netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max, $unit) { global $nfdump_date_format; - + + // Get the command to call nfdump + $command = netflow_get_command ($filter); + + // Execute nfdump $command .= " -q -s $aggregate/$unit -n $max -t " .date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); exec($command, $string); @@ -486,15 +493,18 @@ function netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max, * * @param string start_date Period start date. * @param string end_date Period end date. - * @param string command Command used to retrieve netflow data. + * @param string filter Netflow filter. * @param string unique_id A unique number that is used to generate a cache file. * * @return An array with netflow stats. */ -function netflow_get_summary ($start_date, $end_date, $command, $unique_id) { +function netflow_get_summary ($start_date, $end_date, $filter, $unique_id) { global $nfdump_date_format; global $config; - + + // Get the command to call nfdump + $command = netflow_get_command ($filter); + // Execute nfdump and save its output in a temporary file $temp_file = $config['attachment_store'] . '/netflow_' . $unique_id . '.tmp'; $command .= " -o \"fmt: \" -t " .date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); @@ -842,7 +852,7 @@ function netflow_parse_file ($start_date, $end_date, $file, &$values, $aggregate */ function netflow_save_cache ($data, $cache_file) { - @file_put_contents ($cache_file, serialize ($data)); + //@file_put_contents ($cache_file, serialize ($data)); return; } @@ -969,48 +979,216 @@ function netflow_get_valid_intervals () { * @param string start_date Period start date. * @param string end_date Period end date. * @param string type Chart type. - * @param string command Command used to retrieve netflow data. * @param array filter Netflow filter. * @param int max_aggregates Maximum number of aggregates. * @param string unique_id A unique number that is used to generate a cache file. + * @param string output Output format. Only HTML and XML are supported. * */ -function netflow_draw_item ($start_date, $end_date, $type, $filter, $command, $filter, $max_aggregates, $unique_id) { +function netflow_draw_item ($start_date, $end_date, $type, $filter, $max_aggregates, $unique_id, $output = 'HTML') { $aggregate = $filter['aggregate']; $unit = $filter['output']; $interval = $end_date - $start_date; - + // Process item switch ($type) { case '0': - $data = netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggregate, $max_aggregates, $unit); + $data = netflow_get_data ($start_date, $end_date, $filter, $unique_id, $aggregate, $max_aggregates, $unit); if ($aggregate != 'none') { - echo graph_netflow_aggregate_area($data, $interval, 660, 320, 0); + if ($output == 'HTML') { + echo graph_netflow_aggregate_area($data, $interval, 660, 320, 0); + } else if ($output == 'XML') { + netflow_aggregate_area_xml ($data); + } } else { - echo graph_netflow_total_area($data, $interval, 660, 320, 0); + if ($output == 'HTML') { + echo graph_netflow_total_area($data, $interval, 660, 320, 0); + } else if ($output == 'XML') { + netflow_total_area_xml ($data); + } } break; case '1': - $data = netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max_aggregates, $unit); - echo graph_netflow_aggregate_pie($data, $aggregate); + $data = netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max_aggregates, $unit); + if ($output == 'HTML') { + echo graph_netflow_aggregate_pie($data, $aggregate); + } else if ($output == 'XML') { + netflow_aggregate_pie_xml ($data); + } break; case '2': - $data = netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggregate, $max_aggregates, $unit); - echo netflow_data_table ($data, $start_date, $end_date, $aggregate); + $data = netflow_get_data ($start_date, $end_date, $filter, $unique_id, $aggregate, $max_aggregates, $unit); + if ($output == 'HTML') { + echo netflow_data_table ($data, $start_date, $end_date, $aggregate); + } else if ($output == 'XML') { + // Same as netflow_aggregate_area_xml + netflow_aggregate_area_xml ($data); + } break; case '3': - $data = netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max_aggregates, $unit); - echo netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit); + $data = netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max_aggregates, $unit); + if ($output == 'HTML') { + echo netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit); + } else if ($output == 'XML') { + netflow_stat_xml ($data); + } break; case '4': - $data = netflow_get_summary ($start_date, $end_date, $command, $unique_id); - netflow_summary_table ($data); + $data = netflow_get_summary ($start_date, $end_date, $filter, $unique_id); + if ($output == 'HTML') { + netflow_summary_table ($data); + } else { + netflow_summary_xml ($data); + } break; default: echo fs_error_image(); break; } } -?> \ No newline at end of file + +function netflow_xml_report ($id, $start_date, $end_date) { + + // Get report data + $report = db_get_row_sql ('SELECT * FROM tnetflow_report WHERE id_report =' . (int) $id); + if ($report === FALSE) { + echo "" . __('Error generating report') . "\n"; + return; + } + + // Print report header + $time = get_system_time (); + echo ''; + echo "\n"; + echo " \n"; + echo " " . $time . "\n"; + echo " " . date ("r", $time) . "\n"; + echo " \n"; + echo " " . io_safe_output ($report['id_name']) . "\n"; + echo " " . io_safe_output ($report['description']) . "\n"; + echo " " . date ("r", $start_date) . "\n"; + echo " " . date ("r", $end_date) . "\n"; + + // Get netflow item types + $item_types = netflow_get_chart_types (); + + // Print report items + $report_contents = db_get_all_rows_sql ("SELECT * FROM tnetflow_report_content WHERE id_report='" . $report['id_report'] . "' ORDER BY `order`"); + foreach ($report_contents as $content) { + + // Get item filters + $filter = db_get_row_sql("SELECT * FROM tnetflow_filter WHERE id_sg = '" . io_safe_input ($content['id_filter']) . "'", false, true); + if ($filter === FALSE) { + continue; + } + + echo " \n"; + echo " " . io_safe_output ($item_types[$content['show_graph']]) . "\n"; + echo " " . $content['max'] . "\n"; + echo " \n"; + echo " " . io_safe_output ($filter['id_name']) . "\n"; + echo " " . io_safe_output ($filter['ip_src']) . "\n"; + echo " " . io_safe_output ($filter['ip_dst']) . "\n"; + echo " " . io_safe_output ($filter['src_port']) . "\n"; + echo " " . io_safe_output ($filter['src_port']) . "\n"; + echo " " . io_safe_output ($filter['advanced_filter']) . "\n"; + echo " " . io_safe_output ($filter['aggregate']) . "\n"; + echo " " . io_safe_output ($filter['output']) . "\n"; + echo " \n"; + + // Build a unique id for the cache + $unique_id = $report['id_report'] . '_' . $content['id_rc'] . '_' . ($end_date - $start_date); + + netflow_draw_item ($start_date, $end_date, $content['show_graph'], $filter, $content['max'], $unique_id, 'XML'); + + echo " \n"; + } + echo "\n"; +} + +function netflow_aggregate_area_xml ($data) { + + // Print source information + echo "\n"; + foreach ($data['sources'] as $source => $discard) { + echo "$source\n"; + } + echo "\n"; + + // Print flow information + echo "\n"; + foreach ($data['data'] as $timestamp => $flow) { + + echo "\n"; + echo " " . $timestamp . "\n"; + echo " \n"; + foreach ($flow as $source => $data) { + echo " $source\n"; + echo " " . $data . "\n"; + } + echo " \n"; + echo "\n"; + } + echo "\n"; +} + +function netflow_total_area_xml ($data) { + + // Print flow information + echo "\n"; + foreach ($data as $timestamp => $flow) { + echo "\n"; + echo " " . $timestamp . "\n"; + echo " " . $flow['data'] . "\n"; + echo "\n"; + } + echo "\n"; +} + +function netflow_aggregate_pie_xml ($data) { + + // Calculate total + $total = 0; + foreach ($data as $flow) { + $total += $flow['data']; + } + if ($total == 0) { + return; + } + + // Print percentages + echo "\n"; + foreach ($data as $flow) { + echo "" . $flow['agg'] . "\n"; + echo "" . format_numeric (100 * $flow['data'] / $total, 2) . "%\n"; + } + echo "\n"; +} + +function netflow_stat_xml ($data) { + + // Print stats + echo "\n"; + foreach ($data as $flow) { + echo "" . $flow['agg'] . "\n"; + echo "" . $flow['data'] . "\n"; + } + echo "\n"; +} + +function netflow_summary_xml ($data) { + + // Print summary + echo "\n"; + echo " " . $data['totalflows'] . "\n"; + echo " " . $data['totalbytes'] . "\n"; + echo " " . $data['totalbytes'] . "\n"; + echo " " . $data['avgbps'] . "\n"; + echo " " . $data['avgpps'] . "\n"; + echo " " . $data['avgpps'] . "\n"; + echo "\n"; +} + +?> diff --git a/pandora_console/operation/netflow/nf_reporting.php b/pandora_console/operation/netflow/nf_reporting.php index 30561341b1..4e5ae55a0f 100644 --- a/pandora_console/operation/netflow/nf_reporting.php +++ b/pandora_console/operation/netflow/nf_reporting.php @@ -16,10 +16,10 @@ global $config; -include_once("include/functions_ui.php"); -include_once("include/functions_db.php"); -include_once("include/functions_netflow.php"); -include_once("include/functions_html.php"); +include_once($config['homedir'] . "/include/functions_ui.php"); +include_once($config['homedir'] . "/include/functions_db.php"); +include_once($config['homedir'] . "/include/functions_netflow.php"); +include_once($config['homedir'] . "/include/functions_html.php"); check_login (); @@ -81,12 +81,8 @@ foreach ($reports as $report) { $data[0] = ''.$report['id_name'].''; $data[1] = $report['description']; - - $group = db_get_value('nombre','tgrupo', 'id_grupo', $report['id_group']); - if ($group == '') - $group = 'All'; - $data[2] = $group; - + $data[2] = ui_print_group_icon($report['id_group'], true); + array_push ($table->data, $data); } diff --git a/pandora_console/operation/netflow/nf_view.php b/pandora_console/operation/netflow/nf_view.php index 800dccc9a4..88120d059b 100644 --- a/pandora_console/operation/netflow/nf_view.php +++ b/pandora_console/operation/netflow/nf_view.php @@ -16,10 +16,39 @@ global $config; -include_once("include/functions_graph.php"); -include_once("include/functions_ui.php"); -include_once("include/functions_netflow.php"); -ui_require_javascript_file ('calendar'); +// Login check +if (isset ($_GET["direct"])) { + require_once ("../../include/config.php"); + require_once ("../../include/auth/mysql.php"); + require_once("../../include/functions_netflow.php"); + $nick = get_parameter ("nick"); + $pass = get_parameter ("pass"); + if (isset ($nick) && isset ($pass)) { + + $nick = process_user_login ($nick, $pass); + if ($nick !== false) { + unset ($_GET["sec2"]); + $_GET["sec"] = "general/logon_ok"; + db_logon ($nick, $_SERVER['REMOTE_ADDR']); + $_SESSION['id_usuario'] = $nick; + $config['id_user'] = $nick; + //Remove everything that might have to do with people's passwords or logins + unset ($_GET['pass'], $pass, $_POST['pass'], $_REQUEST['pass'], $login_good); + } + else { + // User not known + $login_failed = true; + require_once ('general/login_page.php'); + db_pandora_audit("Logon Failed", "Invalid login: ".$nick, $nick); + exit; + } + } +} else { + include_once($config['homedir'] . "/include/functions_graph.php"); + include_once($config['homedir'] . "/include/functions_ui.php"); + include_once($config['homedir'] . "/include/functions_netflow.php"); + ui_require_javascript_file ('calendar'); +} check_login (); @@ -41,19 +70,18 @@ if ($id) { } $period = get_parameter('period', '86400'); -$update_date = get_parameter('update_date', 0); -if ($update_date) { - $date = get_parameter_post ('date'); - $time = get_parameter_post ('time'); - $interval = get_parameter('period','86400'); -} -else { - $date = date ("Y/m/d", get_system_time ()); - $time = date ("H:i:s", get_system_time ()); - $interval ='86400'; -} +$date = get_parameter_post ('date', date ("Y/m/d", get_system_time ())); +$time = get_parameter_post ('time', date ("H:i:s", get_system_time ())); + $end_date = strtotime ($date . " " . $time); -$start_date = $end_date - $interval; +$start_date = $end_date - $period; + +// Generate an XML report +if (isset ($_GET["xml"])) { + header ('Content-type: application/xml; charset="utf-8"', true); + netflow_xml_report ($id, $start_date, $end_date); + return; +} $buttons['report_list'] = '' . html_print_image ("images/edit.png", true, array ("title" => __('Report list'))) @@ -83,11 +111,15 @@ echo '
" . html_print_image("images/database_lightning.png", true) . ''; + + html_print_table ($table); echo '
'; html_print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"'); - html_print_input_hidden ('update_date', 1); echo '
'; echo'
'; @@ -109,7 +141,7 @@ if (empty ($report_contents)) { foreach ($report_contents as $content_report) { // Get report item - $report_id = $all_rcs[$x]['id_rc']; + $report_id = $content_report['id_report']; $content_id = $content_report['id_rc']; $max_aggregates= $content_report['max']; $type = $content_report['show_graph']; @@ -117,9 +149,6 @@ foreach ($report_contents as $content_report) { // Get item filters $filter = db_get_row_sql("SELECT * FROM tnetflow_filter WHERE id_sg = '" . io_safe_input ($content_report['id_filter']) . "'", false, true); - // Get the command to call nfdump - $command = netflow_get_command ($filter); - if ($filter['aggregate'] != 'none') { echo '

' . $filter['id_name'] . ' (' . __($filter['aggregate']) . '/' . __($filter['output']) . ')

'; } @@ -131,6 +160,6 @@ foreach ($report_contents as $content_report) { $unique_id = $report_id . '_' . $content_id . '_' . ($end_date - $start_date); // Draw - netflow_draw_item ($start_date, $end_date, $type, $filter, $command, $filter, $max_aggregates, $unique_id); + netflow_draw_item ($start_date, $end_date, $type, $filter, $max_aggregates, $unique_id); } ?> \ No newline at end of file