From a495c5e7b171b8ecba7c7aea5070cc758f514863 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 6 Dec 2012 18:12:28 +0000 Subject: [PATCH] 2012-12-06 Miguel de Dios * include/functions_agents.php, include/functions_html.php, include/functions_netflow.php: cleaned source code style. * include/db/mysql.php: fixed into the function "mysql_db_process_sql" a big bug that runs fine the select querys in a metaconsole enviorement with several DBs but the insert querys make in the previous connection. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7235 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 ++++++++++ pandora_console/include/db/mysql.php | 11 ++++++----- pandora_console/include/functions_agents.php | 4 +++- pandora_console/include/functions_html.php | 2 +- pandora_console/include/functions_netflow.php | 16 ++++++++-------- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 338c2e0472..7bed5752d3 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2012-12-06 Miguel de Dios + + * include/functions_agents.php, include/functions_html.php, + include/functions_netflow.php: cleaned source code style. + + * include/db/mysql.php: fixed into the function + "mysql_db_process_sql" a big bug that runs fine the select querys in + a metaconsole enviorement with several DBs but the insert querys + make in the previous connection. + 2012-12-06 Miguel de Dios * include/functions_agents.php, diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index d8e34809c7..03447a8c6e 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -275,12 +275,13 @@ function mysql_db_process_sql($sql, $rettype = "affected_rows", $dbconnection = } else { $start = microtime (true); + if ($dbconnection == '') { - $result = mysql_query ($sql); - } - else { - $result = mysql_query ($sql, $dbconnection); + $dbconnection = $config['dbconnection']; } + + $result = mysql_query ($sql, $dbconnection); + $time = microtime (true) - $start; if ($result === false) { $backtrace = debug_backtrace (); @@ -313,7 +314,7 @@ function mysql_db_process_sql($sql, $rettype = "affected_rows", $dbconnection = while ($row = mysql_fetch_assoc ($result)) { array_push ($retval, $row); } - + if ($cache === true) $sql_cache[$sql] = $retval; mysql_free_result ($result); diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 1f783a57cb..40ab077b46 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1314,7 +1314,9 @@ function agents_get_agent_id ($agent_name, $io_safe_input = false) { * @return string Name of the given agent. */ function agents_get_name ($id_agent, $case = "none") { - $agent = (string) db_get_value ('nombre', 'tagente', 'id_agente', (int) $id_agent); + $agent = (string) db_get_value ('nombre', + 'tagente', 'id_agente', (int) $id_agent); + // Version 3.0 has enforced case sensitive agent names // so we always should show real case names. switch ($case) { diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 0d280a4f69..a07b171ef7 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -213,7 +213,7 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $returnAl $fields = users_get_groups_for_select($id_user, $privilege, $returnAllGroup, true, $id_group); - + $output = html_print_select ($fields, $name, $selected, $script, $nothing, $nothing_value, $return, $multiple, false, $class, $disabled, $style, $option_style); diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 94c930e431..445d3b8a42 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -458,7 +458,7 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $u if ($aggregate == 'none') { netflow_save_cache ($values, $cache_file); } - + return $values; } @@ -489,14 +489,14 @@ function netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max, $ // Execute nfdump $command .= " -o csv -q -s $aggregate/bytes -n $max -t " .date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); exec($command, $string); - + if (! is_array($string)) { return array (); } - + // Remove the first line $string[0] = ''; - + $i = 0; $values = array(); $interval_length = $end_date - $start_date; @@ -542,7 +542,7 @@ function netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max, $ } $i++; } - + sort_netflow_data ($values); return $values; @@ -575,7 +575,7 @@ function netflow_get_summary ($start_date, $end_date, $filter, $unique_id, $conn $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); exec("$command > $temp_file"); - + // Parse data file // We must parse from $start_date to avoid creating new intervals! $values = array (); @@ -823,7 +823,7 @@ function netflow_parse_file ($start_date, $end_date, $interval_length, $file, &$ $flow['timestamp'] = strtotime ($flow['datetime']); $last_timestamp = $flow['timestamp']; } - + if ($flow['timestamp'] >= $timestamp && $flow['timestamp'] <= $timestamp + $interval_length) { $read_flag = 1; if ($aggregate != 'none') { @@ -847,7 +847,7 @@ function netflow_parse_file ($start_date, $end_date, $interval_length, $file, &$ $no_data = 1; if ($aggregate != 'none') { foreach ($interval_total as $agg => $val) { - + // No data for this interval/aggregate if ($interval_count[$agg] == 0) { continue;