<?php

include __DIR__ . '/common.php';
use Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\k8281faec2a4a41f470b00112682ddabf;
use Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2;
$from_date = \date(\Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::DATETIME_FORMAT, \time() - \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\k8281faec2a4a41f470b00112682ddabf::getSafe('events_messages_ttl', 14) * 24 * 60 * 60);
$from_id = \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->select('max(id) as max_id')->from('events')->where(['eventtime<' => $from_date])->get()->first('max_id');
if ($from_id) {
    \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->delete('events', ['id<' => $from_id]);
}
$from_date = \date('Y-m-d H:i:s', \time() - \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\k8281faec2a4a41f470b00112682ddabf::getSafe('user_log_ttl', 1) * 24 * 60 * 60);
$from_id = \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->select('max(id) as max_id')->from('user_log')->where(['time<' => $from_date])->get()->first('max_id');
if ($from_id) {
    \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->delete('user_log', ['id<' => $from_id]);
    if (\Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\k8281faec2a4a41f470b00112682ddabf::getSafe('use_optimize_table', \true)) {
        \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->query('optimize table user_log');
    }
}
$from_time = \date('Y-m-d H:i:s', \strtotime('-1 month'));
$from_id = \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->select('max(id) as max_id')->from('readed_anec')->where(['readed<' => $from_time])->get()->first('max_id');
if ($from_id) {
    \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->delete('readed_anec', ['id<' => $from_id]);
}
echo 1;
