From 3f0c3884aa35563eaca220881b0ee6403905946a Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 14 Jun 2013 15:20:30 +0200 Subject: [PATCH 1/2] Adding some more information for PPS to sidebar * Added user share rate to sidebar for PPS * Added estimated 24h LTC payout based on PPS value and share rate Addresses #160 --- public/include/classes/statistics.class.php | 25 ++++++++++++++++++++- public/include/smarty_globals.inc.php | 1 + public/templates/mmcFE/global/sidebar.tpl | 10 ++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index f9f2ea9a..a30aba1b 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -199,7 +199,7 @@ class Statistics { a.username AS username, a.donate_percent AS donate_percent, a.email AS email, - COUNT(s.id) AS shares + COUNT(s.id) AS shares FROM " . $this->user->getTableName() . " AS a LEFT JOIN " . $this->share->getTableName() . " AS s ON a.username = SUBSTRING_INDEX( s.username, '.', 1 ) @@ -219,6 +219,7 @@ class Statistics { * @return data integer Current Hashrate in khash/s **/ public function getUserHashrate($account_id) { + $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 @@ -234,6 +235,28 @@ class Statistics { return false; } + /** + * Same as getUserHashrate for Sharerate + * @param account_id integer User ID + * @return data integer Current Sharerate in shares/s + **/ + public function getUserSharerate($account_id) { + $this->debug->append("STA " . __METHOD__, 4); + if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data; + $stmt = $this->mysqli->prepare(" + SELECT COUNT(s.id)/600 AS sharerate + 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() ) + return $this->memcache->setCache(__FUNCTION__ . $account_id, $result->fetch_object()->sharerate); + // Catchall + $this->debug->append("Failed to fetch sharerate: " . $this->mysqli->error); + return false; + } + /** * Get hashrate for a specific worker * @param worker_id int Worker ID to fetch hashrate for diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index d55318d8..2d33a173 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -59,6 +59,7 @@ if (@$_SESSION['USERDATA']['id']) { // Other userdata that we can cache savely $aGlobal['userdata']['shares'] = $statistics->getUserShares($_SESSION['USERDATA']['id']); $aGlobal['userdata']['hashrate'] = $statistics->getUserHashrate($_SESSION['USERDATA']['id']); + $aGlobal['userdata']['sharerate'] = $statistics->getUserSharerate($_SESSION['USERDATA']['id']); // Some estimations $aGlobal['userdata']['est_block'] = round(( (int)$aGlobal['userdata']['shares']['valid'] / (int)$aRoundShares['valid'] ) * (int)$config['reward'], 3); diff --git a/public/templates/mmcFE/global/sidebar.tpl b/public/templates/mmcFE/global/sidebar.tpl index 34018785..450be70d 100644 --- a/public/templates/mmcFE/global/sidebar.tpl +++ b/public/templates/mmcFE/global/sidebar.tpl @@ -14,9 +14,17 @@ {$GLOBAL.userdata.hashrate|number_format} KH/s {if $GLOBAL.config.payout_system == 'pps'} + + Share Rate + {$GLOBAL.userdata.sharerate|number_format:"2"} S/s + PPS Value - {$GLOBAL.ppsvalue} + {$GLOBAL.ppsvalue} + + + {$GLOBAL.config.currency} in 24h + {($GLOBAL.userdata.sharerate * 24 * 60 * 60 * $GLOBAL.ppsvalue)|number_format:"8"} {/if} {if $GLOBAL.config.payout_system != 'pps'} From 82f696164524c7d2813e2c3409ae7b04307e2164 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 18 Jun 2013 10:22:43 +0200 Subject: [PATCH 2/2] Adding PPS specific sidebar * Adding PPS sidebar to seperate the HTML code * Added PPS specific globals section if need be some day * Added payout detection to master template for sidebar * Added 7 days and 14 days estimates Fixes #160 --- public/include/smarty_globals.inc.php | 16 +++-- public/templates/mmcFE/global/sidebar.tpl | 18 ------ public/templates/mmcFE/global/sidebar_pps.tpl | 61 +++++++++++++++++++ public/templates/mmcFE/master.tpl | 6 +- 4 files changed, 77 insertions(+), 24 deletions(-) create mode 100644 public/templates/mmcFE/global/sidebar_pps.tpl diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index 2d33a173..923b7263 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -61,11 +61,17 @@ if (@$_SESSION['USERDATA']['id']) { $aGlobal['userdata']['hashrate'] = $statistics->getUserHashrate($_SESSION['USERDATA']['id']); $aGlobal['userdata']['sharerate'] = $statistics->getUserSharerate($_SESSION['USERDATA']['id']); - // Some estimations - $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); + switch ($config['payout_system']) { + case 'pps': + break; + default: + // Some estimations + $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); + break; + } } // Make it available in Smarty diff --git a/public/templates/mmcFE/global/sidebar.tpl b/public/templates/mmcFE/global/sidebar.tpl index 450be70d..58d49c67 100644 --- a/public/templates/mmcFE/global/sidebar.tpl +++ b/public/templates/mmcFE/global/sidebar.tpl @@ -13,21 +13,6 @@ Hashrate {$GLOBAL.userdata.hashrate|number_format} KH/s -{if $GLOBAL.config.payout_system == 'pps'} - - Share Rate - {$GLOBAL.userdata.sharerate|number_format:"2"} S/s - - - PPS Value - {$GLOBAL.ppsvalue} - - - {$GLOBAL.config.currency} in 24h - {($GLOBAL.userdata.sharerate * 24 * 60 * 60 * $GLOBAL.ppsvalue)|number_format:"8"} - -{/if} -{if $GLOBAL.config.payout_system != 'pps'} Unpaid Shares @@ -39,7 +24,6 @@ Pool Valid {$GLOBAL.roundshares.valid|number_format} -{/if} Round Shares @@ -55,7 +39,6 @@ Your Invalid {$GLOBAL.userdata.shares.invalid|number_format} -{if $GLOBAL.config.payout_system != 'pps'} {$GLOBAL.config.currency} Round Estimate @@ -75,7 +58,6 @@ Payout {$GLOBAL.userdata.est_payout|number_format:"3"} -{/if}   {$GLOBAL.config.currency} Account Balance Confirmed{$GLOBAL.userdata.balance.confirmed|default:"0"} diff --git a/public/templates/mmcFE/global/sidebar_pps.tpl b/public/templates/mmcFE/global/sidebar_pps.tpl new file mode 100644 index 00000000..b7aa8617 --- /dev/null +++ b/public/templates/mmcFE/global/sidebar_pps.tpl @@ -0,0 +1,61 @@ +
+
+
+
+

Dashboard

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
diff --git a/public/templates/mmcFE/master.tpl b/public/templates/mmcFE/master.tpl index 4c3204dc..8709e974 100644 --- a/public/templates/mmcFE/master.tpl +++ b/public/templates/mmcFE/master.tpl @@ -47,7 +47,11 @@