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

* godmode/reporting/visual_console_builder.editor.js,
	godmode/reporting/visual_console_builder.elements.php,
	include/functions_visual_map.php,
	include/ajax/visual_console_builder.ajax.php,
	include/functions_visual_map_editor.php: uploaded some fixes and
	changes for the visualmap, for example refactored some part of
	print the visualmap in operation.
	
	* include/functions_html.php: fixed when included from standarlone
	file from enterprise structure directory.
	
	* include/constants.php: added constants for avoid magic numbers
	into the code of Visualmaps.
	
	* include/graphs/functions_gd.php, include/functions.php,
	include/functions_io.php, include/functions_modules.php,
	include/functions_ui.php: cleaned source code style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6747 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-07-06 11:45:02 +00:00
parent 8bf7d40fc2
commit a489b4800e
13 changed files with 579 additions and 586 deletions

View File

@ -1,3 +1,23 @@
2012-07-06 Miguel de Dios <miguel.dedios@artica.es>
* godmode/reporting/visual_console_builder.editor.js,
godmode/reporting/visual_console_builder.elements.php,
include/functions_visual_map.php,
include/ajax/visual_console_builder.ajax.php,
include/functions_visual_map_editor.php: uploaded some fixes and
changes for the visualmap, for example refactored some part of
print the visualmap in operation.
* include/functions_html.php: fixed when included from standarlone
file from enterprise structure directory.
* include/constants.php: added constants for avoid magic numbers
into the code of Visualmaps.
* include/graphs/functions_gd.php, include/functions.php,
include/functions_io.php, include/functions_modules.php,
include/functions_ui.php: cleaned source code style.
2012-07-06 Sergio Martin <sergio.martin@artica.es>
* pandoradb.sql

View File

