From e31662232732f0b6fdf2911560b456e69677642e Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 14 May 2013 00:07:28 +0200 Subject: [PATCH] quickly added user hashrate and shares, dirty but working, better to cache those --- public/include/classes/user.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/include/classes/user.class.php b/public/include/classes/user.class.php index 33fcd3c4..32ad8380 100644 --- a/public/include/classes/user.class.php +++ b/public/include/classes/user.class.php @@ -167,9 +167,16 @@ class User { $stmt = $this->mysqli->prepare(" SELECT id, username, pin, pass, admin, - IFNULL(donate_percent, '0') as donate_percent, coin_address, ap_threshold + IFNULL(donate_percent, '0') as donate_percent, coin_address, ap_threshold, + ( + SELECT ROUND(COUNT(id) * POW(2,21)/600/1000) FROM shares WHERE $this->table.username = SUBSTRING_INDEX( `username` , '.', 1 ) AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) + ) AS hashrate, + ( + SELECT COUNT(id) FROM shares WHERE $this->table.username = SUBSTRING_INDEX( `username` , '.', 1 ) AND UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM blocks),0) + ) AS shares FROM $this->table WHERE id = ? LIMIT 0,1"); +echo $this->mysqli->error; if ($this->checkStmt($stmt)) { $stmt->bind_param('i', $userID); if (!$stmt->execute()) {