Skip to content

Commit

Permalink
Merge pull request MPOS#2402 from MPOS/development
Browse files Browse the repository at this point in the history
UPDATE : Development to Master
  • Loading branch information
TheSerapher committed Apr 28, 2015
2 parents 308ddc8 + dfa34bc commit 50af836
Show file tree
Hide file tree
Showing 211 changed files with 4,504 additions and 17,326 deletions.
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
1.0.2 (Apr 28th 2015)
---------------------

* Allow SSO accross MPOS pools
* Added a new config options
* `$config['db']['shared']['acounts']`, defaults to `$config['db']['name']`
* `$config['db']['shared']['workers']`, defaults to `$config['db']['name']`
* `$config['db']['shared']['news']`, defaults to `$config['db']['name']`
* Will access `accounts`, `pool_workers` and `news` on shared table
* Does not allow splitting `accounts` and `pool_woker` across database hosts
* Required `$config['cookie']['domain']` to be set
* You need to use the top domain shared between hosts as the setting
* e.g. `ltc.thepool.com` and `btc.thepool.com` it has to be `.thepool.com` (NOTE the leading .)
* Increased information on `Admin -> Wallet Info`
* Added block count to Wallet Status
* Added number of accounts to Wallet Status
* Added Peer information
* Added last 25 transactions
* Can be changed via Admin System Settings -> Wallet
* Always show all accounts
* Updated Auto Payout Threshold to be stored in `coin_address` table
* Existing thresholds will be migrated when upgrading
* Update to `1.0.1` for the database using the upgrade script supplied in MPOS
* Updated Bootstrap to 3.3.4
* Updated MorrisJS to 0.5.1
* Updated RaphaelJS to 2.1.2
* Updated Bootstrap Switch to 3.3.2
* Updated CLEditor to 1.4.5
* Removed unneeded JS files
* Removed unneeded CSS files
* Fixed ding for block notifications not playing on Safari
* Fixed manual payout warning to show when account balance is too low

1.0.1 (Apr 15th 2015)
---------------------

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/MPOS/php-mpos.png?branch=master)](https://travis-ci.org/MPOS/php-mpos) [![Code Coverage](https://scrutinizer-ci.com/g/MPOS/php-mpos/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/MPOS/php-mpos/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/MPOS/php-mpos/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/MPOS/php-mpos/?branch=master) master<br />
[![Build Status](https://travis-ci.org/MPOS/php-mpos.png?branch=master)](https://travis-ci.org/MPOS/php-mpos) [![Code Climate](https://codeclimate.com/github/MPOS/php-mpos/badges/gpa.svg)](https://codeclimate.com/github/MPOS/php-mpos) [![Code Coverage](https://scrutinizer-ci.com/g/MPOS/php-mpos/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/MPOS/php-mpos/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/MPOS/php-mpos/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/MPOS/php-mpos/?branch=master) master<br />
[![Build Status](https://travis-ci.org/MPOS/php-mpos.png?branch=development)](https://travis-ci.org/MPOS/php-mpos) [![Code Coverage](https://scrutinizer-ci.com/g/MPOS/php-mpos/badges/coverage.png?b=development)](https://scrutinizer-ci.com/g/MPOS/php-mpos/?branch=development) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/MPOS/php-mpos/badges/quality-score.png?b=development)](https://scrutinizer-ci.com/g/MPOS/php-mpos/?branch=development) development


Expand Down
1 change: 0 additions & 1 deletion cronjobs/blockupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,3 @@
}

require_once('cron_end.inc.php');
?>
1 change: 0 additions & 1 deletion cronjobs/cron_end.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@
$monitoring->endCronjob($cron_name, 'OK', 0, false, false);
$monitoring->setStatus($cron_name . "_runtime", "time", microtime(true) - $cron_start[$cron_name]);
$monitoring->setStatus($cron_name . "_endtime", "date", time());
?>
1 change: 0 additions & 1 deletion cronjobs/findblock.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,3 @@
}

require_once('cron_end.inc.php');
?>
1 change: 0 additions & 1 deletion cronjobs/notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,3 @@
}

require_once('cron_end.inc.php');
?>
1 change: 0 additions & 1 deletion cronjobs/pplns_payout.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,3 @@
}

require_once('cron_end.inc.php');
?>
1 change: 0 additions & 1 deletion cronjobs/pps_payout.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,3 @@
$log->logInfo("Completed PPS Payout");

require_once('cron_end.inc.php');
?>
1 change: 0 additions & 1 deletion cronjobs/proportional_payout.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,3 @@
}

