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; 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)

37
pool/page.php

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

Loading…
Cancel
Save