Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Version 5.0.2, 2026-05-05
- Robustness & i18n
- **`DieWithErrorMsg` / `DieWithFriendlyErrorMsg`**: fix invalid extra `<tr>` in the auxiliary error table; normalise detail rows; correct friendly-error footer cell markup; trim redundant padding `<br>` in error cells ([`functions_common.php`](src/include/functions_common.php)).
- Export placeholder copy: strip decorative **`&gt;` / `&lt;`** from **`LN_GEN_SELECTEXPORT`** in en/de/es/ja `main.php`.
- PHP 8.1+: cast event timestamps to **`int`** before **`date()`** in disk consolidation/chart helpers, grid date formatting, DB/PDO/ClickHouse date-range filters, and export filenames; fix wrong field variable in disk **`ConsolidateItemListByField`** / **`ConsolidateDataByField`** date grouping ([#132](https://github.com/rsyslog/loganalyzer/issues/132), thanks **@KDocProf**).
- E2E / Playwright
- **`Modern theme visual review`**: switch session style via `userchange.php`, assert theme stylesheets, capture **`modern-01`…`modern-05`** screenshots under `e2e/test-results/ci-visual/` (index grid, **details dialog**, admin index, advanced search, reports).

Expand Down
8 changes: 4 additions & 4 deletions src/classes/logstreamclickhouse.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1518,20 +1518,20 @@ private function CreateSQLWhereClause()
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'";
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", (int)$myeventtime[EVTIME_TIMESTAMP]) . "'";
}
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_TO )
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " < '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'";
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " < '" . date("Y-m-d H:i:s", (int)$myeventtime[EVTIME_TIMESTAMP]) . "'";
}
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_DATE )
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "' AND " .
$dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " < '" . date("Y-m-d H:i:s", ($myeventtime[EVTIME_TIMESTAMP]+86400) ) . "'";
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", (int)$myeventtime[EVTIME_TIMESTAMP]) . "' AND " .
$dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " < '" . date("Y-m-d H:i:s", (int)$myeventtime[EVTIME_TIMESTAMP] + 86400 ) . "'";
}

break;
Expand Down
8 changes: 4 additions & 4 deletions src/classes/logstreamdb.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1547,20 +1547,20 @@ private function CreateSQLWhereClause()
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'";
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", (int)$myeventtime[EVTIME_TIMESTAMP]) . "'";
}
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_TO )
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " < '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'";
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " < '" . date("Y-m-d H:i:s", (int)$myeventtime[EVTIME_TIMESTAMP]) . "'";
}
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_DATE )
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "' AND " .
$dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " < '" . date("Y-m-d H:i:s", ($myeventtime[EVTIME_TIMESTAMP]+86400) ) . "'";
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", (int)$myeventtime[EVTIME_TIMESTAMP]) . "' AND " .
$dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " < '" . date("Y-m-d H:i:s", (int)$myeventtime[EVTIME_TIMESTAMP] + 86400 ) . "'";
}

