Browse Source

php - show mostly real stats at the top

master
kanoi 11 years ago
parent
commit
54e48c1ed9
  1. 21
      pool/db.php
  2. 37
      pool/page.php

21
pool/db.php

@ -71,34 +71,25 @@ function getStats($user)
{
global $fld_sep;
if ($user === null)
$msg = "s$fld_sep";
$msg = msgEncode('homepage', 'home', array());
else
$msg = "s$fld_sep$user";
$msg = msgEncode('homepage', 'home', array('username'=>$user));
return $msg;
}
#
function homeInfo($user)
{
$msg = getStats($user);
/*
$rep = sendsockreply('homeInfo', $msg);
$rep = sendsockreply('homepage', $msg);
if ($rep === false)
$ans = false;
else
{
$ans = repDecode($rep);
$ans['lastblock'] = 1401237522;
}
return $ans;
*/
if ($user !== null)
$uhr = rand(500, 2500);
else
$uhr = 0;
$plb = 1401237522;
$nlb = time() - rand(200,500);
return array('PoolHashRate' => '250', 'PoolLastBlock' => "$plb", 'NetLastBlock' => "$nlb", 'UserHashRate' => "$uhr");
}
#
function checkpass($user, $pass)

37
pool/page.php

@ -131,12 +131,21 @@ function pgtop($dotop, $user, $douser)
{
$now = time();
if (isset($info['PoolHashRate']))
$phr = $info['PoolHashRate'].'TH/s';
if (isset($info['p_hashrate5m']))
{
$phr = $info['p_hashrate5m'];
if ($phr == '?')
$phr .= 'THs';
else
$phr = (round($phr/10)/100).'THs';
}
if (isset($info['PoolLastBlock']))
if (isset($info['lastblock']))
{
$plb = $info['lastblock'];
if ($plb != '?')
{
$sec = $now - $info['PoolLastBlock'];
$sec = $now - $plb;
if ($sec < 60)
$plb = $sec.'s';
else
@ -156,23 +165,35 @@ function pgtop($dotop, $user, $douser)
}
}
}
}
if (isset($info['NetLastBlock']))
if (isset($info['lastlp']))
{
$nlb = $info['lastlp'];
if ($nlb != '?')
{
$sec = $now - $info['NetLastBlock'];
$sec = $now - $info['lastlp'];
$min = round($sec / 60);
$nlb = $min.'m';
}
}
if (isset($info['UserHashRate']))
if (isset($info['u_hashrate5m']))
{
$uhr = $info['u_hashrate5m'];
if ($uhr == '?')
{
$uhr .= 'GHs';
}
else
{
$uhr = $info['UserHashRate'];
if ($uhr < 1000)
$uhr .= 'GHs';
else
$uhr = (round($uhr/10)/100).'THs';
}
}
}
addscript("function jst(){document.getElementById('jst').style.visibility='hidden';}");
$top = "<div class=jst id=jst>&nbsp;Javascript isn't enabled.";

Loading…
Cancel
Save