From 8a2d727659296e20f0b6f34b8ca0615ca3005502 Mon Sep 17 00:00:00 2001 From: novgorodschi catalin Date: Thu, 23 Jul 2026 11:49:27 +0300 Subject: [PATCH] Last Phase before v11 release. New Automation Cleanup Last Phase before v11 release. New Automation Cleanup --- Admin/Templates/config.tpl | 32 +++++ Admin/Templates/editCronSet.tpl | 50 +++++++ GameEngine/Admin/Mods/config_template.php | 18 +++ GameEngine/Admin/Mods/editCronSet.php | 25 +++- GameEngine/Automation.php | 6 +- GameEngine/Automation/AutomationCleanup.php | 141 ++++++++++++++++++++ Templates/footer.tpl | 2 +- install/data/constant_format.tpl | 12 ++ install/process.php | 5 + 9 files changed, 288 insertions(+), 3 deletions(-) create mode 100644 GameEngine/Automation/AutomationCleanup.php diff --git a/Admin/Templates/config.tpl b/Admin/Templates/config.tpl index 4a2df605..8526f49b 100644 --- a/Admin/Templates/config.tpl +++ b/Admin/Templates/config.tpl @@ -113,6 +113,12 @@ $cronKey = defined('CRON_KEY') ? (string) CRON_KEY : ''; $cronBase = defined('HOMEPAGE') ? rtrim(HOMEPAGE, '/') : ''; $cronUrl = ($cronBase !== '' && $cronKey !== '') ? $cronBase . '/cron.php?key=' . $cronKey : ''; +$cleanReports = defined('CLEANUP_REPORTS_DAYS') ? (int) CLEANUP_REPORTS_DAYS : 14; +$cleanChat = defined('CLEANUP_CHAT_DAYS') ? (int) CLEANUP_CHAT_DAYS : 7; +$cleanMessages = defined('CLEANUP_MESSAGES_DAYS') ? (int) CLEANUP_MESSAGES_DAYS : 0; +$cleanupMarker = __DIR__ . '/../../GameEngine/Prevention/cleanup_last.txt'; +$cleanupInfo = @is_file($cleanupMarker) ? @json_decode((string) @file_get_contents($cleanupMarker), true) : null; + $cronPath = realpath(__DIR__ . '/../../cron.php'); $cronCmd = $cronPath ? '*/5 * * * * /usr/local/bin/php ' . $cronPath . ' >/dev/null 2>&1' : ''; @@ -175,6 +181,32 @@ $cronKeyMasked = ($cronKey === '') + + Database cleanup ?Automation trims tables that would otherwise grow forever. Archived reports are never deleted. 0 disables a rule. + 0 ? $cleanReports . 'd' : 'off'); + $parts[] = 'chat: ' . ($cleanChat > 0 ? $cleanChat . 'd' : 'off'); + $parts[] = 'deleted messages: ' . ($cleanMessages > 0 ? $cleanMessages . 'd' : 'off'); + echo implode('  |  ', $parts); + ?> + + + + Last cleanup run ?Cleanup runs once per hour from Automation and deletes in batches, so a first run on an old server catches up over several passes. + (' . (int) ($r['reports'] ?? 0) . ' reports, ' + . (int) ($r['chat'] ?? 0) . ' chat, ' + . (int) ($r['messages'] ?? 0) . ' messages)'; + } else { + echo "Not run yet"; + } + ?> + + Cron job command ?Add this in cPanel → Cron Jobs. The path is detected from this installation. diff --git a/Admin/Templates/editCronSet.tpl b/Admin/Templates/editCronSet.tpl index b3bc22ee..bf20ce69 100644 --- a/Admin/Templates/editCronSet.tpl +++ b/Admin/Templates/editCronSet.tpl @@ -27,6 +27,13 @@ $cronLoop = defined('CRON_LOOP_SECONDS') ? (int) CRON_LOOP_SECONDS : 300; $cronTick = defined('CRON_TICK_SECONDS') ? (int) CRON_TICK_SECONDS : 60; $cronKey = defined('CRON_KEY') ? (string) CRON_KEY : ''; +$cleanReports = defined('CLEANUP_REPORTS_DAYS') ? (int) CLEANUP_REPORTS_DAYS : 14; +$cleanChat = defined('CLEANUP_CHAT_DAYS') ? (int) CLEANUP_CHAT_DAYS : 7; +$cleanMessages = defined('CLEANUP_MESSAGES_DAYS') ? (int) CLEANUP_MESSAGES_DAYS : 0; + +$cleanupMarker = __DIR__ . '/../../GameEngine/Prevention/cleanup_last.txt'; +$cleanupInfo = @is_file($cleanupMarker) ? @json_decode((string) @file_get_contents($cleanupMarker), true) : null; + $cronPath = realpath(__DIR__ . '/../../cron.php'); $cronCmd = $cronPath ? '*/5 * * * * /usr/local/bin/php ' . $cronPath . ' >> ' . dirname(dirname($cronPath)) . '/cron.log 2>&1' : ''; ?> @@ -132,6 +139,49 @@ code{background:#f1f5f9;padding:2px 5px;border-radius:4px;font-size:11px;word-br +
+
Database cleanup
+ + + + + + + + + + + + + + + + + +
Last cleanup run(removed: ' + . (int) ($r['reports'] ?? 0) . ' reports, ' + . (int) ($r['chat'] ?? 0) . ' chat, ' + . (int) ($r['messages'] ?? 0) . ' messages)'; + } else { + echo "Not run yet"; + } + ?> + Runs from Automation once per hour. Rows are removed in batches, so the first run on an old server catches up over several passes.
Battle reports (days) + ?Unarchived reports older than this are deleted. Reports a player archived are never touched. 0 disables the rule. + + 0 = keep forever.
Chat messages (days) + ?The chat window only ever shows the last 13 messages per alliance, so older history is not used anywhere in the game. + + 0 = keep forever.
Deleted messages (days) + ?Only messages deleted by BOTH the sender and the recipient are removed — they are no longer visible to anyone in the game. Disabled by default. + + 0 = disabled (default).
+
+