diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 594db90e..2a9dd185 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -353,7 +353,7 @@ class Statistics extends Base { * @param username str username * @return data array invalid and valid share counts **/ - public function getUserShares($username) { + public function getUserShares($username, $account_id) { $this->debug->append("STA " . __METHOD__, 4); // Dual-caching, try statistics cron first, then fallback to local, then fallbock to SQL if ($data = $this->memcache->get(STATISTICS_ALL_USER_SHARES)) { @@ -495,7 +495,7 @@ class Statistics extends Base { * @param $username string username * @return data integer Current Hashrate in khash/s **/ - public function getUserHashrate($username, $interval=600) { + public function getUserHashrate($username, $account_id, $interval=600) { $this->debug->append("STA " . __METHOD__, 4); // Dual-caching, try statistics cron first, then fallback to local, then fallbock to SQL if ($data = $this->memcache->get(STATISTICS_ALL_USER_HASHRATES)) { @@ -551,7 +551,7 @@ class Statistics extends Base { * @param interval int Data interval in seconds * @return double Share difficulty or 0 **/ - public function getUserShareDifficulty($username, $interval=600) { + public function getUserShareDifficulty($username, $account_id, $interval=600) { $this->debug->append("STA " . __METHOD__, 4); // Dual-caching, try statistics cron first, then fallback to local, then fallbock to SQL if ($data = $this->memcache->get(STATISTICS_ALL_USER_HASHRATES)) { @@ -568,7 +568,8 @@ class Statistics extends Base { FROM " . $this->share->getTableName() . " AS s WHERE username = '?.%' AND time > DATE_SUB(now(), INTERVAL ? SECOND) - AND our_result = 'Y'); + AND our_result = 'Y' + "); if ($this->checkStmt($stmt) && $stmt->bind_param("ii", $username, $interval) && $stmt->execute() && $result = $stmt->get_result() ) return $this->memcache->setCache(__FUNCTION__ . $username, $result->fetch_object()->avgsharediff); return $this->sqlError(); @@ -579,7 +580,7 @@ class Statistics extends Base { * @param username string username * @return data integer Current Sharerate in shares/s **/ - public function getUserSharerate($username, $interval=600) { + public function getUserSharerate($username, $account_id, $interval=600) { $this->debug->append("STA " . __METHOD__, 4); // Dual-caching, try statistics cron first, then fallback to local, then fallbock to SQL if ($data = $this->memcache->get(STATISTICS_ALL_USER_HASHRATES)) { @@ -627,7 +628,7 @@ class Statistics extends Base { FROM " . $this->share->getTableName() . " AS WHERE username = '?.%' AND our_result = 'Y' - AND time > DATE_SUB(now(), INTERVAL ? SECOND)); + AND time > DATE_SUB(now(), INTERVAL ? SECOND)"); if ($this->checkStmt($stmt) && $stmt->bind_param("i", $username, $interval) && $stmt->execute() && $result = $stmt->get_result() ) return $this->memcache->setCache(__FUNCTION__ . $username, $result->fetch_object()->hashrate); return $this->sqlError(); diff --git a/public/include/pages/api/getdashboarddata.inc.php b/public/include/pages/api/getdashboarddata.inc.php index 69d4ed35..3ca71365 100644 --- a/public/include/pages/api/getdashboarddata.inc.php +++ b/public/include/pages/api/getdashboarddata.inc.php @@ -45,13 +45,13 @@ if ( ! $dNetworkHashrateModifier = $setting->getValue('statistics_network_hashra $statistics->setGetCache(false); $dPoolHashrate = $statistics->getCurrentHashrate($interval); if ($dPoolHashrate > $dNetworkHashrate) $dNetworkHashrate = $dPoolHashrate; -$dPersonalHashrate = $statistics->getUserHashrate($username, $interval); -$dPersonalSharerate = $statistics->getUserSharerate($username, $interval); -$dPersonalShareDifficulty = $statistics->getUserShareDifficulty($username, $interval); +$dPersonalHashrate = $statistics->getUserHashrate($username, $user_id, $interval); +$dPersonalSharerate = $statistics->getUserSharerate($username, $user_id, $interval); +$dPersonalShareDifficulty = $statistics->getUserShareDifficulty($username, $user_id, $interval); $statistics->setGetCache(true); // Use caches for this one -$aUserRoundShares = $statistics->getUserShares($username); +$aUserRoundShares = $statistics->getUserShares($username, $user_id); $aRoundShares = $statistics->getRoundShares(); if ($config['payout_system'] != 'pps') { diff --git a/public/include/pages/api/getusersharerate.inc.php b/public/include/pages/api/getusersharerate.inc.php index a51db57a..3549c0f4 100644 --- a/public/include/pages/api/getusersharerate.inc.php +++ b/public/include/pages/api/getusersharerate.inc.php @@ -15,7 +15,7 @@ if ( ! $interval = $setting->getValue('statistics_ajax_data_interval')) $interva // Gather un-cached data $statistics->setGetCache(false); -$sharerate = $statistics->getUserSharerate($username, $interval); +$sharerate = $statistics->getUserSharerate($username, $user_id, $interval); $statistics->setGetCache(true); // Output JSON format diff --git a/public/include/pages/api/getuserstatus.inc.php b/public/include/pages/api/getuserstatus.inc.php index 2a717cd6..23ef53c7 100644 --- a/public/include/pages/api/getuserstatus.inc.php +++ b/public/include/pages/api/getuserstatus.inc.php @@ -15,9 +15,9 @@ $aTransactionSummary = $transaction->getTransactionSummary($user_id); // Output JSON format $data = array( 'username' => $username, - 'shares' => $statistics->getUserShares($username), - 'hashrate' => $statistics->getUserHashrate($username), - 'sharerate' => $statistics->getUserSharerate($username) + 'shares' => $statistics->getUserShares($username, $user_id), + 'hashrate' => $statistics->getUserHashrate($username, $user_id), + 'sharerate' => $statistics->getUserSharerate($username, $user_id) ); echo $api->get_json($data); diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index e564b252..e3637cd3 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -129,10 +129,10 @@ if (@$_SESSION['USERDATA']['id']) { $aGlobal['userdata']['balance'] = $transaction->getBalance($_SESSION['USERDATA']['id']); // Other userdata that we can cache savely - $aGlobal['userdata']['shares'] = $statistics->getUserShares($_SESSION['USERDATA']['username']); - $aGlobal['userdata']['rawhashrate'] = $statistics->getUserHashrate($_SESSION['USERDATA']['username']); + $aGlobal['userdata']['shares'] = $statistics->getUserShares($_SESSION['USERDATA']['username'], $_SESSION['USERDATA']['id']); + $aGlobal['userdata']['rawhashrate'] = $statistics->getUserHashrate($_SESSION['USERDATA']['username'], $_SESSION['USERDATA']['id']); $aGlobal['userdata']['hashrate'] = $aGlobal['userdata']['rawhashrate'] * $dPersonalHashrateModifier; - $aGlobal['userdata']['sharerate'] = $statistics->getUserSharerate($_SESSION['USERDATA']['username']); + $aGlobal['userdata']['sharerate'] = $statistics->getUserSharerate($_SESSION['USERDATA']['username'], $_SESSION['USERDATA']['id']); switch ($config['payout_system']) { case 'prop':