2603.8 purging old records
This commit is contained in:
@@ -181,6 +181,38 @@ function run_fetch(): array {
|
||||
return $results;
|
||||
}
|
||||
|
||||
// ── Settings ──────────────────────────────────────────────────────────────────
|
||||
|
||||
function get_setting(string $key, string $default = ''): string {
|
||||
$s = db()->prepare('SELECT value FROM settings WHERE key_name = ?');
|
||||
$s->execute([$key]);
|
||||
$row = $s->fetchColumn();
|
||||
return $row !== false ? $row : $default;
|
||||
}
|
||||
|
||||
function set_setting(string $key, string $value): void {
|
||||
$s = db()->prepare(
|
||||
'INSERT INTO settings (key_name, value) VALUES (?, ?)
|
||||
ON DUPLICATE KEY UPDATE value = VALUES(value)'
|
||||
);
|
||||
$s->execute([$key, $value]);
|
||||
}
|
||||
|
||||
// ── Purge ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Delete connections older than retention_days setting.
|
||||
* Returns the number of rows deleted.
|
||||
*/
|
||||
function purge_old_connections(): int {
|
||||
$days = max(1, (int)get_setting('retention_days', '7'));
|
||||
$s = db()->prepare(
|
||||
'DELETE FROM connections WHERE occurred_at < NOW() - INTERVAL ? DAY'
|
||||
);
|
||||
$s->execute([$days]);
|
||||
return $s->rowCount();
|
||||
}
|
||||
|
||||
// ── Upstream version check ────────────────────────────────────────────────────
|
||||
|
||||
define('UPSTREAM_VERSION_URL', 'https://git.ny.daprogs.com/api/v1/repos/DAProgs/portspoof_concentrator/raw/version.php?ref=main');
|
||||
|
||||
@@ -56,7 +56,7 @@ code { font-family: 'Cascadia Code', 'Fira Mono', monospace; font-size: .8rem; c
|
||||
|
||||
label { display: block; margin-bottom: .75rem; font-size: .85rem; color: var(--muted); }
|
||||
label.inline { display: flex; align-items: center; gap: .5rem; color: var(--text); }
|
||||
label input[type=text], label input[type=url], label input[type=password] {
|
||||
label input[type=text], label input[type=url], label input[type=password], label input[type=number] {
|
||||
display: block; width: 100%; margin-top: .3rem;
|
||||
background: var(--bg); border: 1px solid var(--border); border-radius: 5px;
|
||||
color: var(--text); padding: .45rem .6rem; font-size: .9rem;
|
||||
|
||||
Reference in New Issue
Block a user