php8 review + pdf images b64 fix
This commit is contained in:
parent
fee3f4ab96
commit
8e5a0917ba
|
@ -581,10 +581,12 @@ class Tree
|
|||
}
|
||||
|
||||
|
||||
protected function processModule(&$module, $server=false, $all_groups)
|
||||
protected function processModule(&$module, $server, $all_groups)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$server ??= false;
|
||||
|
||||
if (isset($module['children'])) {
|
||||
foreach ($module['children'] as $i => $children) {
|
||||
$this->processModule($module['children'][$i], $server, $all_groups);
|
||||
|
@ -713,22 +715,23 @@ class Tree
|
|||
// Info to be able to open the snapshot image new page
|
||||
$module['snapshot'] = ui_get_snapshot_link(
|
||||
[
|
||||
'id_module' => $module['id'],
|
||||
'interval' => $module['current_interval'],
|
||||
'module_name' => $module['name'],
|
||||
'id_node' => $module['serverID'] ? $module['serverID'] : 0,
|
||||
'id_module' => ($module['id'] ?? null),
|
||||
'interval' => ($module['current_interval'] ?? null),
|
||||
'module_name' => ($module['name'] ?? null),
|
||||
'id_node' => ((isset($module['serverID']) === true) ? $module['serverID'] : 0),
|
||||
],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$module_alerts = alerts_get_alerts_agent_module($module['id']);
|
||||
|
||||
$module_alert_triggered = false;
|
||||
|
||||
foreach ($module_alerts as $module_alert) {
|
||||
if ($module_alert['times_fired'] > 0) {
|
||||
$module_alert_triggered = true;
|
||||
if (is_array($module_alerts) === true) {
|
||||
foreach ($module_alerts as $module_alert) {
|
||||
if ($module_alert['times_fired'] > 0) {
|
||||
$module_alert_triggered = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -262,7 +262,7 @@ class TreeGroup extends Tree
|
|||
$groups = array_filter(
|
||||
$groups,
|
||||
function ($group) {
|
||||
return !$group['have_parent'];
|
||||
return !($group['have_parent'] ?? false);
|
||||
}
|
||||
);
|
||||
// Propagate child counters to her parents.
|
||||
|
@ -417,7 +417,7 @@ class TreeGroup extends Tree
|
|||
$groups = array_filter(
|
||||
$groups,
|
||||
function ($group) {
|
||||
return !$group['have_parent'];
|
||||
return !($group['have_parent'] ?? false);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -489,6 +489,10 @@ class TreeGroup extends Tree
|
|||
}
|
||||
|
||||
foreach ($groups[$id]['counters'] as $type => $value) {
|
||||
if (isset($all_counters[$type]) === false) {
|
||||
$all_counters[$type] = 0;
|
||||
}
|
||||
|
||||
$all_counters[$type] += $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ class TreeGroupEdition extends TreeGroup
|
|||
$groups = array_filter(
|
||||
$groups,
|
||||
function ($group) {
|
||||
return !$group['have_parent'];
|
||||
return !($group['have_parent'] ?? false);
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -551,8 +551,9 @@ function gis_get_groups_layer_by_agent_id($idLayer)
|
|||
}
|
||||
|
||||
|
||||
function gis_add_point_path($layerName, $lat, $lon, $color, $manual=1, $id)
|
||||
function gis_add_point_path($layerName, $lat, $lon, $color, $manual, $id)
|
||||
{
|
||||
$manual ??= 1;
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(document).ready (
|
||||
|
|
|
@ -794,7 +794,7 @@ function grafico_modulo_sparse($params)
|
|||
}
|
||||
|
||||
if (isset($params['type_mode_graph']) === false) {
|
||||
$params['type_mode_graph'] = $config['type_mode_graph'];
|
||||
$params['type_mode_graph'] = ($config['type_mode_graph'] ?? null);
|
||||
if (isset($params['graph_render']) === true) {
|
||||
$params['type_mode_graph'] = $params['graph_render'];
|
||||
}
|
||||
|
@ -2595,7 +2595,7 @@ function graphic_agentaccess(
|
|||
} else {
|
||||
$options['generals']['pdf']['width'] = 350;
|
||||
$options['generals']['pdf']['height'] = 125;
|
||||
$imgbase64 = '<img src="data:image/jpg;base64,';
|
||||
$imgbase64 = '<img src="data:image/png;base64,';
|
||||
$imgbase64 .= vbar_graph($data_array, $options, 2);
|
||||
$imgbase64 .= '" />';
|
||||
|
||||
|
@ -3866,7 +3866,7 @@ function graph_custom_sql_graph(
|
|||
$options['x']['color'] = 'transparent';
|
||||
$options['generals']['pdf']['width'] = $width;
|
||||
$options['generals']['pdf']['height'] = $height;
|
||||
$output .= '<img src="data:image/jpg;base64,';
|
||||
$output .= '<img src="data:image/png;base64,';
|
||||
$output .= vbar_graph($data, $options, $ttl);
|
||||
$output .= '" />';
|
||||
} else {
|
||||
|
@ -4234,6 +4234,14 @@ function fullscale_data(
|
|||
$flag_unknown = 0;
|
||||
$array_percentil = [];
|
||||
|
||||
// Missing initializations.
|
||||
$params = ['baseline' => false];
|
||||
$sum_data_total = 0;
|
||||
$count_data_total = 0;
|
||||
$sum_data_min = 0;
|
||||
$sum_data_max = 0;
|
||||
$sum_data_avg = 0;
|
||||
|
||||
if ($data_slice) {
|
||||
if (isset($data_uncompress) === true
|
||||
&& is_array($data_uncompress) === true
|
||||
|
@ -4478,6 +4486,8 @@ function fullscale_data(
|
|||
}
|
||||
}
|
||||
} else {
|
||||
$sum_data = 0;
|
||||
$count_data = 0;
|
||||
foreach ($data_uncompress as $k) {
|
||||
foreach ($k['data'] as $v) {
|
||||
if (isset($v['type']) && $v['type'] == 1) {
|
||||
|
|
|
@ -4543,7 +4543,7 @@ function agents_get_network_interfaces_array(
|
|||
$params_combined
|
||||
);
|
||||
} else {
|
||||
$row_interface['chart'] = '<img src="data:image/jpg;base64,';
|
||||
$row_interface['chart'] = '<img src="data:image/png;base64,';
|
||||
$row_interface['chart'] .= graphic_combined_module(
|
||||
array_values($interface['traffic']),
|
||||
$params,
|
||||
|
@ -5683,7 +5683,7 @@ function reporting_projection_graph(
|
|||
];
|
||||
|
||||
if ($pdf === true) {
|
||||
$return['chart'] = '<img src="data:image/jpg;base64,';
|
||||
$return['chart'] = '<img src="data:image/png;base64,';
|
||||
$return['chart'] .= graphic_combined_module(
|
||||
[$content['id_agent_module']],
|
||||
$params,
|
||||
|
@ -6139,7 +6139,7 @@ function reporting_value($report, $content, $type, $pdf=false)
|
|||
if ($only_image === false) {
|
||||
$graph = grafico_modulo_sparse($params);
|
||||
} else {
|
||||
$graph = '<img src="data:image/jpg;base64,'.grafico_modulo_sparse($params).'" />';
|
||||
$graph = '<img src="data:image/png;base64,'.grafico_modulo_sparse($params).'" />';
|
||||
}
|
||||
|
||||
$return['data'][] = ['value' => $graph];
|
||||
|
@ -9480,7 +9480,7 @@ function reporting_custom_graph(
|
|||
|
||||
$return['chart'] = '';
|
||||
if ($pdf === true) {
|
||||
$return['chart'] .= '<img src="data:image/jpg;base64,';
|
||||
$return['chart'] .= '<img src="data:image/png;base64,';
|
||||
$return['chart'] .= graphic_combined_module(
|
||||
$modules,
|
||||
$params,
|
||||
|
@ -9685,7 +9685,7 @@ function reporting_simple_graph(
|
|||
if ($only_image === false) {
|
||||
$return['chart'] = grafico_modulo_sparse($params);
|
||||
} else {
|
||||
$return['chart'] = '<img src="data:image/jpg;base64,'.grafico_modulo_sparse($params).'" />';
|
||||
$return['chart'] = '<img src="data:image/png;base64,'.grafico_modulo_sparse($params).'" />';
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -1627,31 +1627,31 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
|||
switch ($agent_status) {
|
||||
case AGENT_STATUS_CRITICAL:
|
||||
if ($critical > 0) {
|
||||
$count ++;
|
||||
$count++;
|
||||
}
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_WARNING:
|
||||
if ($total > 0 && $critical = 0 && $warning > 0) {
|
||||
$count ++;
|
||||
$count++;
|
||||
}
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_UNKNOWN:
|
||||
if ($critical == 0 && $warning == 0 && $unknown > 0) {
|
||||
$count ++;
|
||||
$count++;
|
||||
}
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_NOT_INIT:
|
||||
if ($total == 0 || $total == $not_init) {
|
||||
$count ++;
|
||||
$count++;
|
||||
}
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_NORMAL:
|
||||
if ($critical == 0 && $warning == 0 && $unknown == 0 && $normal > 0) {
|
||||
$count ++;
|
||||
$count++;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1662,23 +1662,23 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
|||
} else {
|
||||
if (array_search(AGENT_STATUS_CRITICAL, $agent_status) !== false) {
|
||||
if ($critical > 0) {
|
||||
$count ++;
|
||||
$count++;
|
||||
}
|
||||
} else if (array_search(AGENT_STATUS_WARNING, $agent_status) !== false) {
|
||||
if ($total > 0 && $critical = 0 && $warning > 0) {
|
||||
$count ++;
|
||||
$count++;
|
||||
}
|
||||
} else if (array_search(AGENT_STATUS_UNKNOWN, $agent_status) !== false) {
|
||||
if ($critical == 0 && $warning == 0 && $unknown > 0) {
|
||||
$count ++;
|
||||
$count++;
|
||||
}
|
||||
} else if (array_search(AGENT_STATUS_NOT_INIT, $agent_status) !== false) {
|
||||
if ($total == 0 || $total == $not_init) {
|
||||
$count ++;
|
||||
$count++;
|
||||
}
|
||||
} else if (array_search(AGENT_STATUS_NORMAL, $agent_status) !== false) {
|
||||
if ($critical == 0 && $warning == 0 && $unknown == 0 && $normal > 0) {
|
||||
$count ++;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
// Invalid status.
|
||||
|
@ -2692,8 +2692,14 @@ function tags_get_user_applied_agent_tags($id_agent, $access='AR')
|
|||
continue;
|
||||
}
|
||||
|
||||
$group_tags = $user_groups[$group]['tags'][$acl_column];
|
||||
if (!empty($group_tags)) {
|
||||
$group_tags = null;
|
||||
if (isset($user_groups[$group]) === true
|
||||
&& isset($user_groups[$group]['tags']) === true
|
||||
) {
|
||||
$group_tags = $user_groups[$group]['tags'][$acl_column];
|
||||
}
|
||||
|
||||
if (empty($group_tags) === false) {
|
||||
$tags = array_merge($tags, $group_tags);
|
||||
} else {
|
||||
// If an agent
|
||||
|
|
|
@ -750,7 +750,7 @@ function flot_slicesbar_graph(
|
|||
'server_id' => $server_id,
|
||||
];
|
||||
|
||||
$graph = '<img src="data:image/jpg;base64,';
|
||||
$graph = '<img src="data:image/png;base64,';
|
||||
$graph .= generator_chart_to_pdf('slicebar', $params);
|
||||
$graph .= '" />';
|
||||
|
||||
|
|
|
@ -425,7 +425,7 @@ final class BarsGraph extends Item
|
|||
\metaconsole_restore_db();
|
||||
}
|
||||
|
||||
$imgbase64 = 'data:image/jpg;base64,';
|
||||
$imgbase64 = 'data:image/png;base64,';
|
||||
$imgbase64 .= $graph;
|
||||
|
||||
$data['html'] = $imgbase64;
|
||||
|
|
|
@ -227,7 +227,7 @@ final class BasicChart extends Item
|
|||
];
|
||||
|
||||
if ($imageOnly !== false) {
|
||||
$imgbase64 = 'data:image/jpg;base64,';
|
||||
$imgbase64 = 'data:image/png;base64,';
|
||||
}
|
||||
|
||||
$imgbase64 .= \grafico_modulo_sparse($params);
|
||||
|
|
|
@ -385,7 +385,7 @@ final class ModuleGraph extends Item
|
|||
];
|
||||
|
||||
if ($imageOnly !== false) {
|
||||
$imgbase64 = 'data:image/jpg;base64,';
|
||||
$imgbase64 = 'data:image/png;base64,';
|
||||
}
|
||||
|
||||
$imgbase64 .= \graphic_combined_module(
|
||||
|
@ -430,7 +430,7 @@ final class ModuleGraph extends Item
|
|||
];
|
||||
|
||||
if ($imageOnly !== false) {
|
||||
$imgbase64 = 'data:image/jpg;base64,';
|
||||
$imgbase64 = 'data:image/png;base64,';
|
||||
}
|
||||
|
||||
$imgbase64 .= \grafico_modulo_sparse($params);
|
||||
|
|
Loading…
Reference in New Issue