Merge branch 'ent-4032-new-macro-sql-reports' into 'develop'

Ent 4032 new macro sql reports

See merge request artica/pandorafms!2610
This commit is contained in:
Alejandro Fraguas 2019-08-21 14:23:28 +02:00
commit 0f1baadb00
1 changed files with 25 additions and 0 deletions

View File

@ -5309,6 +5309,9 @@ function reporting_sql($report, $content)
$sql = io_safe_output($content['external_source']);
}
// Check if exist sql macro
$sql = reporting_sql_macro($report, $sql);
// Do a security check on SQL coming from the user.
$sql = check_sql($sql);
@ -12080,6 +12083,28 @@ function reporting_label_macro($item, $label)
}
/**
* Convert macro in sql string to value
*
* @param array $report
* @param string $sql
*
* @return string
*/
function reporting_sql_macro(array $report, string $sql): string
{
if (preg_match('/_timefrom_/', $sql)) {
$sql = str_replace(
'_timefrom_',
$report['datetime'],
$sql
);
}
return $sql;
}
/**
* @brief Calculates the SLA compliance value given an sla array
*