From 9562d4b594b8ebd0c1ab8ba5605f21581c2a5898 Mon Sep 17 00:00:00 2001 From: kanoi Date: Sun, 28 Dec 2014 15:24:26 +1100 Subject: [PATCH] php - pplns number formatting to help with visual comparisons --- pool/page_pplns.php | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/pool/page_pplns.php b/pool/page_pplns.php index bd6d0751..9bae4f6c 100644 --- a/pool/page_pplns.php +++ b/pool/page_pplns.php @@ -111,6 +111,22 @@ function calctx($ans, $count, $miner_sat, $diffacc_total) return $pg; } # +function fmtdata($code, $val) +{ + switch ($code) + { + case ',': + $ret = number_format($val); + break; + case '.': + $ret = number_format($val, 1); + break; + default: + $ret = $val; + } + return $ret; +} +# function dopplns($data, $user) { global $send_sep; @@ -169,9 +185,9 @@ Block: 'Block Hash' => 'block_hash', 'Block Reward (Satoshis)' => 'block_reward', 'Miner Reward (Satoshis)' => 'miner_sat', - 'PPLNS Wanted' => 'diff_want', - 'PPLNS Used' => 'diffacc_total', - 'Elapsed Seconds' => 'pplns_elapsed', + 'PPLNS Wanted' => '.diff_want', + 'PPLNS Used' => '.diffacc_total', + 'Elapsed Seconds' => ',pplns_elapsed', 'Users' => 'rows', 'Oldest Workinfoid' => 'begin_workinfoid', 'Oldest Time' => 'begin_stamp', @@ -185,11 +201,11 @@ Block: 'Network Difficulty' => 'block_ndiff', 'PPLNS Factor' => 'diff_times', 'PPLNS Added' => 'diff_add', - 'Accepted Share Count' => 'acc_share_count', - 'Total Share Count' => 'total_share_count', - 'ShareSummary Count' => 'ss_count', - 'WorkMarkers Count' => 'wm_count', - 'MarkerSummary Count' => 'ms_count'); + 'Accepted Share Count' => ',acc_share_count', + 'Total Share Count' => ',total_share_count', + 'ShareSummary Count' => ',ss_count', + 'WorkMarkers Count' => ',wm_count', + 'MarkerSummary Count' => ',ms_count'); $pg = '
Blockchain '.$ans['block']."
\n"; @@ -230,7 +246,18 @@ Block: $pg .= ""; $pg .= "$dsp"; - $pg .= ''.$ans[$name].''; + switch ($name[0]) + { + case ',': + case '.': + $nm = substr($name, 1); + $fmt = fmtdata($name[0], $ans[$nm]); + break; + default: + $fmt = $ans[$name]; + break; + } + $pg .= "$fmt"; $pg .= "\n"; }