Browse Source

php - add Block Acclaim

master
kanoi 10 years ago
parent
commit
ad53fac155
  1. 43
      pool/page_userinfo.php
  2. 3
      pool/prime.php

43
pool/page_userinfo.php

@ -2,22 +2,33 @@
# #
function blocksorder($a, $b) function blocksorder($a, $b)
{ {
if ($b['blocks'] == $a['blocks']) if ($b['blocks'] != $a['blocks'])
return $b['diffacc'] - $a['diffacc']; return $b['blocks'] - $a['blocks'];
else else
return $a['blocks'] - $b['blocks']; {
if ($b['diffacc'] != $a['diffacc'])
return $a['diffacc'] - $b['diffacc'];
else
return strcmp($a['username'], $b['username']);
}
} }
# #
function douserinfo($data, $user) function douserinfo($data, $user)
{ {
$sall = ($user == 'Kano');
$ans = getUserInfo($user); $ans = getUserInfo($user);
$pg = '<h1>Block Hall of Fame</h1>'.$pg; $pg = '<h1>Block Acclaim</h1>'.$pg;
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$pg .= "<tr class=title>"; $pg .= "<tr class=title>";
$pg .= "<td class=dl>User</td>"; $pg .= "<td class=dl>User</td>";
$pg .= "<td class=dr>Blocks</td>"; $pg .= "<td class=dr>Blocks</td>";
$pg .= "<td class=dr>Diff</td>"; if ($sall)
{
$pg .= "<td class=dr>Diff</td>";
$pg .= "<td class=dr>Avg</td>";
}
$pg .= "</tr>\n"; $pg .= "</tr>\n";
if ($ans['STATUS'] == 'ok') if ($ans['STATUS'] == 'ok')
@ -26,14 +37,23 @@ function douserinfo($data, $user)
$count = $ans['rows']; $count = $ans['rows'];
for ($i = 0; $i < $count; $i++) for ($i = 0; $i < $count; $i++)
{ {
if ($sall)
$diffacc = $ans['diffacc:'.$i];
else
$diffacc = 0;
$all[] = array('blocks' => $ans['blocks:'.$i], $all[] = array('blocks' => $ans['blocks:'.$i],
'username' => $ans['username:'.$i], 'username' => $ans['username:'.$i],
'diffacc' => $ans['diffacc:'.$i]); 'diffacc' => $diffacc);
} }
usort($all, 'blocksorder'); usort($all, 'blocksorder');
for ($i = 0; $i < $count; $i++) for ($i = 0; $i < $count; $i++)
{ {
$bl = $all[$i]['blocks'];
if ($sall == false && $bl < 1)
break;
if (($i % 2) == 0) if (($i % 2) == 0)
$row = 'even'; $row = 'even';
else else
@ -42,10 +62,15 @@ function douserinfo($data, $user)
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$un = htmlspecialchars($all[$i]['username']); $un = htmlspecialchars($all[$i]['username']);
$pg .= "<td class=dl>$un</td>"; $pg .= "<td class=dl>$un</td>";
$bl = $all[$i]['blocks'];
$pg .= "<td class=dr>$bl</td>"; $pg .= "<td class=dr>$bl</td>";
$diffacc = difffmt($all[$i]['diffacc']); if ($sall)
$pg .= "<td class=dr>$diffacc</td>"; {
$diffacc = $all[$i]['diffacc'];
$pg .= '<td class=dr>'.difffmt($diffacc).'</td>';
if ($bl == 0)
$bl = 1;
$pg .= '<td class=dr>'.difffmt($diffacc/$bl).'</td>';
}
$pg .= "</tr>\n"; $pg .= "</tr>\n";
} }
} }

3
pool/prime.php

@ -84,7 +84,8 @@ function check()
'Pool' => array( 'Pool' => array(
'Stats' => 'stats', 'Stats' => 'stats',
'Blocks' => 'blocks', 'Blocks' => 'blocks',
'Graph' => 'psperf' 'Graph' => 'psperf',
'Acclaim' => 'userinfo'
), ),
'Admin' => NULL, 'Admin' => NULL,
'gap' => array( # options not shown 'gap' => array( # options not shown

Loading…
Cancel
Save