From 90bf52ef6de1dc5d7d62654f4ad751621b527e99 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 28 Aug 2014 00:30:58 +1000 Subject: [PATCH] php - add user restricted PPLNS calc page --- pool/db.php | 9 ++++ pool/page_pplns.php | 110 ++++++++++++++++++++++++++++++++++++++++++++ pool/prime.php | 2 + 3 files changed, 121 insertions(+) create mode 100644 pool/page_pplns.php diff --git a/pool/db.php b/pool/db.php index 14a939c3..7e705c81 100644 --- a/pool/db.php +++ b/pool/db.php @@ -42,6 +42,15 @@ function repDecode($rep) $ans['ID'] = $major[0]; $ans['STAMP'] = $major[1]; $ans['STATUS'] = $major[2]; + if ($major[2] == 'ok') + $ans['ERROR'] = null; + else + { + if (isset($major[3])) + $ans['ERROR'] = $major[3]; + else + $ans['ERROR'] = 'unknown'; + } return $ans; } diff --git a/pool/page_pplns.php b/pool/page_pplns.php new file mode 100644 index 00000000..d2b812a6 --- /dev/null +++ b/pool/page_pplns.php @@ -0,0 +1,110 @@ + 99999999) + $b4 = ''; + else if ($num > 9999999) + $b4 = ''; + if ($b4 != '') + $af = ''; + return $b4.$fmt.$af; +} +# +function dopplns($data, $user) +{ + global $send_sep; + + $pg = '

CKPool

'; + + $blk = getparam('blk', true); + if (nuem($blk)) + { + $pg = "
+
+ +Block: +
"; + } + else + { + $msg = msgEncode('pplns', 'pplns', array('height' => $blk, 'allow_aged' => 'Y')); + $rep = sendsockreply('pplns', $msg); + if ($rep == false) + $ans = array(); + else + $ans = repDecode($rep); + + + if ($ans['ERROR'] != null) + return '
'.$ans['STATUS'].': '.$ans['ERROR'].'
'; + + $data = array( 'Block' => 'block', + 'PPLNS Wanted' => 'diff_want', + 'PPLNS Used' => 'diffacc_total', + 'Elapsed Seconds' => 'pplns_elapsed', + 'Users' => 'rows', + 'Oldest Workinfoid' => 'begin_workinfoid', + 'Oldest Time' => 'begin_stamp', + 'Block Workinfoid' => 'block_workinfoid', + 'Block Time' => 'block_stamp', + 'Newest Workinfoid' => 'end_workinfoid', + 'Newest Time' => 'end_stamp', + 'Network Difficulty' => 'block_ndiff', + 'PPLNS Factor' => 'diff_times', + 'PPLNS Added' => 'diff_add', + 'Share Count' => 'share_count'); + + $pg = "
\n"; + $pg .= ''; + $pg .= ''; + $pg .= ''; + $pg .= "\n"; + $i = 0; + foreach ($data as $dsp => $name) + { + if (($i++ % 2) == 0) + $row = 'even'; + else + $row = 'odd'; + + $pg .= ""; + $pg .= ""; + $pg .= ''; + $pg .= "\n"; + } + + $pg .= "
NameValue
$dsp'.$ans[$name].'

\n"; + $pg .= ''; + $pg .= ''; + $pg .= ''; + $pg .= "\n"; + $count = $ans['rows']; + for ($i = 1; $i <= $count; $i++) + { + if (($i % 2) == 0) + $row = 'even'; + else + $row = 'odd'; + + $pg .= ""; + $pg .= ''; + $pg .= ''; + $pg .= "\n"; + } + $pg .= "
UserDiff Accepted
'.$ans['user'.$i].''.$ans['diffacc_user'.$i].'
\n"; + } + + return $pg; +} +# +function show_pplns($menu, $name, $user) +{ + gopage(NULL, 'dopplns', $menu, $name, $user); +} +# +?> diff --git a/pool/prime.php b/pool/prime.php index ae6e5069..66e27b64 100644 --- a/pool/prime.php +++ b/pool/prime.php @@ -25,6 +25,8 @@ function process($p, $user) ); if ($user == 'Kano' || $user == 'ckolivas') $menu['Help']['ckp'] = 'ckp'; + if ($user == 'Kano' || $user == 'ckolivas' || $user == 'wvr2') + $menu['Pool']['PPLNS'] = 'pplns'; $page = ''; $n = ''; foreach ($menu as $item => $options)