From c568683152aeb44fe46ca73f1ea9686f680f5eb2 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 8 Aug 2013 09:59:38 +0200 Subject: [PATCH 1/9] Adding empty example for round stat integration Addresses #543 --- public/include/pages/statistics/round.inc.php | 19 +++++++++++++++++++ .../mmcFE/statistics/round/default.tpl | 1 + 2 files changed, 20 insertions(+) create mode 100644 public/include/pages/statistics/round.inc.php create mode 100644 public/templates/mmcFE/statistics/round/default.tpl diff --git a/public/include/pages/statistics/round.inc.php b/public/include/pages/statistics/round.inc.php new file mode 100644 index 00000000..ac0adf66 --- /dev/null +++ b/public/include/pages/statistics/round.inc.php @@ -0,0 +1,19 @@ +isAuthenticated()) { + // Check if we want a specific round or general stats + if (!empty($_REQUEST['round'])) $round = $_REQUEST['round']; + + // Cache detection and content generation + if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { + $debug->append('No cached version available, fetching from backend', 3); + + } else { + $debug->append('Using cached page', 3); + } + $smarty->assign("CONTENT", "default.tpl"); +} +?> diff --git a/public/templates/mmcFE/statistics/round/default.tpl b/public/templates/mmcFE/statistics/round/default.tpl new file mode 100644 index 00000000..271b7a25 --- /dev/null +++ b/public/templates/mmcFE/statistics/round/default.tpl @@ -0,0 +1 @@ +Need content for me From c578ed21f1c1aa3cd2cec70328adc7cbd90eb4e7 Mon Sep 17 00:00:00 2001 From: Dids Date: Tue, 27 Aug 2013 23:01:35 +0300 Subject: [PATCH 2/9] Updated Pools --- POOLS.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/POOLS.md b/POOLS.md index 42ffd0b4..723c3e53 100644 --- a/POOLS.md +++ b/POOLS.md @@ -111,3 +111,9 @@ Small Time Miners are running various stratum only pools for different coins. | http://ftc.nut2pools.com | Feathercoin | 45-50Mhs | 25 workers | New style, PPLNS | | http://wdc.nut2pools.com | Worldcoin | 3.5 Mhs | 3 workers | New style, PPLNS | | http://pxc.nut2pools.com | Phenixcoin | 0 | 0 | New style | PPLNS | + +### Dids + +| Pool URL | Coin | Avg. Hashrate | Avg. Active Workers | Notes | +| -------- | ---- | ------------: | ------------------: | ----- | +| http://poolmine.it | Litecoin | 0.23 MHash | 5 | PPLNS, Custom Template | From b3ba080345ab683947b5fdcb15964445307d39b7 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 6 Sep 2013 09:48:08 +0200 Subject: [PATCH 3/9] obigals work, cherrypicked --- public/include/classes/roundstats.class.php | 160 ++++++++++++++++++ public/include/pages/statistics/round.inc.php | 42 +++-- public/templates/mmcFE/global/navigation.tpl | 1 + .../mmcFE/statistics/round/block_stats.tpl | 61 +++++++ .../mmcFE/statistics/round/default.tpl | 10 +- .../mmcFE/statistics/round/round_shares.tpl | 26 +++ .../statistics/round/round_transactions.tpl | 24 +++ 7 files changed, 313 insertions(+), 11 deletions(-) create mode 100644 public/include/classes/roundstats.class.php create mode 100644 public/templates/mmcFE/statistics/round/block_stats.tpl create mode 100644 public/templates/mmcFE/statistics/round/round_shares.tpl create mode 100644 public/templates/mmcFE/statistics/round/round_transactions.tpl diff --git a/public/include/classes/roundstats.class.php b/public/include/classes/roundstats.class.php new file mode 100644 index 00000000..5cbbfb4e --- /dev/null +++ b/public/include/classes/roundstats.class.php @@ -0,0 +1,160 @@ +debug = $debug; + $this->mysqli = $mysqli; + $this->config = $config; + $this->debug->append("Instantiated RoundStats class", 2); + } + + // get and set methods + private function setErrorMessage($msg) { + $this->sError = $msg; + } + public function getError() { + return $this->sError; + } + + /** + * Get next block for round stats + **/ + public function getNextBlockDesc($iHeight=0) { + $stmt = $this->mysqli->prepare(" + SELECT height + FROM $this->tableBlocks + WHERE height < ? + ORDER BY height DESC + LIMIT 1"); + if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iHeight) && $stmt->execute() && $result = $stmt->get_result()) + return $result->fetch_object()->height; + return false; + } + + /** + * Get prev block for round stats + **/ + public function getNextBlockAsc($iHeight=0) { + $stmt = $this->mysqli->prepare(" + SELECT height + FROM $this->tableBlocks + WHERE height > ? + ORDER BY height ASC + LIMIT 1"); + if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iHeight) && $stmt->execute() && $result = $stmt->get_result()) + return $result->fetch_object()->height; + return false; + } + + /** + * Get details for block height + * @param height int Block Height + * @return data array Block information from DB + **/ + public function getDetailsForBlockHeight($iHeight=0, $isAdmin=0) { + $stmt = $this->mysqli->prepare(" + SELECT + b.id, height, amount, confirmations, difficulty, FROM_UNIXTIME(time) as time, shares, + IF(a.is_anonymous, IF( ? , a.username, 'anonymous'), a.username) AS finder + FROM $this->tableBlocks as b + LEFT JOIN $this->tableUsers AS a ON b.account_id = a.id + WHERE b.height = ? LIMIT 1"); + if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $isAdmin, $iHeight) && $stmt->execute() && $result = $stmt->get_result()) + return $result->fetch_assoc(); + return false; + } + + /** + * Get shares statistics for round block height + * @param height int Block Height + * @return data array Block information from DB + **/ + public function getRoundStatsForAccounts($iHeight=0, $isAdmin=0) { + $stmt = $this->mysqli->prepare(" + SELECT + IF(a.is_anonymous, IF( ? , a.username, 'anonymous'), a.username) AS username, + s.valid, + s.invalid + FROM $this->tableStats AS s + LEFT JOIN $this->tableBlocks AS b ON s.block_id = b.id + LEFT JOIN $this->tableUsers AS a ON a.id = s.account_id + WHERE b.height = ? + GROUP BY username ASC + ORDER BY valid DESC + "); + if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $isAdmin, $iHeight) && $stmt->execute() && $result = $stmt->get_result()) + return $result->fetch_all(MYSQLI_ASSOC); + return false; + } + + /** + * Get all transactions for round block height for admin + * @param height int Block Height + * @return data array Block round transactions + **/ + public function getAllRoundTransactions($iHeight=0) { + $this->debug->append("STA " . __METHOD__, 4); + $stmt = $this->mysqli->prepare(" + SELECT + t.id AS id, + a.username AS username, + t.type AS type, + t.amount AS amount + FROM $this->tableTrans AS t + LEFT JOIN $this->tableBlocks AS b ON t.block_id = b.id + LEFT JOIN $this->tableUsers AS a ON t.account_id = a.id + WHERE b.height = ? + ORDER BY id ASC"); + if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iHeight) && $stmt->execute() && $result = $stmt->get_result()) + return $result->fetch_all(MYSQLI_ASSOC); + $this->debug->append('Unable to fetch transactions'); + return false; + } + + /** + * Get transactions for round block height user id + * @param height int Block Height + * @param id int user id + * @return data array Block round transactions for user id + **/ + public function getUserRoundTransactions($iHeight=0, $id=0) { + $this->debug->append("STA " . __METHOD__, 4); + $stmt = $this->mysqli->prepare(" + SELECT + t.id AS id, + a.username AS username, + t.type AS type, + t.amount AS amount + FROM $this->tableTrans AS t + LEFT JOIN $this->tableBlocks AS b ON t.block_id = b.id + LEFT JOIN $this->tableUsers AS a ON t.account_id = a.id + WHERE b.height = ? AND a.id = ? + ORDER BY id ASC"); + if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $iHeight, $id) && $stmt->execute() && $result = $stmt->get_result()) + return $result->fetch_all(MYSQLI_ASSOC); + $this->debug->append('Unable to fetch transactions'); + return false; + } + + private function checkStmt($bState) { + if ($bState ===! true) { + $this->debug->append("Failed to prepare statement: " . $this->mysqli->error); + $this->setErrorMessage('Internal application Error'); + return false; + } + return true; + } + +} + +$roundstats = new RoundStats($debug, $mysqli, $config); diff --git a/public/include/pages/statistics/round.inc.php b/public/include/pages/statistics/round.inc.php index ac0adf66..06b3b8f5 100644 --- a/public/include/pages/statistics/round.inc.php +++ b/public/include/pages/statistics/round.inc.php @@ -3,17 +3,39 @@ // Make sure we are called from index.php if (!defined('SECURITY')) die('Hacking attempt'); -if ($user->isAuthenticated()) { - // Check if we want a specific round or general stats - if (!empty($_REQUEST['round'])) $round = $_REQUEST['round']; +if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { + $debug->append('No cached version available, fetching from backend', 3); - // Cache detection and content generation - if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { - $debug->append('No cached version available, fetching from backend', 3); +if (@$_REQUEST['next'] && !empty($_REQUEST['tx_key'])) { + $_REQUEST['tx_key'] = $roundstats->getNextBlockDesc($_REQUEST['tx_key']); +} else if (@$_REQUEST['prev'] && !empty($_REQUEST['tx_key'])) { + $_REQUEST['tx_key'] = $roundstats->getNextBlockAsc($_REQUEST['tx_key']); +} - } else { - $debug->append('Using cached page', 3); - } - $smarty->assign("CONTENT", "default.tpl"); +if (empty($_REQUEST['tx_key'])) { + $iBlock = $block->getLast(); + $iKey = $iBlock['height']; + $_REQUEST['tx_key'] = $iKey; +} else { + $iKey = $_REQUEST['tx_key']; } + + $aDetailsForBlockHeight = $roundstats->getDetailsForBlockHeight($iKey, $user->isAdmin($_SESSION['USERDATA']['id'])); + $aRoundShareStats = $roundstats->getRoundStatsForAccounts($iKey, $user->isAdmin($_SESSION['USERDATA']['id'])); + +if ($user->isAdmin($_SESSION['USERDATA']['id'])) { + $aUserRoundTransactions = $roundstats->getAllRoundTransactions($iKey); +} else { + $aUserRoundTransactions = $roundstats->getUserRoundTransactions($iKey, $_SESSION['USERDATA']['id']); +} + + // Propagate content our template + $smarty->assign('BLOCKDETAILS', $aDetailsForBlockHeight); + $smarty->assign('ROUNDSHARES', $aRoundShareStats); + $smarty->assign("ROUNDTRANSACTIONS", $aUserRoundTransactions); +} else { + $debug->append('Using cached page', 3); +} + +$smarty->assign("CONTENT", "default.tpl"); ?> diff --git a/public/templates/mmcFE/global/navigation.tpl b/public/templates/mmcFE/global/navigation.tpl index 407f24b0..75db64ce 100644 --- a/public/templates/mmcFE/global/navigation.tpl +++ b/public/templates/mmcFE/global/navigation.tpl @@ -30,6 +30,7 @@
  • Pool Stats
  • Block Stats
  • Hashrate Graphs
  • +
  • Round Stats
  • {else} diff --git a/public/templates/mmcFE/statistics/round/block_stats.tpl b/public/templates/mmcFE/statistics/round/block_stats.tpl new file mode 100644 index 00000000..40081671 --- /dev/null +++ b/public/templates/mmcFE/statistics/round/block_stats.tpl @@ -0,0 +1,61 @@ +{include file="global/block_header.tpl" ALIGN="left" BLOCK_STYLE="width: 100%" BLOCK_HEADER="Block Stats" STYLE="padding-left:5px;padding-right:5px;"} + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameValue
    Block Id{$BLOCKDETAILS.id|default:"0"}
    Heigth{$BLOCKDETAILS.height|default:"0"}
    Amount{$BLOCKDETAILS.amount|default:"0"}
    Confirmations{$BLOCKDETAILS.confirmations|default:"0"}
    Difficulty{$BLOCKDETAILS.difficulty|default:"0"}
    Time{$BLOCKDETAILS.time|default:"0"}
    Shares{$BLOCKDETAILS.shares|default:"0"}
    Finder{$BLOCKDETAILS.finder|default:"0"}
    +
    + + + + +
    + + + +
    +{include file="global/block_footer.tpl"} diff --git a/public/templates/mmcFE/statistics/round/default.tpl b/public/templates/mmcFE/statistics/round/default.tpl index 271b7a25..7098eb06 100644 --- a/public/templates/mmcFE/statistics/round/default.tpl +++ b/public/templates/mmcFE/statistics/round/default.tpl @@ -1 +1,9 @@ -Need content for me +{include file="global/block_header.tpl" BLOCK_HEADER="Round Statistics" BLOCK_STYLE="clear:none;"} + +{include file="statistics/round/block_stats.tpl"} + +{include file="statistics/round/round_transactions.tpl"} + +{include file="statistics/round/round_shares.tpl"} + +{include file="global/block_footer.tpl"} diff --git a/public/templates/mmcFE/statistics/round/round_shares.tpl b/public/templates/mmcFE/statistics/round/round_shares.tpl new file mode 100644 index 00000000..db1083d2 --- /dev/null +++ b/public/templates/mmcFE/statistics/round/round_shares.tpl @@ -0,0 +1,26 @@ +{include file="global/block_header.tpl" ALIGN="left" BLOCK_HEADER="Round Shares" } +
    + + + + + + + + + + +{assign var=rank value=1} +{assign var=listed value=0} +{section contrib $ROUNDSHARES} + + + + + + +{/section} + +
    RankUser NameValidInvalid
    {$rank++}{if $ROUNDSHARES[contrib].is_anonymous|default:"0" == 1}anonymous{else}{$ROUNDSHARES[contrib].username|escape}{/if}{$ROUNDSHARES[contrib].valid|number_format}{$ROUNDSHARES[contrib].invalid|number_format}
    +
    +{include file="global/block_footer.tpl"} diff --git a/public/templates/mmcFE/statistics/round/round_transactions.tpl b/public/templates/mmcFE/statistics/round/round_transactions.tpl new file mode 100644 index 00000000..ecb4ea75 --- /dev/null +++ b/public/templates/mmcFE/statistics/round/round_transactions.tpl @@ -0,0 +1,24 @@ +{include file="global/block_header.tpl" ALIGN="right" BLOCK_HEADER="Round Transactions"} +
    + + + + + + + + + + +{section txs $ROUNDTRANSACTIONS} + + + + + + +{/section} + +
    Tx IdUser NameTypeAmount
    {$ROUNDTRANSACTIONS[txs].id|default:"0"}{$ROUNDTRANSACTIONS[txs].username|escape}{$ROUNDTRANSACTIONS[txs].type|default:""}{$ROUNDTRANSACTIONS[txs].amount|default:"0"|number_format:"8"}
    +
    +{include file="global/block_footer.tpl"} From ab6a4f57d31bd6fe884f0cc48d3a9544cbab905a Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 6 Sep 2013 10:29:42 +0200 Subject: [PATCH 4/9] further implemetation into mmcfe-ng --- public/include/autoloader.inc.php | 1 + public/include/config/admin_settings.inc.php | 9 ++++++++- public/include/pages/statistics/round.inc.php | 20 +++++++++++-------- public/include/smarty_globals.inc.php | 1 + public/templates/mmcFE/global/navigation.tpl | 3 +++ .../mmcFE/statistics/blocks/default.tpl | 6 +----- .../mmcFE/statistics/blocks/small_table.tpl | 6 +----- .../mmcFE/statistics/round/block_stats.tpl | 10 +++++++--- .../mmcFE/statistics/round/round_shares.tpl | 8 +++++--- 9 files changed, 39 insertions(+), 25 deletions(-) diff --git a/public/include/autoloader.inc.php b/public/include/autoloader.inc.php index 35ce807e..d86245fb 100644 --- a/public/include/autoloader.inc.php +++ b/public/include/autoloader.inc.php @@ -41,6 +41,7 @@ require_once(CLASS_DIR . '/invitation.class.php'); require_once(CLASS_DIR . '/share.class.php'); require_once(CLASS_DIR . '/worker.class.php'); require_once(CLASS_DIR . '/statistics.class.php'); +require_once(CLASS_DIR . '/roundstats.class.php'); require_once(CLASS_DIR . '/transaction.class.php'); require_once(CLASS_DIR . '/notification.class.php'); require_once(CLASS_DIR . '/news.class.php'); diff --git a/public/include/config/admin_settings.inc.php b/public/include/config/admin_settings.inc.php index f3b68cd8..3342ef49 100644 --- a/public/include/config/admin_settings.inc.php +++ b/public/include/config/admin_settings.inc.php @@ -108,12 +108,19 @@ $aSettings['acl'][] = array( 'tooltip' => 'Make the pool statistics page private (users only) or public.' ); $aSettings['acl'][] = array( - 'display' => 'Blcok Statistics', 'type' => 'select', + 'display' => 'Block Statistics', 'type' => 'select', 'options' => array( 0 => 'Private', 1 => 'Public'), 'default' => 1, 'name' => 'acl_block_statistics', 'value' => $setting->getValue('acl_block_statistics'), 'tooltip' => 'Make the block statistics page private (users only) or public.' ); +$aSettings['acl'][] = array( + 'display' => 'Round Statistics', 'type' => 'select', + 'options' => array( 0 => 'Private', 1 => 'Public'), + 'default' => 1, + 'name' => 'acl_round_statistics', 'value' => $setting->getValue('acl_round_statistics'), + 'tooltip' => 'Make the round statistics page private (users only) or public.' +); $aSettings['system'][] = array( 'display' => 'Disable e-mail confirmations', 'type' => 'select', 'options' => array( 0 => 'No', 1 => 'Yes' ), diff --git a/public/include/pages/statistics/round.inc.php b/public/include/pages/statistics/round.inc.php index 06b3b8f5..b4d138e1 100644 --- a/public/include/pages/statistics/round.inc.php +++ b/public/include/pages/statistics/round.inc.php @@ -6,18 +6,18 @@ if (!defined('SECURITY')) die('Hacking attempt'); if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $debug->append('No cached version available, fetching from backend', 3); -if (@$_REQUEST['next'] && !empty($_REQUEST['tx_key'])) { - $_REQUEST['tx_key'] = $roundstats->getNextBlockDesc($_REQUEST['tx_key']); -} else if (@$_REQUEST['prev'] && !empty($_REQUEST['tx_key'])) { - $_REQUEST['tx_key'] = $roundstats->getNextBlockAsc($_REQUEST['tx_key']); +if (@$_REQUEST['next'] && !empty($_REQUEST['height'])) { + $_REQUEST['height'] = $roundstats->getNextBlockDesc($_REQUEST['height']); +} else if (@$_REQUEST['prev'] && !empty($_REQUEST['height'])) { + $_REQUEST['height'] = $roundstats->getNextBlockAsc($_REQUEST['height']); } -if (empty($_REQUEST['tx_key'])) { +if (empty($_REQUEST['height'])) { $iBlock = $block->getLast(); $iKey = $iBlock['height']; - $_REQUEST['tx_key'] = $iKey; + $_REQUEST['height'] = $iKey; } else { - $iKey = $_REQUEST['tx_key']; + $iKey = $_REQUEST['height']; } $aDetailsForBlockHeight = $roundstats->getDetailsForBlockHeight($iKey, $user->isAdmin($_SESSION['USERDATA']['id'])); @@ -37,5 +37,9 @@ if ($user->isAdmin($_SESSION['USERDATA']['id'])) { $debug->append('Using cached page', 3); } -$smarty->assign("CONTENT", "default.tpl"); +if ($setting->getValue('acl_round_statistics')) { + $smarty->assign("CONTENT", "default.tpl"); +} else if ($user->isAuthenticated()) { + $smarty->assign("CONTENT", "default.tpl"); +} ?> diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index af2805b8..d457ee4e 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -72,6 +72,7 @@ $setting->getValue('website_chaininfo_url') ? $aGlobal['website']['chaininfo'][' // ACLs $aGlobal['acl']['pool']['statistics'] = $setting->getValue('acl_pool_statistics'); $aGlobal['acl']['block']['statistics'] = $setting->getValue('acl_block_statistics'); +$aGlobal['acl']['round']['statistics'] = $setting->getValue('acl_round_statistics'); // Special calculations for PPS Values based on reward_type setting and/or available blocks if ($config['reward_type'] != 'block') { diff --git a/public/templates/mmcFE/global/navigation.tpl b/public/templates/mmcFE/global/navigation.tpl index 75db64ce..c7f762e9 100644 --- a/public/templates/mmcFE/global/navigation.tpl +++ b/public/templates/mmcFE/global/navigation.tpl @@ -41,6 +41,9 @@ {/if} {if $GLOBAL.acl.block.statistics}
  • Block Stats
  • + {/if} + {if $GLOBAL.acl.round.statistics} +
  • Round Stats
  • {/if} {/if} diff --git a/public/templates/mmcFE/statistics/blocks/default.tpl b/public/templates/mmcFE/statistics/blocks/default.tpl index 6596647f..2bf8e85c 100644 --- a/public/templates/mmcFE/statistics/blocks/default.tpl +++ b/public/templates/mmcFE/statistics/blocks/default.tpl @@ -55,11 +55,7 @@ target and network difficulty and assuming a zero variance scenario. {assign var="totalshares" value=$totalshares+$BLOCKSFOUND[block].shares} {assign var="count" value=$count+1} - {if ! $GLOBAL.website.blockexplorer.disabled} - {$BLOCKSFOUND[block].height} - {else} - {$BLOCKSFOUND[block].height} - {/if} + {$BLOCKSFOUND[block].height} {if $BLOCKSFOUND[block].confirmations >= $GLOBAL.confirmations} Confirmed diff --git a/public/templates/mmcFE/statistics/blocks/small_table.tpl b/public/templates/mmcFE/statistics/blocks/small_table.tpl index e826fd3a..0c1760ff 100644 --- a/public/templates/mmcFE/statistics/blocks/small_table.tpl +++ b/public/templates/mmcFE/statistics/blocks/small_table.tpl @@ -13,11 +13,7 @@ {assign var=rank value=1} {section block $BLOCKSFOUND} - {if ! $GLOBAL.website.blockexplorer.disabled} - {$BLOCKSFOUND[block].height} - {else} - {$BLOCKSFOUND[block].height} - {/if} + {$BLOCKSFOUND[block].height} {if $BLOCKSFOUND[block].is_anonymous|default:"0" == 1}anonymous{else}{$BLOCKSFOUND[block].finder|default:"unknown"|escape}{/if} {$BLOCKSFOUND[block].time|date_format:"%d/%m %H:%M:%S"} {$BLOCKSFOUND[block].shares|number_format} diff --git a/public/templates/mmcFE/statistics/round/block_stats.tpl b/public/templates/mmcFE/statistics/round/block_stats.tpl index 40081671..5943e421 100644 --- a/public/templates/mmcFE/statistics/round/block_stats.tpl +++ b/public/templates/mmcFE/statistics/round/block_stats.tpl @@ -9,12 +9,16 @@ - Block Id + ID {$BLOCKDETAILS.id|default:"0"} - Heigth - {$BLOCKDETAILS.height|default:"0"} + Height + {if ! $GLOBAL.website.blockexplorer.disabled} + {$BLOCKDETAILS.height} + {else} + {$BLOCKDETAILS.height} + {/if} Amount diff --git a/public/templates/mmcFE/statistics/round/round_shares.tpl b/public/templates/mmcFE/statistics/round/round_shares.tpl index db1083d2..919aed8e 100644 --- a/public/templates/mmcFE/statistics/round/round_shares.tpl +++ b/public/templates/mmcFE/statistics/round/round_shares.tpl @@ -3,10 +3,11 @@ - - + + + @@ -14,10 +15,11 @@ {assign var=listed value=0} {section contrib $ROUNDSHARES} - + + {/section} From d4ce764d77facac83a9e8e717aa670d7f81dab44 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 6 Sep 2013 10:49:19 +0200 Subject: [PATCH 5/9] proper allow back/forth on blocks --- public/include/classes/roundstats.class.php | 12 ++++++------ public/include/pages/statistics/round.inc.php | 10 +++++----- .../templates/mmcFE/statistics/round/block_stats.tpl | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/public/include/classes/roundstats.class.php b/public/include/classes/roundstats.class.php index 5cbbfb4e..aebdd257 100644 --- a/public/include/classes/roundstats.class.php +++ b/public/include/classes/roundstats.class.php @@ -29,12 +29,12 @@ class RoundStats { /** * Get next block for round stats **/ - public function getNextBlockDesc($iHeight=0) { + public function getNextBlock($iHeight=0) { $stmt = $this->mysqli->prepare(" SELECT height FROM $this->tableBlocks - WHERE height < ? - ORDER BY height DESC + WHERE height > ? + ORDER BY height ASC LIMIT 1"); if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iHeight) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_object()->height; @@ -44,12 +44,12 @@ class RoundStats { /** * Get prev block for round stats **/ - public function getNextBlockAsc($iHeight=0) { + public function getPreviousBlock($iHeight=0) { $stmt = $this->mysqli->prepare(" SELECT height FROM $this->tableBlocks - WHERE height > ? - ORDER BY height ASC + WHERE height < ? + ORDER BY height DESC LIMIT 1"); if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iHeight) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_object()->height; diff --git a/public/include/pages/statistics/round.inc.php b/public/include/pages/statistics/round.inc.php index b4d138e1..f7ce285d 100644 --- a/public/include/pages/statistics/round.inc.php +++ b/public/include/pages/statistics/round.inc.php @@ -7,19 +7,19 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $debug->append('No cached version available, fetching from backend', 3); if (@$_REQUEST['next'] && !empty($_REQUEST['height'])) { - $_REQUEST['height'] = $roundstats->getNextBlockDesc($_REQUEST['height']); + $iKey = $roundstats->getNextBlock($_REQUEST['height']); } else if (@$_REQUEST['prev'] && !empty($_REQUEST['height'])) { - $_REQUEST['height'] = $roundstats->getNextBlockAsc($_REQUEST['height']); -} + $iKey = $roundstats->getPreviousBlock($_REQUEST['height']); +} else { if (empty($_REQUEST['height'])) { $iBlock = $block->getLast(); $iKey = $iBlock['height']; - $_REQUEST['height'] = $iKey; } else { $iKey = $_REQUEST['height']; } - +} +echo $iKey; $aDetailsForBlockHeight = $roundstats->getDetailsForBlockHeight($iKey, $user->isAdmin($_SESSION['USERDATA']['id'])); $aRoundShareStats = $roundstats->getRoundStatsForAccounts($iKey, $user->isAdmin($_SESSION['USERDATA']['id'])); diff --git a/public/templates/mmcFE/statistics/round/block_stats.tpl b/public/templates/mmcFE/statistics/round/block_stats.tpl index 5943e421..75b33950 100644 --- a/public/templates/mmcFE/statistics/round/block_stats.tpl +++ b/public/templates/mmcFE/statistics/round/block_stats.tpl @@ -47,18 +47,18 @@
    RankUser NameRankUser Name Valid InvalidInvalid %
    {$rank++}{$rank++} {if $ROUNDSHARES[contrib].is_anonymous|default:"0" == 1}anonymous{else}{$ROUNDSHARES[contrib].username|escape}{/if} {$ROUNDSHARES[contrib].valid|number_format} {$ROUNDSHARES[contrib].invalid|number_format}{($ROUNDSHARES[contrib].invalid / $ROUNDSHARES[contrib].valid * 100)|number_format:"2"}
    -
    + - +
    - + - + From b656be751dabe7ed02b49e52515616f82deb65c4 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 6 Sep 2013 10:51:55 +0200 Subject: [PATCH 6/9] indentations --- public/include/classes/roundstats.class.php | 64 +++++++++---------- public/include/pages/statistics/round.inc.php | 36 +++++------ 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/public/include/classes/roundstats.class.php b/public/include/classes/roundstats.class.php index aebdd257..d93cca43 100644 --- a/public/include/classes/roundstats.class.php +++ b/public/include/classes/roundstats.class.php @@ -31,11 +31,11 @@ class RoundStats { **/ public function getNextBlock($iHeight=0) { $stmt = $this->mysqli->prepare(" - SELECT height - FROM $this->tableBlocks - WHERE height > ? - ORDER BY height ASC - LIMIT 1"); + SELECT height + FROM $this->tableBlocks + WHERE height > ? + ORDER BY height ASC + LIMIT 1"); if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iHeight) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_object()->height; return false; @@ -46,11 +46,11 @@ class RoundStats { **/ public function getPreviousBlock($iHeight=0) { $stmt = $this->mysqli->prepare(" - SELECT height - FROM $this->tableBlocks - WHERE height < ? - ORDER BY height DESC - LIMIT 1"); + SELECT height + FROM $this->tableBlocks + WHERE height < ? + ORDER BY height DESC + LIMIT 1"); if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iHeight) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_object()->height; return false; @@ -63,12 +63,12 @@ class RoundStats { **/ public function getDetailsForBlockHeight($iHeight=0, $isAdmin=0) { $stmt = $this->mysqli->prepare(" - SELECT - b.id, height, amount, confirmations, difficulty, FROM_UNIXTIME(time) as time, shares, - IF(a.is_anonymous, IF( ? , a.username, 'anonymous'), a.username) AS finder - FROM $this->tableBlocks as b - LEFT JOIN $this->tableUsers AS a ON b.account_id = a.id - WHERE b.height = ? LIMIT 1"); + SELECT + b.id, height, amount, confirmations, difficulty, FROM_UNIXTIME(time) as time, shares, + IF(a.is_anonymous, IF( ? , a.username, 'anonymous'), a.username) AS finder + FROM $this->tableBlocks as b + LEFT JOIN $this->tableUsers AS a ON b.account_id = a.id + WHERE b.height = ? LIMIT 1"); if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $isAdmin, $iHeight) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_assoc(); return false; @@ -82,16 +82,16 @@ class RoundStats { public function getRoundStatsForAccounts($iHeight=0, $isAdmin=0) { $stmt = $this->mysqli->prepare(" SELECT - IF(a.is_anonymous, IF( ? , a.username, 'anonymous'), a.username) AS username, + IF(a.is_anonymous, IF( ? , a.username, 'anonymous'), a.username) AS username, s.valid, s.invalid - FROM $this->tableStats AS s - LEFT JOIN $this->tableBlocks AS b ON s.block_id = b.id - LEFT JOIN $this->tableUsers AS a ON a.id = s.account_id - WHERE b.height = ? - GROUP BY username ASC - ORDER BY valid DESC - "); + FROM $this->tableStats AS s + LEFT JOIN $this->tableBlocks AS b ON s.block_id = b.id + LEFT JOIN $this->tableUsers AS a ON a.id = s.account_id + WHERE b.height = ? + GROUP BY username ASC + ORDER BY valid DESC + "); if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $isAdmin, $iHeight) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_all(MYSQLI_ASSOC); return false; @@ -106,10 +106,10 @@ class RoundStats { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare(" SELECT - t.id AS id, - a.username AS username, - t.type AS type, - t.amount AS amount + t.id AS id, + a.username AS username, + t.type AS type, + t.amount AS amount FROM $this->tableTrans AS t LEFT JOIN $this->tableBlocks AS b ON t.block_id = b.id LEFT JOIN $this->tableUsers AS a ON t.account_id = a.id @@ -131,10 +131,10 @@ class RoundStats { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare(" SELECT - t.id AS id, - a.username AS username, - t.type AS type, - t.amount AS amount + t.id AS id, + a.username AS username, + t.type AS type, + t.amount AS amount FROM $this->tableTrans AS t LEFT JOIN $this->tableBlocks AS b ON t.block_id = b.id LEFT JOIN $this->tableUsers AS a ON t.account_id = a.id diff --git a/public/include/pages/statistics/round.inc.php b/public/include/pages/statistics/round.inc.php index f7ce285d..b6e40a3a 100644 --- a/public/include/pages/statistics/round.inc.php +++ b/public/include/pages/statistics/round.inc.php @@ -6,28 +6,28 @@ if (!defined('SECURITY')) die('Hacking attempt'); if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $debug->append('No cached version available, fetching from backend', 3); -if (@$_REQUEST['next'] && !empty($_REQUEST['height'])) { - $iKey = $roundstats->getNextBlock($_REQUEST['height']); -} else if (@$_REQUEST['prev'] && !empty($_REQUEST['height'])) { - $iKey = $roundstats->getPreviousBlock($_REQUEST['height']); -} else { + if (@$_REQUEST['next'] && !empty($_REQUEST['height'])) { + $iKey = $roundstats->getNextBlock($_REQUEST['height']); + } else if (@$_REQUEST['prev'] && !empty($_REQUEST['height'])) { + $iKey = $roundstats->getPreviousBlock($_REQUEST['height']); + } else { -if (empty($_REQUEST['height'])) { - $iBlock = $block->getLast(); - $iKey = $iBlock['height']; -} else { - $iKey = $_REQUEST['height']; -} -} -echo $iKey; + if (empty($_REQUEST['height'])) { + $iBlock = $block->getLast(); + $iKey = $iBlock['height']; + } else { + $iKey = $_REQUEST['height']; + } + } + echo $iKey; $aDetailsForBlockHeight = $roundstats->getDetailsForBlockHeight($iKey, $user->isAdmin($_SESSION['USERDATA']['id'])); $aRoundShareStats = $roundstats->getRoundStatsForAccounts($iKey, $user->isAdmin($_SESSION['USERDATA']['id'])); -if ($user->isAdmin($_SESSION['USERDATA']['id'])) { - $aUserRoundTransactions = $roundstats->getAllRoundTransactions($iKey); -} else { - $aUserRoundTransactions = $roundstats->getUserRoundTransactions($iKey, $_SESSION['USERDATA']['id']); -} + if ($user->isAdmin($_SESSION['USERDATA']['id'])) { + $aUserRoundTransactions = $roundstats->getAllRoundTransactions($iKey); + } else { + $aUserRoundTransactions = $roundstats->getUserRoundTransactions($iKey, $_SESSION['USERDATA']['id']); + } // Propagate content our template $smarty->assign('BLOCKDETAILS', $aDetailsForBlockHeight); From 52570011532be12aee42dc02628dc8d33e958bd3 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 6 Sep 2013 14:55:44 +0200 Subject: [PATCH 7/9] fixing blockhash in round block details --- public/include/classes/roundstats.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/include/classes/roundstats.class.php b/public/include/classes/roundstats.class.php index d93cca43..8af22cbf 100644 --- a/public/include/classes/roundstats.class.php +++ b/public/include/classes/roundstats.class.php @@ -31,10 +31,10 @@ class RoundStats { **/ public function getNextBlock($iHeight=0) { $stmt = $this->mysqli->prepare(" - SELECT height + SELECT height FROM $this->tableBlocks WHERE height > ? - ORDER BY height ASC + ORDER BY height ASC LIMIT 1"); if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iHeight) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_object()->height; @@ -46,10 +46,10 @@ class RoundStats { **/ public function getPreviousBlock($iHeight=0) { $stmt = $this->mysqli->prepare(" - SELECT height + SELECT height FROM $this->tableBlocks WHERE height < ? - ORDER BY height DESC + ORDER BY height DESC LIMIT 1"); if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iHeight) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_object()->height; @@ -64,7 +64,7 @@ class RoundStats { public function getDetailsForBlockHeight($iHeight=0, $isAdmin=0) { $stmt = $this->mysqli->prepare(" SELECT - b.id, height, amount, confirmations, difficulty, FROM_UNIXTIME(time) as time, shares, + b.id, height, blockhash, amount, confirmations, difficulty, FROM_UNIXTIME(time) as time, shares, IF(a.is_anonymous, IF( ? , a.username, 'anonymous'), a.username) AS finder FROM $this->tableBlocks as b LEFT JOIN $this->tableUsers AS a ON b.account_id = a.id From bc7e5111779b807fcf165530e72be88ad8c7d341 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 6 Sep 2013 15:00:47 +0200 Subject: [PATCH 8/9] removing debug echos --- public/include/classes/user.class.php | 1 - public/include/pages/statistics/round.inc.php | 1 - 2 files changed, 2 deletions(-) diff --git a/public/include/classes/user.class.php b/public/include/classes/user.class.php index e012505a..dc0c71b7 100644 --- a/public/include/classes/user.class.php +++ b/public/include/classes/user.class.php @@ -201,7 +201,6 @@ class User { return $result->fetch_all(MYSQLI_ASSOC); } $this->debug->append("Unable to fetch users with AP set"); - echo $this->mysqli->error; return false; } diff --git a/public/include/pages/statistics/round.inc.php b/public/include/pages/statistics/round.inc.php index b6e40a3a..869dbb72 100644 --- a/public/include/pages/statistics/round.inc.php +++ b/public/include/pages/statistics/round.inc.php @@ -19,7 +19,6 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $iKey = $_REQUEST['height']; } } - echo $iKey; $aDetailsForBlockHeight = $roundstats->getDetailsForBlockHeight($iKey, $user->isAdmin($_SESSION['USERDATA']['id'])); $aRoundShareStats = $roundstats->getRoundStatsForAccounts($iKey, $user->isAdmin($_SESSION['USERDATA']['id'])); From 8ae36844f12d4ed4bf0456855b43ae84291f5f9c Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sat, 7 Sep 2013 20:53:28 +0200 Subject: [PATCH 9/9] fixing some PHP warnings --- public/include/config/admin_settings.inc.php | 2 ++ public/templates/mmcFE/account/edit/default.tpl | 2 +- public/templates/mmcFE/account/qrcode/default.tpl | 2 +- public/templates/mmcFE/statistics/blocks/default.tpl | 2 ++ public/templates/mmcFE/statistics/default.tpl | 2 +- public/templates/mmcFE/statistics/pool/authenticated.tpl | 2 +- 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/public/include/config/admin_settings.inc.php b/public/include/config/admin_settings.inc.php index 3342ef49..69b55e75 100644 --- a/public/include/config/admin_settings.inc.php +++ b/public/include/config/admin_settings.inc.php @@ -77,6 +77,7 @@ $aSettings['website'][] = array( $aSettings['website'][] = array( 'display' => 'Disable Blockexplorer', 'type' => 'select', 'options' => array( 0 => 'No', 1 => 'Yes' ), + 'default' => 0, 'name' => 'website_blockexplorer_disabled', 'value' => $setting->getValue('website_blockexplorer_disabled'), 'tooltip' => 'Enabled or disable the blockexplorer URL feature. Will remove any links using the blockexplorer URL.' ); @@ -90,6 +91,7 @@ $aSettings['website'][] = array( $aSettings['website'][] = array( 'display' => 'Disable Chaininfo', 'type' => 'select', 'options' => array( 0 => 'No', 1 => 'Yes' ), + 'default' => 0, 'name' => 'website_chaininfo_disabled', 'value' => $setting->getValue('website_chaininfo_disabled'), 'tooltip' => 'Enabled or disable the chainfo URL feature. Will remove any links using the chaininfo URL.' ); diff --git a/public/templates/mmcFE/account/edit/default.tpl b/public/templates/mmcFE/account/edit/default.tpl index 0a3e523d..e548da34 100644 --- a/public/templates/mmcFE/account/edit/default.tpl +++ b/public/templates/mmcFE/account/edit/default.tpl @@ -6,7 +6,7 @@ - {if !$GLOBAL.config.website.api.disabled}{/if} + {if !$GLOBAL.website.api.disabled}{/if} diff --git a/public/templates/mmcFE/account/qrcode/default.tpl b/public/templates/mmcFE/account/qrcode/default.tpl index 2656314e..c185a4b4 100644 --- a/public/templates/mmcFE/account/qrcode/default.tpl +++ b/public/templates/mmcFE/account/qrcode/default.tpl @@ -1,4 +1,4 @@ -{if !$GLOBAL.config.website.api.disabled} +{if !$GLOBAL.website.api.disabled} {include file="global/block_header.tpl" BLOCK_HEADER="API String"}

    This code will allow you to import the full API string into your mobile application.

    diff --git a/public/templates/mmcFE/statistics/blocks/default.tpl b/public/templates/mmcFE/statistics/blocks/default.tpl index 2bf8e85c..596ccfe9 100644 --- a/public/templates/mmcFE/statistics/blocks/default.tpl +++ b/public/templates/mmcFE/statistics/blocks/default.tpl @@ -79,12 +79,14 @@ target and network difficulty and assuming a zero variance scenario. {/section} + {if $count > 0} + {/if}
    Username: {$GLOBAL.userdata.username|escape}
    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)]
    Totals {$totalexpectedshares|number_format} {$totalshares|number_format} {($totalpercentage / $count)|number_format:"2"}
    diff --git a/public/templates/mmcFE/statistics/default.tpl b/public/templates/mmcFE/statistics/default.tpl index 59603d94..5fa45522 100644 --- a/public/templates/mmcFE/statistics/default.tpl +++ b/public/templates/mmcFE/statistics/default.tpl @@ -19,5 +19,5 @@ -{if !$GLOBAL.config.website.api.disabled}
  • These stats are also available in JSON format HERE
  • {/if} +{if !$GLOBAL.website.api.disabled}
  • These stats are also available in JSON format HERE
  • {/if} {include file="global/block_footer.tpl"} diff --git a/public/templates/mmcFE/statistics/pool/authenticated.tpl b/public/templates/mmcFE/statistics/pool/authenticated.tpl index 6189ef78..b19848db 100644 --- a/public/templates/mmcFE/statistics/pool/authenticated.tpl +++ b/public/templates/mmcFE/statistics/pool/authenticated.tpl @@ -32,7 +32,7 @@ {/if} Last Block Found - {if $GLOBAL.website.blockexplorer.url}{$LASTBLOCK|default:"0"}{else}{$LASTBLOCK|default:"0"}{/if} + {if $GLOBAL.website.blockexplorer.url}{$LASTBLOCK|default:"0"}{else}{$LASTBLOCK|default:"0"}{/if} Current Difficulty