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;