<?php
require_once(htmlentities($_SERVER['DOCUMENT_ROOT']) . '/public/assets/php/definitions.php');

// Create connection
$conn = new mysqli(PACKAGE_LOG_DB_SERVER, PACKAGE_LOG_DB_USER, PACKAGE_LOG_DB_PASS, PACKAGE_LOG_DB_NAME);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Delete entries older than 7 days
$sql = "DELETE FROM signature WHERE timestamp < NOW() - INTERVAL 30 DAY";

if ($conn->query($sql) === TRUE) {
    echo "Old entries deleted successfully.\n";
} else {
    echo "Error deleting entries: " . $conn->error . "\n";
}

$conn->close();
?>