From f81be9e0479d074cce1a08eebd91952cc734ae0a Mon Sep 17 00:00:00 2001 From: Edwin Noorlander Date: Tue, 28 Jul 2026 16:56:51 +0200 Subject: [PATCH] Fix newest homepage detection, file creation dates, real IP, and request log visitor type - Fix detectNewestPage() to search subdirectories recursively and handle language prefixes - Fix getFileInfo() to preserve frontmatter created date or ctime instead of overwriting with mtime - Automatically store created date in frontmatter when creating/editing files - Add RequestLogger::getClientIp() with proxy and Cloudflare header support - Replace domain column in request log with visitor/bot type badges (Human, AI, Search, Scraper) - Update 'Activiteitenlog' to 'Activiteiten log' in UI and guide --- admin/src/AdminAuth.php | 9 ++- admin/templates/pages/dashboard.php | 16 ++-- admin/templates/pages/logs.php | 12 ++- cms/core/class/CodePressCMS.php | 105 +++++++++++++++++++++++-- cms/core/class/RequestLogger.php | 117 +++++++++++++++++++++++++++- config.json | 2 +- guide/nl.codepress.md | 4 +- public/admin.php | 26 ++----- public/index.php | 9 ++- 9 files changed, 256 insertions(+), 44 deletions(-) diff --git a/admin/src/AdminAuth.php b/admin/src/AdminAuth.php index 5699db2..6789878 100644 --- a/admin/src/AdminAuth.php +++ b/admin/src/AdminAuth.php @@ -304,7 +304,14 @@ class AdminAuth mkdir($dir, 0755, true); } $timestamp = date('Y-m-d H:i:s'); - $ip = $_SERVER['REMOTE_ADDR'] ?? 'cli'; + if (class_exists('RequestLogger')) { + $ip = RequestLogger::getClientIp(); + } else { + $ip = $_SERVER['HTTP_CF_CONNECTING_IP'] ?? $_SERVER['HTTP_X_REAL_IP'] ?? $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? 'cli'; + if (($commaPos = strpos($ip, ',')) !== false) { + $ip = trim(substr($ip, 0, $commaPos)); + } + } file_put_contents($logFile, "[{$timestamp}] [{$level}] [{$ip}] {$message}\n", FILE_APPEND); } } diff --git a/admin/templates/pages/dashboard.php b/admin/templates/pages/dashboard.php index 6ee80c8..8d219fc 100644 --- a/admin/templates/pages/dashboard.php +++ b/admin/templates/pages/dashboard.php @@ -100,12 +100,16 @@