MPOS Documentation

repository·master·Indexed 23 days ago

https://github.com/mpos/php-mpos

MPOS is a web-based mining portal for various cryptocurrencies designed to manage pooled mining operations. It features an admin panel, user accounts, worker tracking, and payout systems such as PPS and PPLNS. The system requires a 64-bit OS (Ubuntu, CentOS, RHEL, or Debian), Apache2, PHP 5.4+, MySQL, and memcached. Documentation covers installation via stable or development branches, theme customization, KLogger implementation, SECHASH security settings, Anti-DoS rate limiting, and the Page and Action routing model.

Tokens
2.1K
Snippets
2
Records
16
Agent score
81%

What's inside php-mpos

  1. Install MPOS

    master

    To install MPOS, refer to the Quick Start Guide.

    Branch Selection:

    • Stable: Use the master branch for a well-tested system. Run git checkout master after cloning.
    • Bleeding Edge: Use the development branch for upcoming changes and new features, though it may contain bugs. Simply git clone the repository to use this branch.
  2. Customize MPOS Themes

    master

    MPOS allows for easy theme customization without modifying the backend code, which ensures you can apply upstream updates via git pull without conflicts. To create a new theme:

    1. Create a new theme folder inside templates/.
    2. Create a new site_assets folder inside public/site_assets.
    3. Create your own custom templates (you can copy existing ones from the repository).
    4. Navigate to the Admin Panel and select your new theme folder to activate it.
  3. System Requirements for MPOS

    master

    MPOS is designed for pooled mining only; solo mining is not supported and may cause unexpected behavior. To ensure correct network hashrate displays, a 64-bit system is required.

    Required Software Stack:

    • OS: Ubuntu (12.04/13.04+), CentOS, RHEL, or Debian.
    • Web Server: Apache2 with libapache2-mod-php5.
    • PHP: 5.4+ with the following extensions:
      • php5-json
      • php5-mysqlnd
      • php5-memcached
      • php5-curl
    • Database: MySQL Server (mysql-server).
    • Caching: memcached.
    • Mining/Coin Software: stratum-mining and litecoind.
  4. Understand the Page and Action routing model

    master

    The application uses a hierarchical routing system based on files in the INCLUDE_DIR/pages/ directory:

    1. Pages: A page is identified by a .inc.php file in the pages directory. If no page is specified in $_REQUEST['page'], it defaults to home. If the requested page doesn't exist, it defaults to error.
    2. Actions: Within a page directory, the application looks for sub-directories named after the page. It then searches for .inc.php files within that sub-directory to act as actions. An action is triggered via $_REQUEST['action'].

    Routing Logic:

    • If an action is provided and valid, the application loads: PAGES_DIR/{page}/{action}.inc.php.
    • If no valid action is provided, it loads: PAGES_DIR/{page}.inc.php.

    Constants PAGE and ACTION are defined globally once the routing is resolved.

  5. Configure and use CSRF protection

    master

    When $config['csrf']['enabled'] is true, the application validates CSRF tokens provided in $_REQUEST['ctoken'] against the current session and the requested page.

    • Validation: The $csrftoken->checkBasic() method is used to verify the token.
    • Template Integration: The valid CSRF token for the current page is assigned to the Smarty template variable CTOKEN using $smarty->assign('CTOKEN', $csrftoken->getBasic(session_id(), $arrPages[$page])).
  6. Configure SECHASH security settings

    master

    The application uses a time-based security hash (SECHASH) to validate requests. You can configure this by defining two constants in the entrypoint:

    1. SECURITY: A long string containing special characters used as a salt.
    2. SECHASH_CHECK: A boolean. If true, the application generates a rotating SECHASH based on the current time (allowing a 3-second window for clock drift). If false, it simply checks if SECURITY is defined.

    Note: These must be defined before the bootstrap process.

    define('SECURITY', '*)WT#&YHfd');
    define('SECHASH_CHECK', false);
  7. Configure Anti-DoS rate limiting

    master

    The application includes an Anti-DoS mechanism using Memcache. To use it, ensure $config['memcache']['enabled'] and $config['mc_antidos']['enabled'] are both set to true.

    Key behaviors:

    • API Protection: If $config['mc_antidos']['protect_ajax'] is enabled, specific AJAX/API calls (like getuserbalance, getnavbardata, getdashboarddata, and getuserworkers) are rate-limited separately.
    • Admin Bypass: If $config['mc_antidos']['ignore_admins'] is enabled, users with $_SESSION['USERDATA']['is_admin'] skip rate limiting.
    • Error Handling: If a user exceeds the rate limit, the application can either die() with a message or redirect the user to a specific error page defined in $config['mc_antidos']['error_push_page'].
  8. Enable HTTPS redirection

    master
    The application can force HTTPS connections based on the $config['https_only'] setting. If enabled and the current request is not using HTTPS, the application will issue a Location header redirect to the HTTPS version of the current URL.
  9. Retrieve internal KLogger messages

    master

    KLogger maintains an internal message queue to track its own operational status (e.g., whether a file was opened successfully or if a write failed due to permissions). You can inspect these messages to debug logging issues.

    • getMessages(): Returns the entire array of messages currently in the queue.
    • getMessage(): Returns and removes the last message from the queue.
    • clearMessages(): Empties the message queue.