33 lines
888 B
PHP
33 lines
888 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace sammo;
|
|
|
|
if (PHP_SAPI !== 'cli' || getenv('REF_DETERMINISTIC_INSTALL_ENABLED') !== '1') {
|
|
http_response_code(404);
|
|
exit(1);
|
|
}
|
|
|
|
chdir(dirname(__DIR__));
|
|
require_once 'lib.php';
|
|
|
|
$rows = DB::db()->query(
|
|
'SELECT general_id, log_type, year, month, text
|
|
FROM general_record
|
|
WHERE log_type IN ("battle_brief", "battle")
|
|
ORDER BY id'
|
|
);
|
|
|
|
echo json_encode([
|
|
'schemaVersion' => 1,
|
|
'engine' => 'ref',
|
|
'logs' => array_map(static fn(array $row): array => [
|
|
'generalId' => (int)$row['general_id'],
|
|
'category' => $row['log_type'] === 'battle_brief' ? 'BATTLE_BRIEF' : 'BATTLE_DETAIL',
|
|
'year' => (int)$row['year'],
|
|
'month' => (int)$row['month'],
|
|
'text' => (string)$row['text'],
|
|
], $rows),
|
|
], JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), PHP_EOL;
|