mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-25 23:05:30 +02:00
Merge branch '1756-Añadir-gráfico-en-los-correos-de-alertas-de-módulos-tipo-string-dev' into 'develop'
Added string graph in mail See merge request artica/pandorafms!1250
This commit is contained in:
commit
6703f49607
@ -9996,69 +9996,80 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$id_module_type = modules_get_agentmodule_type ($id_module);
|
||||||
|
$module_type = modules_get_moduletype_name ($id_module_type);
|
||||||
|
|
||||||
|
$string_type = strpos($module_type,'string');
|
||||||
// Get the html item
|
// Get the html item
|
||||||
$graph_html = grafico_modulo_sparse(
|
if ($string_type === false) {
|
||||||
$id_module, $graph_seconds, false, 600, 300, '',
|
$graph_html = grafico_modulo_sparse(
|
||||||
'', false, false, true, time(), '', 0, 0, true, true,
|
$id_module, $graph_seconds, false, 600, 300, '',
|
||||||
ui_get_full_url(false) . '/', 1, false, '', false, true,
|
'', false, false, true, time(), '', 0, 0, true, true,
|
||||||
true, 'white', null, false, false, $config['type_module_charts'],
|
ui_get_full_url(false) . '/', 1, false, '', false, true,
|
||||||
false, false);
|
true, 'white', null, false, false, $config['type_module_charts'],
|
||||||
|
false, false);
|
||||||
$graph_image_file_encoded = false;
|
} else {
|
||||||
if (preg_match("/<img src='(.+)'./", $graph_html, $matches)) {
|
$graph_html = grafico_modulo_string(
|
||||||
$file_url = $matches[1];
|
$id_module, $graph_seconds, false, 600, 300, '',
|
||||||
|
'', false, false, true, time(), true, ui_get_full_url(false) . '/',
|
||||||
|
'', 1, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (preg_match("/\?(.+)&(.+)&(.+)&(.+)/", $file_url,$parameters)) {
|
$graph_image_file_encoded = false;
|
||||||
array_shift ($parameters);
|
if (preg_match("/<img src='(.+)'./", $graph_html, $matches)) {
|
||||||
foreach ($parameters as $parameter){
|
$file_url = $matches[1];
|
||||||
$value = explode ("=",$parameter);
|
|
||||||
|
|
||||||
if (strcmp($value[0], "static_graph") == 0){
|
if (preg_match("/\?(.+)&(.+)&(.+)&(.+)/", $file_url,$parameters)) {
|
||||||
$static_graph = $value[1];
|
array_shift ($parameters);
|
||||||
}
|
foreach ($parameters as $parameter){
|
||||||
elseif (strcmp($value[0], "graph_type") == 0){
|
$value = explode ("=",$parameter);
|
||||||
$graph_type = $value[1];
|
|
||||||
}
|
if (strcmp($value[0], "static_graph") == 0){
|
||||||
elseif (strcmp($value[0], "ttl") == 0){
|
$static_graph = $value[1];
|
||||||
$ttl = $value[1];
|
}
|
||||||
}
|
elseif (strcmp($value[0], "graph_type") == 0){
|
||||||
elseif (strcmp($value[0], "id_graph") == 0){
|
$graph_type = $value[1];
|
||||||
$id_graph = $value[1];
|
}
|
||||||
}
|
elseif (strcmp($value[0], "ttl") == 0){
|
||||||
}
|
$ttl = $value[1];
|
||||||
}
|
}
|
||||||
}
|
elseif (strcmp($value[0], "id_graph") == 0){
|
||||||
|
$id_graph = $value[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check values are OK
|
// Check values are OK
|
||||||
if ( (isset ($graph_type))
|
if ( (isset ($graph_type))
|
||||||
&& (isset ($ttl))
|
&& (isset ($ttl))
|
||||||
&& (isset ($id_graph))) {
|
&& (isset ($id_graph))) {
|
||||||
$_GET["ttl"] = $ttl;
|
$_GET["ttl"] = $ttl;
|
||||||
$_GET["id_graph"] = $id_graph;
|
$_GET["id_graph"] = $id_graph;
|
||||||
$_GET["graph_type"] = $graph_type;
|
$_GET["graph_type"] = $graph_type;
|
||||||
$_GET["static_graph"] = $static_graph;
|
$_GET["static_graph"] = $static_graph;
|
||||||
$_GET["graph_threshold"] = $graph_threshold;
|
$_GET["graph_threshold"] = $graph_threshold;
|
||||||
$_GET["id_module"] = $id_module;
|
$_GET["id_module"] = $id_module;
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
include (__DIR__ . "/graphs/functions_pchart.php");
|
include (__DIR__ . "/graphs/functions_pchart.php");
|
||||||
$output = ob_get_clean();
|
$output = ob_get_clean();
|
||||||
|
|
||||||
$graph_image_file_encoded = base64_encode($output);
|
$graph_image_file_encoded = base64_encode($output);
|
||||||
if (empty($graph_image_file_encoded)) {
|
if (empty($graph_image_file_encoded)) {
|
||||||
// returnError('error_module_graph', __(''));
|
// returnError('error_module_graph', __(''));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if($other['data'][1]){
|
if($other['data'][1]){
|
||||||
header('Content-type: text/html');
|
header('Content-type: text/html');
|
||||||
returnData('string', array('type' => 'string', 'data' => '<img src="data:image/jpeg;base64,' . $graph_image_file_encoded . '">'));
|
returnData('string', array('type' => 'string', 'data' => '<img src="data:image/jpeg;base64,' . $graph_image_file_encoded . '">'));
|
||||||
} else {
|
} else {
|
||||||
returnData('string', array('type' => 'string', 'data' => $graph_image_file_encoded));
|
returnData('string', array('type' => 'string', 'data' => $graph_image_file_encoded));
|
||||||
}
|
}
|
||||||
// To show only the base64 code, call returnData as:
|
// To show only the base64 code, call returnData as:
|
||||||
// returnData('string', array('type' => 'string', 'data' => $graph_image_file_encoded));
|
// returnData('string', array('type' => 'string', 'data' => $graph_image_file_encoded));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function api_set_metaconsole_synch($keys) {
|
function api_set_metaconsole_synch($keys) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user