@ -49,7 +49,6 @@ function visual_map_main() {
draw_lines(lines, 'background', true);
}
);
}
function eventsTextAgent() {
@ -681,6 +680,10 @@ function hiddenFields(item) {
$("#module_graph_size_row").css('display', 'none');
$("#module_graph_size_row." + item).css('display', '');
if (typeof(enterprise_hiddenFields) == 'function') {
enterprise_hiddenFields(item);
}
}
function cleanFields() {

View File

@ -45,9 +45,6 @@ foreach ($all_images as $image_file) {
$images_list[$image_file] = $image_file;
}
$layoutDataTypes = visual_map_get_layout_data_types();
$table->width = '100%';
$table->head = array ();
$table->head['icon'] = '';

View File

@ -499,6 +499,9 @@ switch ($action) {
echo json_encode($size);
break;
default:
enterprise_hook("enterprise_visualmap_ajax");
break;
}
/* visual map element status check */

View File

@ -131,4 +131,19 @@ define('PROCESS_VALUE_NONE', 0);
define('PROCESS_VALUE_MIN', 1);
define('PROCESS_VALUE_MAX', 2);
define('PROCESS_VALUE_AVG', 3);
//Status
define('VISUAL_MAP_STATUS_CRITICAL_BAD', 1);
define('VISUAL_MAP_STATUS_CRITICAL_ALERT', 4);
define('VISUAL_MAP_STATUS_NORMAL', 0);
define('VISUAL_MAP_STATUS_WARNING', 2);
define('VISUAL_MAP_STATUS_UNKNOW', 3);
/* Service constants */
//Status
define('SERVICE_STATUS_UNKNOW', -1);
define('SERVICE_STATUS_NORMAL', 0);
define('SERVICE_STATUS_CRITICAL', 1);
define('SERVICE_STATUS_WARNING', 2);
?>

View File

@ -42,7 +42,7 @@ function check_refererer() {
// This is done due to problems with HTTP_REFERER var when metarefresh is performed
if ($config["refr"] > 0)
return true;
//Check if the referer have a port (for example when apache run in other port to 80)
if (preg_match('/http(s?):\/\/.*:[0-9]*/', $referer) == 1) {
$url = $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $config["homeurl"];
@ -50,7 +50,7 @@ function check_refererer() {
else {
$url = $_SERVER['SERVER_NAME'] . $config["homeurl"];
}
// Remove protocol from referer
$referer = preg_replace('/http(s?):\/\//','',$referer);
@ -118,15 +118,15 @@ function output_clean_strict ($string) {
* @return string Cleaned string
*/
function safe_url_extraclean ($string, $default_string = '') {
/* Strip the string to 125 characters */
$string = substr ($string, 0, 125);
/* Search for unwanted characters */
if (preg_match ('/[^a-zA-Z0-9_\/\.\-]|(\/\/)|(\.\.)/', $string)) {
return $default_string;
}
return $string;
}
@ -136,6 +136,7 @@ function safe_url_extraclean ($string, $default_string = '') {
*/
function no_permission () {
require ("config.php");
echo "<h3 class='error'>".__('You don\'t have access')."</h3>";
echo html_print_image('images/noaccess.png', true, array("alt" => 'No access', "width" => '120')) . "<br /><br />";
echo "<table width=550>";
@ -144,6 +145,7 @@ function no_permission () {
echo "</table>";
echo "<tr><td><td><td><td>";
include "general/footer.php";
exit;
}
@ -155,6 +157,7 @@ function no_permission () {
*/
function unmanaged_error ($error = "") {
require_once ("config.php");
echo "<h3 class='error'>".__('Unmanaged error')."</h3>";
echo html_print_image('images/error.png', true, array("alt" => 'error')) . "<br /><br />";
echo "<table width=550>";
@ -165,6 +168,7 @@ function unmanaged_error ($error = "") {
echo "</table>";
echo "<tr><td><td><td><td>";
include "general/footer.php";
exit;
}
@ -310,7 +314,7 @@ function human_time_comparation ($timestamp, $units = 'large') {
}
$seconds = get_system_time () - $timestamp;
return human_time_description_raw($seconds, false, $units);
}
@ -344,16 +348,16 @@ function get_system_time () {
*/
function get_user_language ($id_user = false) {
global $config;
$quick_language = get_parameter('quick_language_change', 0);
if($quick_language) {
$language = get_parameter('language', 0);
if($language === 'default') {
return $config['language'];
}
if($language !== 0) {
return $language;
}
@ -379,10 +383,10 @@ function get_user_language ($id_user = false) {
function set_user_language() {
global $config;
global $l10n;
$l10n = NULL;
$user_language = get_user_language ();
if (file_exists ('./include/languages/'.$user_language.'.mo')) {
$l10n = new gettext_reader (new CachedFileReader ('./include/languages/'.$user_language.'.mo'));
$l10n->load_tables();
@ -421,7 +425,7 @@ function human_time_description_raw ($seconds, $exactly = false, $units = 'large
$nowString = __('N');
break;
}
if (empty ($seconds)) {
return $nowString;
// slerena 25/03/09
@ -447,7 +451,7 @@ function human_time_description_raw ($seconds, $exactly = false, $units = 'large
$returnDate .= "$months $monthsString ";
}
$days = floor($seconds / 86400);
if($days != 0) {
@ -457,7 +461,7 @@ function human_time_description_raw ($seconds, $exactly = false, $units = 'large
}
$returnTime = '';
$hours = floor($seconds / 3600);
if($hours != 0) {
@ -610,10 +614,10 @@ function get_parameter ($name, $default = '') {
// POST has precedence
if (isset($_POST[$name]))
return get_parameter_post ($name, $default);
if (isset($_GET[$name]))
return get_parameter_get ($name, $default);
return $default;
}
@ -628,7 +632,7 @@ function get_parameter ($name, $default = '') {
function get_parameter_get ($name, $default = "") {
if ((isset ($_GET[$name])) && ($_GET[$name] != ""))
return io_safe_input ($_GET[$name]);
return $default;
}
@ -643,7 +647,7 @@ function get_parameter_get ($name, $default = "") {
function get_parameter_post ($name, $default = "") {
if ((isset ($_POST[$name])) && ($_POST[$name] != ""))
return io_safe_input ($_POST[$name]);
return $default;
}
@ -656,29 +660,31 @@ function get_parameter_post ($name, $default = "") {
*/
function get_alert_priority ($priority = 0) {
global $config;
switch ($priority) {
case 0:
return __('Maintenance');
break;
case 1:
return __('Informational');
break;
case 2:
return __('Normal');
break;
case 3:
return __('Warning');
break;
case 4:
return __('Critical');
break;
case 5:
return __('Minor');
break;
case 6:
return __('Major');
break;
case 0:
return __('Maintenance');
break;
case 1:
return __('Informational');
break;
case 2:
return __('Normal');
break;
case 3:
return __('Warning');
break;
case 4:
return __('Critical');
break;
case 5:
return __('Minor');
break;
case 6:
return __('Major');
break;
}
return '';
}
@ -692,12 +698,13 @@ function get_alert_priority ($priority = 0) {
function get_alert_days ($row) {
global $config;
$days_output = "";
$check = $row["monday"] + $row["tuesday"] + $row["wednesday"] + $row["thursday"] + $row["friday"] + $row["saturday"] + $row["sunday"];
if ($check == 7) {
return __('All');
} elseif ($check == 0) {
}
elseif ($check == 0) {
return __('None');
}
@ -716,7 +723,7 @@ function get_alert_days ($row) {
if ($row["sunday"] != 0)
$days_output .= __('Sun');
if ($check > 1) {
if ($check > 1) {
return str_replace (" ",", ",$days_output);
}
@ -731,19 +738,21 @@ function get_alert_days ($row) {
* @return string A string with the concatenated values
*/
function get_alert_times ($row2) {
if ($row2["time_from"]){
if ($row2["time_from"]) {
$time_from_table = $row2["time_from"];
} else {
}
else {
$time_from_table = __('N/A');
}
if ($row2["time_to"]){
if ($row2["time_to"]) {
$time_to_table = $row2["time_to"];
} else {
}
else {
$time_to_table = __('N/A');
}
if ($time_to_table == $time_from_table)
return __('N/A');
return substr ($time_from_table, 0, 5)." - ".substr ($time_to_table, 0, 5);
}
@ -960,12 +969,12 @@ function enterprise_include ($filename) {
global $config;
// Load enterprise extensions
$filepath = realpath ($config["homedir"].'/'.ENTERPRISE_DIR.'/'.$filename);
$filepath = realpath ($config["homedir"] . '/' . ENTERPRISE_DIR . '/' . $filename);
if ($filepath === false)
return ENTERPRISE_NOT_HOOK;
if (strncmp ($config["homedir"], $filepath, strlen ($config["homedir"])) != 0){
if (strncmp ($config["homedir"], $filepath, strlen ($config["homedir"])) != 0) {
return ENTERPRISE_NOT_HOOK;
}
@ -1188,9 +1197,9 @@ function array_key_to_offset($array, $key) {
* @return array SNMP result.
*/
function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', $snmp3_auth_user = '',
$snmp3_security_level = '', $snmp3_auth_method = '', $snmp3_auth_pass = '',
$snmp3_privacy_method = '', $snmp3_privacy_pass = '', $quick_print = 0, $base_oid = "", $snmp_port = '') {
$snmp3_security_level = '', $snmp3_auth_method = '', $snmp3_auth_pass = '',
$snmp3_privacy_method = '', $snmp3_privacy_pass = '', $quick_print = 0, $base_oid = "", $snmp_port = '') {
snmp_set_quick_print ($quick_print);
// Fix for snmp port
@ -1250,9 +1259,9 @@ function string2image($string, $width, $height, $fontsize = 3,
$padding_left = 4, $padding_top = 1, $home_url = '') {
global $config;
$string = str_replace('#','',$string);
//Set the size of image from the size of text
if ($width === false) {
$size = calculateTextBox($fontsize, 0, $config['fontpath'], $string);
@ -1301,7 +1310,7 @@ function string2image($string, $width, $height, $fontsize = 3,
function check_sql ($sql) {
// We remove "*" to avoid things like SELECT * FROM tusuario
//Check that it not delete_ as "delete_pending" (this is a common field in pandora tables).
if (preg_match("/\*|delete[^_]|drop|alter|modify|union|password|pass|insert|update/i", $sql)) {
@ -1401,7 +1410,7 @@ function check_acl($id_user, $id_group, $access, $id_agent = 0) {
if ($id_group != 0) {
$group = db_get_row_filter('tgrupo', array('id_grupo' => $id_group));
$parents = groups_get_parents($group['parent'], true);
foreach ($parents as $parent) {
$parents_id[] = $parent['id_grupo'];
}
@ -1435,12 +1444,12 @@ function check_acl($id_user, $id_group, $access, $id_agent = 0) {
AND (tusuario_perfil.id_grupo IN (%s)
OR tusuario_perfil.id_grupo = 0)", $id_user, implode(', ', $parents_id));
}
$rowdup = db_get_all_rows_sql ($query);
if (empty ($rowdup))
return 0;
$result = 0;
foreach ($rowdup as $row) {
// For each profile for this pair of group and user do...
@ -1481,7 +1490,7 @@ function check_acl($id_user, $id_group, $access, $id_agent = 0) {
if ($result >= 1) {
return 1;
}
return 0;
}

View File

@ -28,6 +28,11 @@ if (!isset($config)) {
require_once(str_repeat("../", $i) . "config.php");
break; // Skip config.php loading after load the first one
}
else if(file_exists(str_repeat("../", $i) . 'include/config.php')) {
//For path from the enterprise structure dirs.
require_once(str_repeat("../", $i) . "include/config.php");
break; // Skip config.php loading after load the first one
}
}
}

View File

@ -153,7 +153,8 @@ function io_ascii_to_html($num) {
if ($num <= 15) {
return "&#x0".dechex($num).";";
} else {
}
else {
return "&#x".dechex($num).";";
}
}

View File

@ -1002,16 +1002,16 @@ function modules_give_agent_id_from_module_id ($id_agent_module) {
*/
function modules_get_agentmodule_status($id_agentmodule = 0, $without_alerts = false) {
$current_timestamp = get_system_time ();
if (!$without_alerts) {
$times_fired = db_get_value ('SUM(times_fired)', 'talert_template_modules', 'id_agent_module', $id_agentmodule);
if ($times_fired > 0) {
return 4; // Alert fired
}
}
$status_row = db_get_row ("tagente_estado", "id_agente_modulo", $id_agentmodule);
return $status_row['estado'];
}
@ -1024,7 +1024,7 @@ function modules_get_agentmodule_status($id_agentmodule = 0, $without_alerts = f
*/
function modules_get_agentmodule_last_status($id_agentmodule = 0) {
$status_row = db_get_row ("tagente_estado", "id_agente_modulo", $id_agentmodule);
return $status_row['last_status'];
}

View File

@ -19,7 +19,7 @@
* @subpackage UI
*/
require_once($config['homedir'].'/include/functions_agents.php');
require_once($config['homedir'] . '/include/functions_agents.php');
require_once($config['homedir'] . '/include/functions_modules.php');
require_once($config['homedir'] . '/include/functions.php');
require_once($config['homedir'] . '/include/functions_groups.php');
@ -1101,7 +1101,7 @@ function ui_process_page_head ($string, $bitfield) {
}
$output = '';
// If user is logged or displayed view is the public view of visual console
if ($config["refr"] > 0 && (isset($config['id_user']) || $vc_public_view == 1)) {
$query = ui_get_url_refresh (false);

File diff suppressed because it is too large Load Diff

View File

@ -43,7 +43,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
echo '<div id="properties_panel" style="display: none; position: absolute; border: 2px solid #114105; padding: 5px; background: white; z-index: 90;">';
//----------------------------Hiden Form----------------------------------------
//----------------------------Hiden Form----------------------------
?>
<table class="databox" border="0" cellpadding="4" cellspacing="4" width="300">
<caption>

View File

@ -12,13 +12,14 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
// If is called from index
if(file_exists('include/functions.php')) {
if (file_exists('include/functions.php')) {
// If is called from index
include_once('include/functions.php');
include_once('include/functions_html.php');
include_once('include/graphs/functions_utils.php');
} // If is called through url
else if(file_exists('../functions.php')) {
}
else if (file_exists('../functions.php')) {
// If is called through url
include_once('../functions.php');
include_once('../functions_html.php');
include_once('functions_utils.php');
@ -45,7 +46,7 @@ if($id_graph && in_array($graph_type, $types)) {
$graph['fontsize'] = 6;
}
switch($graph_type) {
switch ($graph_type) {
case 'histogram':
gd_histogram ($graph['width'],
$graph['height'],
@ -86,11 +87,11 @@ function gd_histogram ($width, $height, $mode, $data, $max_value, $font, $title,
// $title is for future use
$nvalues = count($data);
Header("Content-type: image/png");
Header("Content-type: image/png");
$image = imagecreate($width,$height);
$white = ImageColorAllocate($image,255,255,255);
imagecolortransparent ($image, $white);
$black = ImageColorAllocate($image,0,0,0);
$red = ImageColorAllocate($image,255,60,75);
@ -98,14 +99,15 @@ function gd_histogram ($width, $height, $mode, $data, $max_value, $font, $title,
$green = ImageColorAllocate($image,0,120,0);
$magent = ImageColorAllocate($image,179,0,255);
$yellow = ImageColorAllocate($image,204,255,0);
$colors = array($blue, $red, $green, $magent, $yellow);
$margin_up = 2;
if ($mode != 2) {
$size_per = ($max_value / ($width-40));
} else {
}
else {
$size_per = ($max_value / ($width));
}
@ -113,7 +115,7 @@ function gd_histogram ($width, $height, $mode, $data, $max_value, $font, $title,
$rectangle_height = ($height - 10 - 2 - $margin_up ) / $nvalues;
else
$rectangle_height = ($height - 2 - $margin_up ) / $nvalues;
if ($size_per == 0)
$size_per = 1;
@ -125,14 +127,14 @@ function gd_histogram ($width, $height, $mode, $data, $max_value, $font, $title,
}
$c = 0;
foreach($data as $label => $value) {
foreach($data as $label => $value) {
ImageFilledRectangle($image, $leftmargin, $margin_up, ($value/$size_per)+$leftmargin, $margin_up+$rectangle_height -1 , $colors[$c]);
if ($mode != 2) {
ImageTTFText($image, $fontsize, 0, 0, $margin_up+8, $black, $font, $label);
}
$margin_up += $rectangle_height + 1;
$c++;
if(!isset($colors[$c])) {
$c = 0;