Browse Source

php - break up workers into functions, add an Admin menu, and add an Admin allworkers

master
kanoi 10 years ago
parent
commit
51a1d6ac6a
  1. 43
      pool/page_allwork.php
  2. 121
      pool/page_workers.php
  3. 11
      pool/prime.php

43
pool/page_allwork.php

@ -0,0 +1,43 @@
<?php
#
include_once('page_workers.php');
#
function doallwork($data, $user)
{
$pg = '<h1>All Workers</h1>';
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$totshare = 0;
$totdiff = 0;
$totinvalid = 0;
$totrate = 0;
$offset = 0;
$pg .= worktitle($data, $user);
$ans = getAllUsers();
if ($ans['STATUS'] == 'ok')
{
$count = $ans['rows'];
for ($i = 0; $i < $count; $i++)
{
$pg .= workuser($data, $ans['username:'.$i],
$offset, $totshare, $totdiff,
$totinvalid, $totrate, 3600);
}
}
$pg .= worktotal($offset, $totshare, $totdiff, $totinvalid, $totrate);
$pg .= "</table>\n";
return $pg;
}
#
function show_allwork($page, $menu, $name, $user)
{
gopage(NULL, 'doallwork', $page, $menu, $name, $user);
}
#
?>

121
pool/page_workers.php

