2012-12-06 Miguel de Dios <miguel.dedios@artica.es>

* 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
This commit is contained in:
mdtrooper 2012-12-06 18:12:28 +00:00
parent c422f1a9b5
commit dcd02553b1
5 changed files with 28 additions and 15 deletions

View File

@ -1,3 +1,13 @@
2012-12-06 Miguel de Dios <miguel.dedios@artica.es>
* 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 <miguel.dedios@artica.es> 2012-12-06 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_agents.php, * include/functions_agents.php,

View File

@ -275,12 +275,13 @@ function mysql_db_process_sql($sql, $rettype = "affected_rows", $dbconnection =
} }
else { else {
$start = microtime (true); $start = microtime (true);
if ($dbconnection == '') { if ($dbconnection == '') {
$result = mysql_query ($sql); $dbconnection = $config['dbconnection'];
}
else {
$result = mysql_query ($sql, $dbconnection);
} }
$result = mysql_query ($sql, $dbconnection);
$time = microtime (true) - $start; $time = microtime (true) - $start;
if ($result === false) { if ($result === false) {
$backtrace = debug_backtrace (); $backtrace = debug_backtrace ();
@ -313,7 +314,7 @@ function mysql_db_process_sql($sql, $rettype = "affected_rows", $dbconnection =
while ($row = mysql_fetch_assoc ($result)) { while ($row = mysql_fetch_assoc ($result)) {
array_push ($retval, $row); array_push ($retval, $row);
} }
if ($cache === true) if ($cache === true)
$sql_cache[$sql] = $retval; $sql_cache[$sql] = $retval;
mysql_free_result ($result); mysql_free_result ($result);

View File

@ -1314,7 +1314,9 @@ function agents_get_agent_id ($agent_name, $io_safe_input = false) {
* @return string Name of the given agent. * @return string Name of the given agent.
*/ */
function agents_get_name ($id_agent, $case = "none") { 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 // Version 3.0 has enforced case sensitive agent names
// so we always should show real case names. // so we always should show real case names.
switch ($case) { switch ($case) {

View File

@ -213,7 +213,7 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $returnAl
$fields = users_get_groups_for_select($id_user, $privilege, $fields = users_get_groups_for_select($id_user, $privilege,
$returnAllGroup, true, $id_group); $returnAllGroup, true, $id_group);
$output = html_print_select ($fields, $name, $selected, $script, $output = html_print_select ($fields, $name, $selected, $script,
$nothing, $nothing_value, $return, $multiple, false, $class, $nothing, $nothing_value, $return, $multiple, false, $class,
$disabled, $style, $option_style); $disabled, $style, $option_style);

View File

@ -458,7 +458,7 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $u
if ($aggregate == 'none') { if ($aggregate == 'none') {
netflow_save_cache ($values, $cache_file); netflow_save_cache ($values, $cache_file);
} }
return $values; return $values;
} }
@ -489,14 +489,14 @@ function netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max, $
// Execute nfdump // Execute nfdump
$command .= " -o csv -q -s $aggregate/bytes -n $max -t " .date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); $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); exec($command, $string);
if (! is_array($string)) { if (! is_array($string)) {
return array (); return array ();
} }
// Remove the first line // Remove the first line
$string[0] = ''; $string[0] = '';
$i = 0; $i = 0;
$values = array(); $values = array();
$interval_length = $end_date - $start_date; $interval_length = $end_date - $start_date;
@ -542,7 +542,7 @@ function netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max, $
} }
$i++; $i++;
} }
sort_netflow_data ($values); sort_netflow_data ($values);
return $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'; $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); $command .= " -o \"fmt: \" -t " .date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
exec("$command > $temp_file"); exec("$command > $temp_file");
// Parse data file // Parse data file
// We must parse from $start_date to avoid creating new intervals! // We must parse from $start_date to avoid creating new intervals!
$values = array (); $values = array ();
@ -823,7 +823,7 @@ function netflow_parse_file ($start_date, $end_date, $interval_length, $file, &$
$flow['timestamp'] = strtotime ($flow['datetime']); $flow['timestamp'] = strtotime ($flow['datetime']);
$last_timestamp = $flow['timestamp']; $last_timestamp = $flow['timestamp'];
} }
if ($flow['timestamp'] >= $timestamp && $flow['timestamp'] <= $timestamp + $interval_length) { if ($flow['timestamp'] >= $timestamp && $flow['timestamp'] <= $timestamp + $interval_length) {
$read_flag = 1; $read_flag = 1;
if ($aggregate != 'none') { if ($aggregate != 'none') {
@ -847,7 +847,7 @@ function netflow_parse_file ($start_date, $end_date, $interval_length, $file, &$
$no_data = 1; $no_data = 1;
if ($aggregate != 'none') { if ($aggregate != 'none') {
foreach ($interval_total as $agg => $val) { foreach ($interval_total as $agg => $val) {
// No data for this interval/aggregate // No data for this interval/aggregate
if ($interval_count[$agg] == 0) { if ($interval_count[$agg] == 0) {
continue; continue;