Files
2026-03-13 16:01:19 -04:00

26 lines
732 B
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env php
<?php
/**
* portspoof_concentrator purge cron
*
* Deletes connections older than the retention_days setting.
* Must be run from the command line — exits immediately if called over HTTP.
*
* Recommended crontab entry (once daily at 02:00):
* 0 2 * * * /usr/bin/php /path/to/portspoof_concentrator/cron/purge.php >> /var/log/portspoof_concentrator/purge.log 2>&1
*/
if (PHP_SAPI !== 'cli') {
http_response_code(403);
exit;
}
require_once __DIR__ . '/../includes/functions.php';
$days = max(1, (int)get_setting('retention_days', '7'));
$deleted = purge_old_connections();
echo sprintf("[%s] Purged %d connection(s) older than %d day(s).\n",
date('Y-m-d H:i:s'), $deleted, $days);