MPOS Documentation
repository·master·Indexed 23 days ago
https://github.com/mpos/php-mposMPOS 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.
What's inside php-mpos
- To use the template compilation feature, the webserver must have write permissions for the directory used to store compiled templates. If the webserver cannot write to this folder, template compilation will fail.
Install MPOS
masterTo install MPOS, refer to the Quick Start Guide.
Branch Selection:
- Stable: Use the
masterbranch for a well-tested system. Rungit checkout masterafter cloning. - Bleeding Edge: Use the
developmentbranch for upcoming changes and new features, though it may contain bugs. Simplygit clonethe repository to use this branch.
- Stable: Use the
Configure webserver permissions for template caching
masterTo enable template caching, you must ensure that the webserver has write permissions to the directory used for storing cached templates. If the webserver cannot write to this folder, the caching mechanism will fail.Customize MPOS Themes
masterMPOS allows for easy theme customization without modifying the backend code, which ensures you can apply upstream updates via
git pullwithout conflicts. To create a new theme:- Create a new theme folder inside
templates/. - Create a new
site_assetsfolder insidepublic/site_assets. - Create your own custom templates (you can copy existing ones from the repository).
- Navigate to the Admin Panel and select your new theme folder to activate it.
- Create a new theme folder inside
System Requirements for MPOS
masterMPOS 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-jsonphp5-mysqlndphp5-memcachedphp5-curl
- Database: MySQL Server (
mysql-server). - Caching:
memcached. - Mining/Coin Software:
stratum-miningandlitecoind.
Understand the Page and Action routing model
masterThe application uses a hierarchical routing system based on files in the
INCLUDE_DIR/pages/directory:- Pages: A
pageis identified by a.inc.phpfile in the pages directory. If no page is specified in$_REQUEST['page'], it defaults tohome. If the requested page doesn't exist, it defaults toerror. - Actions: Within a page directory, the application looks for sub-directories named after the page. It then searches for
.inc.phpfiles within that sub-directory to act asactions. An action is triggered via$_REQUEST['action'].
Routing Logic:
- If an
actionis provided and valid, the application loads:PAGES_DIR/{page}/{action}.inc.php. - If no valid
actionis provided, it loads:PAGES_DIR/{page}.inc.php.
Constants
PAGEandACTIONare defined globally once the routing is resolved.- Pages: A
Configure and use CSRF protection
masterWhen
$config['csrf']['enabled']istrue, 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
CTOKENusing$smarty->assign('CTOKEN', $csrftoken->getBasic(session_id(), $arrPages[$page])).
- Validation: The
Configure SECHASH security settings
masterThe application uses a time-based security hash (
SECHASH) to validate requests. You can configure this by defining two constants in the entrypoint:SECURITY: A long string containing special characters used as a salt.SECHASH_CHECK: A boolean. Iftrue, the application generates a rotatingSECHASHbased on the current time (allowing a 3-second window for clock drift). Iffalse, it simply checks ifSECURITYis defined.
Note: These must be defined before the bootstrap process.
define('SECURITY', '*)WT#&YHfd'); define('SECHASH_CHECK', false);Configure Anti-DoS rate limiting
masterThe application includes an Anti-DoS mechanism using Memcache. To use it, ensure
$config['memcache']['enabled']and$config['mc_antidos']['enabled']are both set totrue.Key behaviors:
- API Protection: If
$config['mc_antidos']['protect_ajax']is enabled, specific AJAX/API calls (likegetuserbalance,getnavbardata,getdashboarddata, andgetuserworkers) 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'].
- API Protection: If
Enable HTTPS redirection
masterThe 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 aLocationheader redirect to the HTTPS version of the current URL.Retrieve internal KLogger messages
masterKLogger 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.
Configure KLogger date format
masterYou can globally set the date format used for all log timestamps across all KLogger instances usingsetDateFormat(). This accepts any valid PHPdate()format string.