break;
Expand Down
6 changes: 3 additions & 3 deletions src/classes/logstreamdisk.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ public function ConsolidateItemListByField($szConsFieldId, $nRecordLimit, $szSor
if ( $nConsFieldType == FILTER_TYPE_DATE )
{
// Convert to FULL Day Date for now!
$myFieldData = date( "Y-m-d", $logArray[$szFieldId][EVTIME_TIMESTAMP] );
$myFieldData = date( "Y-m-d", (int)$logArray[$szConsFieldId][EVTIME_TIMESTAMP] );
}
Comment on lines 821 to 825

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

If $logArray[$szConsFieldId] is a string (e.g., a pre-formatted date string from a custom log parser) rather than an array, attempting to access $logArray[$szConsFieldId][EVTIME_TIMESTAMP] will result in an illegal string offset warning in PHP 8, or incorrectly extract a single character and cast it to an incorrect timestamp (e.g., "2" from "2023-..." casting to 2 and resulting in "1970-01-01").\n\nWe should defensively check if the field is an array, and fallback to parsing it with strtotime if it is a string, similar to how it is handled in GetFormatedDate.

					if ( $nConsFieldType == FILTER_TYPE_DATE ) 
					{
						// Convert to FULL Day Date for now!
						$nTimeStamp = is_array($logArray[$szConsFieldId]) ? (int)$logArray[$szConsFieldId][EVTIME_TIMESTAMP] : strtotime($logArray[$szConsFieldId]);
						$myFieldData = date( "Y-m-d", $nTimeStamp !== false ? $nTimeStamp : time() );
					}

else // Just copy the value!
$myFieldData = $logArray[$szConsFieldId];
Expand Down Expand Up @@ -914,7 +914,7 @@ public function ConsolidateDataByField($szConsFieldId, $nRecordLimit, $szSortFie
if ( $nConsFieldType == FILTER_TYPE_DATE )
{
// Convert to FULL Day Date for now!
$myFieldData = date( "Y-m-d", $logArray[$szFieldId][EVTIME_TIMESTAMP] );
$myFieldData = date( "Y-m-d", (int)$logArray[$szConsFieldId][EVTIME_TIMESTAMP] );
}
Comment on lines 914 to 918

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to the issue in ConsolidateItemListByField, if $logArray[$szConsFieldId] is a string rather than an array, accessing it as an array will cause PHP 8 warnings or incorrect date grouping. We should defensively check if it is an array and fallback to strtotime if it is a string.

					if ( $nConsFieldType == FILTER_TYPE_DATE ) 
					{
						// Convert to FULL Day Date for now!
						$nTimeStamp = is_array($logArray[$szConsFieldId]) ? (int)$logArray[$szConsFieldId][EVTIME_TIMESTAMP] : strtotime($logArray[$szConsFieldId]);
						$myFieldData = date( "Y-m-d", $nTimeStamp !== false ? $nTimeStamp : time() );
					}

else // Just copy the value!
$myFieldData = $logArray[$szConsFieldId];
Expand Down Expand Up @@ -1017,7 +1017,7 @@ public function GetCountSortedByField($szFieldId, $nFieldType, $nRecordLimit)
if ( $nFieldType == FILTER_TYPE_DATE )
{
// Convert to FULL Day Date for now!
$myFieldData = date( "Y-m-d", $logArray[$szFieldId][EVTIME_TIMESTAMP] );
$myFieldData = date( "Y-m-d", (int)$logArray[$szFieldId][EVTIME_TIMESTAMP] );
}
Comment on lines 1017 to 1021

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to the other consolidation methods, if $logArray[$szFieldId] is a string rather than an array, accessing it as an array will cause PHP 8 warnings or incorrect date grouping. We should defensively check if it is an array and fallback to strtotime if it is a string.

					if ( $nFieldType == FILTER_TYPE_DATE ) 
					{
						// Convert to FULL Day Date for now!
						$nTimeStamp = is_array($logArray[$szFieldId]) ? (int)$logArray[$szFieldId][EVTIME_TIMESTAMP] : strtotime($logArray[$szFieldId]);
						$myFieldData = date( "Y-m-d", $nTimeStamp !== false ? $nTimeStamp : time() );
					}

else // Just copy the value!
$myFieldData = $logArray[$szFieldId];
Expand Down
8 changes: 4 additions & 4 deletions src/classes/logstreampdo.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1852,20 +1852,20 @@ private function CreateSQLWhereClause()
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'";
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", (int)$myeventtime[EVTIME_TIMESTAMP]) . "'";
}
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_TO )
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " < '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'";
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " < '" . date("Y-m-d H:i:s", (int)$myeventtime[EVTIME_TIMESTAMP]) . "'";
}
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_DATE )
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "' AND " .
$dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " < '" . date("Y-m-d H:i:s", ($myeventtime[EVTIME_TIMESTAMP]+86400) ) . "'";
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", (int)$myeventtime[EVTIME_TIMESTAMP]) . "' AND " .
$dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " < '" . date("Y-m-d H:i:s", (int)$myeventtime[EVTIME_TIMESTAMP] + 86400 ) . "'";
}

break;
Expand Down
2 changes: 1 addition & 1 deletion src/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@
$szOutputCharset = "";

$szOutputFileName = isset($content['period_start_ts'])
? "ExportMessages_" . date('Ymd\THis', $content['period_start_ts']) . "-" . date('Ymd\THis', $content['period_end_ts'])
? "ExportMessages_" . date('Ymd\THis', (int)$content['period_start_ts']) . "-" . date('Ymd\THis', (int)$content['period_end_ts'])
: "ExportMessages";
$szOutputFileExtension = ".txt";
$szOPFieldSeparator = " ";
Expand Down
12 changes: 6 additions & 6 deletions src/include/functions_frontendhelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ function GetFormatedDate($evttimearray, $onExport = false)
($onExport == true && GetConfigSetting("ExportUseTodayYesterday", 0, CFGLEVEL_USER) == 1)
|| (
$onExport == false && GetConfigSetting("ViewUseTodayYesterday", 0, CFGLEVEL_USER) == 1
&& ( date('m', $evttimearray[EVTIME_TIMESTAMP]) == date('m') && date('Y', $evttimearray[EVTIME_TIMESTAMP]) == date('Y') )
&& ( date('m', (int)$evttimearray[EVTIME_TIMESTAMP]) == date('m') && date('Y', (int)$evttimearray[EVTIME_TIMESTAMP]) == date('Y') )
)
)
{
if ( date('d', $evttimearray[EVTIME_TIMESTAMP]) == date('d') )
return "Today " . date("H:i:s", $evttimearray[EVTIME_TIMESTAMP] );
else if ( date('d', $evttimearray[EVTIME_TIMESTAMP] + 86400) == date('d') )
return "Yesterday " . date("H:i:s", $evttimearray[EVTIME_TIMESTAMP] );
if ( date('d', (int)$evttimearray[EVTIME_TIMESTAMP]) == date('d') )
return "Today " . date("H:i:s", (int)$evttimearray[EVTIME_TIMESTAMP] );
else if ( date('d', (int)$evttimearray[EVTIME_TIMESTAMP] + 86400) == date('d') )
return "Yesterday " . date("H:i:s", (int)$evttimearray[EVTIME_TIMESTAMP] );
}

// Copy to local variable
Expand All @@ -251,7 +251,7 @@ function GetFormatedDate($evttimearray, $onExport = false)
}

// Reach return normal format!
return $szDateFormatted = date("Y-m-d H:i:s", $nMyTimeStamp );
return $szDateFormatted = date("Y-m-d H:i:s", (int)$nMyTimeStamp );
}

function GetDebugBgColor( $szDebugMode )
Expand Down
Loading