adding propagates statistics page
This commit is contained in:
parent
5769aad0c0
commit
d6cb93fa5a
@ -21,6 +21,8 @@ define('DEBUG', 5);
|
||||
define('SALT', 'LJKEHFuhgu7%&¤Hg783tr7gf¤%¤fyegfredfoGHYFGYe(%/(&%6');
|
||||
|
||||
$config = array(
|
||||
'difficulty' => '31', // Target difficulty for this pool
|
||||
'reward' => '50', // Reward for finding blocks
|
||||
'wallet' => array(
|
||||
'type' => 'http', // http or https are supported
|
||||
'host' => 'localhost:9332',
|
||||
|
||||
@ -4,8 +4,9 @@
|
||||
if (!defined('SECURITY'))
|
||||
die('Hacking attempt');
|
||||
|
||||
// Fetch data from litecoind
|
||||
if ($bitcoin->can_connect() === true){
|
||||
$iDifficulty = $bitcoin->query('getdifficulty');
|
||||
$dDifficulty = $bitcoin->query('getdifficulty');
|
||||
$iBlock = $bitcoin->query('getblockcount');
|
||||
} else {
|
||||
$iDifficulty = 1;
|
||||
@ -13,8 +14,54 @@ if ($bitcoin->can_connect() === true){
|
||||
$_SESSION['POPUP'][] = array('CONTENT' => 'Unable to connect to pushpool service: ' . $bitcoin->can_connect(), 'TYPE' => 'errormsg');
|
||||
}
|
||||
|
||||
// TODO: For testing
|
||||
$dDifficulty = 396;
|
||||
|
||||
// Top 15 hashrate list
|
||||
$stmt = $mysqli->prepare("SELECT username, id, hashrate FROM webUsers WHERE hashrate != '0' ORDER BY hashrate DESC LIMIT 15");
|
||||
$stmt->execute();
|
||||
$hashrates= $stmt->get_result();
|
||||
$aHashData = $hashrates->fetch_all(MYSQLI_ASSOC);
|
||||
$stmt->close();
|
||||
|
||||
// Top 15 Contributors
|
||||
# SELECT id, shares_this_round AS shares FROM webUsers WHERE shares_this_round > 0 ORDER BY shares DESC LIMIT
|
||||
$stmt = $mysqli->prepare("SELECT id, shares_this_round AS shares, username FROM webUsers WHERE shares_this_round > 0 ORDER BY shares DESC LIMIT 15");
|
||||
$stmt->execute();
|
||||
$contributors = $stmt->get_result();
|
||||
$aContributorData = $contributors->fetch_all(MYSQLI_ASSOC);
|
||||
$stmt->close();
|
||||
|
||||
// Grab the last block found
|
||||
$stmt = $mysqli->prepare("SELECT n.blockNumber, n.confirms, n.timestamp FROM winning_shares w, networkBlocks n WHERE w.blockNumber = n.blockNumber ORDER BY w.blockNumber DESC LIMIT 1");
|
||||
$stmt->execute();
|
||||
$blocks = $stmt->get_result();
|
||||
$aBlockData = $blocks->fetch_array();
|
||||
$stmt->close();
|
||||
|
||||
// Grab the last 10 blocks found
|
||||
$stmt = $mysqli->prepare("SELECT DISTINCT w.shareCount AS shares, w.username, n.blockNumber, n.confirms, n.timestamp FROM winning_shares w, networkBlocks n WHERE w.blockNumber = n.blockNumber ORDER BY w.blockNumber DESC LIMIT 10");
|
||||
$stmt->execute();
|
||||
$blocksfound = $stmt->get_result();
|
||||
$aBlocksFoundData = $blocksfound->fetch_all(MYSQLI_ASSOC);
|
||||
$stmt->close();
|
||||
|
||||
// Estimated time to find the next block
|
||||
$iEstTime = (($dDifficulty * bcpow(2,$config['difficulty'])) / ( $settings->getValue('currenthashrate') * 1000));
|
||||
$now = new DateTime( "now" );
|
||||
$dTimeSinceLast = ($now->getTimestamp() - $aBlockData['timestamp']);
|
||||
|
||||
// Propagate content our template
|
||||
$smarty->assign("ESTTIME", $iEstTime);
|
||||
$smarty->assign("TIMESINCELAST", $dTimeSinceLast);
|
||||
$smarty->assign("CONTRIBUTORS", $aContributorData);
|
||||
$smarty->assign("BLOCKSFOUND", $aBlocksFoundData);
|
||||
$smarty->assign("TOPHASHRATES", $aHashData);
|
||||
$smarty->assign("CURRENTBLOCK", $iBlock);
|
||||
$smarty->assign("DIFFICULTY", $iDifficulty);
|
||||
$smarty->assign("LASTBLOCK", $aBlockData['blockNumber']);
|
||||
$smarty->assign("DIFFICULTY", $dDifficulty);
|
||||
$smarty->assign("TARGETDIFF", $config['difficulty']);
|
||||
$smarty->assign("REWARD", $config['reward']);
|
||||
|
||||
if ($_SESSION['AUTHENTICATED']) {
|
||||
$smarty->assign("CONTENT", "authenticated.tpl");
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright 2010 MAPIX Technologies Ltd, UK, http://mapix.com/
|
||||
* @license http://en.wikipedia.org/wiki/BSD_licenses BSD License
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
function smarty_modifier_seconds_to_words($seconds) {
|
||||
if ($seconds < 0) throw new Exception("Can't do negative numbers!");
|
||||
if ($seconds == 0) return "zero seconds";
|
||||
|
||||
$hours = intval($seconds/pow(60,2));
|
||||
$minutes = intval($seconds/60)%60;
|
||||
$seconds = $seconds%60;
|
||||
$out = "";
|
||||
|
||||
if ($hours > 0) $out .= $hours . " hour". ($hours > 1 ? "s" : "")." ";
|
||||
if ($minutes > 0) $out .= $minutes . " minute". ($minutes > 1 ? "s" : "")." ";
|
||||
if ($seconds > 0) $out .= $seconds . " second". ($seconds > 1 ? "s" : "");
|
||||
return trim($out);
|
||||
}
|
||||
31
public/templates/mmcFE/statistics/blocks/blocks_found.tpl
Normal file
31
public/templates/mmcFE/statistics/blocks/blocks_found.tpl
Normal file
@ -0,0 +1,31 @@
|
||||
{include file="global/block_header.tpl" BLOCK_HEADER="Last 10 Blocks Found" BLOCK_STYLE="clear:none;" BUTTONS=array(More)}
|
||||
<center>
|
||||
<table class="stats_lastblocks" width="100%" style="font-size:13px;">
|
||||
<thead>
|
||||
<tr style="background-color:#B6DAFF;">
|
||||
<th scope="col" align="left">Block</th>
|
||||
<th scope="col" align="left">Validity</th>
|
||||
<th scope="col" align="left">Finder</th>
|
||||
<th scope="col" align="left">Date / Time</th>
|
||||
<th scope="col" align="left">Shares</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{assign var=rank value=1}
|
||||
{section block $BLOCKSFOUND}
|
||||
{assign var=user value="."|explode:$BLOCKSFOUND[block].username}
|
||||
<tr class="{cycle values="odd,even"}">
|
||||
<td>{$BLOCKSFOUND[block].blockNumber}</td>
|
||||
<td>{$BLOCKSFOUND[block].confirmed}</td>
|
||||
<td>{$user.0}</td>
|
||||
<td>{$BLOCKSFOUND[block].timestamp|date_format:"%d/%m/%Y %H:%M:%S"}</td>
|
||||
<td>{$BLOCKSFOUND[block].shares|number_format}</td>
|
||||
</tr>
|
||||
{/section}
|
||||
</tbody>
|
||||
</table>
|
||||
</center>
|
||||
<ul>
|
||||
<li>Note: <font color="orange">Round Earnings are not credited until 120 confirms.</font></li>
|
||||
</ul>
|
||||
{include file="global/block_footer.tpl"}
|
||||
@ -11,12 +11,15 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="">
|
||||
<td>1</td>
|
||||
<td>TheSerapher</td>
|
||||
<td>576</td>
|
||||
<td> 4.045</td>
|
||||
{assign var=rank value=1}
|
||||
{section hashrate $TOPHASHRATES}
|
||||
<tr class="{cycle values="odd,even"}">
|
||||
<td>{$rank++}</td>
|
||||
<td>{$TOPHASHRATES[hashrate].username}</td>
|
||||
<td>{$TOPHASHRATES[hashrate].hashrate|number_format}</td>
|
||||
<td>{math equation="round(( 24 / (((diff * pow(2,targetdiff)) / (hashrate * 1000)) / 3600) * reward ),3)" diff=$DIFFICULTY targetdiff=$TARGETDIFF hashrate=$TOPHASHRATES[hashrate].hashrate reward=$REWARD}</td>
|
||||
</tr>
|
||||
{/section}
|
||||
</tbody>
|
||||
</table>
|
||||
</center>
|
||||
@ -29,11 +32,14 @@
|
||||
<tr style="background-color:#B6DAFF;"><th scope="col" align="left">Rank</th><th scope="col" align="left">User Name</th><th scope="col" align="left">Shares</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="user_position">
|
||||
<td>1</td>
|
||||
<td>TheSerapher</td>
|
||||
<td>94,133</td>
|
||||
{assign var=rank value=1}
|
||||
{section contributor $CONTRIBUTORS}
|
||||
<tr class="{cycle values="odd,even"}">
|
||||
<td>{$rank++}</td>
|
||||
<td>{$CONTRIBUTORS[contributor].username}</td>
|
||||
<td>{$CONTRIBUTORS[contributor].shares|number_format}</td>
|
||||
</tr>
|
||||
{/section}
|
||||
</tbody>
|
||||
</table>
|
||||
</center>
|
||||
@ -44,7 +50,7 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="leftheader">Pool Hash Rate</td>
|
||||
<td>{$GLOBAL.hashrate} Mhash/s</td>
|
||||
<td>{$GLOBAL.hashrate / 1000} Mhash/s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="leftheader">Current Workers Mining</td>
|
||||
@ -52,19 +58,23 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="leftheader">Next Network Block</td>
|
||||
<td><a href="http://explorer.litecoin.net/search?q=333758" target="_new">333,759</a> <font size="1"> (Current: <a href="http://explorer.litecoin.net/search?q=333758" target="_new">333,758)</a></font></td>
|
||||
<td><a href="http://explorer.litecoin.net/search?q={$CURRENTBLOCK}" target="_new">{$CURRENTBLOCK + 1}</a> <font size="1"> (Current: <a href="http://explorer.litecoin.net/search?q={$CURRENTBLOCK}" target="_new">{$CURRENTBLOCK})</a></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="leftheader">Last Block Found</td>
|
||||
<td><a href="http://explorer.litecoin.net/search?q={$LASTBLOCK}" target="_new">{$LASTBLOCK}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="leftheader">Current Difficulty</td>
|
||||
<td><a href="http://allchains.info" target="_new"><font size="2">293.35991187</font></a></td>
|
||||
<td><a href="http://allchains.info" target="_new"><font size="2">{$DIFFICULTY}</font></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="leftheader">Est. Avg. Time per Round</td>
|
||||
<td>205 Hours 40 Minutes</td>
|
||||
<td>{$ESTTIME|seconds_to_words}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="leftheader">Time Since Last Block</td>
|
||||
<td>N/A</td>
|
||||
<td>{$TIMESINCELAST|seconds_to_words}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -74,22 +84,6 @@
|
||||
{include file="global/block_footer.tpl"}
|
||||
|
||||
|
||||
{include file="global/block_header.tpl" BLOCK_HEADER="Last 10 Blocks Found" BLOCK_STYLE="clear:none;" BUTTONS=array(More)}
|
||||
<center>
|
||||
<table class="stats_lastblocks" width="100%" style="font-size:13px;">
|
||||
<tbody>
|
||||
<tr style="background-color:#B6DAFF;">
|
||||
<th scope="col" align="left">Block</th>
|
||||
<th scope="col" align="left">Validity</th>
|
||||
<th scope="col" align="left">Finder</th>
|
||||
<th scope="col" align="left">Date / Time</th>
|
||||
<th scope="col" align="left">Shares</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</center>
|
||||
<ul>
|
||||
<li>Note: <font color="orange">Round Earnings are not credited until 120 confirms.</font></li>
|
||||
</ul>
|
||||
{include file="global/block_footer.tpl"}
|
||||
{include file="statistics/blocks/blocks_found.tpl"}
|
||||
|
||||
{include file="global/block_footer.tpl"}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user