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.
This commit is contained in:
parent
49be7374b1
commit
5747f73c68
1 changed files with 11 additions and 12 deletions
23
index.php
23
index.php
|
@ -7,6 +7,17 @@ header("Pragma: no-cache");
|
||||||
// Get currency data from JSON
|
// Get currency data from JSON
|
||||||
$api_cg = json_decode(file_get_contents('coingecko.json'), true);
|
$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
|
// Extract the keys
|
||||||
$currencies = array_map('strtoupper', array_keys($api_cg));
|
$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, ",", " ");
|
$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
|
// Order preferred currencies to the top
|
||||||
foreach (array_reverse($preferred_currencies) as $currency) {
|
foreach (array_reverse($preferred_currencies) as $currency) {
|
||||||
$currency = strtoupper($currency);
|
$currency = strtoupper($currency);
|
||||||
|
|
Loading…
Reference in a new issue