Skip to content

Commit 50af836

Browse files
committed
Merge pull request #2402 from MPOS/development
UPDATE : Development to Master
2 parents 308ddc8 + dfa34bc commit 50af836

File tree

211 files changed

+4504
-17326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+4504
-17326
lines changed

CHANGELOG.md

+33
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
1.0.2 (Apr 28th 2015)
2+
---------------------
3+
4+
* Allow SSO accross MPOS pools
5+
* Added a new config options
6+
* `$config['db']['shared']['acounts']`, defaults to `$config['db']['name']`
7+
* `$config['db']['shared']['workers']`, defaults to `$config['db']['name']`
8+
* `$config['db']['shared']['news']`, defaults to `$config['db']['name']`
9+
* Will access `accounts`, `pool_workers` and `news` on shared table
10+
* Does not allow splitting `accounts` and `pool_woker` across database hosts
11+
* Required `$config['cookie']['domain']` to be set
12+
* You need to use the top domain shared between hosts as the setting
13+
* e.g. `ltc.thepool.com` and `btc.thepool.com` it has to be `.thepool.com` (NOTE the leading .)
14+
* Increased information on `Admin -> Wallet Info`
15+
* Added block count to Wallet Status
16+
* Added number of accounts to Wallet Status
17+
* Added Peer information
18+
* Added last 25 transactions
19+
* Can be changed via Admin System Settings -> Wallet
20+
* Always show all accounts
21+
* Updated Auto Payout Threshold to be stored in `coin_address` table
22+
* Existing thresholds will be migrated when upgrading
23+
* Update to `1.0.1` for the database using the upgrade script supplied in MPOS
24+
* Updated Bootstrap to 3.3.4
25+
* Updated MorrisJS to 0.5.1
26+
* Updated RaphaelJS to 2.1.2
27+
* Updated Bootstrap Switch to 3.3.2
28+
* Updated CLEditor to 1.4.5
29+
* Removed unneeded JS files
30+
* Removed unneeded CSS files
31+
* Fixed ding for block notifications not playing on Safari
32+
* Fixed manual payout warning to show when account balance is too low
33+
134
1.0.1 (Apr 15th 2015)
235
---------------------
336

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![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 />
1+
[![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 />
22
[![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
33

44

cronjobs/blockupdate.php

-1
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,3 @@
8080
}
8181

8282
require_once('cron_end.inc.php');
83-
?>

cronjobs/cron_end.inc.php

-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@
2222
$monitoring->endCronjob($cron_name, 'OK', 0, false, false);
2323
$monitoring->setStatus($cron_name . "_runtime", "time", microtime(true) - $cron_start[$cron_name]);
2424
$monitoring->setStatus($cron_name . "_endtime", "date", time());
25-
?>

cronjobs/findblock.php

-1
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,3 @@
178178
}
179179

180180
require_once('cron_end.inc.php');
181-
?>

cronjobs/notifications.php

-1
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,3 @@
7575
}
7676

7777
require_once('cron_end.inc.php');
78-
?>

cronjobs/pplns_payout.php

-1
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,3 @@
289289
}
290290

291291
require_once('cron_end.inc.php');
292-
?>

cronjobs/pps_payout.php

-1
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,3 @@
200200
$log->logInfo("Completed PPS Payout");
201201

202202
require_once('cron_end.inc.php');
203-
?>

cronjobs/proportional_payout.php

-1
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,3 @@
169169
}
170170

171171
require_once('cron_end.inc.php');
172-
?>

cronjobs/shared.inc.php

-2
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,3 @@ function cfip() { return (@defined('SECURITY')) ? 1 : 0; }
8787
$log->logFatal('Cronjob is currently disabled due to required upgrades. Import any outstanding SQL files and check your configuration file.');
8888
$monitoring->endCronjob($cron_name, 'E0075', 0, true, false);
8989
}
90-
91-
?>

cronjobs/statistics.php

-1
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,3 @@
5555
$log->logInfo(sprintf($strLogMask, 'getTopContributors(shares)', number_format(microtime(true) - $start, 3), $status));
5656

5757
require_once('cron_end.inc.php');
58-
?>

cronjobs/tables_cleanup.php

-1
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,3 @@
8989

9090
// Cron cleanup and monitoring
9191
require_once('cron_end.inc.php');
92-
?>

cronjobs/tickerupdate.php

-1
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,3 @@
7676
$log->logInfo(sprintf($strLogMask, 'Uptime Robot', 'n/a', number_format(microtime(true) - $start, 3), $status, $message));
7777

