game/cron/battle_optimize.php

22 lines
733 B
PHP

<?php
/** Îïòèìèçèðîâàíî.
* ×èñòêà è ñáðîñ ñ÷åò÷èêîâ ïðè îòñóòñòâèè áîåâ ÷òîá íå ëàìàëñÿ ëîã.
* @var PDO $pdo
* @author Insallah
*/
const GAME = true;
define('DAY', 24 * 60 * 60);
include('/home/newcom1/public_html/_incl_data/class/__db_connect.php');
$tables = ['battle_end', 'battle_last', 'battle_out', 'battle_stat', 'battle_logs', 'battle_logs_save'];
$q = [
'delete from battle_users where time_enter < unix_timestamp() - ? and time_enter != 0',
'delete from battle where time_over < unix_timestamp() - ? and time_over != 0',
];
foreach ($tables as $table) {
$pdo->prepare("delete from $table where time < unix_timestamp() - ?")->execute(DAY);
}
$pdo->prepare($q[0])->execute(DAY);
$pdo->prepare($q[1])->execute(DAY);