diff --git a/config/config-sample.inc.php b/config/config-sample.inc.php index 960542fe..a848fb4b 100755 --- a/config/config-sample.inc.php +++ b/config/config-sample.inc.php @@ -71,3 +71,25 @@ $_config['dapps_private_key']=""; $_config['dapps_anonymous']=false; $_config['dapps_disable_auto_propagate']=true; + +/** + * Homepage Customization + */ +/* +$_config['homepage_apps'] = [ + "explorer" => [ + "title" => "Explorer", + "url" => "/apps/explorer", + "icon_type" => "fa", + "icon" => "fas fa-binoculars", + "condition" => true + ], + "docs" => [ + "title" => "Docs", + "url" => "/apps/docs", + "icon_type" => "fa", + "icon" => "fas fa-file-alt", + "condition" => true + ] +]; +*/ diff --git a/config/config.default.php b/config/config.default.php index ffd57be7..9059ea82 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -104,3 +104,44 @@ // set server to maintenance mode //$_config['maintenance']=1; + +$_config['homepage_apps'] = [ + "explorer" => [ + "title" => "Explorer", + "url" => "/apps/explorer", + "icon_type" => "fa", + "icon" => "fas fa-binoculars", + "condition" => true + ], + "miner" => [ + "title" => "Miner", + "url" => "/apps/miner", + "icon_type" => "fa", + "icon" => "fas fa-hammer", + "condition" => "miner_enabled" + ], + "dapps" => [ + "title" => "Dapps", + "url" => "/dapps.php?url={dapps_id}", + "icon_type" => "fa", + "icon" => "fas fa-cubes", + "condition" => "dapps_enabled", + "tooltip" => "Decentralized apps" + ], + "exchange" => [ + "title" => "Exchange", + "url" => "https://klingex.io/trade/PHP-USDT?ref=3436CA42", + "icon_type" => "img", + "icon" => "https://klingex.io/symbol.svg", + "target" => "_blank", + "condition" => true, + "tooltip" => "Exchange" + ], + "docs" => [ + "title" => "Docs", + "url" => "/apps/docs", + "icon_type" => "fa", + "icon" => "fas fa-file-alt", + "condition" => true + ] +]; diff --git a/docs/node-admin/configuration.md b/docs/node-admin/configuration.md new file mode 100644 index 00000000..4da619f4 --- /dev/null +++ b/docs/node-admin/configuration.md @@ -0,0 +1,251 @@ +# Node Configuration Guide + +This guide provides a comprehensive overview of the configuration system for your node. Proper configuration is essential for the security, performance, and functionality of your node. + +## The Configuration System + +The node uses a multi-file system to manage its configuration, ensuring that your custom settings are not overwritten during updates. + +- **`config/config.default.php`**: This file contains all the default settings for the node. **You should not edit this file directly.** It serves as a template and a reference for all available configuration options. +- **`config/config.inc.php`**: This is where you should place your custom settings. Create this file if it doesn't exist. Any setting you define in this file will override the corresponding default setting from `config.default.php`. + +To customize your node's configuration, copy the relevant settings from `config.default.php` to `config.inc.php` and modify their values. + +--- + +## General Settings + +### `chain_id` +- **Description**: A unique identifier for the blockchain. This helps differentiate between mainnet, testnet, or private chains. +- **Default**: The value from the `chain_id` file at the root of the project. +- **Example**: `$_config['chain_id'] = 'mainnet';` + +### `db_connect` +- **Description**: The database connection string (DSN) for connecting to your MySQL database. +- **Default**: `'mysql:host=localhost;dbname=phpcoin;charset=utf8'` +- **Example**: `$_config['db_connect'] = 'mysql:host=127.0.0.1;dbname=my_phpcoin;charset=utf8mb4';` + +### `db_user` +- **Description**: The username for your MySQL database. +- **Default**: `'phpcoin'` + +### `db_pass` +- **Description**: The password for your MySQL database. +- **Default**: `'phpcoin'` + +--- + +## API and Peering + +### `public_api` +- **Description**: If `true`, allows any remote host to connect to your node's API. If `false`, only hosts listed in `allowed_hosts` can connect. +- **Default**: `true` + +### `allowed_hosts` +- **Description**: A list of IP addresses or hostnames that are allowed to mine on this node or connect to the API if `public_api` is `false`. `*` allows all hosts. +- **Default**: `['*']` +- **Example**: `$_config['allowed_hosts'] = ['192.168.1.100', 'mynode.local'];` + +### `initial_peer_list` +- **Description**: A list of trusted initial peers to connect to and sync the blockchain from when your node first starts. +- **Default**: A list of official PHPCoin nodes. + +### `passive_peering` +- **Description**: If `true`, your node will not actively seek out new peers. It will only use the `initial_peer_list` for syncing. This typically requires a cron job on `sync.php`. +- **Default**: `false` + +### `peers_limit` +- **Description**: The maximum number of peers your node will propagate blocks and transactions to. +- **Default**: `30` + +### `offline` +- **Description**: If `true`, your node will run in offline mode. It will not send or receive any peer requests. +- **Default**: `false` + +### `proxy` +- **Description**: If you need to use a proxy for outgoing peer requests, define it here. +- **Default**: `null` +- **Example**: `$_config['proxy'] = 'socks5://127.0.0.1:9050';` + +### `peer_max_mempool` +- **Description**: The maximum number of transactions your node will accept into its mempool from a single peer during a sync. +- **Default**: `100` + +### `use_official_blacklist` +- **Description**: If `true`, your node will block transfers from addresses that have been blacklisted by the PHPCoin developers. +- **Default**: `true` + +### `sync_recheck_blocks` +- **Description**: The number of recent blocks to re-check during a sync to ensure chain integrity. +- **Default**: `10` + +### `allow_hostname_change` +- **Description**: Set to `true` only if you need to change your node's public hostname. +- **Default**: `false` + +--- + +## Logging + +### `enable_logging` +- **Description**: If `true`, enables logging to the file specified in `log_file`. +- **Default**: `true` + +### `log_file` +- **Description**: The path to the log file. This file should not be publicly accessible via the web. +- **Default**: `'tmp/phpcoin.log'` + +### `log_verbosity` +- **Description**: The level of detail for logs. `0` is the default, and `5` is the most verbose. +- **Default**: `0` + +### `server_log` +- **Description**: If `true`, logs will be sent to the web server's error log (e.g., Apache's `error_log`). +- **Default**: `false` + +--- + +## Miner and Generator + +### `miner` +- **Description**: Set to `true` to enable the mining functionality on your node. +- **Default**: `false` + +### `miner_public_key` / `miner_private_key` +- **Description**: The public and private keys for your miner. The public key is used to receive mining rewards. +- **Default**: `""` + +### `miner_cpu` +- **Description**: The number of CPU cores to use for mining. `0` attempts to auto-detect. +- **Default**: `0` + +### `generator` +- **Description**: Set to `true` to enable block generation (forging). +- **Default**: `false` + +### `generator_public_key` / `generator_private_key` +- **Description**: The public and private keys for your block generator. +- **Default**: `""` + +--- + +## Node Administration + +### `admin` +- **Description**: Set to `true` to enable the web-based administration panel. +- **Default**: `false` + +### `admin_password` +- **Description**: The password for the web admin panel. +- **Default**: `''` + +### `admin_public_key` +- **Description**: Alternatively, you can specify a public key to log in to the admin panel using its corresponding private key. +- **Default**: `''` + +--- + +## Masternode + +### `masternode` +- **Description**: Set to `true` to enable masternode functionality. +- **Default**: `false` + +### `masternode_public_key` / `masternode_private_key` +- **Description**: The public and private keys for your masternode. +- **Default**: `""` + +--- + +## Dapps (Decentralized Apps) + +### `dapps` +- **Description**: Set to `true` to enable support for Dapps. +- **Default**: `false` + +### `dapps_public_key` / `dapps_private_key` +- **Description**: The public and private keys for your Dapps identity. +- **Default**: `""` + +### `dapps_anonymous` +- **Description**: If `true`, allows Dapps to be used anonymously. +- **Default**: `false` + +### `dapps_disable_auto_propagate` +- **Description**: If `true`, disables the automatic propagation of Dapps data. +- **Default**: `true` + +--- + +## Homepage Customization + +### `homepage_apps` + +This setting allows you to fully customize the clickable application blocks on your node's homepage. It is an associative array where each key is a unique identifier for an app, and the value is another array containing the app's properties. + +To customize the apps, you should copy the entire `homepage_apps` array from `config.default.php` into your `config.inc.php` file and then make your modifications. + +#### App Properties + +Each app in the array supports the following properties: + +- `title`: (string, required) The text displayed on the app block. +- `url`: (string, required) The URL the app block links to. +- `icon_type`: (string, required) The type of icon. Supported values are: + - `'fa'`: For a Font Awesome icon. + - `'img'`: For an image URL. +- `icon`: (string, required) The icon identifier. + - If `icon_type` is `'fa'`, this should be the Font Awesome class (e.g., `fas fa-binoculars`). + - If `icon_type` is `'img'`, this should be the full URL to the image. +- `condition`: (mixed, required) Determines if the app block is displayed. + - `true`: The app is always displayed. + - `'miner_enabled'`: The app is displayed only if mining is enabled on the node (`$_config['miner']` is true). + - `'dapps_enabled'`: The app is displayed only if Dapps are enabled (`$_config['dapps']` is true and a public key is set). +- `target`: (string, optional) The `target` attribute for the link. Use `'_blank'` to open the link in a new tab. +- `tooltip`: (string, optional) Text to display as a tooltip when the user hovers over the app block. + +#### Customization Examples + +**1. Adding a New App** + +To add a new link, simply add a new key-value pair to the array in your `config.inc.php`. + +```php +$_config['homepage_apps']['my-explorer'] = [ + "title" => "My Explorer", + "url" => "https://my-custom-explorer.com", + "icon_type" => "fa", + "icon" => "fas fa-search", + "condition" => true, + "target" => "_blank" +]; +``` + +**2. Removing an App** + +To remove an app, you can either delete its entry from the array in your `config.inc.php` or comment it out. + +```php +$_config['homepage_apps'] = [ + "explorer" => [ + // ... explorer config + ], + // The "Exchange" app is now disabled + // "exchange" => [ + // "title" => "Exchange", + // "url" => "https://klingex.io/trade/PHP-USDT?ref=3436CA42", + // "icon_type" => "img", + // "icon" => "https://klingex.io/symbol.svg", + // "target" => "_blank", + // "condition" => true, + // "tooltip" => "Exchange" + // ], + "docs" => [ + // ... docs config + ] +]; +``` + +**3. Reordering Apps** + +The apps appear in the order they are defined in the array. To change the order, simply rearrange the blocks of code in your `config.inc.php`. diff --git a/web/index.php b/web/index.php index 4dc692e8..8787c83c 100755 --- a/web/index.php +++ b/web/index.php @@ -114,45 +114,55 @@
-
- -
- -
- -
- - [ + "title" => "Explorer", + "url" => "/apps/explorer", + "icon_type" => "fa", + "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']; + $icon_type = isset($app['icon_type']) ? $app['icon_type'] : 'fa'; + if ($icon_type === 'img') { + $iconHtml = ''; + } else { + $iconHtml = ''; + } ?>
- -