commit
635ceee1b9
@ -302,24 +302,21 @@ class Statistics {
|
|||||||
if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
|
if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
|
||||||
$stmt = $this->mysqli->prepare("
|
$stmt = $this->mysqli->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
ROUND(COUNT(s.id) * POW(2, 12)/600/1000) AS hashrate,
|
ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate,
|
||||||
HOUR(s.time) AS hour
|
HOUR(s.time) AS hour
|
||||||
FROM " . $this->share->getTableName() . " AS s, accounts AS a
|
FROM " . $this->share->getTableName() . " AS s, accounts AS a
|
||||||
WHERE time < NOW() - INTERVAL 1 HOUR AND time > NOW() - INTERVAL 25 HOUR
|
WHERE time < NOW() - INTERVAL 1 HOUR
|
||||||
|
AND time > NOW() - INTERVAL 25 HOUR
|
||||||
AND a.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
AND a.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
||||||
AND a.id = ?
|
AND a.id = ?
|
||||||
GROUP BY HOUR(time)
|
GROUP BY HOUR(time)
|
||||||
UNION ALL
|
");
|
||||||
SELECT
|
if ($this->checkStmt($stmt) && $stmt->bind_param("i", $account_id) && $stmt->execute() && $result = $stmt->get_result()) {
|
||||||
ROUND(COUNT(s.id) * POW(2, 12)/600/1000) AS hashrate,
|
while ($row = $result->fetch_assoc()) {
|
||||||
HOUR(s.time) AS hour
|
$aData[$row['hour']] = $row['hashrate'];
|
||||||
FROM " . $this->share->getArchiveTableName() . " AS s, accounts AS a
|
}
|
||||||
WHERE time < NOW() - INTERVAL 1 HOUR AND time > NOW() - INTERVAL 25 HOUR
|
return $this->memcache->setCache(__FUNCTION__ . $account_id, $aData);
|
||||||
AND a.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
}
|
||||||
AND a.id = ?
|
|
||||||
GROUP BY HOUR(time)");
|
|
||||||
if ($this->checkStmt($stmt) && $stmt->bind_param("ii", $account_id, $account_id) && $stmt->execute() && $result = $stmt->get_result())
|
|
||||||
return $this->memcache->setCache(__FUNCTION__ . $account_id, $result->fetch_all(MYSQLI_ASSOC), 3600);
|
|
||||||
// Catchall
|
// Catchall
|
||||||
$this->debug->append("Failed to fetch hourly hashrate: " . $this->mysqli->error);
|
$this->debug->append("Failed to fetch hourly hashrate: " . $this->mysqli->error);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -4,21 +4,10 @@
|
|||||||
if (!defined('SECURITY'))
|
if (!defined('SECURITY'))
|
||||||
die('Hacking attempt');
|
die('Hacking attempt');
|
||||||
|
|
||||||
// Fetch data from litecoind
|
|
||||||
if ($bitcoin->can_connect() === true){
|
|
||||||
$dDifficulty = $bitcoin->getdifficulty();
|
|
||||||
$iBlock = $bitcoin->getblockcount();
|
|
||||||
} else {
|
|
||||||
$iDifficulty = 1;
|
|
||||||
$iBlock = 0;
|
|
||||||
$_SESSION['POPUP'][] = array('CONTENT' => 'Unable to connect to litecoind RPC service: ' . $bitcoin->can_connect(), 'TYPE' => 'errormsg');
|
|
||||||
}
|
|
||||||
|
|
||||||
$aHourlyHashRates = $statistics->getHourlyHashrateByAccount($_SESSION['USERDATA']['id']);
|
$aHourlyHashRates = $statistics->getHourlyHashrateByAccount($_SESSION['USERDATA']['id']);
|
||||||
|
|
||||||
// Propagate content our template
|
// Propagate content our template
|
||||||
$smarty->assign("YOURHASHRATES", $aHourlyHashRates);
|
$smarty->assign("YOURHASHRATES", $aHourlyHashRates);
|
||||||
$smarty->assign("DIFFICULTY", $dDifficulty);
|
|
||||||
|
|
||||||
if ($_SESSION['AUTHENTICATED']) {
|
if ($_SESSION['AUTHENTICATED']) {
|
||||||
$smarty->assign("CONTENT", "default.tpl");
|
$smarty->assign("CONTENT", "default.tpl");
|
||||||
|
|||||||
@ -1,23 +1,33 @@
|
|||||||
{include file="global/block_header.tpl" BLOCK_HEADER="Your Average Hourly Hash Rate" BUTTONS=array(mine,pool,both)}
|
{include file="global/block_header.tpl" BLOCK_HEADER="Your Average Hourly Hash Rate" BUTTONS=array(mine,pool,both)}
|
||||||
|
{if is_array($YOURHASHRATES)}
|
||||||
<div class="block_content tab_content" id="mine" style="padding-left:30px;">
|
<div class="block_content tab_content" id="mine" style="padding-left:30px;">
|
||||||
<table class="stats" rel="area" cellpadding="0">
|
<table class="stats" rel="area" cellpadding="0">
|
||||||
<caption>Your Hashrate </caption>
|
<caption>Your Hashrate </caption>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
{section hashrate $YOURHASHRATES}
|
{for $i=date('G') to 23}
|
||||||
<th scope="col">{$YOURHASHRATES[hashrate].hour}</th>
|
<th scope="col">{$i}:00</th>
|
||||||
{/section}
|
{/for}
|
||||||
|
{for $i=0 to date('G', time () - 60 * 60)}
|
||||||
|
<th scope="col">{$i}:00</th>
|
||||||
|
{/for}
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">{$GLOBAL.USERDATA.username}</th>
|
<th scope="row">{$smarty.session.USERDATA.username}</th>
|
||||||
{section hashrate $YOURHASHRATES}
|
{for $i=date('G') to 23}
|
||||||
<td>{$YOURHASHRATES[hashrate].hashrate|number_format}</td>
|
<td>{$YOURHASHRATES.$i|default:"0"}</td>
|
||||||
{/section}
|
{/for}
|
||||||
|
{for $i=0 to date('G', time() - 60 * 60)}
|
||||||
|
<td>{$YOURHASHRATES.$i|default:"0"}</td>
|
||||||
|
{/for}
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
{else}
|
||||||
|
<p><li>No shares available to start calculations</li></p>
|
||||||
|
{/if}
|
||||||
{include file="global/block_footer.tpl"}
|
{include file="global/block_footer.tpl"}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user