require_once('cron_end.inc.php');
?>
2 changes: 0 additions & 2 deletions cronjobs/shared.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,3 @@ function cfip() { return (@defined('SECURITY')) ? 1 : 0; }
$log->logFatal('Cronjob is currently disabled due to required upgrades. Import any outstanding SQL files and check your configuration file.');
$monitoring->endCronjob($cron_name, 'E0075', 0, true, false);
}

?>
1 change: 0 additions & 1 deletion cronjobs/statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,3 @@
$log->logInfo(sprintf($strLogMask, 'getTopContributors(shares)', number_format(microtime(true) - $start, 3), $status));

require_once('cron_end.inc.php');
?>
1 change: 0 additions & 1 deletion cronjobs/tables_cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,3 @@

// Cron cleanup and monitoring
require_once('cron_end.inc.php');
?>
1 change: 0 additions & 1 deletion cronjobs/tickerupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,3 @@
$log->logInfo(sprintf($strLogMask, 'Uptime Robot', 'n/a', number_format(microtime(true) - $start, 3), $status, $message));

require_once('cron_end.inc.php');
?>
2 changes: 0 additions & 2 deletions include/admin_checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,3 @@
}
}
}

?>
2 changes: 0 additions & 2 deletions include/autoloader.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,3 @@
require_once(CLASS_DIR . '/api.class.php');
require_once(INCLUDE_DIR . '/lib/Michelf/Markdown.php');
require_once(INCLUDE_DIR . '/lib/scrypt.php');

?>
12 changes: 10 additions & 2 deletions include/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
if (!include_once(INCLUDE_DIR . '/config/global.inc.dist.php')) die('Unable to load base global config from ['.INCLUDE_DIR. '/config/global.inc.dist.php' . '] - '.$quickstartlink);
if (!@include_once(INCLUDE_DIR . '/config/global.inc.php')) die('Unable to load your global config from ['.INCLUDE_DIR. '/config/global.inc.php' . '] - '.$quickstartlink);

// Check for a shared account database and set to default DB if unset
if (!isset($config['db']['shared']['accounts']))
$config['db']['shared']['accounts'] = $config['db']['name'];
// Check for a shared worker database and set to default DB if unset
if (!isset($config['db']['shared']['workers']))
$config['db']['shared']['workers'] = $config['db']['name'];
// Check for a shared news database and set to default DB if unset
if (!isset($config['db']['shared']['news']))
$config['db']['shared']['news'] = $config['db']['name'];

// load our security configs
if (!include_once(INCLUDE_DIR . '/config/security.inc.dist.php')) die('Unable to load base security config from ['.INCLUDE_DIR. '/config/security.inc.dist.php' . '] - '.$quickstartlink);
if (@file_exists(INCLUDE_DIR . '/config/security.inc.php')) include_once(INCLUDE_DIR . '/config/security.inc.php');
Expand Down Expand Up @@ -43,5 +53,3 @@
// Load Classes, they name defines the $ variable used
// We include all needed files here, even though our templates could load them themself
require_once(INCLUDE_DIR . '/autoloader.inc.php');

?>
1 change: 0 additions & 1 deletion include/classes/base.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,3 @@ public function getParam() {
return $array;
}
}
?>
49 changes: 41 additions & 8 deletions include/classes/coin_address.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@

