Merge pull request #368 from TheSerapher/issue-367

Issue 367
This commit is contained in:
Sebastian Grewe 2013-07-04 04:03:11 -07:00
commit e963072740
2 changed files with 14 additions and 16 deletions

View File

@ -146,8 +146,8 @@ class Statistics {
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data;
$stmt = $this->mysqli->prepare("
SELECT
SUM(IF(our_result='Y', 1, 0)) AS valid,
SUM(IF(our_result='N', 1, 0)) AS invalid
IFNULL(SUM(IF(our_result='Y', 1, 0)), 0) AS valid,
IFNULL(SUM(IF(our_result='N', 1, 0)), 0) AS invalid
FROM " . $this->share->getTableName() . "
WHERE UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM " . $this->block->getTableName() . "),0)");
if ( $this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result() )
@ -168,10 +168,10 @@ class Statistics {
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data;
$stmt = $this->mysqli->prepare("
SELECT
SUM(IF(our_result='Y', 1, 0)) AS valid,
SUM(IF(our_result='N', 1, 0)) AS invalid,
u.id AS id,
u.username AS username
IFNULL(SUM(IF(our_result='Y', 1, 0)), 0) AS valid,
IFNULL(SUM(IF(our_result='N', 1, 0)), 0) AS invalid,
u.id AS id,
u.username AS username
FROM " . $this->share->getTableName() . " AS s,
" . $this->user->getTableName() . " AS u
WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
@ -194,8 +194,8 @@ class Statistics {
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
$stmt = $this->mysqli->prepare("
SELECT
SUM(IF(our_result='Y', 1, 0)) AS valid,
SUM(IF(our_result='N', 1, 0)) AS invalid
IFNULL(SUM(IF(our_result='Y', 1, 0)), 0) AS valid,
IFNULL(SUM(IF(our_result='N', 1, 0)), 0) AS invalid
FROM " . $this->share->getTableName() . " AS s,
" . $this->user->getTableName() . " AS u
WHERE
@ -231,8 +231,7 @@ class Statistics {
WHERE
a.username LIKE ?
GROUP BY username
ORDER BY username
");
ORDER BY username");
if ($this->checkStmt($stmt) && $stmt->bind_param('s', $filter) && $stmt->execute() && $result = $stmt->get_result()) {
return $this->memcache->setCache(__FUNCTION__ . $filter, $result->fetch_all(MYSQLI_ASSOC));
}
@ -402,13 +401,12 @@ class Statistics {
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data;
$stmt = $this->mysqli->prepare("
SELECT
ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate,
ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate,
HOUR(s.time) AS hour
FROM " . $this->share->getTableName() . " AS s
WHERE time < NOW() - INTERVAL 1 HOUR
FROM " . $this->share->getTableName() . " AS s
WHERE time < NOW() - INTERVAL 1 HOUR
AND time > NOW() - INTERVAL 25 HOUR
GROUP BY HOUR(time)
");
GROUP BY HOUR(time)");
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) {
while ($row = $result->fetch_assoc()) {
$aData[$row['hour']] = $row['hashrate'];

View File

@ -6,7 +6,7 @@
<table>
<tbody><tr><td>Username: </td><td>{$GLOBAL.userdata.username}</td></tr>
<tr><td>User Id: </td><td>{$GLOBAL.userdata.id}</td></tr>
<tr><td>API Key: </td><td>{$GLOBAL.userdata.api_key}</td></tr>
<tr><td>API Key: </td><td><a href="{$smarty.server.PHP_SELF}?page=api&action=getuserstatus&api_key={$GLOBAL.userdata.api_key}&id={$GLOBAL.userdata.id}">{$GLOBAL.userdata.api_key}</a></td></tr>
<tr><td>E-Mail: </td><td><input type="text" name="email" value="{$GLOBAL.userdata.email|escape}" size="20"></td></tr>
<tr><td>Payment Address: </td><td><input type="text" name="paymentAddress" value="{$smarty.request.paymentAddress|default:$GLOBAL.userdata.coin_address|escape}" size="40"></td></tr>
<tr><td>Donation %: </td><td><input type="text" name="donatePercent" value="{$smarty.request.donatePercent|default:$GLOBAL.userdata.donate_percent|escape}" size="4"><font size="1"> [donation amount in percent (example: 0.5)]</font></td></tr>