diff options
| author | Christoph Brill <opensource@christophbrill.de> | 2026-08-03 00:51:33 +0200 |
|---|---|---|
| committer | Christoph Brill <opensource@christophbrill.de> | 2026-08-03 00:51:33 +0200 |
| commit | baca6ebbd24e7a50740b06aa83f960a48adadb58 (patch) | |
| tree | d240973f1c786db88b7cb08aa5f3e069b814b829 | |
| parent | c8aa2270bcdca4b35fe64f5d9c982ae34c5cc3fa (diff) | |
Only linkify the time and user a line starts with
| -rw-r--r-- | details.php | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/details.php b/details.php index 0d0636e..5b9d11d 100644 --- a/details.php +++ b/details.php @@ -61,13 +61,22 @@ foreach (readLog(LOG_DIR.$filename) as $line) { // while searching it in the values grows linearly with the log if (!isset($timehashes[$time])) { $time_link = '<a class="time inherit" name="t-'.str_replace(':', '', $time).'">'.$time.'</a>'; - $line = str_replace($time, $time_link, $line); $timehashes[$time] = true; } else { $time_link = '<span class="time">'.$time.'</span>'; - $line = str_replace($time, $time_link, $line); } - echo str_replace($user, $user_link, $line),'<br/>'; + // Only the timestamp the line starts with, a time mentioned in the + // message itself must stay untouched + if ($time !== '' && str_starts_with($line, $time)) { + $line = substr_replace($line, $time_link, 0, strlen($time)); + } + // Same here, only the user the line starts with is turned into a + // link, a user quoted in the message itself is left alone + $user_pos = $user !== '' ? strpos($line, $user) : false; + if ($user_pos !== false) { + $line = substr_replace($line, $user_link, $user_pos, strlen($user)); + } + echo $line, '<br/>'; echo '</span>'; } } |