@ -1,62 +1,47 @@
<?php <?php
# #
function doworker($data, $user) function worktitle($data, $user)
{
$pg = '<tr class=title>';
$pg .= '<td class=dl>Worker Name</td>';
$pg .= '<td class=dr>Work Diff</td>';
$pg .= '<td class=dr>Last Share</td>';
$pg .= '<td class=dr>Shares</td>';
$pg .= '<td class=dr>Diff</td>';
$pg .= '<td class=dr>Invalid</td>';
$pg .= '<td class=dr>Hash Rate</td>';
$pg .= "</tr>\n";
return $pg;
}
#
function workuser($data, $user, &$offset, &$totshare, &$totdiff,
&$totinvalid, &$totrate, $old = false)
{ {
$pg = '<h1>Workers</h1>';
$ans = getWorkers($user); $ans = getWorkers($user);
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg = '';
$pg .= "<tr class=title>";
$pg .= "<td class=dl>Worker Name</td>";
// $pg .= "<td class=dr>Difficulty</td>";
// $pg .= "<td class=dc>Idle Notifications</td>";
// $pg .= "<td class=dr>Idle Notification Time</td>";
$pg .= "<td class=dr>Work Diff</td>";
$pg .= "<td class=dr>Last Share</td>";
$pg .= "<td class=dr>Shares</td>";
$pg .= "<td class=dr>Diff</td>";
$pg .= "<td class=dr>Invalid</td>";
$pg .= "<td class=dr>Hash Rate</td>";
$pg .= "</tr>\n";
$tsh = 0;
$tdif = 0;
$tinv = 0;
$thr = 0;
$i = 0;
if ($ans['STATUS'] == 'ok') if ($ans['STATUS'] == 'ok')
{ {
$count = $ans['rows']; $count = $ans['rows'];
for ($i = 0; $i < $count; $i++) for ($i = 0; $i < $count; $i++)
{ {
if (($i % 2) == 0) $lst = $ans['STAMP'] - $ans['w_lastshare:'.$i];
if ($old !== false && $lst > $old)
continue;
if ((($offset) % 2) == 0)
$row = 'even'; $row = 'even';
else else
$row = 'odd'; $row = 'odd';
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$pg .= '<td class=dl>'.$ans['workername:'.$i].'</td>'; $pg .= '<td class=dl>'.$ans['workername:'.$i].'</td>';
/*
$pg .= '<td class=dr>'.$ans['difficultydefault:'.$i].'</td>';
$nots = $ans['idlenotificationenabled:'.$i];
switch ($nots)
{
case 'Y':
case 'y':
$nots = 'Y';
break;
default:
$nots = 'N';
}
$pg .= '<td class=dc>'.$nots.'</td>';
$pg .= '<td class=dr>'.$ans['idlenotificationtime:'.$i].'</td>';
*/
if ($ans['w_lastdiff:'.$i] > 0) if ($ans['w_lastdiff:'.$i] > 0)
$ld = difffmt($ans['w_lastdiff:'.$i]); $ld = difffmt($ans['w_lastdiff:'.$i]);
else else
$ld = '&nbsp;'; $ld = '&nbsp;';
$pg .= "<td class=dr>$ld</td>"; $pg .= "<td class=dr>$ld</td>";
$lst = $ans['STAMP'] - $ans['w_lastshare:'.$i];
if ($lst < 60) if ($lst < 60)
$lstdes = $lst.'s'; $lstdes = $lst.'s';
else else
@ -90,9 +75,9 @@ function doworker($data, $user)
$pg .= "<td class=dr>$lstdes</td>"; $pg .= "<td class=dr>$lstdes</td>";
$shareacc = number_format($ans['w_shareacc:'.$i], 0); $shareacc = number_format($ans['w_shareacc:'.$i], 0);
$tsh += $ans['w_shareacc:'.$i]; $totshare += $ans['w_shareacc:'.$i];
$diffacc = number_format($ans['w_diffacc:'.$i], 0); $diffacc = number_format($ans['w_diffacc:'.$i], 0);
$tdif += $ans['w_diffacc:'.$i]; $totdiff += $ans['w_diffacc:'.$i];
$pg .= "<td class=dr>$shareacc</td>"; $pg .= "<td class=dr>$shareacc</td>";
$pg .= "<td class=dr>$diffacc</td>"; $pg .= "<td class=dr>$diffacc</td>";
@ -101,7 +86,7 @@ function doworker($data, $user)
$rej = number_format(100.0 * $ans['w_diffinv:'.$i] / $dtot, 3); $rej = number_format(100.0 * $ans['w_diffinv:'.$i] / $dtot, 3);
else else
$rej = '0'; $rej = '0';
$tinv += $ans['w_diffinv:'.$i]; $totinvalid += $ans['w_diffinv:'.$i];
$pg .= "<td class=dr>$rej%</td>"; $pg .= "<td class=dr>$rej%</td>";
@ -113,7 +98,7 @@ function doworker($data, $user)
$uhr = '?GHs'; $uhr = '?GHs';
else else
{ {
$thr += $uhr; $totrate += $uhr;
$uhr /= 10000000; $uhr /= 10000000;
if ($uhr < 0.01) if ($uhr < 0.01)
$uhr = '0GHs'; $uhr = '0GHs';
@ -128,34 +113,62 @@ function doworker($data, $user)
$pg .= "<td class=dr>$uhr</td>"; $pg .= "<td class=dr>$uhr</td>";
$pg .= "</tr>\n"; $pg .= "</tr>\n";
$offset++;
} }
} }
$thr /= 10000000; return $pg;
if ($thr < 0.01) }
$thr = '0GHs'; #
function worktotal($offset, $totshare, $totdiff, $totinvalid, $totrate)
{
$pg = '';
$totrate /= 10000000;
if ($totrate < 0.01)
$totrate = '0GHs';
else else
{ {
if ($thr < 100000) if ($totrate < 100000)
$thr = number_format(round($thr)/100,2).'GHs'; $totrate = number_format(round($totrate)/100,2).'GHs';
else else
$thr = number_format(round($thr/1000)/100,2).'THs'; $totrate = number_format(round($totrate/1000)/100,2).'THs';
} }
if (($i % 2) == 0) if (($offset % 2) == 0)
$row = 'even'; $row = 'even';
else else
$row = 'odd'; $row = 'odd';
$pg .= "<tr class=$row><td class=dl>Total:</td><td colspan=2 class=dl></td>"; $pg .= "<tr class=$row><td class=dl>Total:</td><td colspan=2 class=dl></td>";
$shareacc = number_format($tsh, 0); $shareacc = number_format($totshare, 0);
$pg .= "<td class=dr>$shareacc</td>"; $pg .= "<td class=dr>$shareacc</td>";
$diffacc = number_format($tdif, 0); $diffacc = number_format($totdiff, 0);
$pg .= "<td class=dr>$diffacc</td>"; $pg .= "<td class=dr>$diffacc</td>";
$dtot = $tdif + $tinv; $dtot = $totdiff + $totinvalid;
if ($dtot > 0) if ($dtot > 0)
$rej = number_format(100.0 * $tinv / $dtot, 3); $rej = number_format(100.0 * $totinvalid / $dtot, 3);
else else
$rej = '0'; $rej = '0';
$pg .= "<td class=dr>$rej%</td>"; $pg .= "<td class=dr>$rej%</td>";
$pg .= "<td class=dr>$thr</td></tr>\n"; $pg .= "<td class=dr>$totrate</td></tr>\n";
return $pg;
}
#
function doworker($data, $user)
{
$pg = '<h1>Workers</h1>';
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$totshare = 0;
$totdiff = 0;
$totinvalid = 0;
$totrate = 0;
$offset = 0;
$pg .= worktitle($data, $user);
$pg .= workuser($data, $user, $offset, $totshare, $totdiff, $totinvalid,
$totrate, false);
$pg .= worktotal($offset, $totshare, $totdiff, $totinvalid, $totrate);
$pg .= "</table>\n"; $pg .= "</table>\n";
return $pg; return $pg;

11
pool/prime.php

@ -18,16 +18,21 @@ function process($p, $user)
'Stats' => 'stats', 'Stats' => 'stats',
'Blocks' => 'blocks' 'Blocks' => 'blocks'
), ),
'Admin' => NULL,
'gap' => NULL, 'gap' => NULL,
'Help' => array( 'Help' => array(
'Help' => 'help', 'Help' => 'help',
'Payouts' => 'payout' 'Payouts' => 'payout'
) )
); );
if ($user == 'Kano' || $user == 'ckolivas' || $user == 'aphorise')
$menu['Help']['ckp'] = 'ckp';
if ($user == 'Kano' || $user == 'ckolivas' || $user == 'wvr2' || $user == 'aphorise') if ($user == 'Kano' || $user == 'ckolivas' || $user == 'wvr2' || $user == 'aphorise')
$menu['Pool']['PPLNS'] = 'pplns'; {
$menu['Admin']['ckp'] = 'ckp';
$menu['Admin']['PPLNS'] = 'pplns';
$menu['Admin']['AllWork'] = 'allwork';
}
else
unset($menu['Admin']);
$page = ''; $page = '';
$n = ''; $n = '';
foreach ($menu as $item => $options) foreach ($menu as $item => $options)

Loading…
Cancel
Save