From cb7f114cbc4c86bf3d6c770296b11f704dbed23f Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 1 Jul 2013 17:45:23 +0200 Subject: [PATCH 01/41] Adding dynamic block value support in PPS This will add the block reward typw to PPS systems. Prior to this, each PPS value was hard coded to 50. Not only are other coins not based on this but changing it would require code. Changed it that * Default for fixed type is config reward * Default for block type is **previous** blocks amount ** Fallback for first round is the fixed reward value See in-line documentation of dist configuration. This should help new pool owners to get setup and clarify things. Fixes #308 --- cronjobs/findblock.php | 1 + cronjobs/pps_payout.php | 11 ++++++++++- public/include/config/global.inc.dist.php | 23 ++++++++++++++++++++++- public/include/smarty_globals.inc.php | 13 ++++++++++++- 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/cronjobs/findblock.php b/cronjobs/findblock.php index 3f3fb7e0..c03c0381 100755 --- a/cronjobs/findblock.php +++ b/cronjobs/findblock.php @@ -63,6 +63,7 @@ if (empty($aTransactions['transactions'])) { verbose("Failed" . "\n"); } } + exit; } } diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index 7a2ed5e9..22e5fcf7 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -40,7 +40,16 @@ if ( $bitcoin->can_connect() === true ){ } // Value per share calculation -$pps_value = number_format(round(50 / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12); +if ($config['reward_type'] != 'block') { +$pps_value = number_format(round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12); +} else { + // Try to find the last block value and use that for future payouts, revert to fixed reward if none found + if ($aLastBlock = $block->getLast()) { + $pps_value = number_format(round($aLastBlock['amount'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12); + } else { + $pps_value = number_format(round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12); + } +} // Find our last share accounted and last inserted share for PPS calculations $iPreviousShareId = $setting->getValue('pps_last_share_id'); diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index 48931389..c847dfdc 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -177,12 +177,33 @@ $config['difficulty'] = 20; /** * This defines how rewards are paid to users. * + * Explanation: + * + * Proportional Payout System + * When running a pool on fixed mode, each block will be paid + * out as defined in `reward`. If you wish to pass transaction + * fees inside discovered blocks on to user, set this to `block`. + * This is really helpful for altcoins with dynamic block values! + * + * PPS Payout System + * If set to `fixed`, all PPS values are based on the `reward` setting. + * If you set it to `block` you will calculate the current round based + * on the previous block value. The idea is to pass the block of the + * last round on to the users. If no previous block is found, PPS value + * will fall back to the fixed value set in `reward`. Ensure you don't + * overpay users in the first round! + * * Available options: + * reward_type: * fixed : Fixed value according to `reward` setting * block : Dynamic value based on block amount + * reward: + * float value : Any value of your choice but should reflect base block values * * Default: - * fixed + * reward_type = `fixed` + * reward = 50 + * **/ $config['reward_type'] = 'fixed'; $config['reward'] = 50; diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index a2983baf..ef5beb1b 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -32,7 +32,6 @@ $aGlobal = array( 'websitename' => $config['website']['name'], 'hashrate' => $iCurrentPoolHashrate, 'sharerate' => $iCurrentPoolShareRate, - 'ppsvalue' => number_format(round(50 / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12), 'workers' => $iCurrentActiveWorkers, 'roundshares' => $aRoundShares, 'fees' => $config['fees'], @@ -55,6 +54,18 @@ $aGlobal = array( ) ); +// Special calculations for PPS Values based on reward_type setting and/or available blocks +if ($config['reward_type'] != 'block') { + $aGlobal['ppsvalue'] = number_format(round(50 / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12); +} else { + // Try to find the last block value and use that for future payouts, revert to fixed reward if none found + if ($aLastBlock = $block->getLast()) { + $aGlobal['ppsvalue'] = number_format(round($aLastBlock['amount'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12); + } else { + $aGlobal['ppsvalue'] = number_format(round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12); + } +} + // We don't want these session infos cached if (@$_SESSION['USERDATA']['id']) { $aGlobal['userdata'] = $_SESSION['USERDATA']['id'] ? $user->getUserData($_SESSION['USERDATA']['id']) : array(); From 9e306bf06ee465aeac620986f2dd134be25b91ee Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 2 Jul 2013 09:00:01 +0200 Subject: [PATCH 02/41] Potential fix for PHP Warning This should fix #327 --- public/include/smarty_globals.inc.php | 4 +++- public/templates/mmcFE/global/header.tpl | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index a9b0fdde..ede677cb 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -18,9 +18,11 @@ if (@$_SESSION['AUTHENTICATED']) { $dDifficulty = $bitcoin->query('getdifficulty'); if (is_array($dDifficulty) && array_key_exists('proof-of-work', $dDifficulty)) $dDifficulty = $dDifficulty['proof-of-work']; - $dNetworkHashrate = $bitcoin->query('getnetworkhashps'); } } +// Always fetch this since we need for ministats header +if ($bitcoin->can_connect() === true) + $dNetworkHashrate = $bitcoin->query('getnetworkhashps'); // Fetch some data $iCurrentActiveWorkers = $worker->getCountAllActiveWorkers(); diff --git a/public/templates/mmcFE/global/header.tpl b/public/templates/mmcFE/global/header.tpl index 48ac9ebd..89670daa 100644 --- a/public/templates/mmcFE/global/header.tpl +++ b/public/templates/mmcFE/global/header.tpl @@ -5,7 +5,7 @@ {if $GLOBAL.config.price.currency}{/if} - + From 535f13c1846dc9a18e57ad84a3dbbb7983f022b0 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 2 Jul 2013 10:38:23 +0200 Subject: [PATCH 03/41] Fixing PHP Warnings in Registration page * Fix API Key generation not using SALT when creating hash * This should not affect existing API keys since hashes are compared * Fix PHP Warning for RECAPTCHA if disabled Fixes #328 --- public/include/classes/user.class.php | 2 +- public/templates/mmcFE/register/default.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/include/classes/user.class.php b/public/include/classes/user.class.php index 07cf6107..bbce3571 100644 --- a/public/include/classes/user.class.php +++ b/public/include/classes/user.class.php @@ -449,7 +449,7 @@ class User { $this->setErrorMessage( 'Invalid PIN' ); return false; } - $apikey = hash("sha256",$username.$salt); + $apikey = hash("sha256",$username.$this->salt); if ($this->mysqli->query("SELECT id FROM $this->table LIMIT 1")->num_rows > 0) { $stmt = $this->mysqli->prepare(" INSERT INTO $this->table (username, pass, email, pin, api_key) diff --git a/public/templates/mmcFE/register/default.tpl b/public/templates/mmcFE/register/default.tpl index 94cdf0f8..3316dfa9 100644 --- a/public/templates/mmcFE/register/default.tpl +++ b/public/templates/mmcFE/register/default.tpl @@ -10,7 +10,7 @@ - +
  • {$GLOBAL.config.currency}/{$GLOBAL.config.price.currency}: {$GLOBAL.price|default:"n/a"|number_format:"4"}    
  • Network Hashrate: {($GLOBAL.nethashrate / 1000 / 1000 / 1000)|number_format:"3"} GH/s    
  • Network Hashrate: {($GLOBAL.nethashrate / 1000 / 1000 / 1000)|default:"0"|number_format:"3"} GH/s    
  • Pool Hashrate: {($GLOBAL.hashrate / 1000)|number_format:"3"} MH/s    
  • Pool Sharerate: {$GLOBAL.sharerate|number_format:"2"} Shares/s    
  • Pool Workers: {$GLOBAL.workers}    
  • Email:
    Email Repeat:
    PIN: (4 digit number. Remember this pin!)
    {nocache}{$RECAPTCHA}{/nocache}
    {nocache}{$RECAPTCHA|default:""}{/nocache}
    From a60b8678d987e1772e1429b1461e0a4363731212 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 2 Jul 2013 11:54:32 +0200 Subject: [PATCH 04/41] Starting to add pools to README/POOLS file --- POOLS.md | 18 ++++++++++++++++++ README.md | 5 +++++ 2 files changed, 23 insertions(+) create mode 100644 POOLS.md diff --git a/POOLS.md b/POOLS.md new file mode 100644 index 00000000..7c322f1b --- /dev/null +++ b/POOLS.md @@ -0,0 +1,18 @@ +Pools running mmcfe-ng +====================== + +If you are not sure if you want to use `mmcfe-ng` on your own pool, +maybe this list will push you over the edge of decision making. Some +small and large pools are already running on it and have succesfully +tested it on various coins. + +These tables represent their users pools. Be aware that all values are +as of this writing and may have changed since then. + +# @ahmedbodi + +| Pool URL | Coin | Avg. Hashrate | Avg. Active Users | Notes | +| ------------- |:-------------:| -----:| | | +| http://crypto-expert.com/REDpool/public | Redcoin | 10 MHash | 12 | No modifications required | + + diff --git a/README.md b/README.md index 0a6ed72a..14526524 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,11 @@ These people have supported this project with a donation: * [WKNiGHT](https://github.com/WKNiGHT-) * [ZC](https://github.com/zccopwrx) +Pools running mmcfe-ng +====================== + +You can find a list of active pools [here](POOLS.md). + Requirements ============ From ba4b737f0967b60f5b5301cfdadaba45d21e8dae Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 2 Jul 2013 12:09:24 +0200 Subject: [PATCH 05/41] Update POOLS.md --- POOLS.md | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/POOLS.md b/POOLS.md index 7c322f1b..88402b26 100644 --- a/POOLS.md +++ b/POOLS.md @@ -9,10 +9,44 @@ tested it on various coins. These tables represent their users pools. Be aware that all values are as of this writing and may have changed since then. -# @ahmedbodi +### ahmedbodi -| Pool URL | Coin | Avg. Hashrate | Avg. Active Users | Notes | -| ------------- |:-------------:| -----:| | | +A helpful tester for features and bug fixes in `mmcfe-ng`, he is running +an active pool for Redcoin. + +| Pool URL | Coin | Avg. Hashrate | Avg. Active Workers | Notes | +| :------- | :--- | ------------: | ------------------: | ----- | | http://crypto-expert.com/REDpool/public | Redcoin | 10 MHash | 12 | No modifications required | +| http://crypto-expert.com/ANONpool/public | Anoncoin | 0 MHash | 0 | Template Changes | +### vias79 + +Vias is using mmcfe-ng with a small group of people to mine various coins. +They have succesfully mined blocks on each of those pools listed. +All pools are running on Stratum only. + +| Pool URL | Coin | Avg. Hashrate | Avg. Active Workers | Notes | +| -------- | ---- | ------------- | ----------------- | ----- | +| http://wdc.nordicminers.eu | Worldcoin | n/a | n/a | | +| http://lky.nordicminers.eu | Luckycoin | n/a | n/a | | +| http://fst.nordicminers.eu | Fastcoin | n/a | n/a | | +| http://dgc.nordicminers.eu | Digitalcoin | n/a | n/a | | +| http://ezc.nordicminers.eu | Ezcoin | n/a | n/a | | +| http://sbc.nordicminers.eu | Stablecoin | n/a | n/a | | +| http://mnc.nordicminers.eu | Mincoin | n/a | n/a | | +| http://arg.nordicminers.eu | Argentum | n/a | n/a | | +| http://mem.nordicminers.eu | Memecoin | n/a | n/a | | +| http://frk.nordicminers.eu | Franko | n/a | n/a | | +| http://pxc.nordicminers.eu | Phenixcoin | n/a | n/a | | + +### WKNiGHT + +WKNiGHT was an early adopter of `mmcfe-ng`. He has been around since a first stable release +which only featured proportional payouts. He successfully moved to PPS since then and is +running more or less without any issues (related to `mmcfe-ng` that is ;-)). He is also running +the most powerful pool! + +| Pool URL | Coin | Avg. Hashrate | Avg. Active Workers | Notes | +| -------- | ---- | ------------- | ----------------- | ----- | +| http://www.ejpool.info | Litecoin | 155 MHash | 120 | | From c8f662f91d14383f4fc8974d9af79909b026e686 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 2 Jul 2013 13:28:51 +0200 Subject: [PATCH 06/41] Show nethash rate in MHash/s not GHash/s * Easier to compare directly with pool hashrate * Better display format for low nethash rate coins Fixes #331 --- public/templates/mmcFE/global/header.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/mmcFE/global/header.tpl b/public/templates/mmcFE/global/header.tpl index 89670daa..c195c18a 100644 --- a/public/templates/mmcFE/global/header.tpl +++ b/public/templates/mmcFE/global/header.tpl @@ -5,7 +5,7 @@ {if $GLOBAL.config.price.currency}{/if} - + From 306162a1daaeab123d66f46f7c4671bdd4643199 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 2 Jul 2013 14:02:13 +0200 Subject: [PATCH 07/41] Adding shares archive table back in for hash calcs If the shares archive table is used via config option, those shares are included when calculating the users hashrate. This will help on very short rounds where each round end deletes all shares and users will not be able to track their hashrates. They will be very jumpy and change to 0 all the time. Still missing this implementation for the hourly hashrate function to ensure the graphs are always kept up-to-date. Addresses #331 --- public/include/classes/statistics.class.php | 82 +++++++++++++-------- 1 file changed, 53 insertions(+), 29 deletions(-) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 0ea3c522..0d25d724 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -99,8 +99,19 @@ class Statistics { $this->debug->append("STA " . __METHOD__, 4); if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data; $stmt = $this->mysqli->prepare(" - SELECT ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/600/1000) AS hashrate FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) - "); + SELECT + ( + ( + SELECT ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/600/1000) AS hashrate + FROM " . $this->share->getTableName() . " + WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) + ) + ( + SELECT ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/600/1000) AS hashrate + FROM " . $this->share->getArchiveTableName() . " + WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) + ) + ) AS hashrate + FROM DUAL"); // Catchall if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result() ) return $this->memcache->setCache(__FUNCTION__, $result->fetch_object()->hashrate); $this->debug->append("Failed to get hashrate: " . $this->mysqli->error); @@ -116,8 +127,9 @@ class Statistics { $this->debug->append("STA " . __METHOD__, 4); if ($data = $this->memcache->get(__FUNCTION__)) return $data; $stmt = $this->mysqli->prepare(" - SELECT ROUND(COUNT(id) / 600, 2) AS sharerate FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) - "); + SELECT ROUND(COUNT(id) / 600, 2) AS sharerate + FROM " . $this->share->getTableName() . " + WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)"); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result() ) return $this->memcache->setCache(__FUNCTION__, $result->fetch_object()->sharerate); // Catchall $this->debug->append("Failed to fetch share rate: " . $this->mysqli->error); @@ -161,9 +173,8 @@ class Statistics { u.id AS id, u.username AS username FROM " . $this->share->getTableName() . " AS s, - " . $this->user->getTableName() . " AS u - WHERE - u.username = SUBSTRING_INDEX( s.username, '.', 1 ) + " . $this->user->getTableName() . " AS u + WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 ) AND UNIX_TIMESTAMP(s.time) >IFNULL((SELECT MAX(b.time) FROM " . $this->block->getTableName() . " AS b),0) GROUP BY u.id"); if ($stmt && $stmt->execute() && $result = $stmt->get_result()) @@ -186,7 +197,7 @@ class Statistics { SUM(IF(our_result='Y', 1, 0)) AS valid, SUM(IF(our_result='N', 1, 0)) AS invalid FROM " . $this->share->getTableName() . " AS s, - " . $this->user->getTableName() . " AS u + " . $this->user->getTableName() . " AS u WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 ) AND UNIX_TIMESTAMP(s.time) >IFNULL((SELECT MAX(b.time) FROM " . $this->block->getTableName() . " AS b),0) @@ -236,13 +247,24 @@ class Statistics { $this->debug->append("STA " . __METHOD__, 4); if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data; $stmt = $this->mysqli->prepare(" - SELECT ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ")/600/1000) AS hashrate - FROM " . $this->share->getTableName() . " AS s, - " . $this->user->getTableName() . " AS u - WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 ) - AND s.time > DATE_SUB(now(), INTERVAL 10 MINUTE) - AND u.id = ?"); - if ($this->checkStmt($stmt) && $stmt->bind_param("i", $account_id) && $stmt->execute() && $result = $stmt->get_result() ) + SELECT + ( + SELECT ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 600 / 1000) AS hashrate + FROM " . $this->share->getTableName() . " AS s, + " . $this->user->getTableName() . " AS u + WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 ) + AND s.time > DATE_SUB(now(), INTERVAL 10 MINUTE) + AND u.id = ? + ) + ( + SELECT ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 600 / 1000) AS hashrate + FROM " . $this->share->getArchiveTableName() . " AS s, + " . $this->user->getTableName() . " AS u + WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 ) + AND s.time > DATE_SUB(now(), INTERVAL 10 MINUTE) + AND u.id = ? + ) AS hashrate + FROM DUAL"); + if ($this->checkStmt($stmt) && $stmt->bind_param("ii", $account_id, $account_id) && $stmt->execute() && $result = $stmt->get_result() ) return $this->memcache->setCache(__FUNCTION__ . $account_id, $result->fetch_object()->hashrate); // Catchall $this->debug->append("Failed to fetch hashrate: " . $this->mysqli->error); @@ -306,8 +328,8 @@ class Statistics { case 'shares': $stmt = $this->mysqli->prepare(" SELECT - COUNT(id) AS shares, - SUBSTRING_INDEX( username, '.', 1 ) AS account + COUNT(id) AS shares, + SUBSTRING_INDEX( username, '.', 1 ) AS account FROM " . $this->share->getTableName() . " WHERE our_result = 'Y' GROUP BY account @@ -324,9 +346,12 @@ class Statistics { SELECT ROUND(COUNT(id) * POW(2," . $this->config['difficulty'] . ")/600/1000,2) AS hashrate, SUBSTRING_INDEX( username, '.', 1 ) AS account - FROM " . $this->share->getTableName() . " - WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) - AND our_result = 'Y' + FROM + ( + SELECT id, username FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) AND our_result = 'Y' + UNION + SELECT id, username FROM " . $this->share->getArchiveTableName() ." WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) AND our_result = 'Y' + ) AS t1 GROUP BY account ORDER BY hashrate DESC LIMIT ?"); if ($this->checkStmt($stmt) && $stmt->bind_param("i", $limit) && $stmt->execute() && $result = $stmt->get_result()) @@ -347,15 +372,14 @@ class Statistics { if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data; $stmt = $this->mysqli->prepare(" SELECT - ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate, + ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate, HOUR(s.time) AS hour FROM " . $this->share->getTableName() . " AS s, accounts AS a WHERE time < NOW() - INTERVAL 1 HOUR AND time > NOW() - INTERVAL 25 HOUR AND a.username = SUBSTRING_INDEX( s.username, '.', 1 ) AND a.id = ? - GROUP BY HOUR(time) - "); + GROUP BY HOUR(time)"); if ($this->checkStmt($stmt) && $stmt->bind_param("i", $account_id) && $stmt->execute() && $result = $stmt->get_result()) { $aData = array(); while ($row = $result->fetch_assoc()) { @@ -367,7 +391,7 @@ class Statistics { $this->debug->append("Failed to fetch hourly hashrate: " . $this->mysqli->error); return false; } - + /** * get Hourly hashrate for the pool * @param none @@ -378,13 +402,13 @@ class Statistics { if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data; $stmt = $this->mysqli->prepare(" SELECT - ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate, + ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate, HOUR(s.time) AS hour - FROM " . $this->share->getTableName() . " AS s - WHERE time < NOW() - INTERVAL 1 HOUR + FROM " . $this->share->getTableName() . " AS s + WHERE time < NOW() - INTERVAL 1 HOUR AND time > NOW() - INTERVAL 25 HOUR - GROUP BY HOUR(time) - "); + GROUP BY HOUR(time) + "); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) { while ($row = $result->fetch_assoc()) { $aData[$row['hour']] = $row['hashrate']; From e1c5761cf460af5a76f6661b9407335124f06962 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 2 Jul 2013 20:59:03 +0200 Subject: [PATCH 08/41] Fixing strict PHP warnings when registering a user Fixes #329 --- public/include/classes/user.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/public/include/classes/user.class.php b/public/include/classes/user.class.php index bbce3571..04640043 100644 --- a/public/include/classes/user.class.php +++ b/public/include/classes/user.class.php @@ -449,7 +449,6 @@ class User { $this->setErrorMessage( 'Invalid PIN' ); return false; } - $apikey = hash("sha256",$username.$this->salt); if ($this->mysqli->query("SELECT id FROM $this->table LIMIT 1")->num_rows > 0) { $stmt = $this->mysqli->prepare(" INSERT INTO $this->table (username, pass, email, pin, api_key) @@ -461,12 +460,16 @@ class User { VALUES (?, ?, ?, ?, ?, 1) "); } - if ($this->checkStmt($stmt)) { - $stmt->bind_param('sssss', $username, hash("sha256", $password1.$this->salt), $email1, hash("sha256", $pin.$this->salt), $apikey); + + // Create hashed strings using original string and salt + $password_hash = hash('sha256', $password1.$this->salt); + $pin_hash = hash('sha256', $pin.$this->salt); + $apikey_hash = hash('sha256', $username.$this->salt); + + if ($this->checkStmt($stmt) && $stmt->bind_param('sssss', $username, $password_hash, $email1, $pin_hash, $apikey_hash)) { if (!$stmt->execute()) { $this->setErrorMessage( 'Unable to register' ); if ($stmt->sqlstate == '23000') $this->setErrorMessage( 'Username already exists' ); - echo $this->mysqli->error; return false; } $stmt->close(); From 7e4938f279dd08f2803c87388875082c3858864f Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 2 Jul 2013 21:08:26 +0200 Subject: [PATCH 09/41] Fixing PHP warnings on account workers page * Fixes PHP Warning if no workers are updated * Fixes PHP Warning in worker class if data is empty Fixes #339 --- public/include/classes/worker.class.php | 4 ++++ public/include/pages/account/workers.inc.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/public/include/classes/worker.class.php b/public/include/classes/worker.class.php index 6cac9827..0aff7a62 100644 --- a/public/include/classes/worker.class.php +++ b/public/include/classes/worker.class.php @@ -42,6 +42,10 @@ class Worker { **/ public function updateWorkers($account_id, $data) { $this->debug->append("STA " . __METHOD__, 4); + if (!is_array($data)) { + $this->setErrorMessage('No workers to update'); + return false; + } $username = $this->user->getUserName($account_id); $iFailed = 0; foreach ($data as $key => $value) { diff --git a/public/include/pages/account/workers.inc.php b/public/include/pages/account/workers.inc.php index ccdae2b8..35affca8 100644 --- a/public/include/pages/account/workers.inc.php +++ b/public/include/pages/account/workers.inc.php @@ -1,4 +1,5 @@ isAuthenticated()) { } break; case 'update': - if ($worker->updateWorkers($_SESSION['USERDATA']['id'], $_POST['data'])) { + if ($worker->updateWorkers($_SESSION['USERDATA']['id'], @$_POST['data'])) { $_SESSION['POPUP'][] = array('CONTENT' => 'Worker updated'); } else { $_SESSION['POPUP'][] = array('CONTENT' => $worker->getError(), 'TYPE' => 'errormsg'); From 591fc3733b8cf65458450a504dbed2daf0fa523b Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 2 Jul 2013 21:10:12 +0200 Subject: [PATCH 10/41] removing error reporting for debugging --- public/include/pages/account/workers.inc.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/public/include/pages/account/workers.inc.php b/public/include/pages/account/workers.inc.php index 35affca8..cb0711b1 100644 --- a/public/include/pages/account/workers.inc.php +++ b/public/include/pages/account/workers.inc.php @@ -1,6 +1,4 @@ Date: Tue, 2 Jul 2013 21:11:48 +0200 Subject: [PATCH 11/41] Re-adding default My Account link Fixes #338 --- public/templates/mmcFE/global/navigation.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/mmcFE/global/navigation.tpl b/public/templates/mmcFE/global/navigation.tpl index 90554bed..70619098 100644 --- a/public/templates/mmcFE/global/navigation.tpl +++ b/public/templates/mmcFE/global/navigation.tpl @@ -1,7 +1,7 @@ + {if $GLOBAL.chaininfo} + {else} + + {/if} From 1cfc66e748a7f93eab444353217e383fd4b18019 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 2 Jul 2013 21:26:33 +0200 Subject: [PATCH 13/41] fixing low confirmations limit in dist config --- public/include/config/global.inc.dist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index 48931389..d7d9b824 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -188,7 +188,7 @@ $config['reward_type'] = 'fixed'; $config['reward'] = 50; // Confirmations per block required to credit transactions, default: 120 -$config['confirmations'] = 5; +$config['confirmations'] = 120; /** From 35131aa71b1ec2d4fe44c649f2a4960f28bb7fa8 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 2 Jul 2013 21:27:41 +0200 Subject: [PATCH 14/41] enable memcache by default --- public/include/config/global.inc.dist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index d7d9b824..6771ec4f 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -213,7 +213,7 @@ $config['confirmations'] = 120; * expiration = 90 * splay = 15 **/ -$config['memcache']['enabled'] = false; +$config['memcache']['enabled'] = true; $config['memcache']['host'] = 'localhost'; $config['memcache']['port'] = 11211; $config['memcache']['keyprefix'] = 'mmcfe_ng_'; From 24473ee98f64bc3f32c31b66e7b6e6f2f09c3e4d Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 3 Jul 2013 07:52:38 +0200 Subject: [PATCH 15/41] Remove link on mobile if chaininfo empty * Remove URL from Difficulty on stats page if chaininfo is empty * Added note to global dist configuration file Fixes #336 --- public/include/config/global.inc.dist.php | 1 + public/templates/mobile/statistics/pool/authenticated.tpl | 2 ++ 2 files changed, 3 insertions(+) diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index 6771ec4f..4f693633 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -164,6 +164,7 @@ $config['archive_shares'] = true; $config['blockexplorer'] = 'http://explorer.litecoin.net/search?q='; // Link to blockchain information, used for difficulty link, default: `http://allchains.info` +// If empty, the difficulty link to the chain information will be removed $config['chaininfo'] = 'http://allchains.info'; // Pool fees applied to users in percent, default: 0 (disabled) diff --git a/public/templates/mobile/statistics/pool/authenticated.tpl b/public/templates/mobile/statistics/pool/authenticated.tpl index b2a499e3..5cb2321e 100644 --- a/public/templates/mobile/statistics/pool/authenticated.tpl +++ b/public/templates/mobile/statistics/pool/authenticated.tpl @@ -32,10 +32,12 @@ + {if $GLOBAL.chaininfo} + {/if} From 4f2402e6ed85e874d7e5876b340bb81e0d1ac270 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 3 Jul 2013 08:09:09 +0200 Subject: [PATCH 16/41] Fix PHP warning in notification class * Fix PHP Warning if no notification settings exist yet Fixes #346 --- public/include/classes/notification.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/public/include/classes/notification.class.php b/public/include/classes/notification.class.php index e07b3c32..910f5674 100644 --- a/public/include/classes/notification.class.php +++ b/public/include/classes/notification.class.php @@ -99,12 +99,16 @@ class Notification extends Mail { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare("SELECT * FROM $this->tableSettings WHERE account_id = ?"); if ($stmt && $stmt->bind_param('i', $account_id) && $stmt->execute() && $result = $stmt->get_result()) { - while ($row = $result->fetch_assoc()) { - $aData[$row['type']] = $row['active']; + if ($result->num_rows > 0) { + while ($row = $result->fetch_assoc()) { + $aData[$row['type']] = $row['active']; + } + return $aData; } - return $aData; } // Catchall + $this->setErrorMessage('Unable to fetch notification settings'); + $this->debug->append('Failed fetching notification settings for ' . $account_id . ': ' . $this->mysqli->error); return false; } From 382fddb5283612f595a858d006f6c06d09ce4bc0 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 3 Jul 2013 14:21:05 +0200 Subject: [PATCH 17/41] Remove PHP Warnings from worker page * Added HTML5 required flags for username/passwords * Added empty string check in addWorker method Fixes #347 --- public/include/classes/worker.class.php | 5 ++++- public/templates/mmcFE/account/workers/default.tpl | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/public/include/classes/worker.class.php b/public/include/classes/worker.class.php index 0aff7a62..716a2c15 100644 --- a/public/include/classes/worker.class.php +++ b/public/include/classes/worker.class.php @@ -154,6 +154,10 @@ class Worker { **/ public function addWorker($account_id, $workerName, $workerPassword) { $this->debug->append("STA " . __METHOD__, 4); + if (empty($workerName) || empty($workerPassword)) { + $this->setErrorMessage('Worker and password may not be empty'); + return false; + } $username = $this->user->getUserName($account_id); $workerName = "$username.$workerName"; $stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id, username, password) VALUES(?, ?, ?)"); @@ -181,7 +185,6 @@ class Worker { if ($this->checkStmt($stmt)) { $stmt->bind_param('ii', $account_id, $id); if ($stmt->execute() && $stmt->affected_rows == 1) { - $stmt->close; return true; } else { $this->setErrorMessage( 'Unable to delete worker' ); diff --git a/public/templates/mmcFE/account/workers/default.tpl b/public/templates/mmcFE/account/workers/default.tpl index 8c127400..c69d1139 100644 --- a/public/templates/mmcFE/account/workers/default.tpl +++ b/public/templates/mmcFE/account/workers/default.tpl @@ -18,8 +18,8 @@ {section worker $WORKERS} {assign var="username" value="."|escape|explode:$WORKERS[worker].username:2} - {$username.0|escape}. - + {$username.0|escape}. + - + - + - + - + diff --git a/public/templates/mobile/global/sidebar_prop.tpl b/public/templates/mobile/global/sidebar_prop.tpl index 6cb85adf..18fec375 100644 --- a/public/templates/mobile/global/sidebar_prop.tpl +++ b/public/templates/mobile/global/sidebar_prop.tpl @@ -33,22 +33,22 @@ - + - + - + - + - - + +
  • {$GLOBAL.config.currency}/{$GLOBAL.config.price.currency}: {$GLOBAL.price|default:"n/a"|number_format:"4"}    
  • Network Hashrate: {($GLOBAL.nethashrate / 1000 / 1000 / 1000)|default:"0"|number_format:"3"} GH/s    
  • Network Hashrate: {($GLOBAL.nethashrate / 1000 / 1000 )|default:"0"|number_format:"3"} MH/s    
  • Pool Hashrate: {($GLOBAL.hashrate / 1000)|number_format:"3"} MH/s    
  • Pool Sharerate: {$GLOBAL.sharerate|number_format:"2"} Shares/s    
  • Pool Workers: {$GLOBAL.workers}    
  • Current Difficulty{$DIFFICULTY}{$DIFFICULTY}
    Est. Avg. Time per RoundLast Block Found {$LASTBLOCK|default:"0"}
    Current Difficulty {$DIFFICULTY}
    Est. Avg. Time per Round {$ESTTIME|seconds_to_words}
    @@ -43,7 +43,7 @@ - {$smarty.session.USERDATA.username}. ·   + {$smarty.session.USERDATA.username}. ·   {include file="global/block_footer.tpl"} From ce5a8f72403d99ac7be46aa0f60f69ba9b49368e Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 3 Jul 2013 14:25:14 +0200 Subject: [PATCH 18/41] Fix PHP Warnings on Password Reset page * Added HTML5 required to username field * Added empty string check to resetPassword method Fixes #348 --- public/include/classes/user.class.php | 4 ++++ public/templates/mmcFE/password/default.tpl | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/public/include/classes/user.class.php b/public/include/classes/user.class.php index 04640043..6f8394dc 100644 --- a/public/include/classes/user.class.php +++ b/public/include/classes/user.class.php @@ -517,6 +517,10 @@ class User { public function resetPassword($username, $smarty) { $this->debug->append("STA " . __METHOD__, 4); // Fetch the users mail address + if (empty($username)) { + $this->serErrorMessage("Username must not be empty"); + return false; + } if (!$email = $this->getUserEmail($username)) { $this->setErrorMessage("Unable to find a mail address for user $username"); return false; diff --git a/public/templates/mmcFE/password/default.tpl b/public/templates/mmcFE/password/default.tpl index 35b4a0eb..c82ccd31 100644 --- a/public/templates/mmcFE/password/default.tpl +++ b/public/templates/mmcFE/password/default.tpl @@ -3,6 +3,6 @@

    If you have an email set for your account, enter your username to get your password reset

    -

    +

    {include file="global/block_footer.tpl"} From 76ced07a64d941217c9585af388b64573cffb50a Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 3 Jul 2013 14:32:24 +0200 Subject: [PATCH 19/41] Update POOLS.md Added additional pools --- POOLS.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/POOLS.md b/POOLS.md index 88402b26..88b986b4 100644 --- a/POOLS.md +++ b/POOLS.md @@ -50,3 +50,21 @@ the most powerful pool! | Pool URL | Coin | Avg. Hashrate | Avg. Active Workers | Notes | | -------- | ---- | ------------- | ----------------- | ----- | | http://www.ejpool.info | Litecoin | 155 MHash | 120 | | + +### Obigal + +Small Time Miners are running various stratum only pools for different coins. + +| Pool URL | Coin | Avg. Hashrate | Avg. Active Workers | Notes | +| -------- | ---- | ------------- | ------------------- | ----- | +| http://meg.smalltimeminer.com | Megacoin | 5 - 10 MHash | n/a | | +| http://flo.smalltimeminer.com | Florincoin | 5 - 6 MHash | n/a | | +| http://alf.smalltimeminer.com | Alphacoin | 2 - 4 MHash | n/a | | +| http://cgb.smalltimeminer.com | Cryptobullion | 2 - 4 MHash | n/a | PoS/PoW type coin + +### Feeleep75 + +| Pool URL | Coin | Avg. Hashrate | Avg. Active Workers | Notes | +| -------- | ---- | ------------- | ------------------- | ----- | +| http://bot.coinmine.pl | Bottlecaps | 3 - 50 MHash | n/a | PoS/PoW type coin | +| http://yacp.coinmine.pl | YaCoin | 19 MHash | n/a | | From f4ce22bee8a59579a33c34c703f3068c16908dfa Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 3 Jul 2013 15:01:08 +0200 Subject: [PATCH 20/41] Skip bogus upstream shares This will fix an issue with blocks being assigned upstream shares that are marked as valid but are not the actual solution for a block. Only shares inserted when or after the block timestamp are now looked at. This will ensure other shares inserted earlier and marked as upstream valid are skipped. This will not fix edge cases where many shares are inserted at the same time and are all in the same timeframe of the block. Then the first valid share in that time is used. This worked fine on a testnet with a number of blocks found and false shares inserted by hand. Fixes #352 --- cronjobs/findblock.php | 3 ++- public/include/classes/share.class.php | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cronjobs/findblock.php b/cronjobs/findblock.php index 3f3fb7e0..efcc9f11 100755 --- a/cronjobs/findblock.php +++ b/cronjobs/findblock.php @@ -77,7 +77,7 @@ if (empty($aAllBlocks)) { foreach ($aAllBlocks as $iIndex => $aBlock) { if (empty($aBlock['share_id'])) { // Fetch this blocks upstream ID - if ($share->setUpstream($block->getLastUpstreamId())) { + if ($share->setUpstream($block->getLastUpstreamId(), $aBlock['time'])) { $iCurrentUpstreamId = $share->getUpstreamId(); $iAccountId = $user->getUserId($share->getUpstreamFinder()); } else { @@ -85,6 +85,7 @@ if (empty($aAllBlocks)) { verbose($share->getError() . "\n"); exit; } + // Fetch share information if (!$iPreviousShareId = $block->getLastShareId()) { $iPreviousShareId = 0; diff --git a/public/include/classes/share.class.php b/public/include/classes/share.class.php index 85935a2d..6653814a 100644 --- a/public/include/classes/share.class.php +++ b/public/include/classes/share.class.php @@ -177,15 +177,16 @@ class Share { * @param last int Skips all shares up to last to find new share * @return bool **/ - public function setUpstream($last=0) { + public function setUpstream($last=0, $time=0) { $stmt = $this->mysqli->prepare(" SELECT SUBSTRING_INDEX( `username` , '.', 1 ) AS account, id FROM $this->table WHERE upstream_result = 'Y' AND id > ? + AND UNIX_TIMESTAMP(time) >= ? ORDER BY id ASC LIMIT 1"); - if ($this->checkStmt($stmt) && $stmt->bind_param('i', $last) && $stmt->execute() && $result = $stmt->get_result()) { + if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $last, $time) && $stmt->execute() && $result = $stmt->get_result()) { $this->oUpstream = $result->fetch_object(); if (!empty($this->oUpstream->account) && is_int($this->oUpstream->id)) return true; From bc1ca7feb3d5731fda0c3279d106ea7b1dec7e60 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 3 Jul 2013 19:12:32 +0200 Subject: [PATCH 21/41] Fixing mobile template warning on reset pw --- public/templates/mobile/password/default.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/mobile/password/default.tpl b/public/templates/mobile/password/default.tpl index 20f00297..69943979 100644 --- a/public/templates/mobile/password/default.tpl +++ b/public/templates/mobile/password/default.tpl @@ -2,5 +2,5 @@

    If you have an email set for your account, enter your username to get your password reset

    -

    +

    From d848e3fe7099d72c12da90f6b1030f070014f05f Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 4 Jul 2013 08:51:13 +0200 Subject: [PATCH 22/41] Fix PHP warning on empty news table Fixes #358 --- public/include/pages/home.inc.php | 8 +++++--- public/include/pages/news.inc.php | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/public/include/pages/home.inc.php b/public/include/pages/home.inc.php index 2d0f5b23..ea4bd8fb 100644 --- a/public/include/pages/home.inc.php +++ b/public/include/pages/home.inc.php @@ -8,9 +8,11 @@ use \Michelf\Markdown; // Fetch active news to display $aNews = $news->getAllActive(); -foreach ($aNews as $key => $aData) { - // Transform Markdown content to HTML - $aNews[$key]['content'] = Markdown::defaultTransform($aData['content']); +if (is_array($aNews)) { + foreach ($aNews as $key => $aData) { + // Transform Markdown content to HTML + $aNews[$key]['content'] = Markdown::defaultTransform($aData['content']); + } } // Load news entries for Desktop site and unauthenticated users diff --git a/public/include/pages/news.inc.php b/public/include/pages/news.inc.php index 38e1022d..127b1775 100644 --- a/public/include/pages/news.inc.php +++ b/public/include/pages/news.inc.php @@ -8,9 +8,11 @@ use \Michelf\Markdown; // Fetch active news to display $aNews = $news->getAllActive(); -foreach ($aNews as $key => $aData) { - // Transform Markdown content to HTML - $aNews[$key]['content'] = Markdown::defaultTransform($aData['content']); +if (is_array($aNews)) { + foreach ($aNews as $key => $aData) { + // Transform Markdown content to HTML + $aNews[$key]['content'] = Markdown::defaultTransform($aData['content']); + } } // Tempalte specifics From b021440ab7f3681f755a58147794adfc78f3a57d Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 4 Jul 2013 09:12:11 +0200 Subject: [PATCH 23/41] Removed debug exit on findblock cron --- cronjobs/findblock.php | 1 - 1 file changed, 1 deletion(-) diff --git a/cronjobs/findblock.php b/cronjobs/findblock.php index 93e7e51a..efcc9f11 100755 --- a/cronjobs/findblock.php +++ b/cronjobs/findblock.php @@ -63,7 +63,6 @@ if (empty($aTransactions['transactions'])) { verbose("Failed" . "\n"); } } - exit; } } From f3dd9caa2c62d90e8e165f6e8ad8162468f0eaea Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 4 Jul 2013 12:17:09 +0200 Subject: [PATCH 24/41] Added 8 digit estimates precision and balance This expands the prevision for LTC estimates to 8 digits. Since the sidebar was widened, they should fit for most resolutions. --- public/include/smarty_globals.inc.php | 8 ++++---- public/templates/mmcFE/global/sidebar_prop.tpl | 8 ++++---- public/templates/mobile/global/sidebar_prop.tpl | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index 996cd101..e2550e84 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -86,10 +86,10 @@ if (@$_SESSION['USERDATA']['id']) { default: // Some estimations if (@$aRoundShares['valid'] > 0) { - $aGlobal['userdata']['est_block'] = round(( (int)$aGlobal['userdata']['shares']['valid'] / (int)$aRoundShares['valid'] ) * (int)$config['reward'], 3); - $aGlobal['userdata']['est_fee'] = round(($config['fees'] / 100) * $aGlobal['userdata']['est_block'], 3); - $aGlobal['userdata']['est_donation'] = round((( $aGlobal['userdata']['donate_percent'] / 100) * ($aGlobal['userdata']['est_block'] - $aGlobal['userdata']['est_fee'])), 3); - $aGlobal['userdata']['est_payout'] = round($aGlobal['userdata']['est_block'] - $aGlobal['userdata']['est_donation'] - $aGlobal['userdata']['est_fee'], 3); + $aGlobal['userdata']['est_block'] = round(( (int)$aGlobal['userdata']['shares']['valid'] / (int)$aRoundShares['valid'] ) * (float)$config['reward'], 8); + $aGlobal['userdata']['est_fee'] = round(((float)$config['fees'] / 100) * (float)$aGlobal['userdata']['est_block'], 8); + $aGlobal['userdata']['est_donation'] = round((( (float)$aGlobal['userdata']['donate_percent'] / 100) * ((float)$aGlobal['userdata']['est_block'] - (float)$aGlobal['userdata']['est_fee'])), 8); + $aGlobal['userdata']['est_payout'] = round((float)$aGlobal['userdata']['est_block'] - (float)$aGlobal['userdata']['est_donation'] - (float)$aGlobal['userdata']['est_fee'], 8); } else { $aGlobal['userdata']['est_block'] = 0; $aGlobal['userdata']['est_fee'] = 0; diff --git a/public/templates/mmcFE/global/sidebar_prop.tpl b/public/templates/mmcFE/global/sidebar_prop.tpl index b3075c57..09159318 100644 --- a/public/templates/mmcFE/global/sidebar_prop.tpl +++ b/public/templates/mmcFE/global/sidebar_prop.tpl @@ -44,19 +44,19 @@
    Block{$GLOBAL.userdata.est_block|number_format:"3"}{$GLOBAL.userdata.est_block|number_format:"8"}
    Fees{$GLOBAL.userdata.est_fee|number_format:"3"}{$GLOBAL.userdata.est_fee|number_format:"8"}
    Donation{$GLOBAL.userdata.est_donation|number_format:"3"}{$GLOBAL.userdata.est_donation|number_format:"8"}
    Payout{$GLOBAL.userdata.est_payout|number_format:"3"}{$GLOBAL.userdata.est_payout|number_format:"8"}
     
    {$GLOBAL.config.currency} Account Balance
    Block{$GLOBAL.userdata.est_block|number_format:"3"}{$GLOBAL.userdata.est_block|number_format:"8"}
    Fees{$GLOBAL.userdata.est_fee|number_format:"3"}{$GLOBAL.userdata.est_fee|number_format:"8"}
    Donation{$GLOBAL.userdata.est_donation|number_format:"3"}{$GLOBAL.userdata.est_donation|number_format:"8"}
    Payout{$GLOBAL.userdata.est_payout|number_format:"3"}{$GLOBAL.userdata.est_payout|number_format:"8"}
     
    {$GLOBAL.config.currency} Account Balance
    Confirmed{$GLOBAL.userdata.balance.confirmed|default:"0"|number_format:"3"}
    Unconfirmed{$GLOBAL.userdata.balance.unconfirmed|default:"0"|number_format:"3"}
    Confirmed{$GLOBAL.userdata.balance.confirmed|default:"0"|number_format:"8"}
    Unconfirmed{$GLOBAL.userdata.balance.unconfirmed|default:"0"|number_format:"8"}
    From 8056ce9f87db722ceedb8ace658a4363225a60af Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 4 Jul 2013 12:42:03 +0200 Subject: [PATCH 25/41] Adding input check for AP and Donation Fixes #354 --- public/include/classes/user.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/include/classes/user.class.php b/public/include/classes/user.class.php index 6f8394dc..a1d508e8 100644 --- a/public/include/classes/user.class.php +++ b/public/include/classes/user.class.php @@ -282,14 +282,20 @@ class User { $bUser = false; // number validation checks - if ($threshold < $this->config['ap_threshold']['min'] && $threshold != 0) { + if (!is_numeric($threshold)) { + $this->setErrorMessage('Invalid input for auto-payout'); + return false; + } else if ($threshold < $this->config['ap_threshold']['min'] && $threshold != 0) { $this->setErrorMessage('Threshold below configured minimum of ' . $this->config['ap_threshold']['min']); return false; } else if ($threshold > $this->config['ap_threshold']['max']) { $this->setErrorMessage('Threshold above configured maximum of ' . $this->config['ap_threshold']['max']); return false; } - if ($donate < 0) { + if (!is_numeric($donate)) { + $this->setErrorMessage('Invalid input for donation'); + return false; + } else if ($donate < 0) { $this->setErrorMessage('Donation below allowed 0% limit'); return false; } else if ($donate > 100) { From dfa8d285cec1f4295352ada1e0096b72f41ad7b8 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 4 Jul 2013 12:50:17 +0200 Subject: [PATCH 26/41] Properly allow '0' as a workername or password This fixes #347 as recommended at http://de3.php.net/manual/en/function.empty.php We allow anything else than an empty string. --- public/include/classes/worker.class.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/public/include/classes/worker.class.php b/public/include/classes/worker.class.php index 716a2c15..ec7abdc9 100644 --- a/public/include/classes/worker.class.php +++ b/public/include/classes/worker.class.php @@ -49,11 +49,15 @@ class Worker { $username = $this->user->getUserName($account_id); $iFailed = 0; foreach ($data as $key => $value) { - // Prefix the WebUser to Worker name - $value['username'] = "$username." . $value['username']; - $stmt = $this->mysqli->prepare("UPDATE $this->table SET password = ?, username = ?, monitor = ? WHERE account_id = ? AND id = ?"); - if ( ! ( $this->checkStmt($stmt) && $stmt->bind_param('ssiii', $value['password'], $value['username'], $value['monitor'], $account_id, $key) && $stmt->execute()) ) + if ('' === $value['username'] || '' === $value['password']) { $iFailed++; + } else { + // Prefix the WebUser to Worker name + $value['username'] = "$username." . $value['username']; + $stmt = $this->mysqli->prepare("UPDATE $this->table SET password = ?, username = ?, monitor = ? WHERE account_id = ? AND id = ?"); + if ( ! ( $this->checkStmt($stmt) && $stmt->bind_param('ssiii', $value['password'], $value['username'], $value['monitor'], $account_id, $key) && $stmt->execute()) ) + $iFailed++; + } } if ($iFailed == 0) return true; @@ -154,8 +158,8 @@ class Worker { **/ public function addWorker($account_id, $workerName, $workerPassword) { $this->debug->append("STA " . __METHOD__, 4); - if (empty($workerName) || empty($workerPassword)) { - $this->setErrorMessage('Worker and password may not be empty'); + if ('' === $workerName || '' === $workerPassword) { + $this->setErrorMessage('Worker name and/or password may not be empty'); return false; } $username = $this->user->getUserName($account_id); From 463b97ea50f4b419b27ec233df26ce6db8f52b45 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 4 Jul 2013 13:01:29 +0200 Subject: [PATCH 27/41] Do not return null on empty valid/invalid shares --- public/include/classes/statistics.class.php | 29 ++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 0d25d724..4852d1d2 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -146,8 +146,8 @@ class Statistics { if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data; $stmt = $this->mysqli->prepare(" SELECT - SUM(IF(our_result='Y', 1, 0)) AS valid, - SUM(IF(our_result='N', 1, 0)) AS invalid + IFNULL(SUM(IF(our_result='Y', 1, 0)), 0) AS valid, + IFNULL(SUM(IF(our_result='N', 1, 0)), 0) AS invalid FROM " . $this->share->getTableName() . " WHERE UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM " . $this->block->getTableName() . "),0)"); if ( $this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result() ) @@ -168,10 +168,10 @@ class Statistics { if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data; $stmt = $this->mysqli->prepare(" SELECT - SUM(IF(our_result='Y', 1, 0)) AS valid, - SUM(IF(our_result='N', 1, 0)) AS invalid, - u.id AS id, - u.username AS username + IFNULL(SUM(IF(our_result='Y', 1, 0)), 0) AS valid, + IFNULL(SUM(IF(our_result='N', 1, 0)), 0) AS invalid, + u.id AS id, + u.username AS username FROM " . $this->share->getTableName() . " AS s, " . $this->user->getTableName() . " AS u WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 ) @@ -194,8 +194,8 @@ class Statistics { if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data; $stmt = $this->mysqli->prepare(" SELECT - SUM(IF(our_result='Y', 1, 0)) AS valid, - SUM(IF(our_result='N', 1, 0)) AS invalid + IFNULL(SUM(IF(our_result='Y', 1, 0)), 0) AS valid, + IFNULL(SUM(IF(our_result='N', 1, 0)), 0) AS invalid FROM " . $this->share->getTableName() . " AS s, " . $this->user->getTableName() . " AS u WHERE @@ -203,6 +203,7 @@ class Statistics { AND UNIX_TIMESTAMP(s.time) >IFNULL((SELECT MAX(b.time) FROM " . $this->block->getTableName() . " AS b),0) AND u.id = ?"); if ($stmt && $stmt->bind_param("i", $account_id) && $stmt->execute() && $result = $stmt->get_result()) + var_dump($result->fetch_assoc()); return $this->memcache->setCache(__FUNCTION__ . $account_id, $result->fetch_assoc()); // Catchall $this->debug->append("Unable to fetch user round shares: " . $this->mysqli->error); @@ -231,8 +232,7 @@ class Statistics { WHERE a.username LIKE ? GROUP BY username - ORDER BY username - "); + ORDER BY username"); if ($this->checkStmt($stmt) && $stmt->bind_param('s', $filter) && $stmt->execute() && $result = $stmt->get_result()) { return $this->memcache->setCache(__FUNCTION__ . $filter, $result->fetch_all(MYSQLI_ASSOC)); } @@ -402,13 +402,12 @@ class Statistics { if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data; $stmt = $this->mysqli->prepare(" SELECT - ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate, + ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate, HOUR(s.time) AS hour - FROM " . $this->share->getTableName() . " AS s - WHERE time < NOW() - INTERVAL 1 HOUR + FROM " . $this->share->getTableName() . " AS s + WHERE time < NOW() - INTERVAL 1 HOUR AND time > NOW() - INTERVAL 25 HOUR - GROUP BY HOUR(time) - "); + GROUP BY HOUR(time)"); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) { while ($row = $result->fetch_assoc()) { $aData[$row['hour']] = $row['hashrate']; From 425b821618367c1319c2ff7786e11e0d17ac91e8 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 4 Jul 2013 13:01:48 +0200 Subject: [PATCH 28/41] Link API key to User API Call Fixes #367 --- public/templates/mmcFE/account/edit/default.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/mmcFE/account/edit/default.tpl b/public/templates/mmcFE/account/edit/default.tpl index 69861d61..482c3579 100644 --- a/public/templates/mmcFE/account/edit/default.tpl +++ b/public/templates/mmcFE/account/edit/default.tpl @@ -6,7 +6,7 @@ - + From c9915ce6281b36c234e33f5e4e66518a979b2006 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 4 Jul 2013 13:02:36 +0200 Subject: [PATCH 29/41] Removed var_dump debug output --- public/include/classes/statistics.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 4852d1d2..d8554191 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -203,7 +203,6 @@ class Statistics { AND UNIX_TIMESTAMP(s.time) >IFNULL((SELECT MAX(b.time) FROM " . $this->block->getTableName() . " AS b),0) AND u.id = ?"); if ($stmt && $stmt->bind_param("i", $account_id) && $stmt->execute() && $result = $stmt->get_result()) - var_dump($result->fetch_assoc()); return $this->memcache->setCache(__FUNCTION__ . $account_id, $result->fetch_assoc()); // Catchall $this->debug->append("Unable to fetch user round shares: " . $this->mysqli->error); From b3479a9c04a0baa0d1fa2d4728036e2fa3c0e225 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 4 Jul 2013 13:25:11 +0200 Subject: [PATCH 30/41] Adding further IFNULL checks to statistics class --- public/include/classes/statistics.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index d8554191..2ca5bfd1 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -102,11 +102,11 @@ class Statistics { SELECT ( ( - SELECT ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/600/1000) AS hashrate + SELECT IFNULL(ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/600/1000), 0) AS hashrate FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) ) + ( - SELECT ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/600/1000) AS hashrate + SELECT IFNULL(ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/600/1000), 0) AS hashrate FROM " . $this->share->getArchiveTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) ) @@ -248,14 +248,14 @@ class Statistics { $stmt = $this->mysqli->prepare(" SELECT ( - SELECT ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 600 / 1000) AS hashrate + SELECT IFNULL(ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 600 / 1000), 0) AS hashrate FROM " . $this->share->getTableName() . " AS s, " . $this->user->getTableName() . " AS u WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 ) AND s.time > DATE_SUB(now(), INTERVAL 10 MINUTE) AND u.id = ? ) + ( - SELECT ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 600 / 1000) AS hashrate + SELECT IFNULL(ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 600 / 1000), 0) AS hashrate FROM " . $this->share->getArchiveTableName() . " AS s, " . $this->user->getTableName() . " AS u WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 ) @@ -301,7 +301,7 @@ class Statistics { $this->debug->append("STA " . __METHOD__, 4); if ($data = $this->memcache->get(__FUNCTION__ . $worker_id)) return $data; $stmt = $this->mysqli->prepare(" - SELECT ROUND(COUNT(s.id) * POW(2,21)/600/1000) AS hashrate + SELECT IFNULL(ROUND(COUNT(s.id) * POW(2,21)/600/1000), 0) AS hashrate FROM " . $this->share->getTableName() . " AS s, " . $this->user->getTableName() . " AS u WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 ) @@ -343,7 +343,7 @@ class Statistics { case 'hashes': $stmt = $this->mysqli->prepare(" SELECT - ROUND(COUNT(id) * POW(2," . $this->config['difficulty'] . ")/600/1000,2) AS hashrate, + IFNULL(ROUND(COUNT(id) * POW(2," . $this->config['difficulty'] . ")/600/1000, 2), 0) AS hashrate, SUBSTRING_INDEX( username, '.', 1 ) AS account FROM ( @@ -401,7 +401,7 @@ class Statistics { if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data; $stmt = $this->mysqli->prepare(" SELECT - ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate, + IFNULL(ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000), 0) AS hashrate, HOUR(s.time) AS hour FROM " . $this->share->getTableName() . " AS s WHERE time < NOW() - INTERVAL 1 HOUR From c6e6c4dee6f7800082e80ad55835db2e8199fe5c Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 4 Jul 2013 13:25:41 +0200 Subject: [PATCH 31/41] Changed error catching in pools page --- public/include/pages/statistics/pool.inc.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/public/include/pages/statistics/pool.inc.php b/public/include/pages/statistics/pool.inc.php index 323066f2..1cab1009 100644 --- a/public/include/pages/statistics/pool.inc.php +++ b/public/include/pages/statistics/pool.inc.php @@ -29,10 +29,9 @@ count($aBlocksFoundData) > 0 ? $aBlockData = $aBlocksFoundData[0] : $aBlockData // Estimated time to find the next block $iCurrentPoolHashrate = $statistics->getCurrentHashrate(); -$iCurrentPoolHashrate == 0 ? $iCurrentPoolHashrate = 1 : true; // Time in seconds, not hours, using modifier in smarty to translate -$iEstTime = $dDifficulty * pow(2,32) / ($iCurrentPoolHashrate * 1000); +$iCurrentPoolHashrate > 0 ? $iEstTime = $dDifficulty * pow(2,32) / ($iCurrentPoolHashrate * 1000) : $iEstTime = 0; // Time since last block $now = new DateTime( "now" ); From b8771091fbe63359ab69326abed76ee60e1a99a6 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 4 Jul 2013 13:26:03 +0200 Subject: [PATCH 32/41] Adding link to JSON API to server stats page --- public/templates/mmcFE/statistics/pool/authenticated.tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/public/templates/mmcFE/statistics/pool/authenticated.tpl b/public/templates/mmcFE/statistics/pool/authenticated.tpl index 178ec807..9d855afa 100644 --- a/public/templates/mmcFE/statistics/pool/authenticated.tpl +++ b/public/templates/mmcFE/statistics/pool/authenticated.tpl @@ -49,6 +49,7 @@
    Username: {$GLOBAL.userdata.username}
    User Id: {$GLOBAL.userdata.id}
    API Key: {$GLOBAL.userdata.api_key}
    API Key: {$GLOBAL.userdata.api_key}
    E-Mail:
    Payment Address:
    Donation %: [donation amount in percent (example: 0.5)]
    +
  • These stats are also available in JSON format HERE
  • {include file="global/block_footer.tpl"} From 3d942e843445c6772f425c910339a0efd78557dd Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 4 Jul 2013 13:26:58 +0200 Subject: [PATCH 33/41] Adding getpoolstatus API Method Fixes #369 --- .../include/pages/api/getpoolstatus.inc.php | 60 +++++++++++++++++++ .../mmcFE/statistics/pool/authenticated.tpl | 2 +- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 public/include/pages/api/getpoolstatus.inc.php diff --git a/public/include/pages/api/getpoolstatus.inc.php b/public/include/pages/api/getpoolstatus.inc.php new file mode 100644 index 00000000..ece9f557 --- /dev/null +++ b/public/include/pages/api/getpoolstatus.inc.php @@ -0,0 +1,60 @@ +checkApiKey($_REQUEST['api_key']); + +// Fetch last block information +$aLastBlock = $block->getLast(); + +// Efficiency +$aShares = $statistics->getRoundShares(); +$aShares['valid'] > 0 ? $dEfficiency = round((100 - (100 / $aShares['valid'] * $aShares['invalid'])), 2) : $dEfficiency = 0; + +// Fetch RPC data +if ($bitcoin->can_connect() === true){ + $dDifficulty = $bitcoin->getdifficulty(); + if (is_array($dDifficulty) && array_key_exists('proof-of-work', $dDifficulty)) + $dDifficulty = $dDifficulty['proof-of-work']; + $iBlock = $bitcoin->getblockcount(); +} else { + $dDifficulty = 1; + $iBlock = 0; +} + +// Estimated time to find the next block +$iCurrentPoolHashrate = $statistics->getCurrentHashrate(); + +// Time in seconds, not hours, using modifier in smarty to translate +$iCurrentPoolHashrate > 0 ? $iEstTime = $dDifficulty * pow(2,32) / ($iCurrentPoolHashrate * 1000) : $iEstTime = 0; +$iEstShares = (pow(2, 32 - $config['difficulty']) * $dDifficulty); + +// Time since last +$now = new DateTime( "now" ); +if (!empty($aLastBlock)) { + $dTimeSinceLast = ($now->getTimestamp() - $aLastBlock['time']); +} else { + $dTimeSinceLast = 0; +} + +// Output JSON format +echo json_encode( + array( + 'getpoolstatus' => array( + 'hashrate' => $iCurrentPoolHashrate, + 'efficiency' => $dEfficiency, + 'workers' => $worker->getCountAllActiveWorkers(), + 'currentnetworkblock' => $iBlock, + 'nextnetworkblock' => $iBlock + 1, + 'lastblock' => $aLastBlock['height'], + 'networkdiff' => $dDifficulty, + 'esttime' => $iEstTime, + 'estshares' => $iEstShares, + 'timesincelast' => $dTimeSinceLast, + ))); + +// Supress master template +$supress_master = 1; +?> diff --git a/public/templates/mmcFE/statistics/pool/authenticated.tpl b/public/templates/mmcFE/statistics/pool/authenticated.tpl index 9d855afa..b85a3926 100644 --- a/public/templates/mmcFE/statistics/pool/authenticated.tpl +++ b/public/templates/mmcFE/statistics/pool/authenticated.tpl @@ -49,7 +49,7 @@ -
  • These stats are also available in JSON format HERE
  • +
  • These stats are also available in JSON format HERE
  • {include file="global/block_footer.tpl"} From a012fc2ee5e95b11c525d1863eb69fe4f2aed106 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 4 Jul 2013 16:06:59 +0200 Subject: [PATCH 34/41] catch PHP warning --- public/include/smarty_globals.inc.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index e2550e84..dd72974a 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -21,8 +21,7 @@ if (@$_SESSION['AUTHENTICATED']) { } } // Always fetch this since we need for ministats header -if ($bitcoin->can_connect() === true) - $dNetworkHashrate = $bitcoin->query('getnetworkhashps'); +$bitcoin->can_connect() === true ? $dNetworkHashrate = $bitcoin->query('getnetworkhashps') : $dNetworkHashrate = 0; // Fetch some data $iCurrentActiveWorkers = $worker->getCountAllActiveWorkers(); From a0243ee31e91fd9c1fe34d0d0cfc308872e564b7 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 5 Jul 2013 09:47:44 +0200 Subject: [PATCH 35/41] allow empty blockexplorer URL --- public/templates/mmcFE/statistics/pool/authenticated.tpl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/templates/mmcFE/statistics/pool/authenticated.tpl b/public/templates/mmcFE/statistics/pool/authenticated.tpl index b85a3926..65cafbb1 100644 --- a/public/templates/mmcFE/statistics/pool/authenticated.tpl +++ b/public/templates/mmcFE/statistics/pool/authenticated.tpl @@ -19,13 +19,20 @@ Current Active Workers {$GLOBAL.workers} + {if $GLOBAL.blockexplorer} Next Network Block {$CURRENTBLOCK + 1}    (Current: {$CURRENTBLOCK}) + {else} + + Next Network Block + {$CURRENTBLOCK + 1}    (Current: {$CURRENTBLOCK}) + + {/if} Last Block Found - {$LASTBLOCK|default:"0"} + {if $GLOBAL.blockexplorer}{$LASTBLOCK|default:"0"}{else}{$LASTBLOCK|default:"0"}{/if} Current Difficulty From 57ce619ac2c4ee8bb09558f21c9e9f83d0747b26 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 5 Jul 2013 09:57:00 +0200 Subject: [PATCH 36/41] updated dist config --- public/include/config/global.inc.dist.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index bbfb7c41..c5a298c7 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -161,6 +161,7 @@ $config['payout_system'] = 'prop'; $config['archive_shares'] = true; // URL prefix for block searches, used for block links, default: `http://explorer.litecoin.net/search?q=` +// If empty, the block link to the block information page will be removed $config['blockexplorer'] = 'http://explorer.litecoin.net/search?q='; // Link to blockchain information, used for difficulty link, default: `http://allchains.info` @@ -204,7 +205,7 @@ $config['difficulty'] = 20; * Default: * reward_type = `fixed` * reward = 50 - * + * **/ $config['reward_type'] = 'fixed'; $config['reward'] = 50; From 5654f3815482c10fa3fd2c259e2d5c437db1241c Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 5 Jul 2013 11:04:56 +0200 Subject: [PATCH 37/41] remove link to block when blockexplorer empty --- .../templates/mobile/statistics/pool/authenticated.tpl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/templates/mobile/statistics/pool/authenticated.tpl b/public/templates/mobile/statistics/pool/authenticated.tpl index 5cb2321e..0889347c 100644 --- a/public/templates/mobile/statistics/pool/authenticated.tpl +++ b/public/templates/mobile/statistics/pool/authenticated.tpl @@ -24,13 +24,20 @@ Current Active Workers {$GLOBAL.workers} + {if $GLOBAL.blockexplorer} Next Network Block {$CURRENTBLOCK + 1}    (Current: {$CURRENTBLOCK}) + {else} + + Next Network Block + {$CURRENTBLOCK + 1}    (Current: {$CURRENTBLOCK}) + + {/if} Last Block Found - {$LASTBLOCK|default:"0"} + {if $GLOBAL.blockexplorer}{$LASTBLOCK|default:"0"}{else}{$LASTBLOCK|default:"0"}{/if} {if $GLOBAL.chaininfo} From 9601f075cebb7aa455153591ee685ef2fea6dcd3 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 5 Jul 2013 13:38:10 +0200 Subject: [PATCH 38/41] Removing old upgrade SQL for old issues To avoid confusion when setting up mmcfe-ng up for the first time I decided to remove these files. If new ones should be required I will base them on the then recent main structure and order them by number. --- sql/issue_144_notification_upgrade.sql | 17 --------------- sql/issue_147_accounts_upgrade.sql | 2 -- sql/issue_148_transactions_upgrade.sql | 1 - sql/issue_167_settings_upgrade.sql | 1 - sql/issue_182_accounts_upgrade.sql | 1 - sql/issue_203_transactions_upgrade.sql | 1 - ...ssue_212_notification_settings_upgrade.sql | 1 - sql/issue_226_news_upgrade.sql | 1 - sql/issue_61_news_table.sql | 21 ------------------- sql/issue_70_transactions_upgrade.sql | 1 - 10 files changed, 47 deletions(-) delete mode 100644 sql/issue_144_notification_upgrade.sql delete mode 100644 sql/issue_147_accounts_upgrade.sql delete mode 100644 sql/issue_148_transactions_upgrade.sql delete mode 100644 sql/issue_167_settings_upgrade.sql delete mode 100644 sql/issue_182_accounts_upgrade.sql delete mode 100644 sql/issue_203_transactions_upgrade.sql delete mode 100644 sql/issue_212_notification_settings_upgrade.sql delete mode 100644 sql/issue_226_news_upgrade.sql delete mode 100644 sql/issue_61_news_table.sql delete mode 100644 sql/issue_70_transactions_upgrade.sql diff --git a/sql/issue_144_notification_upgrade.sql b/sql/issue_144_notification_upgrade.sql deleted file mode 100644 index 73985979..00000000 --- a/sql/issue_144_notification_upgrade.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE IF NOT EXISTS `notifications` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `type` varchar(25) NOT NULL, - `data` varchar(255) NOT NULL, - `active` tinyint(1) NOT NULL DEFAULT '1', - `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `account_id` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `active` (`active`), - KEY `data` (`data`), - KEY `account_id` (`account_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE IF NOT EXISTS `notification_settings` ( - `type` varchar(15) NOT NULL, - `account_id` int(11) NOT NULL, - `active` tinyint(1) NOT NULL DEFAULT '0' -) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/sql/issue_147_accounts_upgrade.sql b/sql/issue_147_accounts_upgrade.sql deleted file mode 100644 index ecff0f6f..00000000 --- a/sql/issue_147_accounts_upgrade.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `accounts` ADD `is_locked` BOOLEAN NOT NULL DEFAULT FALSE AFTER `email` ; -ALTER TABLE `accounts` CHANGE `admin` `is_admin` BOOLEAN NOT NULL DEFAULT FALSE ; diff --git a/sql/issue_148_transactions_upgrade.sql b/sql/issue_148_transactions_upgrade.sql deleted file mode 100644 index 2c0a47a7..00000000 --- a/sql/issue_148_transactions_upgrade.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `transactions` CHANGE `type` `type` ENUM( 'Credit', 'Debit_MP', 'Debit_AP', 'Donation', 'Fee', 'Orphan_Credit', 'Orphan_Fee', 'Orphan_Donation', 'Bonus', 'Orphan_Bonus' ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL; diff --git a/sql/issue_167_settings_upgrade.sql b/sql/issue_167_settings_upgrade.sql deleted file mode 100644 index dff0378a..00000000 --- a/sql/issue_167_settings_upgrade.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `settings` CHANGE `setting` `name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ; diff --git a/sql/issue_182_accounts_upgrade.sql b/sql/issue_182_accounts_upgrade.sql deleted file mode 100644 index 62266515..00000000 --- a/sql/issue_182_accounts_upgrade.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `accounts` ADD `failed_logins` INT( 5 ) UNSIGNED NULL DEFAULT '0' AFTER `is_locked` ; diff --git a/sql/issue_203_transactions_upgrade.sql b/sql/issue_203_transactions_upgrade.sql deleted file mode 100644 index 13d19701..00000000 --- a/sql/issue_203_transactions_upgrade.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `transactions` CHANGE `type` `type` ENUM( 'Credit', 'Debit_MP', 'Debit_AP', 'Donation', 'Fee', 'Orphan_Credit', 'Orphan_Fee', 'Orphan_Donation', 'Credit_PPS', 'Fee_PPS', 'Donation_PPS', 'TXFee', 'Bonus') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ; diff --git a/sql/issue_212_notification_settings_upgrade.sql b/sql/issue_212_notification_settings_upgrade.sql deleted file mode 100644 index 1a07b26e..00000000 --- a/sql/issue_212_notification_settings_upgrade.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `notification_settings` ADD `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST ; diff --git a/sql/issue_226_news_upgrade.sql b/sql/issue_226_news_upgrade.sql deleted file mode 100644 index dabc48bb..00000000 --- a/sql/issue_226_news_upgrade.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `news` ADD `time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `content` ; diff --git a/sql/issue_61_news_table.sql b/sql/issue_61_news_table.sql deleted file mode 100644 index 70b26331..00000000 --- a/sql/issue_61_news_table.sql +++ /dev/null @@ -1,21 +0,0 @@ -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; - - -CREATE TABLE IF NOT EXISTS `news` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `account_id` int(10) unsigned NOT NULL, - `header` varchar(255) NOT NULL, - `content` text NOT NULL, - `active` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/sql/issue_70_transactions_upgrade.sql b/sql/issue_70_transactions_upgrade.sql deleted file mode 100644 index 90561397..00000000 --- a/sql/issue_70_transactions_upgrade.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `transactions` CHANGE `type` `type` ENUM( 'Credit', 'Debit_MP', 'Debit_AP', 'Donation', 'Fee', 'Orphan_Credit', 'Orphan_Fee', 'Orphan_Donation', 'Bonus', 'Orphan_Bonus', 'Credit_PPS', 'Debit_PPS', 'Donation_PPS' ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL; From 7a194a629338184cbe5645eeea7c80ec712e6f9b Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 5 Jul 2013 15:30:51 +0200 Subject: [PATCH 39/41] Further attempt to clean up transactions list This hopefully cleans out remaining PHP warnings and table issues with no/partial transactions available. Please test this out and report back in #315. --- .../mmcFE/account/transactions/default.tpl | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/public/templates/mmcFE/account/transactions/default.tpl b/public/templates/mmcFE/account/transactions/default.tpl index bf64450d..160b12e4 100644 --- a/public/templates/mmcFE/account/transactions/default.tpl +++ b/public/templates/mmcFE/account/transactions/default.tpl @@ -14,6 +14,7 @@ +{assign var=has_confirmed value=false} {section transaction $TRANSACTIONS} {if ( (($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus')and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations) @@ -26,6 +27,7 @@ or $TRANSACTIONS[transaction].type == 'Debit_MP' or $TRANSACTIONS[transaction].type == 'TXFee' )} + {assign var=has_credits value=true} {$TRANSACTIONS[transaction].id} {$TRANSACTIONS[transaction].timestamp} @@ -36,6 +38,9 @@ {/if} {/section} +{if !$has_confirmed} + No data +{/if}

    @@ -60,12 +65,14 @@ +{assign var=has_unconfirmed value=false} {section transaction $TRANSACTIONS} {if ( ($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus') and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations or ($TRANSACTIONS[transaction].type == 'Donation' and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations) or ($TRANSACTIONS[transaction].type == 'Fee' and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations) )} + {assign var=has_unconfirmed value=true} {$TRANSACTIONS[transaction].id} {$TRANSACTIONS[transaction].timestamp} @@ -75,12 +82,15 @@ {$TRANSACTIONS[transaction].amount|number_format:"8"} {if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'} - {assign var="credits" value="`$credits+$TRANSACTIONS[transaction].amount`"} + {assign var="credits" value="`$credits|default:"0"+$TRANSACTIONS[transaction].amount`"} {else} - {assign var="debits" value="`$debits+$TRANSACTIONS[transaction].amount`"} + {assign var="debits" value="`$debits|default:"0"+$TRANSACTIONS[transaction].amount`"} {/if} {/if} {/section} +{if !$has_unconfirmed} + No data +{/if} Unconfirmed Totals: {($credits|default - $debits|default)|number_format:"8"} @@ -105,6 +115,7 @@ +{assign var=has_orphaned value=false} {section transaction $TRANSACTIONS} {if ( $TRANSACTIONS[transaction].type == 'Orphan_Credit' @@ -121,12 +132,15 @@ {$TRANSACTIONS[transaction].amount|number_format:"8"} {if $TRANSACTIONS[transaction].type == 'Orphan_Credit' or $TRANSACTIONS[transaction].type == 'Orphan_Bonus'} - {assign var="orphan_credits" value="`$orphan_credits+$TRANSACTIONS[transaction].amount`"} + {assign var="orphan_credits" value="`$orphan_credits|default:"0"+$TRANSACTIONS[transaction].amount`"} {else} - {assign var="orphan_debits" value="`$orphan_debits+$TRANSACTIONS[transaction].amount`"} + {assign var="orphan_debits" value="`$orphan_debits|default:"0"+$TRANSACTIONS[transaction].amount`"} {/if} {/if} {/section} +{if !$has_orphaned} + No data +{/if} Orphaned Totals: {($orphan_credits|default - $orphan_debits|default)|number_format:"8"} From 7a0f08d3d092cecd7601011d0393c07ea1e1e7b8 Mon Sep 17 00:00:00 2001 From: Ilya Stromberg Date: Fri, 5 Jul 2013 21:16:51 +0400 Subject: [PATCH 40/41] (#376) Fix HTML/CSS markup at Statistics page --- public/templates/mmcFE/statistics/pool/authenticated.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/mmcFE/statistics/pool/authenticated.tpl b/public/templates/mmcFE/statistics/pool/authenticated.tpl index 65cafbb1..9e41b6d3 100644 --- a/public/templates/mmcFE/statistics/pool/authenticated.tpl +++ b/public/templates/mmcFE/statistics/pool/authenticated.tpl @@ -4,7 +4,7 @@ {include file="statistics/pool/contributors_hashrate.tpl"} -{include file="global/block_header.tpl" ALIGN="left" BLOCK_HEADER="Server Stats" BLOCK_STYLE="clear:all;" STYLE="padding-left:5px;padding-right:5px;"} +{include file="global/block_header.tpl" ALIGN="left" BLOCK_HEADER="Server Stats" BLOCK_STYLE="clear:both;" STYLE="padding-left:5px;padding-right:5px;"} From 7099b2cc042d895bf2402f3cdcf841a11dd47c42 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 5 Jul 2013 22:02:16 +0200 Subject: [PATCH 41/41] Use poolhash rate if nethash is smaller This should avoid some confusion for coins where the network hashrate drops under the pool hashrate due to slow block finding rates. Fixes #378 --- public/include/smarty_globals.inc.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index dd72974a..e7bfd4b5 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -28,6 +28,9 @@ $iCurrentActiveWorkers = $worker->getCountAllActiveWorkers(); $iCurrentPoolHashrate = $statistics->getCurrentHashrate(); $iCurrentPoolShareRate = $statistics->getCurrentShareRate(); +// Avoid confusion, ensure our nethash isn't higher than poolhash +if ($iCurrentPoolHashrate > $dNetworkHashrate) $dNetworkHashrate = $iCurrentPoolHashrate; + // Global data for Smarty $aGlobal = array( 'slogan' => $config['website']['slogan'],