Browse Source

php - add user restricted PPLNS calc page

master
kanoi 10 years ago
parent
commit
90bf52ef6d
  1. 9
      pool/db.php
  2. 110
      pool/page_pplns.php
  3. 2
      pool/prime.php

9
pool/db.php

@ -42,6 +42,15 @@ function repDecode($rep)
$ans['ID'] = $major[0]; $ans['ID'] = $major[0];
$ans['STAMP'] = $major[1]; $ans['STAMP'] = $major[1];
$ans['STATUS'] = $major[2]; $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; return $ans;
} }

110
pool/page_pplns.php

@ -0,0 +1,110 @@
<?php
#
function stnum($num)
{
$b4 = '';
$af = '';
$fmt = number_format($num, 0);
if ($num > 99999999)
$b4 = '<span class=urg>';
else if ($num > 9999999)
$b4 = '<span class=warn>';
if ($b4 != '')
$af = '</span>';
return $b4.$fmt.$af;
}
#
function dopplns($data, $user)
{
global $send_sep;
$pg = '<h1>CKPool</h1>';
$blk = getparam('blk', true);
if (nuem($blk))
{
$pg = "<br>
<form action=index.php method=POST>
<input type=hidden name=k value=pplns>
Block: <input type=text name=blk size=10 value=''>
&nbsp;<input type=submit name=Calc value=Calc>
</form>";
}
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 '<font color=red size=+1><br>'.$ans['STATUS'].': '.$ans['ERROR'].'</font>';
$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 = "<br><table callpadding=0 cellspacing=0 border=0>\n";
$pg .= '<tr class=title>';
$pg .= '<td class=dl>Name</td>';
$pg .= '<td class=dr>Value</td>';
$pg .= "</tr>\n";
$i = 0;
foreach ($data as $dsp => $name)
{
if (($i++ % 2) == 0)
$row = 'even';
else
$row = 'odd';
$pg .= "<tr class=$row>";
$pg .= "<td class=dl>$dsp</td>";
$pg .= '<td class=dr>'.$ans[$name].'</td>';
$pg .= "</tr>\n";
}
$pg .= "</table><br><table callpadding=0 cellspacing=0 border=0>\n";
$pg .= '<tr class=title>';
$pg .= '<td class=dl>User</td>';
$pg .= '<td class=dr>Diff Accepted</td>';
$pg .= "</tr>\n";
$count = $ans['rows'];
for ($i = 1; $i <= $count; $i++)
{
if (($i % 2) == 0)
$row = 'even';
else
$row = 'odd';
$pg .= "<tr class=$row>";
$pg .= '<td class=dl>'.$ans['user'.$i].'</td>';
$pg .= '<td class=dr>'.$ans['diffacc_user'.$i].'</td>';
$pg .= "</tr>\n";
}
$pg .= "</table>\n";
}
return $pg;
}
#
function show_pplns($menu, $name, $user)
{
gopage(NULL, 'dopplns', $menu, $name, $user);
}
#
?>

2
pool/prime.php

@ -25,6 +25,8 @@ function process($p, $user)
); );
if ($user == 'Kano' || $user == 'ckolivas') if ($user == 'Kano' || $user == 'ckolivas')
$menu['Help']['ckp'] = 'ckp'; $menu['Help']['ckp'] = 'ckp';
if ($user == 'Kano' || $user == 'ckolivas' || $user == 'wvr2')
$menu['Pool']['PPLNS'] = 'pplns';
$page = ''; $page = '';
$n = ''; $n = '';
foreach ($menu as $item => $options) foreach ($menu as $item => $options)

Loading…
Cancel
Save