X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=ND%2FWeb%2FPages%2FPoints.pm;fp=ND%2FWeb%2FPages%2FPoints.pm;h=30512fbdfe5131be97c3bc0a41173ea4033cac29;hb=9ce5a8529e75cb109ed9ba3fc788c94ef47b1080;hp=0000000000000000000000000000000000000000;hpb=03830799201db0b0f28e9c494fdd1b5b5143749c;p=ndwebbie.git diff --git a/ND/Web/Pages/Points.pm b/ND/Web/Pages/Points.pm new file mode 100644 index 0000000..30512fb --- /dev/null +++ b/ND/Web/Pages/Points.pm @@ -0,0 +1,67 @@ +#************************************************************************** +# Copyright (C) 2006 by Michael Andreen * +# * +# This program is free software; you can redistribute it and/or modify * +# it under the terms of the GNU General Public License as published by * +# the Free Software Foundation; either version 2 of the License, or * +# (at your option) any later version. * +# * +# This program is distributed in the hope that it will be useful, * +# but WITHOUT ANY WARRANTY; without even the implied warranty of * +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# GNU General Public License for more details. * +# * +# You should have received a copy of the GNU General Public License * +# along with this program; if not, write to the * +# Free Software Foundation, Inc., * +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +#**************************************************************************/ + +package ND::Web::Pages::Points; +use strict; +use warnings FATAL => 'all'; +use CGI qw/:standard/; +use ND::Web::Include; + +$ND::PAGES{points} = {parse => \&parse, process => \&process, render=> \&render}; + +sub parse { +} + +sub process { + +} + +sub render { + my ($DBH,$BODY) = @_; + $ND::TEMPLATE->param(TITLE => 'Top Members'); + + return $ND::NOACCESS unless isMember(); + + my $type = "total"; + if (defined param('type') && param('type') =~ /^(defense|attack|total|humor|scan|rank)$/){ + $type = $1; + } + $type .= '_points' unless ($type eq 'rank'); + + my $order = 'DESC'; + $order = 'ASC' if ($type eq 'rank'); + + my $limit = 'LIMIT 10'; + $limit = '' if isHC(); + + my $query = $DBH->prepare("SELECT username,defense_points,attack_points,scan_points,humor_points, (attack_points+defense_points+scan_points/20) as total_points, rank FROM users WHERE uid IN (SELECT uid FROM groupmembers WHERE gid = 2) ORDER BY $type $order $limit"); + $query->execute; + + my @members; + my $i = 0; + while (my ($username,$defense,$attack,$scan,$humor,$total,$rank) = $query->fetchrow){ + $i++; + push @members,{Username => $username, Defense => $defense, Attack => $attack + , Scan => $scan, Humor => $humor, Total => $total, Rank => $rank, ODD => $i % 2}; + } + $BODY->param(Members => \@members); + return $BODY; +} + +1;