mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-08-28 14:11:08 -05:00
This is the first step in replacing them (#2723). Since this step doesn't involve any breaking changes, I'm just pushing it directly. At some point, you will want to run: php build-tools/config-to-json.php to migrate your own files over. It only needs to be run once, at any time, though.
33 lines
1.1 KiB
PHP
33 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* One-time migration: generates config/news.json and config/servers.json from
|
|
* their .inc.php equivalents.
|
|
*
|
|
* From here on, saveNews() in pokemonshowdown.com/news/manage.php and
|
|
* saveservers() in pokemonshowdown.com/servers/servers.lib.php write both
|
|
* formats, so this only needs to be run once (but it's safe to re-run).
|
|
*/
|
|
|
|
$configdir = __DIR__ . '/../config';
|
|
$jsonflags = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
|
|
|
|
if (file_exists("$configdir/news.inc.php")) {
|
|
include "$configdir/news.inc.php";
|
|
file_put_contents("$configdir/news.json", json_encode([
|
|
'latest' => array_values($latestNewsCache),
|
|
'news' => (object)$newsCache,
|
|
], $jsonflags));
|
|
echo "wrote config/news.json\n";
|
|
} else {
|
|
echo "config/news.inc.php not found, skipping\n";
|
|
}
|
|
|
|
if (file_exists("$configdir/servers.inc.php")) {
|
|
include "$configdir/servers.inc.php";
|
|
file_put_contents("$configdir/servers.json", json_encode((object)$PokemonServers, $jsonflags));
|
|
echo "wrote config/servers.json\n";
|
|
} else {
|
|
echo "config/servers.inc.php not found, skipping\n";
|
|
}
|