From 440ca027a2fba59347929c5ccd11af3cb3840d46 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 21 Jul 2013 08:12:40 +0200 Subject: [PATCH 1/7] Fixing PPLNS target calculation on blockavg This will fix #492 with PPLNS targets not taking the blocks in proper order. --- public/include/classes/block.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/include/classes/block.class.php b/public/include/classes/block.class.php index 711ed0b5..c08f89d6 100644 --- a/public/include/classes/block.class.php +++ b/public/include/classes/block.class.php @@ -109,7 +109,7 @@ class Block { * @return data float Float value of average shares **/ public function getAvgBlockShares($limit=10) { - $stmt = $this->mysqli->prepare("SELECT AVG(shares) AS average FROM $this->table LIMIT ?"); + $stmt = $this->mysqli->prepare("SELECT AVG(shares) AS average FROM $this->table ORDER BY height DESC LIMIT ?"); if ($this->checkStmt($stmt) && $stmt->bind_param('i', $limit) && $stmt->execute() && $result = $stmt->get_result()) return (float)$result->fetch_object()->average; return false; From 7d801a561c8daf5cb706250c3c4cdc8a0ce6cb26 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 21 Jul 2013 08:20:53 +0200 Subject: [PATCH 2/7] Fixing Orphan showing as unconfirmed * Fixes orphaned transactions showing as unconfirmed too * Fixes transaction tables to show orphaned credits in green, not red Fixes #490 --- public/include/classes/transaction.class.php | 4 ++-- public/templates/mmcFE/account/transactions/default.tpl | 2 +- public/templates/mmcFE/admin/transactions/default.tpl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index 30867cc6..229c8581 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -235,7 +235,7 @@ class Transaction { FROM $this->table AS t LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id WHERE - t.type IN ('Credit','Bonus') AND b.confirmations < ? + t.type IN ('Credit','Bonus') AND b.confirmations < ? AND b.confirmations > 0 AND t.account_id = ? ) AS t4, ( @@ -244,7 +244,7 @@ class Transaction { LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id WHERE ( - t.type IN ('Donation','Fee') AND b.confirmations < ? + t.type IN ('Donation','Fee') AND b.confirmations < ? AND b.confirmations > 0 ) AND t.account_id = ? ) AS t5, diff --git a/public/templates/mmcFE/account/transactions/default.tpl b/public/templates/mmcFE/account/transactions/default.tpl index 4bbe7b4b..52602088 100644 --- a/public/templates/mmcFE/account/transactions/default.tpl +++ b/public/templates/mmcFE/account/transactions/default.tpl @@ -116,7 +116,7 @@ {$TRANSACTIONS[transaction].type} {$TRANSACTIONS[transaction].coin_address} {if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if} - {$TRANSACTIONS[transaction].amount|number_format:"8"} + {$TRANSACTIONS[transaction].amount|number_format:"8"} {if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'} {assign var="orphan_credits" value="`$orphan_credits|default:"0"+$TRANSACTIONS[transaction].amount`"} diff --git a/public/templates/mmcFE/admin/transactions/default.tpl b/public/templates/mmcFE/admin/transactions/default.tpl index aba15f12..ecf0dc70 100644 --- a/public/templates/mmcFE/admin/transactions/default.tpl +++ b/public/templates/mmcFE/admin/transactions/default.tpl @@ -117,7 +117,7 @@ {$TRANSACTIONS[transaction].type} {$TRANSACTIONS[transaction].coin_address} {if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if} - {$TRANSACTIONS[transaction].amount|number_format:"8"} + {$TRANSACTIONS[transaction].amount|number_format:"8"} {/if} {/section} From c94c1be7be64d4d2416741361f9d95810f63475a Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 21 Jul 2013 08:35:57 +0200 Subject: [PATCH 3/7] Using proper SQL query by @CaptainAK Proposed fix did not work, using proper Query now. Thank @CaptainAK for the fix! Fixes #492 --- public/include/classes/block.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/include/classes/block.class.php b/public/include/classes/block.class.php index c08f89d6..8ce985d1 100644 --- a/public/include/classes/block.class.php +++ b/public/include/classes/block.class.php @@ -108,8 +108,8 @@ class Block { * @param limit int Maximum blocks to check * @return data float Float value of average shares **/ - public function getAvgBlockShares($limit=10) { - $stmt = $this->mysqli->prepare("SELECT AVG(shares) AS average FROM $this->table ORDER BY height DESC LIMIT ?"); + public function getAvgBlockShares($limit=1) { + $stmt = $this->mysqli->prepare("SELECT AVG(x.shares) AS average FROM (SELECT shares FROM $this->table ORDER BY height DESC LIMIT ?) AS x"); if ($this->checkStmt($stmt) && $stmt->bind_param('i', $limit) && $stmt->execute() && $result = $stmt->get_result()) return (float)$result->fetch_object()->average; return false; From 36a74b0bbf206b7b0f5c9bfed48192ecf3934a79 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 21 Jul 2013 17:25:09 +0200 Subject: [PATCH 4/7] Fix transaction table, adjust transaction class * Ensure we also check newly added blocks for unconfirmed tx * Only list orphaned transactions in the orphaned tab Fixes #490 --- public/include/classes/transaction.class.php | 4 ++-- public/templates/mmcFE/account/transactions/default.tpl | 2 +- public/templates/mmcFE/admin/transactions/default.tpl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index 229c8581..2cbe4312 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -235,7 +235,7 @@ class Transaction { FROM $this->table AS t LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id WHERE - t.type IN ('Credit','Bonus') AND b.confirmations < ? AND b.confirmations > 0 + t.type IN ('Credit','Bonus') AND b.confirmations < ? AND b.confirmations >= 0 AND t.account_id = ? ) AS t4, ( @@ -244,7 +244,7 @@ class Transaction { LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id WHERE ( - t.type IN ('Donation','Fee') AND b.confirmations < ? AND b.confirmations > 0 + t.type IN ('Donation','Fee') AND b.confirmations < ? AND b.confirmations >= 0 ) AND t.account_id = ? ) AS t5, diff --git a/public/templates/mmcFE/account/transactions/default.tpl b/public/templates/mmcFE/account/transactions/default.tpl index 52602088..a7337bd6 100644 --- a/public/templates/mmcFE/account/transactions/default.tpl +++ b/public/templates/mmcFE/account/transactions/default.tpl @@ -62,7 +62,7 @@ {assign var=has_unconfirmed value=false} {section transaction $TRANSACTIONS} {if - (($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus' or $TRANSACTIONS[transaction].type == 'Donation' or $TRANSACTIONS[transaction].type == 'Fee') and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations) + (($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus' or $TRANSACTIONS[transaction].type == 'Donation' or $TRANSACTIONS[transaction].type == 'Fee') and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations and $TRANSACTIONS[transaction].confirmations >= 0) } {assign var=has_unconfirmed value=true} diff --git a/public/templates/mmcFE/admin/transactions/default.tpl b/public/templates/mmcFE/admin/transactions/default.tpl index ecf0dc70..c493de8b 100644 --- a/public/templates/mmcFE/admin/transactions/default.tpl +++ b/public/templates/mmcFE/admin/transactions/default.tpl @@ -68,7 +68,7 @@ {assign var=unconfirmed value=0} {section transaction $TRANSACTIONS} - {if ($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus' or $TRANSACTIONS[transaction].type == 'Donation' or $TRANSACTIONS[transaction].type == 'Fee') and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations} + {if ($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus' or $TRANSACTIONS[transaction].type == 'Donation' or $TRANSACTIONS[transaction].type == 'Fee') and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations and $TRANSACTIONS[transaction].confirmations >= 0} {assign var=unconfirmed value=1} {$TRANSACTIONS[transaction].id} From bb313bee3605b321e77a2153d15c265e293cbe07 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 21 Jul 2013 17:31:32 +0200 Subject: [PATCH 5/7] Update README.md Adding smarty template reference --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a7787bb2..95a26d3f 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ Features The following feature have been implemented so far: +* Fully re-written GUI with [Smarty][2] templates * Mobile WebUI * Reward Systems * Propotional @@ -142,3 +143,4 @@ limitations under the License. [1]: https://github.com/TheSerapher/php-mmcfe-ng/issues "Issue" + [2]: http://www.smarty.net/docs/en/ "Smarty" From ee2c90525cda600710304a7559d1795e334e13e9 Mon Sep 17 00:00:00 2001 From: obigal Date: Sun, 21 Jul 2013 14:14:12 -0400 Subject: [PATCH 6/7] Cryptsy api support --- public/include/classes/tools.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/include/classes/tools.class.php b/public/include/classes/tools.class.php index b160711d..dcfa1959 100644 --- a/public/include/classes/tools.class.php +++ b/public/include/classes/tools.class.php @@ -48,6 +48,8 @@ class Tools extends Base { return 'coinchose'; } else if (preg_match('/btc-e.com/', $url)) { return 'btce'; + } else if (preg_match('/cryptsy.com/', $url)) { + return 'cryptsy'; } $this->setErrorMessage("API URL unknown"); return false; @@ -73,6 +75,9 @@ class Tools extends Base { case 'btce': return $aData['ticker']['last']; break; + case 'cryptsy': + return $aData['return']['markets'][$strCurrency]['lasttradeprice']; + break; } // Catchall, we have no data extractor for this API url $this->setErrorMessage("Undefined API to getPrice() on URL " . $this->config['price']['url']); From 93e36a82593002329cb12eceea20bb6a50c3efcc Mon Sep 17 00:00:00 2001 From: obigal Date: Sun, 21 Jul 2013 14:15:34 -0400 Subject: [PATCH 7/7] Cryptsy api support --- public/include/config/global.inc.dist.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index 0634101d..359f74da 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -73,6 +73,11 @@ $config['wallet']['password'] = 'testnet'; * url = `http://www.coinchoose.com` * target = `/api.php` * currency = `BTC` + * + * Optional (cryptsy.com): + * url = `https://www.cryptsy.com` + * target = `/api.php?method=marketdata` + * currency = `BTC` **/ $config['price']['url'] = 'https://btc-e.com'; $config['price']['target'] = '/api/2/ltc_usd/ticker';