403Webshell
Server IP : 213.255.246.8  /  Your IP : 216.73.217.178
Web Server : Apache
System : Linux dublin.stapolin.com 5.14.0-362.18.1.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jan 29 07:05:48 EST 2024 x86_64
User : stapolin ( 1019)
PHP Version : 8.4.24
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/stapolin/public_html/tracking.stapolin.com/cron/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/stapolin/public_html/tracking.stapolin.com/cron/cleanup_old_data.php
<?php

declare(strict_types=1);

require_once __DIR__ . '/../includes/cron.php';

run_cron_job('cleanup_old_data', function (): string {
    $websites = db_fetch_all('SELECT id, retention_days FROM websites WHERE status != "archived"');
    $deleted = 0;
    foreach ($websites as $website) {
        $cutoff = gmdate('Y-m-d H:i:s', time() - (int) $website['retention_days'] * 86400);
        $websiteId = (int) $website['id'];

        $stmt = db_execute('DELETE FROM events WHERE website_id = ? AND occurred_at < ? LIMIT 5000', 'is', [$websiteId, $cutoff]);
        $deleted += $stmt->affected_rows;

        $stmt = db_execute('DELETE FROM page_views WHERE website_id = ? AND entered_at < ? LIMIT 5000', 'is', [$websiteId, $cutoff]);
        $deleted += $stmt->affected_rows;

        $stmt = db_execute('DELETE FROM sessions WHERE website_id = ? AND started_at < ? LIMIT 5000', 'is', [$websiteId, $cutoff]);
        $deleted += $stmt->affected_rows;

        $stmt = db_execute('DELETE FROM visitors WHERE website_id = ? AND last_seen_at < ? LIMIT 5000', 'is', [$websiteId, $cutoff]);
        $deleted += $stmt->affected_rows;

        $stmt = db_execute('DELETE FROM tracking_errors WHERE website_id = ? AND created_at < ? LIMIT 5000', 'is', [$websiteId, $cutoff]);
        $deleted += $stmt->affected_rows;
    }
    return $deleted . ' old records removed';
});

Youez - 2016 - github.com/yon3zu
LinuXploit