From ad53fac155fdf21068c98cbd3f901110dc8254e0 Mon Sep 17 00:00:00 2001 From: kanoi Date: Mon, 11 May 2015 06:35:50 +1000 Subject: [PATCH] php - add Block Acclaim --- pool/page_userinfo.php | 43 +++++++++++++++++++++++++++++++++--------- pool/prime.php | 3 ++- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/pool/page_userinfo.php b/pool/page_userinfo.php index 1531fa1d..046be50d 100644 --- a/pool/page_userinfo.php +++ b/pool/page_userinfo.php @@ -2,22 +2,33 @@ # function blocksorder($a, $b) { - if ($b['blocks'] == $a['blocks']) - return $b['diffacc'] - $a['diffacc']; + if ($b['blocks'] != $a['blocks']) + return $b['blocks'] - $a['blocks']; 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) { + $sall = ($user == 'Kano'); + $ans = getUserInfo($user); - $pg = '

Block Hall of Fame

'.$pg; + $pg = '

Block Acclaim

'.$pg; $pg .= "\n"; $pg .= ""; $pg .= ""; $pg .= ""; - $pg .= ""; + if ($sall) + { + $pg .= ""; + $pg .= ""; + } $pg .= "\n"; if ($ans['STATUS'] == 'ok') @@ -26,14 +37,23 @@ function douserinfo($data, $user) $count = $ans['rows']; for ($i = 0; $i < $count; $i++) { + if ($sall) + $diffacc = $ans['diffacc:'.$i]; + else + $diffacc = 0; + $all[] = array('blocks' => $ans['blocks:'.$i], 'username' => $ans['username:'.$i], - 'diffacc' => $ans['diffacc:'.$i]); + 'diffacc' => $diffacc); } usort($all, 'blocksorder'); for ($i = 0; $i < $count; $i++) { + $bl = $all[$i]['blocks']; + if ($sall == false && $bl < 1) + break; + if (($i % 2) == 0) $row = 'even'; else @@ -42,10 +62,15 @@ function douserinfo($data, $user) $pg .= ""; $un = htmlspecialchars($all[$i]['username']); $pg .= ""; - $bl = $all[$i]['blocks']; $pg .= ""; - $diffacc = difffmt($all[$i]['diffacc']); - $pg .= ""; + if ($sall) + { + $diffacc = $all[$i]['diffacc']; + $pg .= ''; + if ($bl == 0) + $bl = 1; + $pg .= ''; + } $pg .= "\n"; } } diff --git a/pool/prime.php b/pool/prime.php index ea3d8ea2..0aafe808 100644 --- a/pool/prime.php +++ b/pool/prime.php @@ -84,7 +84,8 @@ function check() 'Pool' => array( 'Stats' => 'stats', 'Blocks' => 'blocks', - 'Graph' => 'psperf' + 'Graph' => 'psperf', + 'Acclaim' => 'userinfo' ), 'Admin' => NULL, 'gap' => array( # options not shown
UserBlocksDiffDiffAvg
$un$bl$diffacc'.difffmt($diffacc).''.difffmt($diffacc/$bl).'