Skip to content

Commit

Permalink
Merged Done Cloes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedbodi committed Dec 16, 2014
1 parent 6549909 commit c3fb53c
Show file tree
Hide file tree
Showing 897 changed files with 26,196 additions and 32,587 deletions.
22 changes: 13 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# Local Config
/public/include/config/global.inc.php
/public/include/config/security.inc.php
/include/config/global.inc.php
/include/config/security.inc.php

# Templates
/public/templates/compile/*.php
/public/templates/compile/**
/public/templates/cache/*.php
/public/templates/cache/**
/templates/compile/*.php
/templates/compile/**
/templates/cache/*.php
/templates/cache/**

# Logs
/cronjobs/logs
/cronjobs/logs/**.txt.*.gz
/logs/*

# Test configs
public/include/config/global.inc.scrypt.php
public/include/config/global.inc.sha.php
public/include/config/**/*.php
/include/config/global.inc.test.php
/include/config/global.inc.scrypt.php
/include/config/global.inc.sha.php

# Test files
/scripts/test.php
/cronjobs/test.php

# IDE Settings
/.idea/*
Expand Down
9 changes: 8 additions & 1 deletion .htaccess
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
ErrorDocument 404 /public/index.php?page=error&action=404
RedirectMatch 404 /logs(/|$)
Options -Indexes
RedirectMatch 404 /templates(/|$)
RedirectMatch 404 /include(/|$)
RedirectMatch 404 /scripts(/|$)
RedirectMatch 404 /sql(/|$)
RedirectMatch 404 /upgrade(/|$)
RedirectMatch 404 /cronjobs(/|$)
RedirectMatch 404 /tests(/|$)
Options -Indexes
36 changes: 17 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
Description [ ![Codeship Status for TheSerapher/php-mpos](https://www.codeship.io/projects/40fa7600-61a6-0131-3fd3-367b94dc0d60/status?branch=next)](https://www.codeship.io/projects/12276)
Description
===========

MPOS is a web based Mining Portal for various crypto currencies. It was created by [TheSerapher](https://github.com/TheSerapher) and has hence grown quite large. Recently it was migrated into a Github Organization to make development easier. It's a community driven open source project. Support can be requested on IRC at https://webchat.freenode.net/?channels=#mpos


**NOTE**: This project is still under development and commits are happening on a daily basis.
I do not recommend using this for a live setup as of yet. Wait for the later Release Candidate
if you wish to run your pool with it. Testing pools are much appreciated though!
MPOS is a web based Mining Portal for various crypto currencies. It was created by [TheSerapher](https://github.com/TheSerapher) and has hence grown quite large. Recently it was migrated into a Github Organization to make development easier. It's a community driven open source project. Support can be requested on IRC at https://webchat.freenode.net/?channels=#mpos - Be **PATIENT** ... People listed in this channel may currently be inactive but most users there have offline logging of messages. They **will** see your questions and answer if they can. Don't join, ask the question and leave. Sit around if you want answers to your questions!

Donations
=========
Expand All @@ -15,13 +10,16 @@ Donations to this project are going directly to [TheSerapher](https://github.com

* LTC address: `Lge95QR2frp9y1wJufjUPCycVsg5gLJPW8`
* BTC address: `1HuYK6WPU8o3yWCrAaADDZPRpL5QiXitfv`
* DOGE Address: `D6YtvxFGBmaD8Yq3i8LZsBQVPvCbZwCDzF`
* DOGE address: `DANk8bnc3vHEf7Jthaxq1Xgn1BSiArNdjG`
* 42Coin address: `4VxA6Ht59Mj6ikhA4gDXLiHuAaDCJEvYTZ`
* FST address: `fiRqMgZyhjTN1GSEB3ZxV35JXsE5bjEaQ2`
* FRK address: `FDcgGZjX2B29qevSuiuQVwXhkNhtQT4cEW`
* Cryptsy Trade Key: `6ff7292142463b7b80cbbbdfc52334ba89727b11`

Website Footer
==============

When you decide to use `MPOS` please be so kind and leave the footer intact. You are not the author of the software and should honor those that have worked on it. I don't mind changing the LTC donation address at the bottom, but keep in mind who really wrote this software and would deserve those ;-).
When you decide to use `MPOS` please be so kind and leave the footer intact. You are not the author of the software and should honor those that have worked on it. Keeping the footer intact helps spreading the word. Leaving the donation address untouched allows miners to donate to the author.

Donors
======
Expand Down Expand Up @@ -79,23 +77,22 @@ The following feature have been implemented so far:

* Fully re-written GUI with [Smarty][2] templates
* Full file based template support
* **NEW** SQL based templates
* Mobile WebUI
* Scrypt, SHA256, VARDIFF Support
* VARDIFF Support
* Reward Systems
* Propotional, PPS and PPLNS
* New Theme
* Live Dashboard
* AJAX Support
* Overhauled API
* Bootstrap
* Web User accounts
* Re-Captcha protected registration form
* Worker accounts
* Worker activity
* Worker hashrates
* Pool statistics
* Block statistics
* Pool donations, fees and block bonuses
* Pool donations, bonuses, fees and block bonuses
* Manual and auto payout
* Transaction list
* Admin Panel
Expand All @@ -105,24 +102,24 @@ The following feature have been implemented so far:
* User Transactions
* News Posts
* Pool Settings
* Templates
* Pool Workers
* User Reports
* Template Overwrite
* Notification system
* IDLE Workers
* New blocks found in pool
* Auto Payout
* Manual Payout
* User-to-user Invitation System
* Support for various coins via config
* Support for various coins via coin class and config
* All scrypt coins
* All sha256d coins
* All x11 coins
* Others may be supported by creating a custom coin class

Installation
============

Please take a look at the [Quick Start Guide](https://github.com/TheSerapher/php-mpos/wiki/Quick-Start-Guide). This will give you an idea how to setup `MPOS`.
Please take a look at the [Quick Start Guide](https://github.com/TheSerapher/php-mpos/wiki/Quick-Start-Guide). This will give you an idea how to setup `MPOS`. Please be aware that the `master` branch is our currently considered stable system while `development` is used as a test bed for all upcoming changes for `master`. If you wish to run a stable, well tested system ensure you run `git checkout master`. If you decide to stick to the `development` branch with bleeding edge code and potential bugs, just `git clone` the project.

Customization
=============
Expand All @@ -131,7 +128,7 @@ This project was meant to allow users to easily customize the system and templat
If you are just using the system, there will be no need to adjust anything. Things will work out of the box! But if you plan on creating
your own theme, things are pretty easy:

* Create a new theme folder in `public/templates/`
* Create a new theme folder in `templates/`
* Create a new site_assets folder in `public/site_assets`
* Create your own complete custom template or copy from an existing one
* Change your theme in the `Admin Panel` and point it to the newly created folder
Expand All @@ -153,6 +150,7 @@ There are a few other projects out there that take advantage of MPOS and it's in
* [MPOS Eggdrop Module](https://github.com/iAmShorty/mpos-eggdrop-tcl) written in TCL, adding MPOS commands to this bot, using the MPOS API
* [Windows Phone Pool App](http://www.windowsphone.com/en-us/store/app/meeneminermonitor/7ec6eac7-a642-409b-96c8-57b5cfdf45cf)
* [iPhone iMPOS App](https://itunes.apple.com/us/app/impos/id742179239?mt=8)
* [Other Windows Phone App](http://www.windowsphone.com/en-us/store/app/mining-info/952f1137-eb62-4613-8057-34576d3c9c44)

Contributing
============
Expand All @@ -173,7 +171,7 @@ You can find the team on Freenode.net, #MPOS.
Team Members
============

Author and Github Owner: [TheSerapher](https://github.com/TheSerapher) aka Sebastian Grewe
Author and Project Owner: [TheSerapher](https://github.com/TheSerapher) aka Sebastian Grewe

Developers:

Expand Down
2 changes: 1 addition & 1 deletion cronjobs/findblock.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
$config['reward_type'] == 'block' ? $aData['amount'] = $aData['amount'] : $aData['amount'] = $config['reward'];
$aData['height'] = $aBlockRPCInfo['height'];
$aTxDetails = $bitcoin->gettransaction($aBlockRPCInfo['tx'][0]);
if (!isset($aBlockRPCInfo['confirmations'])) {
if (isset($aBlockRPCInfo['confirmations'])) {
$aData['confirmations'] = $aBlockRPCInfo['confirmations'];
} else if (isset($aTxDetails['confirmations'])) {
$aData['confirmations'] = $aTxDetails['confirmations'];
Expand Down
1 change: 0 additions & 1 deletion cronjobs/logs/README.md

This file was deleted.

8 changes: 4 additions & 4 deletions cronjobs/payouts.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
foreach ($aManualPayouts as $aUserData) $dMPTotalAmount += $aUserData['confirmed'];
if ($dMPTotalAmount > $dWalletBalance) {
$log->logError(" Wallet does not cover MP payouts - Payout: " . $dMPTotalAmount . " - Balance: " . $dWalletBalance);
$monitoring->endCronjob($cron_name, 'E0079', 0, true);
$monitoring->endCronjob($cron_name, 'E0079', 1, true);
}

$log->logInfo("Manual Payout Sum: " . $dMPTotalAmount . " | Liquid Assets: " . $dWalletBalance . " | Wallet Balance: " . ($dWalletBalance + $dBlocksUnconfirmedBalance) . " | Unconfirmed: " . $dBlocksUnconfirmedBalance);
$log->logInfo(' found ' . count($aManualPayouts) . ' queued manual payouts');
$mask = ' | %-10.10s | %-25.25s | %-20.20s | %-40.40s | %-20.20s |';
Expand Down Expand Up @@ -156,9 +156,9 @@
foreach ($aAutoPayouts as $aUserData) $dAPTotalAmount += $aUserData['confirmed'];
if ($dAPTotalAmount > $dWalletBalance) {
$log->logError(" Wallet does not cover AP payouts - Payout: " . $dAPTotalAmount . " - Balance: " . $dWalletBalance);
$monitoring->endCronjob($cron_name, 'E0079', 0, true);
$monitoring->endCronjob($cron_name, 'E0079', 1, true);
}

$log->logInfo("Auto Payout Sum: " . $dAPTotalAmount . " | Liquid Assets: " . $dWalletBalance . " | Wallet Balance: " . ($dWalletBalance + $dBlocksUnconfirmedBalance) . " | Unconfirmed: " . $dBlocksUnconfirmedBalance);
$log->logInfo(' found ' . count($aAutoPayouts) . ' queued auto payouts');
$mask = ' | %-10.10s | %-25.25s | %-20.20s | %-40.40s | %-20.20s |';
Expand Down
36 changes: 20 additions & 16 deletions cronjobs/pplns_payout.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
$monitoring->endCronjob($cron_name, 'E0011', 0, true, false);
}

// Fetch precision
$precision = $coin->getCoinValuePrevision();
$table_precision = $coin->getCoinValuePrevision() + 3;

$log->logDebug('Starting PPLNS payout process');
$count = 0;
foreach ($aAllBlocks as $iIndex => $aBlock) {
Expand Down Expand Up @@ -115,30 +119,30 @@
// Add archived shares to users current shares, if we have any in archive
if (is_array($aArchiveShares)) {
$log->logDebug('Found shares in archive to match PPLNS target, calculating per-user shares');
$strLogMask = "| %-20.20s | %15.15s | %15.15s | %15.15s | %15.15s | %15.15s | %15.15s |";
$log->logDebug(sprintf($strLogMask, 'Username', 'Round Valid', 'Archive Valid', 'Total Valid', 'Round Invalid', 'Archive Invalid', 'Total Invalid'));
$strLogMask = "| %5.5s | %-20.20s | %15.15s | %15.15s | %15.15s | %15.15s | %15.15s | %15.15s |";
$log->logDebug(sprintf($strLogMask, 'ID', 'Username', 'Round Valid', 'Archive Valid', 'Total Valid', 'Round Invalid', 'Archive Invalid', 'Total Invalid'));
foreach($aAccountShares as $key => $aData) {
if (array_key_exists($aData['username'], $aArchiveShares)) {
$log->logDebug(sprintf($strLogMask, $aData['username'],
$aAccountShares[$key]['valid'], $aArchiveShares[$aData['username']]['valid'], ($aAccountShares[$key]['valid'] + $aArchiveShares[$aData['username']]['valid']),
$aAccountShares[$key]['invalid'], $aArchiveShares[$aData['username']]['invalid'], ($aAccountShares[$key]['invalid'] + $aArchiveShares[$aData['username']]['invalid']))
if (array_key_exists(strtolower($aData['username']), $aArchiveShares)) {
$log->logDebug(sprintf($strLogMask, $aData['id'], $aData['username'],
$aAccountShares[$key]['valid'], $aArchiveShares[strtolower($aData['username'])]['valid'], ($aAccountShares[$key]['valid'] + $aArchiveShares[strtolower($aData['username'])]['valid']),
$aAccountShares[$key]['invalid'], $aArchiveShares[strtolower($aData['username'])]['invalid'], ($aAccountShares[$key]['invalid'] + $aArchiveShares[strtolower($aData['username'])]['invalid']))
);
$aAccountShares[$key]['valid'] += $aArchiveShares[$aData['username']]['valid'];
$aAccountShares[$key]['invalid'] += $aArchiveShares[$aData['username']]['invalid'];
$aAccountShares[$key]['valid'] += $aArchiveShares[strtolower($aData['username'])]['valid'];
$aAccountShares[$key]['invalid'] += $aArchiveShares[strtolower($aData['username'])]['invalid'];
}
}
// reverse payout
if ($config['pplns']['reverse_payout']) {
$log->logDebug('Reverse payout enabled, adding shelved shares for all users');
$aSharesData = NULL;
foreach($aAccountShares as $key => $aData) {
$aSharesData[$aData['username']] = $aData;
$aSharesData[strtolower($aData['username'])] = $aData;
}
// Add users from archive not in current round
$strLogMask = "| %-20.20s | %15.15s | %15.15s |";
$log->logDebug(sprintf($strLogMask, 'Username', 'Shelved Valid', 'Shelved Invalid'));
foreach($aArchiveShares as $key => $aArchData) {
if (!array_key_exists($aArchData['account'], $aSharesData)) {
if (!array_key_exists(strtolower($aArchData['account']), $aSharesData)) {
$log->logDebug(sprintf($strLogMask, $aArchData['account'], $aArchData['valid'], $aArchData['invalid']));
$aArchData['username'] = $aArchData['account'];
$aSharesData[$aArchData['account']] = $aArchData;
Expand Down Expand Up @@ -181,7 +185,7 @@
}

// Table header for account shares
$strLogMask = "| %5.5s | %-15.15s | %15.15s | %15.15s | %12.12s | %15.15s | %15.15s | %15.15s | %15.15s |";
$strLogMask = "| %5.5s | %-15.15s | %15.15s | %15.15s | %12.12s | %${table_precision}.${table_precision}s | %${table_precision}.${table_precision}s | %${table_precision}.${table_precision}s | %${table_precision}.${table_precision}s |";
$log->logInfo(sprintf($strLogMask, 'ID', 'Username', 'Valid', 'Invalid', 'Percentage', 'Payout', 'Donation', 'Fee', 'Bonus'));

// Loop through all accounts that have found shares for this round
Expand All @@ -197,27 +201,27 @@

// Payout based on PPLNS target shares, proportional payout for all users
$aData['percentage'] = round(( 100 / $iRoundShares) * $aData['pplns_valid'], 8);
$aData['payout'] = round(( $aData['percentage'] / 100 ) * $dReward, 8);
$aData['payout'] = ( $aData['percentage'] / 100 ) * $dReward;
// Defaults
$aData['fee' ] = 0;
$aData['donation'] = 0;
$aData['pool_bonus'] = 0;

// Calculate pool fees
if ($config['fees'] > 0 && $aData['no_fees'] == 0)
$aData['fee'] = round($config['fees'] / 100 * $aData['payout'], 8);
$aData['fee'] = $config['fees'] / 100 * $aData['payout'];

// Calculate pool bonus if it applies, will be paid from liquid assets!
if ($config['pool_bonus'] > 0) {
if ($config['pool_bonus_type'] == 'block') {
$aData['pool_bonus'] = round(( $config['pool_bonus'] / 100 ) * $dReward, 8);
$aData['pool_bonus'] = ( $config['pool_bonus'] / 100 ) * $dReward;
} else {
$aData['pool_bonus'] = round(( $config['pool_bonus'] / 100 ) * $aData['payout'], 8);
$aData['pool_bonus'] = ( $config['pool_bonus'] / 100 ) * $aData['payout'];
}
}

// Calculate donation amount, fees not included
$aData['donation'] = round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8);
$aData['donation'] = $user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']);

// Verbose output of this users calculations
$log->logInfo(
Expand Down
22 changes: 12 additions & 10 deletions cronjobs/pps_payout.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
}

// Per-share value to be paid out to users
$pps_value = round($coin->calcPPSValue($pps_reward, $dDifficulty), 12);
$pps_value = $coin->calcPPSValue($pps_reward, $dDifficulty);

// Find our last share accounted and last inserted share for PPS calculations
if (!$iPreviousShareId = $setting->getValue('pps_last_share_id')) {
Expand All @@ -89,13 +89,15 @@

if (!empty($aAccountShares)) {
// Runtime information for this payout
$precision = $coin->getCoinValuePrevision();
$table_precision = $coin->getCoinValuePrevision() + 3;
$log->logInfo('Runtime information for this payout');
$strLogMask = "| %-15.15s | %15.15s | %15.15s | %15.15s |";
$log->logInfo(sprintf($strLogMask, 'PPS reward type', 'Reward Base', 'Difficulty', 'PPS Value'));
$log->logInfo(sprintf($strLogMask, $strRewardType, $pps_reward, $dDifficulty, $pps_value));
$strLogMask = "| %-15.15s | %15.15s | %15.15s | %${table_precision}.${table_precision}s | %3.3s |";
$log->logInfo(sprintf($strLogMask, 'PPS reward type', 'Reward Base', 'Difficulty', 'PPS Value', 'Precision'));
$log->logInfo(sprintf($strLogMask, $strRewardType, $pps_reward, $dDifficulty, $pps_value, $precision));
$log->logInfo('Per-user payout information');
$strLogMask = "| %8.8s | %25.25s | %15.15s | %15.15s | %18.18s | %18.18s | %18.18s |";
$log->logInfo(sprintf($strLogMask, 'User ID', 'Username', 'Invalid', 'Valid', ' * PPS Value', ' = Payout', 'Donation', 'Fee'));
$strLogMask = "| %8.8s | %25.25s | %15.15s | %${table_precision}.${table_precision}s | %${table_precision}.${table_precision}s | %${table_precision}.${table_precision}s | %${table_precision}.${table_precision}s |";
$log->logInfo(sprintf($strLogMask, 'User ID', 'Username', 'Invalid', 'Valid', '* PPS Value', ' = Payout', 'Donation', 'Fee'));
}

foreach ($aAccountShares as $aData) {
Expand All @@ -106,21 +108,21 @@
}

// Payout for this user
$aData['payout'] = round($aData['valid'] * $pps_value, 12);
$aData['payout'] = $aData['valid'] * $pps_value;

// Defaults
$aData['fee' ] = 0;
$aData['donation'] = 0;

// Calculate block fees
if ($config['fees'] > 0 && $aData['no_fees'] == 0)
$aData['fee'] = round($config['fees'] / 100 * $aData['payout'], 12);
$aData['fee'] = $config['fees'] / 100 * $aData['payout'];
// Calculate donation amount
$aData['donation'] = round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 12);
$aData['donation'] = $user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']);

$log->logInfo(sprintf(
$strLogMask, $aData['id'], $aData['username'], $aData['invalid'], $aData['valid'],
number_format($pps_value, 12), number_format($aData['payout'], 12), number_format($aData['donation'], 12), number_format($aData['fee'], 12)
number_format($pps_value, $precision), number_format($aData['payout'], $precision), number_format($aData['donation'], $precision), number_format($aData['fee'], $precision)
));

// Add new credit transaction
Expand Down
Loading

0 comments on commit c3fb53c

Please sign in to comment.