mirror of
https://github.com/rottenwheel/moner.ooo.git
synced 2024-11-09 20:53:46 +01:00
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
23
index.php
23
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);
|
||||
|
Loading…
Reference in New Issue
Block a user