7878
require_once('cron_end.inc.php');
79-
?>

include/admin_checks.php

-2
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,3 @@
148148
}
149149
}
150150
}
151-
152-
?>

include/autoloader.inc.php

-2
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,3 @@
8080
require_once(CLASS_DIR . '/api.class.php');
8181
require_once(INCLUDE_DIR . '/lib/Michelf/Markdown.php');
8282
require_once(INCLUDE_DIR . '/lib/scrypt.php');
83-
84-
?>

include/bootstrap.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
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);
1515
if (!@include_once(INCLUDE_DIR . '/config/global.inc.php')) die('Unable to load your global config from ['.INCLUDE_DIR. '/config/global.inc.php' . '] - '.$quickstartlink);
1616

17+
// Check for a shared account database and set to default DB if unset
18+
if (!isset($config['db']['shared']['accounts']))
19+
$config['db']['shared']['accounts'] = $config['db']['name'];
20+
// Check for a shared worker database and set to default DB if unset
21+
if (!isset($config['db']['shared']['workers']))
22+
$config['db']['shared']['workers'] = $config['db']['name'];
23+
// Check for a shared news database and set to default DB if unset
24+
if (!isset($config['db']['shared']['news']))
25+
$config['db']['shared']['news'] = $config['db']['name'];
26+
1727
// load our security configs
1828
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);
1929
if (@file_exists(INCLUDE_DIR . '/config/security.inc.php')) include_once(INCLUDE_DIR . '/config/security.inc.php');
@@ -43,5 +53,3 @@
4353
// Load Classes, they name defines the $ variable used
4454
// We include all needed files here, even though our templates could load them themself
4555
require_once(INCLUDE_DIR . '/autoloader.inc.php');
46-
47-
?>

include/classes/base.class.php

-1
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,3 @@ public function getParam() {
284284
return $array;
285285
}
286286
}
287-
?>

include/classes/coin_address.class.php

+41-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@
33

