255) $grn = 255; if ($grn > 190) $fg = 'blue'; else $fg = 'white'; $bg = sprintf("#00%02x00", $grn); } else # ($erl > 0.5) { $red = (-0.3 - log10(1.0 - $erl)) * 255; if ($red < 0) $red = 0; if ($red > 255) $red = 255; $fg = 'white'; $bg = sprintf("#%02x0000", $red); } return array($fg, $bg); } # function pctcolour($pct) { if ($pct == 100) { $fg = 'white'; $bg = 'black'; } if ($pct < 100) { $grn = (2.0 - log10($pct)) * 255; if ($grn < 0) $grn = 0; if ($grn > 255) $grn = 255; if ($grn > 190) $fg = 'blue'; else $fg = 'white'; $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 = 'white'; $bg = sprintf("#%02x0000", $red); } return array($fg, $bg); } # function doblocks($data, $user) { $blink = ' 0) { $pg .= '

Block Statistics

'; $pg .= "\n"; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= "\n"; $count = $ans['s_rows']; for ($i = 0; $i < $count; $i++) { if (($i % 2) == 0) $row = 'even'; else $row = 'odd'; $desc = $ans['s_desc:'.$i]; $age = daysago($ans['STAMP'] - $ans['s_createdate:'.$i]); $diff = number_format(100 * $ans['s_diffratio:'.$i], 2); $mean = number_format(100 * $ans['s_diffmean:'.$i], 2); $cdferl = $ans['s_cdferl:'.$i]; list($fg, $bg) = erlcolour($cdferl); $cdferldsp = "".number_format($cdferl, 4).''; $bg = " bgcolor=$bg"; $luck = number_format(100 * $ans['s_luck:'.$i], 2); $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= "\n"; } $pg .= "
DescriptionAgeDiff%Mean%CDF[Erl]Luck%
$desc Blocks$age$diff%$mean%$cdferldsp$luck%
\n"; } if ($ans['STATUS'] == 'ok') { $count = $ans['rows']; if ($count == 1) { $num = ''; $s = ''; } else { $num = " $count"; $s = 's'; } $pg .= "

Last$num Block$s

"; } else $pg .= '

Blocks

'; list($fg, $bg) = pctcolour(25.0); $pg .= ""; $pg .= " Green  "; $pg .= 'is good luck. Lower Diff% and brighter green is better luck.
'; list($fg, $bg) = pctcolour(100.0); $pg .= ""; $pg .= " 100%  "; $pg .= 'is expected average. '; list($fg, $bg) = pctcolour(400.0); $pg .= ""; $pg .= " Red  "; $pg .= 'is bad luck. Higher Diff% and brighter red is worse luck.

'; $pg .= "\n"; $pg .= ""; $pg .= ""; $pg .= ""; if ($user !== null) $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= "\n"; } $blktot = 0; $nettot = 0; $i = 0; $cnt = 0; $orph = false; $csv = "Sequence,Height,Status,Timestamp,DiffAcc,NetDiff,Hash\n"; 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 = ''; $conf = $ans['confirmed:'.$i]; $stat = $ans['status:'.$i]; $inf = $ans['info:'.$i]; $tt = ''; if ($conf == 'O' or $conf == 'R') { $ex = 's'; $orph = true; $seq = ''; $nn = $cnt; if ($conf == 'R') { addTips(); $in = explode(':', $inf, 2); if (trim($in[0]) != '') $stat = trim($in[0]); if (count($in) < 2 or trim($in[1]) == '') { $tip = 'Share diff was VERY close
'; $tip .= 'so we tested it,
'; $tip .= "but it wasn't worthy
"; } else $tip = str_replace('+', '
', trim($in[1])); $tt = ""; $tt .= '?'; $tt .= ""; $tt .= "$tip"; } } else { $seq = $ans['seq:'.$i]; $nn = ++$cnt; } if ($conf == '1') { if (isset($data['info']['lastheight'])) { $confn = 1 + $data['info']['lastheight'] - $hi; $stat = '+'.$confn.' Confirms'; } else $stat = 'Conf'; } $stara = ''; if ($conf == 'O' or $conf == 'R') $stara = '*'; if (isset($ans['statsconf:'.$i])) { if ($ans['statsconf:'.$i] == 'Y') $approx = ''; else $approx = '~'; } else $approx = ''; $diffacc = $ans['diffacc:'.$i]; $acc = number_format($diffacc, 0); $netdiff = $ans['netdiff:'.$i]; $diffratio = $ans['diffratio:'.$i]; $cdf = $ans['cdf:'.$i]; $luck = $ans['luck:'.$i]; if ($diffratio > 0) { $pct = 100.0 * $diffratio; list($fg, $bg) = pctcolour($pct); $bpct = "$approx".number_format($pct, 3).'%'; $bg = " bgcolor=$bg"; $blktot += $diffacc; if ($conf != 'O' and $conf != 'R') $nettot += $netdiff; $cdfdsp = number_format($cdf, 3); } else { $bg = ''; $bpct = '?'; $cdfdsp = '?'; } if ($wantcsv === false) { $pg .= ""; $pg .= ""; $pg .= ""; if ($user !== null) $pg .= "'; $pg .= "'; $pg .= "'; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= "\n"; } else { $csv .= "$seq,"; $csv .= "$hi,"; $csv .= "\"$stat\","; $csv .= $ans['firstcreatedate:'.$i].','; $csv .= "$diffacc,"; $csv .= "$netdiff,"; $csv .= $ans['blockhash:'.$i]."\n"; } } } if ($wantcsv === true) { echo $csv; exit(0); } if ($orph === true) { $pg .= '
#HeightWhoBlock RewardWhenStatusDiffDiff%CDFB
$seq$hifld".htmlspecialchars($ans['workername:'.$i]).'".btcfmt($ans['reward:'.$i]).'".utcd($ans['firstcreatedate:'.$i]).'$tt$stat$stara$approx$acc$bpct$cdfdsp$nn