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

71
pool/page.php

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

Loading…
Cancel
Save