<?php
$cfg = json_decode(file_get_contents(__DIR__ . '/core/config.json'), true);
$pdo = new PDO('mysql:host=' . $cfg['db_host'] . ';dbname=' . $cfg['db_name'] . ';charset=utf8mb4', $cfg['db_user'], $cfg['db_pass']);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$used = [
    'all_pass_pages', 'charts_pages', 'cms_pages', 'cms_settings', 'daily_results', 'dpboss_weekly_data',
    'free_game', 'games', 'media', 'menu_items', 'pages', 'plugins', 'predefined_panels', 'results',
    'settings', 'themes', 'users', 'weekly_chart_guesses'
];
$current = [];
foreach ($pdo->query('SHOW TABLES') as $row) {
    $current[] = (string) reset($row);
}
sort($current);
$unused = array_values(array_diff($current, $used));
foreach ($unused as $table) {
    $count = (int) $pdo->query('SELECT COUNT(*) FROM `' . str_replace('`', '``', $table) . '`')->fetchColumn();
    echo $table . '|' . $count . PHP_EOL;
}
