108 lines
3.0 KiB
Plaintext
Executable File
108 lines
3.0 KiB
Plaintext
Executable File
<?page
|
|
title=>High Scores
|
|
head=><?_code return LJ::robot_meta_tags(); _code?>
|
|
body<=
|
|
|
|
The following people have helped other users in the support area:
|
|
|
|
<?_code
|
|
use strict;
|
|
use vars qw(%GET);
|
|
|
|
LJ::set_active_crumb('supportscores');
|
|
|
|
my $dbr = LJ::get_db_reader();
|
|
|
|
my $sth;
|
|
my %rank;
|
|
|
|
$sth = $dbr->prepare("SELECT statcat, statkey, statval FROM stats ".
|
|
"WHERE statcat IN ('supportrank', 'supportrank_prev')");
|
|
$sth->execute;
|
|
|
|
while (my ($cat, $userid, $rank) = $sth->fetchrow_array) {
|
|
if ($cat eq "supportrank") {
|
|
$rank{$userid}->{'now'} = $rank;
|
|
} else {
|
|
$rank{$userid}->{'last'} = $rank;
|
|
}
|
|
}
|
|
return "<blockquote>Support high score data is not available.</blockquote>"
|
|
unless %rank;
|
|
|
|
$sth = $dbr->prepare("SELECT u.userid, u.user, u.name, sp.totpoints AS 'points', sp.lastupdate ".
|
|
"FROM user u, supportpointsum sp WHERE u.userid=sp.userid");
|
|
$sth->execute;
|
|
my @rows;
|
|
push @rows, $_ while $_ = $sth->fetchrow_hashref;
|
|
if ($GET{'sort'} eq "lastupdate") {
|
|
@rows = sort { $b->{lastupdate} <=> $a->{lastupdate} } @rows;
|
|
} else {
|
|
@rows = sort { $b->{points} <=> $a->{points} } @rows;
|
|
}
|
|
|
|
my $page = $GET{page}+0;
|
|
my $shown = 100 * ($page - 1) - 1;
|
|
my $rank = 0;
|
|
my $lastpoints = 0;
|
|
my $buildup = 0;
|
|
foreach (@rows[0..$shown]) {
|
|
if ($_->{'points'} != $lastpoints) {
|
|
$lastpoints = $_->{'points'};
|
|
$rank += (1 + $buildup);
|
|
$buildup = 0;
|
|
} else {
|
|
$buildup++;
|
|
}
|
|
}
|
|
my $total = scalar(@rows);
|
|
|
|
my %items = BML::paging(\@rows, $GET{'page'}, 100);
|
|
my $navbar = LJ::paging_bar($items{'page'}, $items{'pages'});
|
|
@rows = @{$items{'items'}};
|
|
|
|
my $ret = $navbar;
|
|
$ret .= "<table>";
|
|
my $count = 0;
|
|
foreach (@rows)
|
|
{
|
|
$count++;
|
|
my $userid = $_->{'userid'};
|
|
if ($_->{'points'} != $lastpoints) {
|
|
$lastpoints = $_->{'points'};
|
|
$rank += (1 + $buildup);
|
|
$buildup = 0;
|
|
} else {
|
|
$buildup++;
|
|
}
|
|
my $change = "";
|
|
if ($rank{$userid}->{'now'} && $rank{$userid}->{'last'}) {
|
|
$change = $rank{$userid}->{'last'} - $rank{$userid}->{'now'}; # from 5th to 4th is 5-4 = 1 (+1 for increase)
|
|
if ($change == 0) {
|
|
$change = "";
|
|
} elsif ($change > 0) {
|
|
$change = "<font color=\"#00dd00\">(+$change)</font>";
|
|
} else {
|
|
$change = "<font color=\"#dd0000\">($change)</font>";
|
|
}
|
|
}
|
|
my $pts = $_->{'points'};
|
|
my $s = $pts > 1 ? "s" : "";
|
|
|
|
my $name = LJ::ehtml($_->{'name'});
|
|
$ret .= "<tr><td align=\"right\">$rank.</td><td>$change</td><td><?ljuser $_->{'user'} ljuser?> - $name</td><td><b>$_->{'points'} point$s</b></td></tr>\n";
|
|
}
|
|
$ret .= "</table>";
|
|
$ret .= "<p><b>$total</b> total supporting users, <b>$count</b> displayed.</p>";
|
|
$ret .= $navbar;
|
|
return $ret;
|
|
|
|
_code?>
|
|
<?hr?>
|
|
Back to the <A HREF="./">support area</A>.
|
|
|
|
<=body
|
|
page?><?_c <LJDEP>
|
|
link: htdocs/admin/priv/index.bml, htdocs/support/index.bml
|
|
</LJDEP> _c?>
|