pandorafms/pandora_console/include/functions_custom_graphs.php
ramonn 4f2867c0a0 2009-06-30 Ramon Novoa <rnovoa@artica.es>
* nclude/FusionCharts,
	  include/FusionCharts/FCF_Column3D.swf,
	  include/FusionCharts/FCF_Pie3D.swf,
	  include/FusionCharts/FusionCharts.js,
	  include/FusionCharts/FCF_MSLine.swf,
	  include/FusionCharts/FusionCharts_Gen.php,
	  include/FusionCharts/FCF_StackedArea2D.swf,
	  include/FusionCharts/FCF_Area2D.swf,
	  include/FusionCharts/FCF_MSArea2D.swf,
	  include/FusionCharts/FusionCharts.php: Added to repository. Fusion
	  Charts Free.

	* include/functions_fsgraph.php: Added to repository. Fusion Charts
	  chart generation functions for Pandora FMS.
	
	* include/pchart_graph.php, include/pandora_graph.php,
	  include/fgraph2.php, include/pChart, include/Image,
	  include/fgraph.php: Moved from reporting to include.

	* operation/agentes/stat_win.php: Moved from reporting to
	  operation/agentes.

	* reporting: Deleted from repository.

	* general/logon_ok.php, godmode/setup/setup.php,
	  godmode/admin_access_logs.php, godmode/db/db_main.php,
	  godmode/db/db_info.php, godmode/db/db_purge.php,
	  godmode/reporting/graph_builder.php,
	  operation/reporting/reporting_xml.php,
	  operation/reporting/reporting_viewer.php,
	  operation/servers/view_server.php,
	  operation/servers/view_server_detail.php,
	  operation/incidents/incident_statistics.php
	  operation/users/user_statistics.php,
	  operation/events/event_statistics.php, operation/events/events.php,
	  operation/agentes/estado_ultimopaquete.php,
	  operation/agentes/estado_generalagente.php,
	  operation/agentes/tactical.php, include/functions_config.php,
	  include/functions_custom_graphs.php,
	  include/functions_visual_map.php,
	  include/functions_reporting.php: Added flash charts.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1779 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-06-30 15:08:14 +00:00

122 lines
3.5 KiB
PHP

<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
if ($config['flash_charts']) {
require_once ('include/fgraph.php');
}
/**
* Get all the custom graphs a user can see.
*
* @param $id_user User id to check.
* @param $only_names Wheter to return only graphs names in an associative array
* or all the values.
*
* @return Custom graphs of a an user. Empty array if none.
*/
function get_user_custom_graphs ($id_user = 0, $only_names = false) {
global $config;
if (!$id_user) {
$id_user = $config['id_user'];
}
$all_graphs = get_db_all_rows_in_table ('tgraph', 'name');
if ($all_graphs === false)
return array ();
$graphs = array ();
foreach ($all_graphs as $graph) {
if ($graph["id_user"] != $id_user && $graph['private'])
continue;
if ($only_names) {
$graphs[$graph['id_graph']] = $graph['name'];
} else {
$graphs[$graph['id_graph']] = $graph;
}
}
return $graphs;
}
/**
* Print a custom graph image.
*
* @param $id_graph Graph id to print.
* @param $height Height of the returning image.
* @param $width Width of the returning image.
* @param $period Period of time to get data in seconds.
* @param $stacked Wheter the graph is stacked or not.
* @param $return Whether to return an output string or echo now (optional, echo by default).
*/
function print_custom_graph ($id_graph, $height, $width, $period, $stacked, $return = false) {
global $config;
$sources = get_db_all_rows_field_filter ('tgraph_source', 'id_graph', $id_graph);
$modules = array ();
$weights = array ();
foreach ($sources as $source) {
$sql = sprintf ("SELECT id_grupo
FROM tagente, tagente_modulo
WHERE tagente_modulo.id_agente_modulo = %d
AND tagente.id_agente = tagente_modulo.id_agente",
$source['id_agent_module']);
$id_group = get_db_sql ($sql);
if (! give_acl ($config["id_user"], $id_group, 'AR'))
continue;
array_push ($modules, $source['id_agent_module']);
array_push ($weights, $source['weight']);
}
if ($config['flash_charts']) {
$output = graphic_combined_module ($modules, $weights, $period, $width, $height,
'', '', 0, 0, 0, $stacked);
} else {
$modules = implode (',', $modules);
$weights = implode (',', $weights);
$output = '<img src="include/fgraph.php?tipo=combined&height='.$height.'&width='.$width.'&id='.$modules.'&period='.$period.'&weight_l='.$weights.'&stacked='.$stacked.'">';
}
if ($return)
return $output;
echo $output;
}
/**
* Get all the possible periods in a custom graph.
*
* @return The possible periods in a custom graph in an associative array.
*/
function get_custom_graph_periods () {
$periods = array ();
$periods[1] = __('1 hour');
$periods[2] = '2 '.__('hours');
$periods[3] = '3 '.__('hours');
$periods[6] = '6 '.__('hours');
$periods[12] = '12 '.__('hours');
$periods[24] = __('1 day');
$periods[48] = __('2 days');
$periods[360] = __('1 week');
$periods[720] = __('1 month');
$periods[4320] = __('6 months');
return $periods;
}
?>