From 8270ef2bb6f9fec1964ac6688911491ac293fc15 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 10 Jul 2012 13:31:34 +0000 Subject: [PATCH] 2012-07-10 Miguel de Dios * 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 --- pandora_console/ChangeLog | 17 + pandora_console/extensions/agents_modules.php | 12 +- pandora_console/extensions/module_groups.php | 2 +- .../extensions/resource_exportation.php | 4 +- pandora_console/extensions/system_info.php | 8 +- pandora_console/extensions/update_manager.php | 17 +- .../lib/libupdate_manager_client.php | 2 +- .../godmode/alerts/alert_commands.php | 10 +- pandora_console/godmode/setup/performance.php | 16 +- pandora_console/include/constants.php | 41 +- pandora_console/include/functions_modules.php | 7 +- pandora_console/include/functions_netflow.php | 97 +-- pandora_console/include/functions_tags.php | 18 +- .../include/graphs/functions_pchart.php | 574 +++++++++--------- .../include/help/en/help_date_format.php | 10 +- .../mobile/include/system.class.php | 2 +- .../mobile/operation/events/events.php | 2 +- .../operation/events/events_rss.php | 6 +- .../operation/events/export_csv.php | 8 +- 19 files changed, 440 insertions(+), 413 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 79f4bb398a..9ab860a01f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,20 @@ +2012-07-10 Miguel de Dios + + * 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 * include/functions_ui.php: moved the constants for the status diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index e09e9ac91b..2ed7bfd2c7 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -163,9 +163,9 @@ function mainAgentsModules() { } echo ''; - - echo ""; - + + echo ""; + if($hor_offset > 0) { $new_hor_offset = $hor_offset-$block; echo ""; @@ -185,7 +185,7 @@ function mainAgentsModules() { $new_hor_offset = $hor_offset+$block; echo ""; } - + $filter_agents = false; if($group_id > 0) { $filter_agents = array('id_grupo' => $group_id); @@ -193,11 +193,11 @@ function mainAgentsModules() { // Prepare pagination ui_pagination ((int)count(agents_get_agents ($filter_agents))); echo "
"; - + foreach ($agents as $agent) { // Get stats for this group $agent_status = agents_get_status($agent['id_agente']); - + switch($agent_status) { case 4: // Alert fired status $rowcolor = 'group_view_alrm'; diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 8bb72d438b..612c6795f0 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -49,7 +49,7 @@ if (is_ajax ()) { FROM talert_template_module_actions AS t1 INNER JOIN talert_actions AS t2 ON t1.id_alert_action = t2.id WHERE t1.id_alert_template_module = ' . $template['id'] . ' - OR t2.id = ' . $template['id_alert_action'] . ';'; + OR t2.id = ' . $template['id_alert_action'] . ';'; $actions = db_get_all_rows_sql($sql); if ($actions === false) { $actions = array(); diff --git a/pandora_console/extensions/resource_exportation.php b/pandora_console/extensions/resource_exportation.php index 547deae9eb..02ec30bdf0 100644 --- a/pandora_console/extensions/resource_exportation.php +++ b/pandora_console/extensions/resource_exportation.php @@ -103,7 +103,7 @@ function output_xml_report($id) { echo "" . io_safe_output($item['description']) . "\n"; echo "" . io_safe_output($item['period']) . "\n"; if ($item['id_agent'] != 0) { - $agent = agents_get_name($item['id_agent']); + $agent = agents_get_name($item['id_agent']); } if ($item['id_agent_module'] != 0) { $module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $item['id_agent_module']); @@ -118,7 +118,7 @@ function output_xml_report($id) { switch (io_safe_output($item['type'])) { case 1: case 'simple_graph': - break; + break; case 'simple_baseline_graph': break; case 2: diff --git a/pandora_console/extensions/system_info.php b/pandora_console/extensions/system_info.php index 017af49919..0c4c3e8193 100644 --- a/pandora_console/extensions/system_info.php +++ b/pandora_console/extensions/system_info.php @@ -190,7 +190,7 @@ function getLastLog($numLines = 2000) { show_logfile("/etc/mysql/my.cnf", $numLines); show_logfile($config["homedir"]."/include/config.php", $numLines); show_logfile("/etc/pandora/pandora_server.conf", $numLines); - show_logfile("/var/log/syslog", $numLines); + show_logfile("/var/log/syslog", $numLines); } function show_array($title, $anchor, $array = array()) { @@ -238,7 +238,7 @@ function show_array($title, $anchor, $array = array()) { function mainSystemInfo() { global $config; - + if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_user'])) { db_pandora_audit("ACL Violation", "Trying to access Setup Management"); require ("general/noaccess.php"); @@ -324,9 +324,9 @@ function mainSystemInfo() { @unlink($zipArchive); $url_zip = ui_get_full_url(false); - + $url = '' . __('System info file zipped') . ''; - + if($log_info || $system_info || $pandora_diag) { echo '' . __('File:') . ' ' . $url . '
'; echo '' . __('Location:') . ' ' . $zipArchive; diff --git a/pandora_console/extensions/update_manager.php b/pandora_console/extensions/update_manager.php index 6c6e0d28de..5c3ef582da 100644 --- a/pandora_console/extensions/update_manager.php +++ b/pandora_console/extensions/update_manager.php @@ -31,31 +31,31 @@ if (is_ajax ()) { $checking_online_enterprise_package = (bool)get_parameter('checking_online_enterprise_package', false); - $get_license_info = get_parameter('get_license_info', 0); + $get_license_info = get_parameter('get_license_info', 0); if ($checking_online_enterprise_package) { checking_online_enterprise_package(); return; } - + if ($get_license_info) { enterprise_include_once('include/functions_license.php'); - + // If Pandora enterprise check license $is_enteprise = enterprise_hook('license_show_info'); - + // If Open show info if ($is_enteprise === ENTERPRISE_NOT_HOOK){ $table->width = '98%'; $table->data = array (); $table->style = array(); $table->style[0] = 'text-align: left'; - + echo '
'; html_print_image('images/lock_license.png', false); echo '
'; - + $table->data[0][0] = ''.__('Expires').''; $table->data[0][1] = __('Never'); $table->data[1][0] = ''.__('Platform Limit').''; @@ -65,12 +65,11 @@ if (is_ajax ()) { $table->data[2][1] = $count_agents; $table->data[3][0] = ''.__('License Mode').''; $table->data[3][1] = __('Open Source Version'); - + echo '
'; html_print_table ($table); - echo '
'; + echo ''; } - } return; diff --git a/pandora_console/extensions/update_manager/lib/libupdate_manager_client.php b/pandora_console/extensions/update_manager/lib/libupdate_manager_client.php index b9f447732a..a34c3689ac 100644 --- a/pandora_console/extensions/update_manager/lib/libupdate_manager_client.php +++ b/pandora_console/extensions/update_manager/lib/libupdate_manager_client.php @@ -505,7 +505,7 @@ function um_client_upgrade_to_package ($package, $settings, $force = true, $upda um_client_db_connect ($settings); um_component_db_connect (); foreach ($package->updates as $update) { - $success = um_client_apply_update ($update, $settings, $force); + $success = um_client_apply_update ($update, $settings, $force); if (! $success) { echo '

Failed on:
'; um_client_print_update ($update, $settings); diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 1301b36ca8..ede69b3953 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -49,8 +49,8 @@ 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, array ('description' => $description)); @@ -60,7 +60,7 @@ if ($create_command) { else { $result = ''; } - + if ($result) { db_pandora_audit("Command management", "Create alert command #" . $result, false, false, $info); } @@ -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 = ''; @@ -98,7 +98,7 @@ if ($update_command) { $result = alerts_update_alert_command ($id, $values); $info = 'Name: ' . $name . ' Command: ' . $command . ' Description: ' . $description; } - + if ($result) { db_pandora_audit("Command management", "Update alert command #" . $id, false, false, $info); } diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index 584032c0b7..bf2e0a57c8 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -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); diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index bf171e5637..1a387f24b2 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -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); diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 4f737041b5..ddd0ac22f7 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -1057,22 +1057,21 @@ function modules_get_last_value ($id_agentmodule) { function modules_get_previous_data ($id_agent_module, $utimestamp = 0, $string = 0) { if (empty ($utimestamp)) $utimestamp = time (); - + if ($string == 1) { $table = 'tagente_datos_string'; } else { $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); } diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 24f856f3e9..09b3651b78 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -744,17 +744,17 @@ function netflow_save_cache ($data, $cache_file) { */ function netflow_load_cache (&$data, $cache_file, $start_date, $end_date, $aggregate) { global $config; - + // Open cache file $cache_data = @file_get_contents ($cache_file); $cache_data = @unserialize ($cache_data); - + // Calculate the number of intervals $num_intervals = $config['graph_res'] * 50; $period = $end_date - $start_date; $interval_length = (int) ($period / $num_intervals); $last_timestamp = $start_date; - + // Initializa chart data if ($aggregate == 'none') { if ($cache_data === FALSE) { @@ -772,29 +772,32 @@ 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 (); - - foreach ($data['sources'] as $source => $null) { - $data['data'][$timestamp][$source] = 0; - } - } } - + 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; + } + } + } + return $last_timestamp; } @@ -805,43 +808,42 @@ 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')); } /** @@ -857,18 +859,19 @@ function netflow_get_valid_intervals () { * */ function netflow_draw_item ($start_date, $end_date, $type, $filter, $command, $filter, $max_aggregates, $unique_id) { - + $aggregate = $filter['aggregate']; $unit = $filter['output']; $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; diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index eaaed06bd5..06eb0d0993 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -381,16 +381,16 @@ 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; + continue; $values['id_tag'] = $tag; $values['id_policy_module'] = $id_policy_module; $result_tag = db_process_sql_insert('ttag_policy_module', $values, false); if ($result_tag === false) - $errn++; + $errn++; } } @@ -407,7 +407,7 @@ function tags_get_module_tags ($id_agent_module){ return false; $tags = db_get_all_rows_filter('ttag_module', array('id_agente_modulo' => $id_agent_module), false); - + if ($tags === false) return false; @@ -431,7 +431,7 @@ function tags_get_policy_module_tags ($id_policy_module){ return false; $tags = db_get_all_rows_filter('ttag_policy_module', array('id_policy_module' => $id_policy_module), false); - + if ($tags === false) return false; @@ -449,9 +449,8 @@ 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; } - -?> +?> \ No newline at end of file diff --git a/pandora_console/include/graphs/functions_pchart.php b/pandora_console/include/graphs/functions_pchart.php index bfe1d3953c..13f4ca21e2 100755 --- a/pandora_console/include/graphs/functions_pchart.php +++ b/pandora_console/include/graphs/functions_pchart.php @@ -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); @@ -312,7 +312,7 @@ function pch_slicebar_graph ($graph_type, $data, $period, $width, $height, $colo /* Turn of Antialiasing */ $myPicture->Antialias = 0; - + $myPicture->setFontProperties(array("FontName"=> $font, "FontSize"=>$font_size,"R"=>80,"G"=>80,"B"=>80)); // Round corners defined in global setup @@ -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"); - - /* 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)); + /* Define the absissa serie */ + $MyData->addPoints($legend_values,"Labels"); + $MyData->setAbscissa("Labels"); + + /* 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)); - - - $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); - } - - - /* Create the pPie object */ - $PieChart = new pPie($myPicture,$MyData); + ($height - $water_mark_height) - 50, $water_mark); + } + + + /* 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)); - - /* Render the picture */ - $myPicture->stroke(); + /* Enable shadow computing */ + $myPicture->setShadow(TRUE,array("X"=>3,"Y"=>3,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10)); + + /* 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"); - - /* Create the pChart object */ - $myPicture = new pImage($width,$height,$MyData,TRUE); + /* Define the absissa serie */ + $MyData->addPoints($legend_values,"Labels"); + $MyData->setAbscissa("Labels"); + + /* 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); - - /* 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)); - - /* 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)); - - /* 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; + /* Create the pChart object */ + $myPicture = new pImage($width,$height,$MyData); - switch($graph_type) { + /* 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)); + + /* 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)); + + /* 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; + + 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); - } - - /* Define the chart area */ - $myPicture->setGraphArea($margin_left,$margin_top,$width - $water_mark_width,$height-$margin_bottom); + ($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); - $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); - - $myPicture->drawBarChart($settings); + /* 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); - /* 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,22 +611,22 @@ 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(); + } - foreach($data as $i => $values) { - if(isset($legend)) { + /* Create and populate the pData object */ + $MyData = new pData(); + + 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)) { $MyData->setPalette($point_id, @@ -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"]; @@ -652,30 +652,30 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, if (isset($rgb_color[$i]['color'])) { $palette_color["Alpha"] = $rgb_color[$i]['Alpha']; } - + $MyData->setPalette($point_id, $palette_color);*/ - } + } $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,167 +688,167 @@ 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; - - $water_mark_height = 0; - $water_mark_width = 0; - if (!empty($water_mark)) { + } + + //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)) { $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 != ''){ $chart_size += 40; } else{ $chart_size = 40; - } - - 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); - } + } - /*Get minimun value to draw axis properly*/ - $min_data = min(min($data)); - - $mode = SCALE_MODE_START0; - if ($min_data < 0) { + 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); + } + + /*Get minimun value to draw axis properly*/ + $min_data = min(min($data)); + + $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); - - /* 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; - } - - /* 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 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)); + + 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); + - 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; - } - - /* Render the picture */ - $myPicture->stroke(); + $myPicture->drawLineChart($settings); + break; + } + + /* 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)); - - /* 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)); - - /* 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) { + $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)); + + /* 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); + + if($show_legend) { /* Write the chart legend */ $myPicture->drawLegend(643,210,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL)); } diff --git a/pandora_console/include/help/en/help_date_format.php b/pandora_console/include/help/en/help_date_format.php index 4c61c8f7ad..e9e2daa1e2 100644 --- a/pandora_console/include/help/en/help_date_format.php +++ b/pandora_console/include/help/en/help_date_format.php @@ -3,11 +3,11 @@ * @package Include/help/en */ ?> -

- The format of the outputted date string. See the formatting - options below. -

-

+

+ The format of the outputted date string. See the formatting + options below. +

+

".__("Agents")." / ".__("Modules")."".__("Agents")." / ".__("Modules")."".html_print_image("images/darrowleft.png",true, array('title' => __('Previous modules')))." ".html_print_image("images/darrowright.png",true, array('title' => __('More modules')))."
The following characters are recognized in the diff --git a/pandora_console/mobile/include/system.class.php b/pandora_console/mobile/include/system.class.php index a4c7e1238c..76263a0588 100644 --- a/pandora_console/mobile/include/system.class.php +++ b/pandora_console/mobile/include/system.class.php @@ -23,7 +23,7 @@ class System { private $db; function __construct() { - $this->loadConfig(); + $this->loadConfig(); $this->db = new DB($this, $this->getConfig('db_engine', 'mysql')); session_start(); diff --git a/pandora_console/mobile/operation/events/events.php b/pandora_console/mobile/operation/events/events.php index f6f672c88d..4cf5582a42 100644 --- a/pandora_console/mobile/operation/events/events.php +++ b/pandora_console/mobile/operation/events/events.php @@ -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 * diff --git a/pandora_console/operation/events/events_rss.php b/pandora_console/operation/events/events_rss.php index 5a0861ccfe..5a6d5d2b0a 100644 --- a/pandora_console/operation/events/events_rss.php +++ b/pandora_console/operation/events/events_rss.php @@ -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) @@ -95,7 +95,7 @@ switch($status) { break; } - + if ($search != "") $sql_post .= " AND tevento.evento LIKE '%$search%'"; if ($event_type != "") { @@ -117,7 +117,7 @@ if ($severity != -1) if ($id_agent == -2) { $text_agent = (string) get_parameter("text_agent", __("All")); - + switch ($text_agent) { case __('All'): diff --git a/pandora_console/operation/events/export_csv.php b/pandora_console/operation/events/export_csv.php index 04a0c79e89..9d216c7d50 100644 --- a/pandora_console/operation/events/export_csv.php +++ b/pandora_console/operation/events/export_csv.php @@ -113,17 +113,17 @@ 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)"; } if ($id_user_ack != "0") $filter['id_usuario'] = $id_user_ack; - + //Search by tag if ($tag != "") { $filter['tags'] = "%".io_safe_input($tag)."%"; -} +} //$filter['order'] = 'timestamp DESC'; $now = date ("Y-m-d"); @@ -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"];