255)
$grn = 255;
if ($grn > 190)
$fg = '#00f';
else
$fg = '#fff';
$bg = sprintf("#00%02x00", $grn);
}
if ($pct > 100)
{
$red = (log10(pow($pct,4.0)) - 8.0) / 3.0 * 255;
if ($red < 0)
$red = 0;
if ($red > 255)
$red = 255;
$fg = '#fff';
$bg = sprintf("#%02x0000", $red);
}
return array($fg, $bg);
}
#
function doblocks($data, $user)
{
$blink = 'Blocks';
$ans = getBlocks($user);
$pg .= "
\n";
$pg .= "";
$pg .= "Height | ";
$pg .= "Who | ";
$pg .= "Reward | ";
$pg .= "When | ";
$pg .= "Status | ";
$pg .= "Diff | ";
$pg .= "% | ";
$pg .= "
\n";
$blktot = 0;
$nettot = 0;
$i = 0;
if ($ans['STATUS'] == 'ok')
{
$count = $ans['rows'];
for ($i = 0; $i < $count; $i++)
{
if (($i % 2) == 0)
$row = 'even';
else
$row = 'odd';
$hi = $ans['height:'.$i];
$hifld = "$blink$hi>$hi";
$ex = '';
$stat = $ans['status:'.$i];
if ($stat == 'Orphan')
$ex = 's';
if ($stat == '1-Confirm')
{
if (isset($data['info']['lastheight']))
{
$conf = 1 + $data['info']['lastheight'] - $hi;
$stat = '+'.$conf.' Confirms';
}
else
$stat = 'Conf';
}
$stara = '';
$starp = '';
if (isset($ans['status:'.($i+1)]))
if ($ans['status:'.($i+1)] == 'Orphan'
&& $stat != 'Orphan')
{
$stara = '*';
$starp = '*';
}
$diffacc = $ans['diffacc:'.$i];
$acc = number_format($diffacc, 0);
$netdiff = $ans['netdiff:'.$i];
if ($netdiff > 0)
{
$pct = 100.0 * $diffacc / $netdiff;
list($fg, $bg) = pctcolour($pct);
$bpct = "$starp".number_format($pct, 2).'%';
$bg = " bgcolor=$bg";
$blktot += $diffacc;
if ($stat != 'Orphan')
$nettot += $netdiff;
}
else
{
$bg = '';
$bpct = '?';
}
$pg .= "";
$pg .= "$hifld | ";
$pg .= "".htmlspecialchars($ans['workername:'.$i]).' | ';
$pg .= "".btcfmt($ans['reward:'.$i]).' | ';
$pg .= "".gmdate('Y-m-d H:i:s+00', $ans['firstcreatedate:'.$i]).' | ';
$pg .= "".$stat.' | ';
$pg .= "$stara$acc | ";
$pg .= "$bpct | ";
$pg .= "
\n";
}
}
if ($nettot > 0)
{
if (($i % 2) == 0)
$row = 'even';
else
$row = 'odd';
$pct = 100.0 * $blktot / $nettot;
list($fg, $bg) = pctcolour($pct);
$bpct = "".number_format($pct, 2).'%';
$bg = " bgcolor=$bg";
$pg .= "";
$pg .= " | ";
$pg .= "".$bpct.' | ';
$pg .= "
\n";
}
$pg .= "
\n";
return $pg;
}
#
function show_blocks($page, $menu, $name, $user)
{
gopage(NULL, 'doblocks', $page, $menu, $name, $user);
}
#
?>