@@ -99,25 +99,25 @@ public function updateShareStatistics($aStats, $iBlockId) {
9999 * @param none
100100 * @return data object Return our hashrateas an object
101101 **/
102- public function getCurrentHashrate () {
102+ public function getCurrentHashrate ($ interval = 600 ) {
103103 $ this ->debug ->append ("STA " . __METHOD__ , 4 );
104104 if ($ this ->getGetCache () && $ data = $ this ->memcache ->get (__FUNCTION__ )) return $ data ;
105105 $ stmt = $ this ->mysqli ->prepare ("
106106 SELECT
107107 (
108108 (
109- SELECT IFNULL(ROUND(SUM(IF(difficulty=0, POW(2, ( " . $ this ->config ['difficulty ' ] . " - 16)), difficulty)) * 65536 / 600 / 1000), 0) AS hashrate
109+ SELECT IFNULL(ROUND(SUM(IF(difficulty=0, POW(2, ( " . $ this ->config ['difficulty ' ] . " - 16)), difficulty)) * 65536 / ? / 1000), 0) AS hashrate
110110 FROM " . $ this ->share ->getTableName () . "
111- WHERE time > DATE_SUB(now(), INTERVAL 600 SECOND)
111+ WHERE time > DATE_SUB(now(), INTERVAL ? SECOND)
112112 ) + (
113- SELECT IFNULL(ROUND(SUM(IF(difficulty=0, POW(2, ( " . $ this ->config ['difficulty ' ] . " - 16)), difficulty)) * 65536 / 600 / 1000), 0) AS hashrate
113+ SELECT IFNULL(ROUND(SUM(IF(difficulty=0, POW(2, ( " . $ this ->config ['difficulty ' ] . " - 16)), difficulty)) * 65536 / ? / 1000), 0) AS hashrate
114114 FROM " . $ this ->share ->getArchiveTableName () . "
115- WHERE time > DATE_SUB(now(), INTERVAL 600 SECOND)
115+ WHERE time > DATE_SUB(now(), INTERVAL ? SECOND)
116116 )
117117 ) AS hashrate
118118 FROM DUAL " );
119119 // Catchall
120- if ($ this ->checkStmt ($ stmt ) && $ stmt ->execute () && $ result = $ stmt ->get_result () ) return $ this ->memcache ->setCache (__FUNCTION__ , $ result ->fetch_object ()->hashrate );
120+ if ($ this ->checkStmt ($ stmt ) && $ stmt ->bind_param ( ' iiii ' , $ interval , $ interval , $ interval , $ interval ) && $ stmt -> execute () && $ result = $ stmt ->get_result () ) return $ this ->memcache ->setCache (__FUNCTION__ , $ result ->fetch_object ()->hashrate );
121121 $ this ->debug ->append ("Failed to get hashrate: " . $ this ->mysqli ->error );
122122 return false ;
123123 }
@@ -222,6 +222,8 @@ public function getAllUserShares() {
222222 } else {
223223 $ data ['data ' ][$ row ['id ' ]]['valid ' ] += $ row ['valid ' ];
224224 $ data ['data ' ][$ row ['id ' ]]['invalid ' ] += $ row ['invalid ' ];
225+ $ data ['data ' ][$ row ['id ' ]]['donate_percent ' ] = $ row ['donate_percent ' ];
226+ $ data ['data ' ][$ row ['id ' ]]['is_anonymous ' ] = $ row ['is_anonymous ' ];
225227 }
226228 }
227229 $ data ['share_id ' ] = $ this ->share ->getMaxShareId ();
@@ -293,28 +295,28 @@ public function getAllUserStats($filter='%') {
293295 * @param account_id integer User ID
294296 * @return data integer Current Hashrate in khash/s
295297 **/
296- public function getUserHashrate ($ account_id ) {
298+ public function getUserHashrate ($ account_id, $ interval = 600 ) {
297299 $ this ->debug ->append ("STA " . __METHOD__ , 4 );
298- if ($ data = $ this ->memcache ->get (__FUNCTION__ . $ account_id )) return $ data ;
300+ if ($ this -> getGetCache () && $ data = $ this ->memcache ->get (__FUNCTION__ . $ account_id )) return $ data ;
299301 $ stmt = $ this ->mysqli ->prepare ("
300302 SELECT
301303 (
302- SELECT IFNULL(ROUND(SUM(IF(difficulty=0, POW(2, ( " . $ this ->config ['difficulty ' ] . " - 16)), difficulty)) * 65536 / 600 / 1000), 0) AS hashrate
304+ SELECT IFNULL(ROUND(SUM(IF(difficulty=0, POW(2, ( " . $ this ->config ['difficulty ' ] . " - 16)), difficulty)) * 65536 / ? / 1000), 0) AS hashrate
303305 FROM " . $ this ->share ->getTableName () . " AS s,
304306 " . $ this ->user ->getTableName () . " AS u
305307 WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
306- AND s.time > DATE_SUB(now(), INTERVAL 600 SECOND)
308+ AND s.time > DATE_SUB(now(), INTERVAL ? SECOND)
307309 AND u.id = ?
308310 ) + (
309- SELECT IFNULL(ROUND(SUM(IF(difficulty=0, POW(2, ( " . $ this ->config ['difficulty ' ] . " - 16)), difficulty)) * 65536 / 600 / 1000), 0) AS hashrate
311+ SELECT IFNULL(ROUND(SUM(IF(difficulty=0, POW(2, ( " . $ this ->config ['difficulty ' ] . " - 16)), difficulty)) * 65536 / ? / 1000), 0) AS hashrate
310312 FROM " . $ this ->share ->getArchiveTableName () . " AS s,
311313 " . $ this ->user ->getTableName () . " AS u
312314 WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
313- AND s.time > DATE_SUB(now(), INTERVAL 600 SECOND)
315+ AND s.time > DATE_SUB(now(), INTERVAL ? SECOND)
314316 AND u.id = ?
315317 ) AS hashrate
316318 FROM DUAL " );
317- if ($ this ->checkStmt ($ stmt ) && $ stmt ->bind_param ("ii " , $ account_id , $ account_id ) && $ stmt ->execute () && $ result = $ stmt ->get_result () )
319+ if ($ this ->checkStmt ($ stmt ) && $ stmt ->bind_param ("iiiiii " , $ interval , $ interval , $ account_id, $ interval , $ interval , $ account_id ) && $ stmt ->execute () && $ result = $ stmt ->get_result () )
318320 return $ this ->memcache ->setCache (__FUNCTION__ . $ account_id , $ result ->fetch_object ()->hashrate );
319321 // Catchall
320322 $ this ->debug ->append ("Failed to fetch hashrate: " . $ this ->mysqli ->error );
@@ -328,7 +330,7 @@ public function getUserHashrate($account_id) {
328330 **/
329331 public function getUserSharerate ($ account_id , $ interval =600 ) {
330332 $ this ->debug ->append ("STA " . __METHOD__ , 4 );
331- if ($ data = $ this ->memcache ->get (__FUNCTION__ . $ account_id )) return $ data ;
333+ if ($ this -> getGetCache () && $ data = $ this ->memcache ->get (__FUNCTION__ . $ account_id )) return $ data ;
332334 $ stmt = $ this ->mysqli ->prepare ("
333335 SELECT
334336 (
@@ -400,6 +402,8 @@ public function getTopContributors($type='shares', $limit=15) {
400402 foreach ($ data ['data ' ] as $ key => $ aUser ) {
401403 $ data_new [$ key ]['shares ' ] = $ aUser ['valid ' ];
402404 $ data_new [$ key ]['account ' ] = $ aUser ['username ' ];
405+ $ data_new [$ key ]['donate_percent ' ] = $ aUser ['donate_percent ' ];
406+ $ data_new [$ key ]['is_anonymous ' ] = $ aUser ['is_anonymous ' ];
403407 }
404408 return $ data_new ;
405409 }
0 commit comments