2012-07-10 Miguel de Dios <miguel.dedios@artica.es>

* include/constants.php: added more constants into the constants
	block of time conversion to seconds.
	
	* godmode/alerts/alert_commands.php, godmode/setup/performance.php,
	include/help/en/help_date_format.php, include/functions_netflow.php,
	include/functions_tags.php, include/graphs/functions_pchart.php,
	include/functions_modules.php, extensions/agents_modules.php,
	extensions/update_manager.php, extensions/resource_exportation.php,
	extensions/module_groups.php,
	extensions/update_manager/lib/libupdate_manager_client.php,
	extensions/system_info.php, operation/events/events_rss.php,
	operation/events/export_csv.php, mobile/operation/events/events.php,
	mobile/include/system.class.php: used the new constants time instead
	the magic numbers, and cleaned source code style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6762 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-07-10 13:31:34 +00:00
parent 9f3f620015
commit 8270ef2bb6
19 changed files with 440 additions and 413 deletions

View File

@ -1,3 +1,20 @@
2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* include/constants.php: added more constants into the constants
block of time conversion to seconds.
* godmode/alerts/alert_commands.php, godmode/setup/performance.php,
include/help/en/help_date_format.php, include/functions_netflow.php,
include/functions_tags.php, include/graphs/functions_pchart.php,
include/functions_modules.php, extensions/agents_modules.php,
extensions/update_manager.php, extensions/resource_exportation.php,
extensions/module_groups.php,
extensions/update_manager/lib/libupdate_manager_client.php,
extensions/system_info.php, operation/events/events_rss.php,
operation/events/export_csv.php, mobile/operation/events/events.php,
mobile/include/system.class.php: used the new constants time instead
the magic numbers, and cleaned source code style.
2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_ui.php: moved the constants for the status

View File

@ -70,7 +70,6 @@ if (is_ajax ()) {
html_print_table ($table);
echo '</div>';
}
}
return;

View File

