From 3ae73463fe27753eb2c6d0c2d1f22959abf70aac Mon Sep 17 00:00:00 2001 From: kanoi Date: Wed, 16 Dec 2015 12:25:39 +1100 Subject: [PATCH] php - payout help number formatting --- pool/base.php | 20 ++++++++++++++++---- pool/page_payout.php | 8 ++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/pool/base.php b/pool/base.php index 4acf3de0..35523c92 100644 --- a/pool/base.php +++ b/pool/base.php @@ -121,14 +121,26 @@ function howmanyhrs($tot, $days = false, $dh = false) if ($dh == true) { if ($min >= 30) + { $hr++; + if ($hr == 24) + { + $days++; + $hr = 0; + } + } $ds = ''; if ($dy != 1) $ds = 's'; - $hs = ''; - if ($hr != 1) - $hs = 's'; - $des = "${dy}day$ds ${hr}hr$hs"; + if ($hr == 0) + $des = "${dy}day$ds"; + else + { + $hs = ''; + if ($hr != 1) + $hs = 's'; + $des = "${dy}day$ds ${hr}hr$hs"; + } } else $des = $dy.'d '.$hr.'hr '.$min.'m '.$sec.'s'; diff --git a/pool/page_payout.php b/pool/page_payout.php index a99f09fd..5990b6fd 100644 --- a/pool/page_payout.php +++ b/pool/page_payout.php @@ -15,14 +15,14 @@ function dopayout($data, $user) $nd = $data['info']['currndiff']; $nv = number_format($nd, 1); $nvx = ''.number_format($N*$nd, 1).''; - $phr = $data['info']['p_hashrate24hr']; + $pd = $data['info']['p_hashrate24hr']; $hr = 'is ?'; $hrt = '?'; - if ($phr != '?' && $phr != '' && $phr > 0) + if ($pd != '?' && $pd != '' && $pd > 0) { - $hr = 'for the last day is '.dsprate($phr).''; + $hr = 'for the last day is roughly '.siprefmt($pd,2).'Hs'; if ($nd > 0) - $hrt = ''.howmanyhrs($nd / ($phr / pow(2,32)), true, true).''; + $hrt = ''.howmanyhrs($nd * $N / ($pd / pow(2,32)), true, true).''; } $pg = "

Payouts