From 0d369027c9194bf7484844b9f8e0d5e1f20ab2b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gonz=C3=A1lez?= Date: Tue, 13 Sep 2022 11:51:59 +0200 Subject: [PATCH] Added new macros --- .../include/functions_reporting.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 31026035f7..aee6a8e1ac 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -7213,7 +7213,7 @@ function reporting_sql($report, $content) $sql = $content['external_source']; } - // Check if exist sql macro + // Check if exist sql macro. $sql = reporting_sql_macro($report, $sql); // Do a security check on SQL coming from the user. @@ -14723,6 +14723,25 @@ function reporting_sql_macro(array $report, string $sql): string ); } + if (preg_match('/_start_date_/', $sql)) { + $date_init = get_parameter('date_init', date(DATE_FORMAT, (strtotime(date('Y-m-j')) - SECONDS_1DAY))); + $time_init = get_parameter('time_init', date(TIME_FORMAT, (strtotime(date('Y-m-j')) - SECONDS_1DAY))); + $datetime_init = strtotime($date_init.' '.$time_init); + $sql = str_replace( + '_start_date_', + $datetime_init, + $sql + ); + } + + if (preg_match('/_end_date_/', $sql)) { + $sql = str_replace( + '_end_date_', + $report['datetime'], + $sql + ); + } + return $sql; }