class CoinAddress extends Base {
protected $table = 'coin_addresses';
private $cache = array();

/**
* We allow changing the database for shared accounts across pools
* Load the config on construct so we can assign the DB name
* @param config array MPOS configuration
* @return none
**/
public function __construct($config) {
$this->setConfig($config);
$this->table = $this->config['db']['shared']['accounts'] . '.' . $this->table;
}

/**
* Fetch users coin address for a currency
Expand All @@ -27,6 +37,29 @@ public function getCoinAddress($userID, $currency=NULL) {
return $this->sqlError();
}

/**
* Fetch users Auto Payout Threshold for a currency
* @param UserID int UserID
* @return mixed Float value for threshold, false on error
**/
public function getAPThreshold($userID, $currency=NULL) {
if ($currency === NULL) $currency = $this->config['currency'];
$this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare("
SELECT ap_threshold
FROM " . $this->getTableName() . "
WHERE account_id = ? AND currency = ?
");
if ( $this->checkStmt($stmt) && $stmt->bind_param('is', $userID, $currency) && $stmt->execute() && $result = $stmt->get_result()) {
if ($result->num_rows == 1) {
return $result->fetch_object()->ap_threshold;
}
}
$this->debug->append("Unable to fetch users auto payout threshold for " . $currency);
return $this->sqlError();
}


/**
* Check if a coin address is already set
* @param address string Coin Address to check for
Expand Down Expand Up @@ -76,32 +109,32 @@ public function remove ($userID, $currency=NULL) {
* Update a coin address record for a user and a currency
* @param userID int Account ID
* @param address string Coin Address
* @param ap_threshold float Threshold for auto payouts for this currency
* @param currency string Currency short handle, defaults to config option
* @return bool true or false
**/
public function update($userID, $address, $currency=NULL) {
public function update($userID, $address, $ap_threshold, $currency=NULL) {
if ($currency === NULL) $currency = $this->config['currency'];
if ($address != $this->getCoinAddress($userID) && $this->existsCoinAddress($address)) {
$this->setErrorMessage('Unable to update coin address, address already exists');
return false;
}
if ($this->getCoinAddress($userID) != NULL) {
$stmt = $this->mysqli->prepare("UPDATE " . $this->getTableName() . " SET coin_address = ? WHERE account_id = ? AND currency = ?");
if ( $this->checkStmt($stmt) && $stmt->bind_param('sis', $address, $userID, $currency) && $stmt->execute()) {
$stmt = $this->mysqli->prepare("UPDATE " . $this->getTableName() . " SET coin_address = ?, ap_threshold = ? WHERE account_id = ? AND currency = ?");
if ( $this->checkStmt($stmt) && $stmt->bind_param('sdis', $address, $ap_threshold, $userID, $currency) && $stmt->execute()) {
return true;
}
} else {
$stmt = $this->mysqli->prepare("INSERT INTO " . $this->getTableName() . " (coin_address, account_id, currency) VALUES (?, ?, ?)");
if ( $this->checkStmt($stmt) && $stmt->bind_param('sis', $address, $userID, $currency) && $stmt->execute()) {
$stmt = $this->mysqli->prepare("INSERT INTO " . $this->getTableName() . " (coin_address, ap_threshold, account_id, currency) VALUES (?, ?, ?, ?)");
if ( $this->checkStmt($stmt) && $stmt->bind_param('sdis', $address, $ap_threshold, $userID, $currency) && $stmt->execute()) {
return true;
}
}
return $this->sqlError();
}
}

$coin_address = new CoinAddress();
$coin_address = new CoinAddress($config);
$coin_address->setDebug($debug);
$coin_address->setConfig($config);
$coin_address->setMysql($mysqli);
$coin_address->setErrorCodes($aErrorCodes);
2 changes: 0 additions & 2 deletions include/classes/coins/coin_base.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,3 @@ public function calcExpectedNextDifficulty($dDifficulty, $dNetworkHashrate) {
}
}
}

?>
2 changes: 0 additions & 2 deletions include/classes/coins/coin_scrypt.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@
class Coin extends CoinBase {
protected $target_bits = 16;
}

?>
2 changes: 0 additions & 2 deletions include/classes/coins/coin_scryptn.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@
class Coin extends CoinBase {
protected $target_bits = 16;
}

?>
2 changes: 0 additions & 2 deletions include/classes/coins/coin_sha256d.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ class Coin extends CoinBase {
protected $target_bits = 32;
protected $coin_value_precision = 20;
}

?>
2 changes: 0 additions & 2 deletions include/classes/coins/coin_x11.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ class Coin extends CoinBase {
protected $target_bits = 24;
protected $share_difficulty_precision = 4;
}

?>
1 change: 0 additions & 1 deletion include/classes/csrftoken.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,3 @@ private function getHash($string) {
$csrftoken->setToken($oToken);
$csrftoken->setConfig($config);
$csrftoken->setErrorCodes($aErrorCodes);
?>
1 change: 0 additions & 1 deletion include/classes/debug.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,3 @@ function printDebugInfo() {

// Instantiate this class
$debug = new Debug($log, $config['DEBUG']);
?>
1 change: 0 additions & 1 deletion include/classes/invitation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,3 @@ public function sendInvitation($account_id, $aData) {
$invitation->setToken($oToken);
$invitation->setConfig($config);
$invitation->setErrorCodes($aErrorCodes);
?>
1 change: 0 additions & 1 deletion include/classes/logger.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,3 @@ public function log($strType, $strMessage) {
}
}
$log = new Logger($config);
?>
1 change: 0 additions & 1 deletion include/classes/mail.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,3 @@ public function sendMail($template, $aData, $throttle=false) {
$mail->setConfig($config);
$mail->setSetting($setting);
$mail->setErrorCodes($aErrorCodes);
?>
2 changes: 0 additions & 2 deletions include/classes/memcache_ad.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,3 @@ public function getRequestBase() {
return $new;
}
}

?>
14 changes: 12 additions & 2 deletions include/classes/news.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
class News extends Base {
protected $table = 'news';

/**
* We allow changing the database for shared accounts across pools
* Load the config on construct so we can assign the DB name
* @param config array MPOS configuration
* @return none
**/
public function __construct($config) {
$this->setConfig($config);
$this->table = $this->config['db']['shared']['news'] . '.' . $this->table;
}

/**
* Get activation status of post
* @param id int News ID
Expand Down Expand Up @@ -96,9 +107,8 @@ public function addNews($account_id, $aData, $active=false) {
}
}

$news = new News();
$news = new News($config);
$news->setDebug($debug);
$news->setMysql($mysqli);
$news->setUser($user);
$news->setErrorCodes($aErrorCodes);
?>
1 change: 0 additions & 1 deletion include/classes/notification.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,3 @@ public function cleanupNotifications($days=7) {
$notification->setConfig($config);
$notification->setSetting($setting);
$notification->setErrorCodes($aErrorCodes);
?>
2 changes: 0 additions & 2 deletions include/classes/payout.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,3 @@ public function setProcessed($id) {
$oPayout->setConfig($config);
$oPayout->setToken($oToken);
$oPayout->setErrorCodes($aErrorCodes);

?>
7 changes: 1 addition & 6 deletions include/classes/roundstats.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;

class RoundStats extends Base {
private $tableTrans = 'transactions';
private $tableStats = 'statistics_shares';
private $tableBlocks = 'blocks';
private $tableUsers = 'accounts';

/**
* Get next block for round stats
**/
Expand Down Expand Up @@ -79,7 +74,7 @@ public function getDetailsForBlockHeight($iHeight=0) {
b.id, height, blockhash, amount, confirmations, difficulty, FROM_UNIXTIME(time) as time, shares,
IF(a.is_anonymous, 'anonymous', a.username) AS finder,
ROUND(difficulty * POW(2, 32 - " . $this->coin->getTargetBits() . "), 0) AS estshares,
(time - (SELECT time FROM $this->tableBlocks WHERE height < ? ORDER BY height DESC LIMIT 1)) AS round_time
(time - (SELECT time FROM " . $this->block->getTableName() . " WHERE height < ? ORDER BY height DESC LIMIT 1)) AS round_time
FROM " . $this->block->getTableName() . " as b
LEFT JOIN " . $this->user->getTableName() . " AS a ON b.account_id = a.id
WHERE b.height = ? LIMIT 1");
Expand Down
1 change: 0 additions & 1 deletion include/classes/statistics.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -927,4 +927,3 @@ public function purgeUserStats($days = 1) {
$statistics->setBitcoin($bitcoin);
$statistics->setErrorCodes($aErrorCodes);
$statistics->setCoin($coin);
?>
2 changes: 0 additions & 2 deletions include/classes/strict.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,3 @@ public function bind_param($paramTypes) {
}
}
}

?>
9 changes: 4 additions & 5 deletions include/classes/transaction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public function getAPQueue($limit=250) {
SELECT
a.id,
a.username,
a.ap_threshold,
ca.ap_threshold,
ca.coin_address,
IFNULL(
(
Expand All @@ -371,9 +371,9 @@ public function getAPQueue($limit=250) {
ON t.account_id = a.id
LEFT JOIN " . $this->coin_address->getTableName() . " AS ca
ON ca.account_id = a.id
WHERE t.archived = 0 AND a.ap_threshold > 0 AND ca.coin_address IS NOT NULL AND ca.coin_address != '' AND ca.currency = ?
WHERE t.archived = 0 AND ca.ap_threshold > 0 AND ca.coin_address IS NOT NULL AND ca.coin_address != '' AND ca.currency = ?
GROUP BY t.account_id
HAVING confirmed > a.ap_threshold AND confirmed > " . $this->config['txfee_auto'] . "
HAVING confirmed > ca.ap_threshold AND confirmed > " . $this->config['txfee_auto'] . "
LIMIT ?");
if ($this->checkStmt($stmt) && $stmt->bind_param('si', $this->config['currency'], $limit) && $stmt->execute() && $result = $stmt->get_result())
return $result->fetch_all(MYSQLI_ASSOC);
Expand Down Expand Up @@ -446,7 +446,7 @@ public function getMPQueue($limit=250) {
SELECT
a.id,
a.username,
a.ap_threshold,
ca.ap_threshold,
ca.coin_address,
p.id AS payout_id,
IFNULL(
Expand Down Expand Up @@ -488,4 +488,3 @@ public function getMPQueue($limit=250) {
$transaction->setUser($user);
$transaction->setPayout($oPayout);
$transaction->setErrorCodes($aErrorCodes);
?>
Loading

0 comments on commit 50af836

Please sign in to comment.