%d AND utimestamp < %d %s GROUP BY %s ORDER BY %s DESC LIMIT %d', $field_to_group, $start, $end, $filter_sql, $field_to_group, $field_to_order, $top ); $data = db_get_all_rows_sql($sql); return ($data !== false) ? $data : []; } /** * Get the possible actions on networking. * * @param boolean $network True if network. False if netflow. * * @return array With the actions to print in a select. */ function network_get_report_actions($network) { $common_actions = [ 'listeners' => __('Top listeners'), 'talkers' => __('Top talkers'), ]; if ($network) { return $common_actions; } return array_merge( $common_actions, [ 'tcp' => __('Top TCP protocols'), 'udp' => __('Top UDP protocols'), ] ); } /** * Print the header of the network * * @param string $title Title of header. * @param string $order Current ordering. * @param string $selected Selected order. * @param array $hidden_data All the data to hide into the button. * * @return string With HTML data. */ function network_print_explorer_header( $title, $order, $selected, $hidden_data ) { $cell = '
'; $cell .= $title; $cell .= html_print_link_with_params( 'images/arrow-down-white.png', array_merge($hidden_data, ['order_by' => $order]), 'image', ($selected === $order) ? 'opacity: 0.5' : '' ); $cell .= '
'; return $cell; } /** * Alias for format_for_graph to print bytes. * * @param integer $value Value to parse like bytes. * * @return string Number parsed. */ function network_format_bytes($value) { if (!isset($value)) { $value = 0; } $value = (int) $value; return format_for_graph( $value, 2, '.', ',', 1024, 'B' ); }