@ -49,7 +49,7 @@ if ($create_command) {
$name = (string) get_parameter ('name');
$command = (string) get_parameter ('command');
$description = (string) get_parameter ('description');
$name_check = db_get_value ('name', 'talert_commands', 'name', $name);
$name_check = db_get_value ('name', 'talert_commands', 'name', $name);
if (!$name_check) {
$result = alerts_create_alert_command ($name, $command,
@ -89,7 +89,7 @@ if ($update_command) {
$values['name'] = $name;
$values['command'] = $command;
$values['description'] = $description;
$name_check = db_get_value ('name', 'talert_commands', 'name', $name);
$name_check = db_get_value ('name', 'talert_commands', 'name', $name);
if (!$name || !$name_check) {
$result = '';

View File

@ -80,14 +80,14 @@ $table_other->data[1][0] = __('Compact interpolation in hours (1 Fine-20 bad)');
$table_other->data[1][1] = html_print_input_text ('step_compact', $config["step_compact"], '', 5, 5, true);
$intervals = array ();
$intervals[3600] = "1 ".__('hour');
$intervals[43200] = "12 ".__('hours');
$intervals[86400] = __('Last day');
$intervals[172800] = "2 ". __('days');
$intervals[864000] = "10 ". __('days');
$intervals[604800] = __('Last week');
$intervals[1209600] = "2 " . __('weeks');
$intervals[2592000] = __('Last month');
$intervals[SECONDS_1HOUR] = __('1 hour');
$intervals[SECONDS_12HOURS] = __('12 hours');
$intervals[SECONDS_1DAY] = __('Last day');
$intervals[SECONDS_2DAY] = __('2 days');
$intervals[SECONDS_10DAY] = __('10 days');
$intervals[SECONDS_1WEEK] = __('Last week');
$intervals[SECONDS_2WEEK] = __('2 weeks');
$intervals[SECONDS_1MONTH] = __('Last month');
$table_other->data[2][0] = __('SLA period (seconds)') . ui_print_help_tip(__('You can see this in SLA agent tab.'), true);
$table_other->data[2][1] = html_print_select ($intervals, 'sla_period', $config["sla_period"], '', '', '0', true);

View File

@ -52,21 +52,32 @@ define ('ERR_CONNECTION', -80000);
/* Seconds in a time unit constants */
define('SECONDS_1MINUTE',60);
define('SECONDS_5MINUTES',300);
define('SECONDS_30MINUTES',1800);
define('SECONDS_1HOUR',3600);
define('SECONDS_6HOURS',21600);
define('SECONDS_12HOURS',43200);
define('SECONDS_1DAY',86400);
define('SECONDS_1WEEK',604800);
define('SECONDS_15DAYS',1296000);
define('SECONDS_1MONTH',2592000);
define('SECONDS_3MONTHS',7776000);
define('SECONDS_6MONTHS',15552000);
define('SECONDS_1YEAR',31104000);
define('SECONDS_2YEARS',62208000);
define('SECONDS_3YEARS',93312000);
define('SECONDS_1MINUTE', 60);
define('SECONDS_5MINUTES', 300);
define('SECONDS_10MINUTES', 600);
define('SECONDS_15MINUTES', 900);
define('SECONDS_30MINUTES', 1800);
define('SECONDS_1HOUR', 3600);
define('SECONDS_2HOUR', 7200);
define('SECONDS_3HOUR', 10800);
define('SECONDS_5HOUR', 18000);
define('SECONDS_6HOURS', 21600);
define('SECONDS_12HOURS', 43200);
define('SECONDS_1DAY', 86400);
define('SECONDS_2DAY', 172800);
define('SECONDS_4DAY', 345600);
define('SECONDS_5DAY', 432000);
define('SECONDS_1WEEK', 604800);
define('SECONDS_10DAY', 864000);
define('SECONDS_2WEEK', 1209600);
define('SECONDS_15DAYS', 1296000);
define('SECONDS_1MONTH', 2592000);
define('SECONDS_2MONTHS', 5184000);
define('SECONDS_3MONTHS', 7776000);
define('SECONDS_6MONTHS', 15552000);
define('SECONDS_1YEAR', 31104000);
define('SECONDS_2YEARS', 62208000);
define('SECONDS_3YEARS', 93312000);

View File

@ -1065,14 +1065,13 @@ function modules_get_previous_data ($id_agent_module, $utimestamp = 0, $string =
$table = 'tagente_datos';
}
// 172800 = 60×60×24*2 Search up to 2 days before utimestamp
$sql = sprintf ('SELECT *
FROM ' . $table . '
WHERE id_agente_modulo = %d
AND utimestamp <= %d
AND utimestamp >= %d
ORDER BY utimestamp DESC',
$id_agent_module, $utimestamp, $utimestamp - 172800);
$id_agent_module, $utimestamp, $utimestamp - SECONDS_2DAY);
return db_get_row_sql ($sql, true);
}

View File

@ -772,27 +772,30 @@ function netflow_load_cache (&$data, $cache_file, $start_date, $end_date, $aggre
$last_timestamp = $cache_timestamp;
}
unset ($cache_data[$cache_timestamp]);
} else {
}
else {
break;
}
}
if ($interval_count > 0) {
$data[$timestamp]['data'] = (int) ($interval_total / $interval_count);
} else {
}
else {
$data[$timestamp]['data'] = 0;
}
}
} else {
for ($i = 0; $i < $num_intervals; $i++) {
$timestamp = $start_date + ($interval_length * $i);
$interval_count = array ();
$interval_total = array ();
}
else {
for ($i = 0; $i < $num_intervals; $i++) {
$timestamp = $start_date + ($interval_length * $i);
$interval_count = array ();
$interval_total = array ();
foreach ($data['sources'] as $source => $null) {
$data['data'][$timestamp][$source] = 0;
}
}
foreach ($data['sources'] as $source => $null) {
$data['data'][$timestamp][$source] = 0;
}
}
}
return $last_timestamp;
@ -807,41 +810,40 @@ function netflow_load_cache (&$data, $cache_file, $start_date, $end_date, $aggre
function netflow_get_chart_types () {
return array(
__('Area graph'),
__('Pie graph'),
__('Data table'),
__('Statistics table')
);
__('Area graph'),
__('Pie graph'),
__('Data table'),
__('Statistics table'));
}
/**
* Gets valid intervals for a netflow chart in the format:
*
* interval_length => interval_description
* interval_length => interval_description
*
* @return Array of valid intervals.
*
*/
function netflow_get_valid_intervals () {
return array ('600' => __('10 mins'),
'900' => __('15 mins'),
'1800' => __('30 mins'),
'3600' => __('1 hour'),
'7200' => __('2 hours'),
'18000' => __('5 hours'),
'43200' => __('12 hours'),
'86400' => __('1 day'),
'172800' => __('2 days'),
'432000' => __('5 days'),
'1296000' => __('15 days'),
'604800' => __('Last week'),
'2592000' => __('Last month'),
'5184000' => __('2 months'),
'7776000' => __('3 months'),
'15552000' => __('6 months'),
'31104000' => __('Last year'),
'62208000' => __('2 years')
);
return array (
(string)SECONDS_10MINUTES => __('10 mins'),
(string)SECONDS_15MINUTES => __('15 mins'),
(string)SECONDS_30MINUTES => __('30 mins'),
(string)SECONDS_1HOUR => __('1 hour'),
(string)SECONDS_2HOUR => __('2 hours'),
(string)SECONDS_5HOUR => __('5 hours'),
(string)SECONDS_12HOURS => __('12 hours'),
(string)SECONDS_1DAY => __('1 day'),
(string)SECONDS_2DAY => __('2 days'),
(string)SECONDS_5DAY => __('5 days'),
(string)SECONDS_15DAYS => __('15 days'),
(string)SECONDS_1WEEK => __('Last week'),
(string)SECONDS_1MONTH => __('Last month'),
(string)SECONDS_2MONTHS => __('2 months'),
(string)SECONDS_3MONTHS => __('3 months'),
(string)SECONDS_6MONTHS => __('6 months'),
(string)SECONDS_1YEAR => __('Last year'),
(string)SECONDS_2YEARS => __('2 years'));
}
/**
@ -863,12 +865,13 @@ function netflow_draw_item ($start_date, $end_date, $type, $filter, $command, $f
$interval = $end_date - $start_date;
// Process item
switch ($type){
switch ($type) {
case '0':
$data = netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggregate, $max_aggregates, $unit);
if ($aggregate != 'none') {
echo graph_netflow_aggregate_area($data, $interval, 660, 320, 0);
} else {
}
else {
echo graph_netflow_total_area($data, $interval, 660, 320, 0);
}
break;

View File

@ -381,7 +381,7 @@ function tags_update_policy_module_tag ($id_policy_module, $tags, $autocommit =
$result_tag = db_process_sql_delete ('ttag_policy_module', array('id_policy_module' => $id_policy_module));
$values = array();
foreach ($tags as $tag){
foreach ($tags as $tag) {
//Protect against default insert
if (empty($tag))
continue;
@ -449,8 +449,7 @@ function tags_get_policy_module_tags ($id_policy_module){
* @return mixed Array with tags.
*/
function tags_get_all_tags (){
$tags = db_get_all_fields_in_table('ttag', 'name');
$tags = db_get_all_fields_in_table('ttag', 'name');
if ($tags === false)
return false;
@ -462,5 +461,4 @@ function tags_get_all_tags (){
return $return;
}
?>

View File

@ -303,7 +303,7 @@ switch($graph_type) {
}
function pch_slicebar_graph ($graph_type, $data, $period, $width, $height, $colors, $font, $round_corner, $font_size) {
/* CAT:Slicebar charts */
/* CAT:Slicebar charts */
set_time_limit (0);
@ -364,108 +364,108 @@ function pch_slicebar_graph ($graph_type, $data, $period, $width, $height, $colo
function pch_pie_graph ($graph_type, $data_values, $legend_values, $width,
$height, $font, $water_mark, $font_size) {
/* CAT:Pie charts */
/* CAT:Pie charts */
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints($data_values,"ScoreA");
$MyData->setSerieDescription("ScoreA","Application A");
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints($data_values,"ScoreA");
$MyData->setSerieDescription("ScoreA","Application A");
/* Define the absissa serie */
$MyData->addPoints($legend_values,"Labels");
$MyData->setAbscissa("Labels");
/* Define the absissa serie */
$MyData->addPoints($legend_values,"Labels");
$MyData->setAbscissa("Labels");
/* Create the pChart object */
$myPicture = new pImage($width,$height,$MyData,TRUE);
/* Create the pChart object */
$myPicture = new pImage($width,$height,$MyData,TRUE);
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size,"R"=>80,"G"=>80,"B"=>80));
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size,"R"=>80,"G"=>80,"B"=>80));
$water_mark_height = 0;
$water_mark_width = 0;
if (!empty($water_mark)) {
$water_mark_height = 0;
$water_mark_width = 0;
if (!empty($water_mark)) {
$size_water_mark = getimagesize($water_mark);
$water_mark_height = $size_water_mark[1];
$water_mark_width = $size_water_mark[0];
$myPicture->drawFromPNG(($width - $water_mark_width),
($height - $water_mark_height) - 50, $water_mark);
}
($height - $water_mark_height) - 50, $water_mark);
}
/* Create the pPie object */
$PieChart = new pPie($myPicture,$MyData);
/* Create the pPie object */
$PieChart = new pPie($myPicture,$MyData);
/* Draw an AA pie chart */
switch($graph_type) {
case "pie2d":
$PieChart->draw2DPie($width/4,$height/2,array("DataGapAngle"=>0,"DataGapRadius"=>0, "Border"=>FALSE, "BorderR"=>200, "BorderG"=>200, "BorderB"=>200, "Radius"=>$width/4, "ValueR"=>0, "ValueG"=>0, "ValueB"=>0, "WriteValues"=>TRUE));
/* Draw an AA pie chart */
switch($graph_type) {
case "pie2d":
$PieChart->draw2DPie($width/4,$height/2,array("DataGapAngle"=>0,"DataGapRadius"=>0, "Border"=>FALSE, "BorderR"=>200, "BorderG"=>200, "BorderB"=>200, "Radius"=>$width/4, "ValueR"=>0, "ValueG"=>0, "ValueB"=>0, "WriteValues"=>TRUE));
break;
case "pie3d":
$PieChart->draw3DPie($width/4, $height/2,array("DataGapAngle"=>5,"DataGapRadius"=>6, "Border"=>TRUE, "Radius"=>$width/4, "ValueR"=>0, "ValueG"=>0, "ValueB"=>0, "WriteValues"=>TRUE));
case "pie3d":
$PieChart->draw3DPie($width/4, $height/2,array("DataGapAngle"=>5,"DataGapRadius"=>6, "Border"=>TRUE, "Radius"=>$width/4, "ValueR"=>0, "ValueG"=>0, "ValueB"=>0, "WriteValues"=>TRUE));
break;
}
}
/* Write down the legend next to the 2nd chart*/
/* Write down the legend next to the 2nd chart*/
//Calculate the bottom margin from the size of string in each index
$max_chars = graph_get_max_index($legend_values);
$legend_with_aprox = 32 + (7 * $max_chars);
$PieChart->drawPieLegend($width - $legend_with_aprox, 5, array("R"=>255,"G"=>255,"B"=>255, "BoxSize"=>10));
$PieChart->drawPieLegend($width - $legend_with_aprox, 5, array("R"=>255,"G"=>255,"B"=>255, "BoxSize"=>10));
/* Enable shadow computing */
$myPicture->setShadow(TRUE,array("X"=>3,"Y"=>3,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
/* Enable shadow computing */
$myPicture->setShadow(TRUE,array("X"=>3,"Y"=>3,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
/* Render the picture */
$myPicture->stroke();
/* Render the picture */
$myPicture->stroke();
}
function pch_kiviat_graph ($graph_type, $data_values, $legend_values, $width,
$height, $font, $font_size) {
/* CAT:Radar/Polar charts */
/* CAT:Radar/Polar charts */
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints($data_values,"ScoreA");
$MyData->setSerieDescription("ScoreA","Application A");
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints($data_values,"ScoreA");
$MyData->setSerieDescription("ScoreA","Application A");
/* Define the absissa serie */
$MyData->addPoints($legend_values,"Labels");
$MyData->setAbscissa("Labels");
/* Define the absissa serie */
$MyData->addPoints($legend_values,"Labels");
$MyData->setAbscissa("Labels");
/* Create the pChart object */
$myPicture = new pImage($width,$height,$MyData,TRUE);
/* Create the pChart object */
$myPicture = new pImage($width,$height,$MyData,TRUE);
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size,"R"=>80,"G"=>80,"B"=>80));
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size,"R"=>80,"G"=>80,"B"=>80));
/* Create the pRadar object */
$SplitChart = new pRadar();
/* Create the pRadar object */
$SplitChart = new pRadar();
/* Draw a radar chart */
$myPicture->setGraphArea(20,25,$width-10,$height-10);
/* Draw a radar chart */
$myPicture->setGraphArea(20,25,$width-10,$height-10);
/* Draw an AA pie chart */
switch($graph_type) {
case "radar":
/* Draw an AA pie chart */
switch($graph_type) {
case "radar":
$Options = array("SkipLabels"=>0,"LabelPos"=>RADAR_LABELS_HORIZONTAL,
"LabelMiddle"=>FALSE,"Layout"=>RADAR_LAYOUT_STAR,
"BackgroundGradient"=>array("StartR"=>255,"StartG"=>255,"StartB"=>255,
"StartAlpha"=>100,"EndR"=>207,"EndG"=>227,"EndB"=>125,"EndAlpha"=>50),
"FontName"=>$font,"FontSize"=>$font_size);
$SplitChart->drawRadar($myPicture,$MyData,$Options);
$SplitChart->drawRadar($myPicture,$MyData,$Options);
break;
case "polar":
case "polar":
$Options = array("Layout"=>RADAR_LAYOUT_CIRCLE,"BackgroundGradient"=>array("StartR"=>255,"StartG"=>255,"StartB"=>255,"StartAlpha"=>100,"EndR"=>207,"EndG"=>227,"EndB"=>125,"EndAlpha"=>50),
"FontName"=>$font,"FontSize"=>$font_size);
$SplitChart->drawRadar($myPicture,$MyData,$Options);
$SplitChart->drawRadar($myPicture,$MyData,$Options);
break;
}
}
/* Render the picture */
$myPicture->stroke();
/* Render the picture */
$myPicture->stroke();
}
function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
@ -476,10 +476,10 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
unset($legend);
}
/* Create and populate the pData object */
$MyData = new pData();
$overridePalette = array();
foreach($data as $i => $values) {
/* Create and populate the pData object */
$MyData = new pData();
$overridePalette = array();
foreach($data as $i => $values) {
$MyData->addPoints($values,$i);
if(!empty($rgb_color)) {
@ -507,37 +507,37 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
else {
$overridePalette = false;
}
}
}
$MyData->setAxisName(0,$yaxisname);
$MyData->addPoints($index,"Xaxis");
$MyData->setSerieDescription("Xaxis", $xaxisname);
$MyData->setAbscissa("Xaxis");
$MyData->setAxisName(0,$yaxisname);
$MyData->addPoints($index,"Xaxis");
$MyData->setSerieDescription("Xaxis", $xaxisname);
$MyData->setAbscissa("Xaxis");
/* Create the pChart object */
$myPicture = new pImage($width,$height,$MyData);
/* Create the pChart object */
$myPicture = new pImage($width,$height,$MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = $antialiasing;
/* Turn of Antialiasing */
$myPicture->Antialias = $antialiasing;
/* Add a border to the picture */
//$myPicture->drawRectangle(0,0,$width,$height,array("R"=>0,"G"=>0,"B"=>0));
/* Add a border to the picture */
//$myPicture->drawRectangle(0,0,$width,$height,array("R"=>0,"G"=>0,"B"=>0));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
/* Set the default font */
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size));
/* Set the default font */
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size));
/* Draw the scale */
// TODO: AvoidTickWhenEmpty = FALSE When the distance between two ticks will be less than 50 px
// TODO: AvoidTickWhenEmpty = TRUE When the distance between two ticks will be greater than 50 px
/* Draw the scale */
// TODO: AvoidTickWhenEmpty = FALSE When the distance between two ticks will be less than 50 px
// TODO: AvoidTickWhenEmpty = TRUE When the distance between two ticks will be greater than 50 px
//Calculate the top margin from the size of string in each index
$max_chars = graph_get_max_index($index);
$margin_top = 10 * $max_chars;
//Calculate the top margin from the size of string in each index
$max_chars = graph_get_max_index($index);
$margin_top = 10 * $max_chars;
switch($graph_type) {
switch($graph_type) {
case "vbar":
$scaleSettings = array("AvoidTickWhenEmpty" => FALSE, "AvoidGridWhenEmpty" => FALSE,
"GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE,
@ -554,55 +554,55 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
$margin_top = 40;
$margin_bottom = 10;
break;
}
}
$water_mark_height = 0;
$water_mark_width = 0;
if (!empty($water_mark)) {
$water_mark_height = 0;
$water_mark_width = 0;
if (!empty($water_mark)) {
$size_water_mark = getimagesize($water_mark);
$water_mark_height = $size_water_mark[1];
$water_mark_width = $size_water_mark[0];
$myPicture->drawFromPNG(($width - $water_mark_width),
($height - $water_mark_height) - $margin_bottom, $water_mark);
}
($height - $water_mark_height) - $margin_bottom, $water_mark);
}
/* Define the chart area */
$myPicture->setGraphArea($margin_left,$margin_top,$width - $water_mark_width,$height-$margin_bottom);
/* Define the chart area */
$myPicture->setGraphArea($margin_left,$margin_top,$width - $water_mark_width,$height-$margin_bottom);
$myPicture->drawScale($scaleSettings);
$myPicture->drawScale($scaleSettings);
if(isset($legend)) {
if(isset($legend)) {
/* Write the chart legend */
$size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
$myPicture->drawLegend($width-$size['Width'],0,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL, "BoxWidth"=>10, "BoxHeight"=>10));
}
}
/* Turn on shadow computing */
$myPicture->setShadow(TRUE,array("X"=>0,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE,array("X"=>0,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
/* Draw the chart */
$settings = array("ForceTransparency"=>"-1", "Gradient"=>TRUE,"GradientMode"=>GRADIENT_EFFECT_CAN,"DisplayValues"=>$show_values,"DisplayZeroValues"=>FALSE,"DisplayR"=>100,"DisplayG"=>100,"DisplayB"=>100,"DisplayShadow"=>TRUE,"Surrounding"=>5,"AroundZero"=>FALSE, "OverrideColors"=>$overridePalette);
/* Draw the chart */
$settings = array("ForceTransparency"=>"-1", "Gradient"=>TRUE,"GradientMode"=>GRADIENT_EFFECT_CAN,"DisplayValues"=>$show_values,"DisplayZeroValues"=>FALSE,"DisplayR"=>100,"DisplayG"=>100,"DisplayB"=>100,"DisplayShadow"=>TRUE,"Surrounding"=>5,"AroundZero"=>FALSE, "OverrideColors"=>$overridePalette);
$myPicture->drawBarChart($settings);
$myPicture->drawBarChart($settings);
/* Render the picture */
$myPicture->stroke();
/* Render the picture */
$myPicture->stroke();
}
function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
$rgb_color = false, $xaxisname = "", $yaxisname = "", $show_values = false,
$legend = array(), $font, $antialiasing, $water_mark = '', $font_size) {
/* CAT:Vertical Charts */
if(!is_array($legend) || empty($legend)) {
if (!is_array($legend) || empty($legend)) {
unset($legend);
}
/*$legend=array('pep1' => 'pep1','pep2' => 'pep2','pep3' => 'pep3','pep4' => 'pep4');
$data=array(array('pep1' => 1, 'pep2' => 1, 'pep3' => 3, 'pep4' => 3), array('pep1' => 1, 'pep2' => 3, 'pep3' => 1,'pep4' => 4), array('pep1' => 3, 'pep2' => 1, 'pep3' => 1,'pep4' =>1), array('pep1' => 1, 'pep2' =>1, 'pep3' =>1,'pep4' =>0));
$index=array(1,2,3,4);
*/
if(is_array(reset($data))) {
$data2 = array();
/*$legend=array('pep1' => 'pep1','pep2' => 'pep2','pep3' => 'pep3','pep4' => 'pep4');
$data=array(array('pep1' => 1, 'pep2' => 1, 'pep3' => 3, 'pep4' => 3), array('pep1' => 1, 'pep2' => 3, 'pep3' => 1,'pep4' => 4), array('pep1' => 3, 'pep2' => 1, 'pep3' => 1,'pep4' =>1), array('pep1' => 1, 'pep2' =>1, 'pep3' =>1,'pep4' =>0));
$index=array(1,2,3,4);
*/
if (is_array(reset($data))) {
$data2 = array();
foreach($data as $i =>$values) {
$c = 0;
foreach($values as $i2 => $value) {
@ -611,21 +611,21 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
}
}
$data = $data2;
}
else {
}
else {
$data = array($data);
}
}
/* Create and populate the pData object */
$MyData = new pData();
/* Create and populate the pData object */
$MyData = new pData();
foreach($data as $i => $values) {
if(isset($legend)) {
foreach ($data as $i => $values) {
if (isset($legend)) {
$point_id = $legend[$i];
}
else {
}
else {
$point_id = $i;
}
}
$MyData->addPoints($values,$point_id);
if (!empty($rgb_color)) {
@ -644,7 +644,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
$palette_color["G"] = $rgb_color[$i]['color']["G"];
$palette_color["B"] = $rgb_color[$i]['color']["B"];
}
if (isset($rgb_color[$i]['color'])) {
if (isset($rgb_color[$i]['color'])) {
$palette_color["BorderR"] = $rgb_color[$i]['border']["R"];
$palette_color["BorderG"] = $rgb_color[$i]['border']["G"];
$palette_color["BorderB"] = $rgb_color[$i]['border']["B"];
@ -657,25 +657,25 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
}
$MyData->setSerieWeight($point_id, 0);
}
}
//$MyData->addPoints($data,"Yaxis");
$MyData->setAxisName(0,$yaxisname);
$MyData->addPoints($index,"Xaxis");
$MyData->setSerieDescription("Xaxis", $xaxisname);
$MyData->setAbscissa("Xaxis");
//$MyData->addPoints($data,"Yaxis");
$MyData->setAxisName(0,$yaxisname);
$MyData->addPoints($index,"Xaxis");
$MyData->setSerieDescription("Xaxis", $xaxisname);
$MyData->setAbscissa("Xaxis");
/* Create the pChart object */
$myPicture = new pImage($width,$height,$MyData);
/* Create the pChart object */
$myPicture = new pImage($width,$height,$MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = $antialiasing;
/* Turn of Antialiasing */
$myPicture->Antialias = $antialiasing;
/* Add a border to the picture */
//$myPicture->drawRectangle(0,0,$width,$height,array("R"=>0,"G"=>0,"B"=>0));
/* Add a border to the picture */
//$myPicture->drawRectangle(0,0,$width,$height,array("R"=>0,"G"=>0,"B"=>0));
/* Set the default font */
$myPicture->setFontProperties(array("FontName"=>$font, "FontSize"=>$font_size));
/* Set the default font */
$myPicture->setFontProperties(array("FontName"=>$font, "FontSize"=>$font_size));
if(isset($legend)) {
/* Set horizontal legend if is posible */
@ -688,54 +688,54 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
/* Write the chart legend */
$myPicture->drawLegend($width-$size['Width'], 8,array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode));
}
}
//Calculate the bottom margin from the size of string in each index
$max_chars = graph_get_max_index($index);
$margin_bottom = $font_size * $max_chars;
//Calculate the bottom margin from the size of string in each index
$max_chars = graph_get_max_index($index);
$margin_bottom = $font_size * $max_chars;
$water_mark_height = 0;
$water_mark_width = 0;
if (!empty($water_mark)) {
$water_mark_height = 0;
$water_mark_width = 0;
if (!empty($water_mark)) {
$size_water_mark = getimagesize($water_mark);
$water_mark_height = $size_water_mark[1];
$water_mark_width = $size_water_mark[0];
$myPicture->drawFromPNG(($width - $water_mark_width),
($height - $water_mark_height) - $margin_bottom, $water_mark);
}
($height - $water_mark_height) - $margin_bottom, $water_mark);
}
// Get the max number of scale
$max_all = 0;
// Get the max number of scale
$max_all = 0;
$serie_ne_zero = false;
foreach($data as $serie) {
$max_this_serie = max($serie);
if($max_this_serie > $max_all) {
$serie_ne_zero = false;
foreach($data as $serie) {
$max_this_serie = max($serie);
if($max_this_serie > $max_all) {
$max_all = $max_this_serie;
}
// Detect if all serie is equal to zero or not
if ($serie != 0)
}
// Detect if all serie is equal to zero or not
if ($serie != 0)
$serie_ne_zero = true;
}
}
// Get the number of digits of the scale
$digits_left = 0;
while($max_all > 1) {
// Get the number of digits of the scale
$digits_left = 0;
while($max_all > 1) {
$digits_left ++;
$max_all /= 10;
}
}
// If the number is less than 1 we count the decimals
// Also check if the serie is not all equal to zero (!$serie_ne_zero)
if($digits_left == 0 and !$serie_ne_zero) {
// If the number is less than 1 we count the decimals
// Also check if the serie is not all equal to zero (!$serie_ne_zero)
if($digits_left == 0 and !$serie_ne_zero) {
while($max_all < 1) {
$digits_left ++;
$max_all *= 10;
}
}
}
$chart_size = ($digits_left * $font_size) + 20;
$chart_size = ($digits_left * $font_size) + 20;
/* Area depends on yaxisname */
if ($yaxisname != ''){
@ -745,110 +745,110 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
$chart_size = 40;
}
if (isset($size['Height'])) {
/* Define the chart area */
//if ($yaxisname != ''){
if (isset($size['Height'])) {
/* Define the chart area */
//if ($yaxisname != ''){
//}
$myPicture->setGraphArea($chart_size,$size['Height'],$width - $water_mark_width,$height - $margin_bottom);
}
else {
/* Define the chart area */
$myPicture->setGraphArea($chart_size, 5,$width - $water_mark_width,$height - $margin_bottom);
}
$myPicture->setGraphArea($chart_size,$size['Height'],$width - $water_mark_width,$height - $margin_bottom);
}
else {
/* Define the chart area */
$myPicture->setGraphArea($chart_size, 5,$width - $water_mark_width,$height - $margin_bottom);
}
/*Get minimun value to draw axis properly*/
$min_data = min(min($data));
/*Get minimun value to draw axis properly*/
$min_data = min(min($data));
$mode = SCALE_MODE_START0;
if ($min_data < 0) {
$mode = SCALE_MODE_START0;
if ($min_data < 0) {
$mode = SCALE_MODE_FLOATING;
}
}
/* Draw the scale */
$scaleSettings = array("GridR"=>200,
"GridG"=>200,
"GridB"=>200,
"DrawSubTicks"=>TRUE,
"CycleBackground"=>TRUE,
"Mode" => $mode,
"LabelRotation" => 40,
"XMargin" => 0,
"MinDivHeight" => 20,
"TicksFontSize" => $font_size - 1);
$myPicture->drawScale($scaleSettings);
/* Draw the scale */
$scaleSettings = array("GridR"=>200,
"GridG"=>200,
"GridB"=>200,
"DrawSubTicks"=>TRUE,
"CycleBackground"=>TRUE,
"Mode" => $mode,
"LabelRotation" => 40,
"XMargin" => 0,
"MinDivHeight" => 20,
"TicksFontSize" => $font_size - 1);
$myPicture->drawScale($scaleSettings);
/* Turn on shadow computing */
//$myPicture->setShadow(TRUE,array("X"=>0,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
/* Turn on shadow computing */
//$myPicture->setShadow(TRUE,array("X"=>0,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
switch ($graph_type) {
case 'stacked_area':
$ForceTransparency = "-1";
break;
default:
$ForceTransparency = "50";
break;
}
switch ($graph_type) {
case 'stacked_area':
$ForceTransparency = "-1";
break;
default:
$ForceTransparency = "50";
break;
}
/* Draw the chart */
$settings = array("ForceTransparency"=> $ForceTransparency, //
"Gradient"=>TRUE,
"GradientMode"=>GRADIENT_EFFECT_CAN,
"DisplayValues"=>$show_values,
"DisplayZeroValues"=>FALSE,
"DisplayR"=>100,
"DisplayZeros"=> FALSE,
"DisplayG"=>100,"DisplayB"=>100,"DisplayShadow"=>TRUE,"Surrounding"=>5,"AroundZero"=>TRUE);
/* Draw the chart */
$settings = array("ForceTransparency"=> $ForceTransparency, //
"Gradient"=>TRUE,
"GradientMode"=>GRADIENT_EFFECT_CAN,
"DisplayValues"=>$show_values,
"DisplayZeroValues"=>FALSE,
"DisplayR"=>100,
"DisplayZeros"=> FALSE,
"DisplayG"=>100,"DisplayB"=>100,"DisplayShadow"=>TRUE,"Surrounding"=>5,"AroundZero"=>TRUE);
switch($graph_type) {
case "stacked_area":
switch($graph_type) {
case "stacked_area":
case "area":
$myPicture->drawAreaChart($settings);
break;
$myPicture->drawAreaChart($settings);
break;
case "line":
$myPicture->drawLineChart($settings);
break;
}
$myPicture->drawLineChart($settings);
break;
}
/* Render the picture */
$myPicture->stroke();
/* Render the picture */
$myPicture->stroke();
}
function pch_threshold_graph ($graph_type, $index, $data, $width, $height, $font,
$antialiasing, $xaxisname = "", $yaxisname = "", $title = "",
$show_values = false, $show_legend = false, $font_size) {
/* CAT:Threshold Chart */
/* CAT:Threshold Chart */
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints($data,"DEFCA");
$MyData->setAxisName(0,$yaxisname);
$MyData->setAxisDisplay(0,AXIS_FORMAT_CURRENCY);
$MyData->addPoints($index,"Labels");
$MyData->setSerieDescription("Labels",$xaxisname);
$MyData->setAbscissa("Labels");
$MyData->setPalette("DEFCA",array("R"=>55,"G"=>91,"B"=>127));
$MyData = new pData();
$MyData->addPoints($data,"DEFCA");
$MyData->setAxisName(0,$yaxisname);
$MyData->setAxisDisplay(0,AXIS_FORMAT_CURRENCY);
$MyData->addPoints($index,"Labels");
$MyData->setSerieDescription("Labels",$xaxisname);
$MyData->setAbscissa("Labels");
$MyData->setPalette("DEFCA",array("R"=>55,"G"=>91,"B"=>127));
/* Create the pChart object */
$myPicture = new pImage(700,230,$MyData);
$myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,array("StartR"=>220,"StartG"=>220,"StartB"=>220,"EndR"=>255,"EndG"=>255,"EndB"=>255,"Alpha"=>100));
$myPicture->drawRectangle(0,0,699,229,array("R"=>200,"G"=>200,"B"=>200));
/* Create the pChart object */
$myPicture = new pImage(700,230,$MyData);
$myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,array("StartR"=>220,"StartG"=>220,"StartB"=>220,"EndR"=>255,"EndG"=>255,"EndB"=>255,"Alpha"=>100));
$myPicture->drawRectangle(0,0,699,229,array("R"=>200,"G"=>200,"B"=>200));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size));
$myPicture->drawText(60,35,$title,array("FontSize"=>$font_size,"Align"=>TEXT_ALIGN_BOTTOMLEFT));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size));
$myPicture->drawText(60,35,$title,array("FontSize"=>$font_size,"Align"=>TEXT_ALIGN_BOTTOMLEFT));
/* Do some cosmetic and draw the chart */
$myPicture->setGraphArea(60,40,670,190);
$myPicture->drawFilledRectangle(60,40,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
$myPicture->drawScale(array("GridR"=>180,"GridG"=>180,"GridB"=>180, "Mode" => SCALE_MODE_START0));
$myPicture->setShadow(TRUE,array("X"=>2,"Y"=>2,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size));
$settings = array("Gradient"=>TRUE,"GradientMode"=>GRADIENT_EFFECT_CAN,"DisplayValues"=>$show_values,"DisplayZeroValues"=>FALSE,"DisplayR"=>100,"DisplayG"=>100,"DisplayB"=>100,"DisplayShadow"=>TRUE,"Surrounding"=>5,"AroundZero"=>FALSE);
$myPicture->drawSplineChart($settings);
$myPicture->setShadow(FALSE);
/* Do some cosmetic and draw the chart */
$myPicture->setGraphArea(60,40,670,190);
$myPicture->drawFilledRectangle(60,40,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
$myPicture->drawScale(array("GridR"=>180,"GridG"=>180,"GridB"=>180, "Mode" => SCALE_MODE_START0));
$myPicture->setShadow(TRUE,array("X"=>2,"Y"=>2,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size));
$settings = array("Gradient"=>TRUE,"GradientMode"=>GRADIENT_EFFECT_CAN,"DisplayValues"=>$show_values,"DisplayZeroValues"=>FALSE,"DisplayR"=>100,"DisplayG"=>100,"DisplayB"=>100,"DisplayShadow"=>TRUE,"Surrounding"=>5,"AroundZero"=>FALSE);
$myPicture->drawSplineChart($settings);
$myPicture->setShadow(FALSE);
if($show_legend) {
if($show_legend) {
/* Write the chart legend */
$myPicture->drawLegend(643,210,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
}

View File

@ -3,11 +3,11 @@
* @package Include/help/en
*/
?>
<p class="para">
The format of the outputted date string. See the formatting
options below.
</p>
<p class="para">
<p class="para">
The format of the outputted date string. See the formatting
options below.
</p>
<p class="para">
</p><table border="5">
<caption><b>The following characters are recognized in the

View File

@ -108,7 +108,7 @@ class EventsView {
if ($search != "")
$sqlFreeSearch .= " AND evento LIKE '%".$search."%'";
$unixtime = get_system_time () - ($event_view_hr * 3600); //Put hours in seconds
$unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR); //Put hours in seconds
$sqlTimestamp = " AND utimestamp > ".$unixtime;
$sql = 'SELECT *

View File

@ -77,7 +77,7 @@ $event_view_hr = (int) get_parameter ("event_view_hr", 0);
$sql_post = "";
if ($event_view_hr > 0) {
$unixtime = (int) (get_system_time () - ($event_view_hr * 3600)); //Put hours in seconds
$unixtime = (int) (get_system_time () - ($event_view_hr * SECONDS_1HOUR)); //Put hours in seconds
$sql_post .= " AND tevento.utimestamp > ".$unixtime;
}
if ($ev_group > 1)

View File

@ -113,7 +113,7 @@ if ($id_event != -1)
$timestamp_filter = '';
if ($event_view_hr > 0) {
$unixtime = get_system_time () - ($event_view_hr * 3600); //Put hours in seconds
$unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR); //Put hours in seconds
$timestamp_filter = " AND (utimestamp > $unixtime OR estado = 2)";
}
@ -150,7 +150,7 @@ $new = true;
while ($event = db_get_all_row_by_steps_sql($new, $result, $sql)) {
$new = false;
if (!check_acl($config["id_user"], $event["id_grupo"], "AR") ||
(!check_acl($config["id_user"], 0, "PM") && $event["event_type"] == 'system'))
(!check_acl($config["id_user"], 0, "PM") && $event["event_type"] == 'system'))
continue;
echo $event["timestamp"];