Browse Source

php - show mostly real stats at the top

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

21
pool/db.php

@ -71,34 +71,25 @@ function getStats($user)
{ {
global $fld_sep; global $fld_sep;
if ($user === null) if ($user === null)
$msg = "s$fld_sep"; $msg = msgEncode('homepage', 'home', array());
else else
$msg = "s$fld_sep$user"; $msg = msgEncode('homepage', 'home', array('username'=>$user));
return $msg; return $msg;
} }
# #
function homeInfo($user) function homeInfo($user)
{ {
$msg = getStats($user); $msg = getStats($user);
/* $rep = sendsockreply('homepage', $msg);
$rep = sendsockreply('homeInfo', $msg);
if ($rep === false) if ($rep === false)
$ans = false; $ans = false;
else else
{
$ans = repDecode($rep); $ans = repDecode($rep);
$ans['lastblock'] = 1401237522;
}
return $ans; 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) function checkpass($user, $pass)

71
pool/page.php

@ -131,46 +131,67 @@ function pgtop($dotop, $user, $douser)
{ {
$now = time(); $now = time();
if (isset($info['PoolHashRate'])) if (isset($info['p_hashrate5m']))
$phr = $info['PoolHashRate'].'TH/s';
if (isset($info['PoolLastBlock']))
{ {
$sec = $now - $info['PoolLastBlock']; $phr = $info['p_hashrate5m'];
if ($sec < 60) if ($phr == '?')
$plb = $sec.'s'; $phr .= 'THs';
else else
$phr = (round($phr/10)/100).'THs';
}
if (isset($info['lastblock']))
{
$plb = $info['lastblock'];
if ($plb != '?')
{ {
if ($sec < 3600) $sec = $now - $plb;
{ if ($sec < 60)
$min = round($sec / 60); $plb = $sec.'s';
$plb = $min.'m';
}
else else
{ {
$min = round(($sec % 3600) / 60); if ($sec < 3600)
$hr = round($sec / 3600); {
$plb = $hr.'h'; $min = round($sec / 60);
if ($min != 0) $plb = $min.'m';
$plb .= ' '.$min.'m'; }
else
{
$min = round(($sec % 3600) / 60);
$hr = round($sec / 3600);
$plb = $hr.'h';
if ($min != 0)
$plb .= ' '.$min.'m';
}
} }
} }
} }
if (isset($info['NetLastBlock'])) if (isset($info['lastlp']))
{ {
$sec = $now - $info['NetLastBlock']; $nlb = $info['lastlp'];
$min = round($sec / 60); if ($nlb != '?')
$nlb = $min.'m'; {
$sec = $now - $info['lastlp'];
$min = round($sec / 60);
$nlb = $min.'m';
}
} }
if (isset($info['UserHashRate'])) if (isset($info['u_hashrate5m']))
{ {
$uhr = $info['UserHashRate']; $uhr = $info['u_hashrate5m'];
if ($uhr < 1000) if ($uhr == '?')
{
$uhr .= 'GHs'; $uhr .= 'GHs';
}
else else
$uhr = (round($uhr/10)/100).'THs'; {
if ($uhr < 1000)
$uhr .= 'GHs';
else
$uhr = (round($uhr/10)/100).'THs';
}
} }
} }

Loading…
Cancel
Save