Ticket Integria: 3951 Changed workaround to generate api module graphs #31
This commit is contained in:
parent
736a2cb2ac
commit
95b162f63a
|
@ -8853,29 +8853,55 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) {
|
||||||
'', false, false, true, time(), '', 0, 0, true, true,
|
'', false, false, true, time(), '', 0, 0, true, true,
|
||||||
ui_get_full_url(false) . '/', 1, false, '', false, true);
|
ui_get_full_url(false) . '/', 1, false, '', false, true);
|
||||||
|
|
||||||
$graph_image_file_encoded = false;
|
$graph_image_file_encoded = false;
|
||||||
|
if (preg_match("/<img src='(.+)'./", $graph_html, $matches)) {
|
||||||
// Get the src of the html item
|
$file_url = $matches[1];
|
||||||
if (preg_match("/<img src='(.+)'.*/", $graph_html, $matches)) {
|
|
||||||
if (isset($matches) && isset($matches[1])) {
|
if (preg_match("/\?(.+)&(.+)&(.+)&(.+)/", $file_url,$parameters)) {
|
||||||
$file_url = $matches[1];
|
array_shift ($parameters);
|
||||||
// Get the file
|
foreach ($parameters as $parameter){
|
||||||
$graph_image_file = file_get_contents($file_url);
|
$value = explode ("=",$parameter);
|
||||||
|
|
||||||
if ($graph_image_file !== false) {
|
if (strcmp($value[0], "static_graph") == 0){
|
||||||
// Encode the file
|
$static_graph = $value[1];
|
||||||
$graph_image_file_encoded = base64_encode($graph_image_file);
|
}
|
||||||
unset($graph_image_file);
|
elseif (strcmp($value[0], "graph_type") == 0){
|
||||||
}
|
$graph_type = $value[1];
|
||||||
}
|
}
|
||||||
}
|
elseif (strcmp($value[0], "ttl") == 0){
|
||||||
|
$ttl = $value[1];
|
||||||
if (empty($graph_image_file_encoded)) {
|
}
|
||||||
// returnError('error_module_graph', __(''));
|
elseif (strcmp($value[0], "id_graph") == 0){
|
||||||
}
|
$id_graph = $value[1];
|
||||||
else {
|
}
|
||||||
returnData('string', array('type' => 'string', 'data' => $graph_image_file_encoded));
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check values are OK
|
||||||
|
if ( (isset ($graph_type))
|
||||||
|
&& (isset ($ttl))
|
||||||
|
&& (isset ($id_graph))) {
|
||||||
|
$_GET["ttl"] = $ttl;
|
||||||
|
$_GET["id_graph"] = $id_graph;
|
||||||
|
$_GET["graph_type"] = $graph_type;
|
||||||
|
$_GET["static_graph"] = $static_graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
include (__DIR__ . "/graphs/functions_pchart.php");
|
||||||
|
$output = ob_get_clean();
|
||||||
|
|
||||||
|
$graph_image_file_encoded = base64_encode($output);
|
||||||
|
if (empty($graph_image_file_encoded)) {
|
||||||
|
// returnError('error_module_graph', __(''));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
header('Content-type: text/html');
|
||||||
|
returnData('string', array('type' => 'string', 'data' => '<img src="data:image/jpeg;base64,' . $graph_image_file_encoded . '">'));
|
||||||
|
// To show only the base64 code, call returnData as:
|
||||||
|
// returnData('string', array('type' => 'string', 'data' => $graph_image_file_encoded));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue