From 05bb562726c7406f93ccf2fa8a31c9aace9d9968 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 3 Dec 2025 17:38:09 +0000 Subject: [PATCH] feat: Make homepage apps configurable - Adds a `homepage_apps` array to the config file to allow for easy customization of the homepage app blocks. - Refactors the homepage to dynamically generate the app blocks from the configuration. - Includes a fallback to a default set of apps if the configuration is not present. - Removes the use of `eval()` for conditional app display and replaces it with a secure, hardcoded mapping. - Adds back tooltips for the "Dapps" and "Exchange" apps. --- config/config.default.php | 36 +++++++++++++++++++ web/index.php | 74 ++++++++++++++++++++++----------------- 2 files changed, 77 insertions(+), 33 deletions(-) diff --git a/config/config.default.php b/config/config.default.php index ffd57be7..93c6b3d2 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -104,3 +104,39 @@ // set server to maintenance mode //$_config['maintenance']=1; + +$_config['homepage_apps'] = [ + "explorer" => [ + "title" => "Explorer", + "url" => "/apps/explorer", + "icon" => "fas fa-binoculars", + "condition" => true + ], + "miner" => [ + "title" => "Miner", + "url" => "/apps/miner", + "icon" => "fas fa-hammer", + "condition" => "miner_enabled" + ], + "dapps" => [ + "title" => "Dapps", + "url" => "/dapps.php?url={dapps_id}", + "icon" => "fas fa-cubes", + "condition" => "dapps_enabled", + "tooltip" => "Decentralized apps" + ], + "exchange" => [ + "title" => "Exchange", + "url" => "https://klingex.io/trade/PHP-USDT?ref=3436CA42", + "icon" => "https://klingex.io/symbol.svg", + "target" => "_blank", + "condition" => true, + "tooltip" => "Exchange" + ], + "docs" => [ + "title" => "Docs", + "url" => "/apps/docs", + "icon" => "fas fa-file-alt", + "condition" => true + ] +]; diff --git a/web/index.php b/web/index.php index 4dc692e8..9423a22b 100755 --- a/web/index.php +++ b/web/index.php @@ -114,45 +114,53 @@
-
- -
- -
- -
- - [ + "title" => "Explorer", + "url" => "/apps/explorer", + "icon" => "fas fa-binoculars", + "condition" => true + ] + ]; + } + foreach ($_config['homepage_apps'] as $app) { + $condition = $app['condition']; + if ($condition !== true) { + $show = false; + if ($condition == "miner_enabled") { + $show = Nodeutil::miningEnabled(); + } else if ($condition == "dapps_enabled") { + $show = Dapps::isEnabled() && !empty($_config['dapps_public_key']); + } + if(!$show) { + continue; + } + } + $url = $app['url']; + if (strpos($url, '{dapps_id}') !== false) { + $dapps_id = Account::getAddress($_config['dapps_public_key']); + $url = str_replace('{dapps_id}', $dapps_id, $url); + } + $target = isset($app['target']) ? 'target="'.$app['target'].'"' : ''; + $tooltip = isset($app['tooltip']) ? 'data-bs-toggle="tooltip" title="'.$app['tooltip'].'"' : ''; + $icon = $app['icon']; + if (strpos($icon, 'http') === 0) { + $iconHtml = ''; + } else { + $iconHtml = ''; + } ?>
- -