feat: auto-generate coingecko.json on first run

Added logic to check for the existence of 'coingecko.json' and generate it by executing 'coingecko.php' if it doesn't exist. This ensures that the necessary data file is available on first run, preventing potential errors or missing data.
This commit is contained in:
Kumi 2024-08-28 15:20:33 +02:00
parent 57a7bca599
commit 90f6f6ce3e
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -9,6 +9,12 @@ $currentUrl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$parentUrl = dirname($currentUrl);
// Get currency data from JSON
if (!file_exists('coingecko.json')) {
// Special case: First run.
exec('php coingecko.php');
sleep(1);
}
$api_cg = json_decode(file_get_contents('coingecko.json'), true);
// Configuration file