44
class CoinAddress extends Base {
55
protected $table = 'coin_addresses';
6-
private $cache = array();
6+
7+
/**
8+
* We allow changing the database for shared accounts across pools
9+
* Load the config on construct so we can assign the DB name
10+
* @param config array MPOS configuration
11+
* @return none
12+
**/
13+
public function __construct($config) {
14+
$this->setConfig($config);
15+
$this->table = $this->config['db']['shared']['accounts'] . '.' . $this->table;
16+
}
717

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

40+
/**
41+
* Fetch users Auto Payout Threshold for a currency
42+
* @param UserID int UserID
43+
* @return mixed Float value for threshold, false on error
44+
**/
45+
public function getAPThreshold($userID, $currency=NULL) {
46+
if ($currency === NULL) $currency = $this->config['currency'];
47+
$this->debug->append("STA " . __METHOD__, 4);
48+
$stmt = $this->mysqli->prepare("
49+
SELECT ap_threshold
50+
FROM " . $this->getTableName() . "
51+
WHERE account_id = ? AND currency = ?
52+
");
53+
if ( $this->checkStmt($stmt) && $stmt->bind_param('is', $userID, $currency) && $stmt->execute() && $result = $stmt->get_result()) {
54+
if ($result->num_rows == 1) {
55+
return $result->fetch_object()->ap_threshold;
56+
}
57+
}
58+
$this->debug->append("Unable to fetch users auto payout threshold for " . $currency);
59+
return $this->sqlError();
60+
}
61+
62+
3063
/**
3164
* Check if a coin address is already set
3265
* @param address string Coin Address to check for
@@ -76,32 +109,32 @@ public function remove ($userID, $currency=NULL) {
76109
* Update a coin address record for a user and a currency
77110
* @param userID int Account ID
78111
* @param address string Coin Address
112+
* @param ap_threshold float Threshold for auto payouts for this currency
79113
* @param currency string Currency short handle, defaults to config option
80114
* @return bool true or false
81115
**/
82-
public function update($userID, $address, $currency=NULL) {
116+
public function update($userID, $address, $ap_threshold, $currency=NULL) {
83117
if ($currency === NULL) $currency = $this->config['currency'];
84118
if ($address != $this->getCoinAddress($userID) && $this->existsCoinAddress($address)) {
85119
$this->setErrorMessage('Unable to update coin address, address already exists');
86120
return false;
87121
}
88122
if ($this->getCoinAddress($userID) != NULL) {
89-
$stmt = $this->mysqli->prepare("UPDATE " . $this->getTableName() . " SET coin_address = ? WHERE account_id = ? AND currency = ?");
90-
if ( $this->checkStmt($stmt) && $stmt->bind_param('sis', $address, $userID, $currency) && $stmt->execute()) {
123+
$stmt = $this->mysqli->prepare("UPDATE " . $this->getTableName() . " SET coin_address = ?, ap_threshold = ? WHERE account_id = ? AND currency = ?");
124+
if ( $this->checkStmt($stmt) && $stmt->bind_param('sdis', $address, $ap_threshold, $userID, $currency) && $stmt->execute()) {
91125
return true;
92126
}
93127
} else {
94-
$stmt = $this->mysqli->prepare("INSERT INTO " . $this->getTableName() . " (coin_address, account_id, currency) VALUES (?, ?, ?)");
95-
if ( $this->checkStmt($stmt) && $stmt->bind_param('sis', $address, $userID, $currency) && $stmt->execute()) {
128+
$stmt = $this->mysqli->prepare("INSERT INTO " . $this->getTableName() . " (coin_address, ap_threshold, account_id, currency) VALUES (?, ?, ?, ?)");
129+
if ( $this->checkStmt($stmt) && $stmt->bind_param('sdis', $address, $ap_threshold, $userID, $currency) && $stmt->execute()) {
96130
return true;
97131
}
98132
}
99133
return $this->sqlError();
100134
}
101135
}
102136

103-
$coin_address = new CoinAddress();
137+
$coin_address = new CoinAddress($config);
104138
$coin_address->setDebug($debug);
105-
$coin_address->setConfig($config);
106139
$coin_address->setMysql($mysqli);
107140
$coin_address->setErrorCodes($aErrorCodes);

include/classes/coins/coin_base.class.php

-2
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,3 @@ public function calcExpectedNextDifficulty($dDifficulty, $dNetworkHashrate) {
8585
}
8686
}
8787
}
88-
89-
?>

include/classes/coins/coin_scrypt.class.php

-2
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@
99
class Coin extends CoinBase {
1010
protected $target_bits = 16;
1111
}
12-
13-
?>

include/classes/coins/coin_scryptn.class.php

-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,3 @@
1212
class Coin extends CoinBase {
1313
protected $target_bits = 16;
1414
}
15-
16-
?>

include/classes/coins/coin_sha256d.class.php

-2
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ class Coin extends CoinBase {
1010
protected $target_bits = 32;
1111
protected $coin_value_precision = 20;
1212
}
13-
14-
?>

include/classes/coins/coin_x11.class.php

-2
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ class Coin extends CoinBase {
1010
protected $target_bits = 24;
1111
protected $share_difficulty_precision = 4;
1212
}
13-
14-
?>

include/classes/csrftoken.class.php

-1
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,3 @@ private function getHash($string) {
104104
$csrftoken->setToken($oToken);
105105
$csrftoken->setConfig($config);
106106
$csrftoken->setErrorCodes($aErrorCodes);
107-
?>

include/classes/debug.class.php

-1
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,3 @@ function printDebugInfo() {
111111

112112
// Instantiate this class
113113
$debug = new Debug($log, $config['DEBUG']);
114-
?>

include/classes/invitation.class.php

-1
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,3 @@ public function sendInvitation($account_id, $aData) {
139139
$invitation->setToken($oToken);
140140
$invitation->setConfig($config);
141141
$invitation->setErrorCodes($aErrorCodes);
142-
?>

include/classes/logger.class.php

-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,3 @@ public function log($strType, $strMessage) {
5757
}
5858
}
5959
$log = new Logger($config);
60-
?>

include/classes/mail.class.php

-1
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,3 @@ public function sendMail($template, $aData, $throttle=false) {
117117
$mail->setConfig($config);
118118
$mail->setSetting($setting);
119119
$mail->setErrorCodes($aErrorCodes);
120-
?>

include/classes/memcache_ad.class.php

-2
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,3 @@ public function getRequestBase() {
8181
return $new;
8282
}
8383
}
84-
85-
?>

include/classes/news.class.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
class News extends Base {
55
protected $table = 'news';
66

7+
/**
8+
* We allow changing the database for shared accounts across pools
9+
* Load the config on construct so we can assign the DB name
10+
* @param config array MPOS configuration
11+
* @return none
12+
**/
13+
public function __construct($config) {
14+
$this->setConfig($config);
15+
$this->table = $this->config['db']['shared']['news'] . '.' . $this->table;
16+
}
17+
718
/**
819
* Get activation status of post
920
* @param id int News ID
@@ -96,9 +107,8 @@ public function addNews($account_id, $aData, $active=false) {
96107
}
97108
}
98109

99-
$news = new News();
110+
$news = new News($config);
100111
$news->setDebug($debug);
101112
$news->setMysql($mysqli);
102113
$news->setUser($user);
103114
$news->setErrorCodes($aErrorCodes);
104-
?>

include/classes/notification.class.php

-1
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,3 @@ public function cleanupNotifications($days=7) {
195195
$notification->setConfig($config);
196196
$notification->setSetting($setting);
197197
$notification->setErrorCodes($aErrorCodes);
198-
?>

include/classes/payout.class.php

-2
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,3 @@ public function setProcessed($id) {
6767
$oPayout->setConfig($config);
6868
$oPayout->setToken($oToken);
6969
$oPayout->setErrorCodes($aErrorCodes);
70-
71-
?>

include/classes/roundstats.class.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
33

44
class RoundStats extends Base {
5-
private $tableTrans = 'transactions';
6-
private $tableStats = 'statistics_shares';
7-
private $tableBlocks = 'blocks';
8-
private $tableUsers = 'accounts';
9-
105
/**
116
* Get next block for round stats
127
**/
@@ -79,7 +74,7 @@ public function getDetailsForBlockHeight($iHeight=0) {
7974
b.id, height, blockhash, amount, confirmations, difficulty, FROM_UNIXTIME(time) as time, shares,
8075
IF(a.is_anonymous, 'anonymous', a.username) AS finder,
8176
ROUND(difficulty * POW(2, 32 - " . $this->coin->getTargetBits() . "), 0) AS estshares,
82-
(time - (SELECT time FROM $this->tableBlocks WHERE height < ? ORDER BY height DESC LIMIT 1)) AS round_time
77+
(time - (SELECT time FROM " . $this->block->getTableName() . " WHERE height < ? ORDER BY height DESC LIMIT 1)) AS round_time
8378
FROM " . $this->block->getTableName() . " as b
8479
LEFT JOIN " . $this->user->getTableName() . " AS a ON b.account_id = a.id
8580
WHERE b.height = ? LIMIT 1");

include/classes/statistics.class.php

-1
Original file line numberDiff line numberDiff line change
@@ -927,4 +927,3 @@ public function purgeUserStats($days = 1) {
927927
$statistics->setBitcoin($bitcoin);
928928
$statistics->setErrorCodes($aErrorCodes);
929929
$statistics->setCoin($coin);
930-
?>

include/classes/strict.class.php

-2
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,3 @@ public function bind_param($paramTypes) {
3535
}
3636
}
3737
}
38-
39-
?>

include/classes/transaction.class.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ public function getAPQueue($limit=250) {
355355
SELECT
356356
a.id,
357357
a.username,
358-
a.ap_threshold,
358+
ca.ap_threshold,
359359
ca.coin_address,
360360
IFNULL(
361361
(
@@ -371,9 +371,9 @@ public function getAPQueue($limit=250) {
371371
ON t.account_id = a.id
372372
LEFT JOIN " . $this->coin_address->getTableName() . " AS ca
373373
ON ca.account_id = a.id
374-
WHERE t.archived = 0 AND a.ap_threshold > 0 AND ca.coin_address IS NOT NULL AND ca.coin_address != '' AND ca.currency = ?
374+
WHERE t.archived = 0 AND ca.ap_threshold > 0 AND ca.coin_address IS NOT NULL AND ca.coin_address != '' AND ca.currency = ?
375375
GROUP BY t.account_id
376-
HAVING confirmed > a.ap_threshold AND confirmed > " . $this->config['txfee_auto'] . "
376+
HAVING confirmed > ca.ap_threshold AND confirmed > " . $this->config['txfee_auto'] . "
377377
LIMIT ?");
378378
if ($this->checkStmt($stmt) && $stmt->bind_param('si', $this->config['currency'], $limit) && $stmt->execute() && $result = $stmt->get_result())
379379
return $result->fetch_all(MYSQLI_ASSOC);
@@ -446,7 +446,7 @@ public function getMPQueue($limit=250) {
446446
SELECT
447447
a.id,
448448
a.username,
449-
a.ap_threshold,
449+
ca.ap_threshold,
450450
ca.coin_address,
451451
p.id AS payout_id,
452452
IFNULL(
@@ -488,4 +488,3 @@ public function getMPQueue($limit=250) {
488488
$transaction->setUser($user);
489489
$transaction->setPayout($oPayout);
490490
$transaction->setErrorCodes($aErrorCodes);
491-
?>

0 commit comments

Comments
 (0)