From 5747f73c6861f0b7a8aee9c6440a1fa2e1dbb41d Mon Sep 17 00:00:00 2001 From: Kumi Date: Fri, 9 Aug 2024 16:03:30 +0200 Subject: [PATCH] refactor(index.php): move config setup to top of the file Relocated the configuration setup to the top of index.php to improve code clarity and maintainability. This ensures configuration settings are initialized before any other operations, reducing potential for unexpected behaviors and making the code easier to follow. No functional changes introduced. --- index.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/index.php b/index.php index 9ae63bf..4e1e784 100644 --- a/index.php +++ b/index.php @@ -7,6 +7,17 @@ header("Pragma: no-cache"); // Get currency data from JSON $api_cg = json_decode(file_get_contents('coingecko.json'), true); +// Configuration file +$config = []; +if (file_exists('config.php')) { + $config = require 'config.php'; +} + +$display_servers_guru = isset($config['servers_guru']) && $config['servers_guru'] === true; +$attribution = isset($config['attribution']) ? $config['attribution'] : ''; +$preferred_currencies = isset($config['preferred_currencies']) ? $config['preferred_currencies'] : []; +$github_url = isset($config['github_url']) ? $config['github_url'] : 'https://github.com/rottenwheel/moner.ooo/'; + // Extract the keys $currencies = array_map('strtoupper', array_keys($api_cg)); @@ -45,18 +56,6 @@ $xmr_in_fiat = number_format($exchangeRates[$xmr_in], $xmr_in == 'BTC' || $xmr_i $xmr_in_fiat = strtr($xmr_in_fiat, ",", " "); -// Configuration file - -$config = []; -if (file_exists('config.php')) { - $config = require 'config.php'; -} - -$display_servers_guru = isset($config['servers_guru']) && $config['servers_guru'] === true; -$attribution = isset($config['attribution']) ? $config['attribution'] : ''; -$preferred_currencies = isset($config['preferred_currencies']) ? $config['preferred_currencies'] : []; -$github_url = isset($config['github_url']) ? $config['github_url'] : 'https://github.com/rottenwheel/moner.ooo/'; - // Order preferred currencies to the top foreach (array_reverse($preferred_currencies) as $currency) { $currency = strtoupper($currency);