]> ruin.nu Git - ndwebbie.git/commitdiff
adding points
authorMichael Andreen <harv@ruin.nu>
Tue, 12 Dec 2006 10:23:25 +0000 (10:23 +0000)
committerMichael Andreen <harv@ruin.nu>
Tue, 12 Dec 2006 10:23:25 +0000 (10:23 +0000)
index.pl
points.pl [new file with mode: 0644]
templates/points.tmpl [new file with mode: 0644]
templates/skel.tmpl

index 118d0332e80db9d62f3079ac00c3dca939db1c38..03f62f1b9779a956b2abb739c2b12a230e882743 100755 (executable)
--- a/index.pl
+++ b/index.pl
@@ -66,7 +66,7 @@ while (my ($name,$attack,$gid) = $query->fetchrow()){
 our $LOG = $DBH->prepare('INSERT INTO log (uid,text) VALUES(?,?)');
 
 my $page = 'main';
-if (param('page') =~ /^(main|check|motd)$/){
+if (param('page') =~ /^(main|check|motd|points)$/){
        $page = $1;
 }
 
diff --git a/points.pl b/points.pl
new file mode 100644 (file)
index 0000000..18f38c3
--- /dev/null
+++ b/points.pl
@@ -0,0 +1,52 @@
+#**************************************************************************
+#   Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu>               *
+#                                                                         *
+#   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.         *
+#**************************************************************************/
+
+use strict;
+
+$ND::TEMPLATE->param(TITLE => 'Edit MOTD');
+
+our $BODY;
+our $DBH;
+our $LOG;
+
+die "You don't have access" unless isMember();
+
+my $type = "total";
+if (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;
+while (my ($username,$defense,$attack,$scan,$humor,$total,$rank) = $query->fetchrow){
+       push @members,{Username => $username, Defense => $defense, Attack => $attack
+               , Scan => $scan, Humor => $humor, Total => $total, Rank => $rank};
+}
+$BODY->param(Members => \@members);
+
+1;
diff --git a/templates/points.tmpl b/templates/points.tmpl
new file mode 100644 (file)
index 0000000..4e6f423
--- /dev/null
@@ -0,0 +1,22 @@
+<table border="1">
+       <tr>
+       <th>User</th>
+       <th><a href="points.php?type=total">Total</a></th>
+       <th><a href="points.php?type=defense">Defenses</a></th>
+       <th><a href="points.php?type=attack">Attacks</a></th>
+       <th><a href="points.php?type=scan">Scans</a></th>
+       <th><a href="points.php?type=humor">Humor</a></th>
+       <th><a href="points.php?type=rank">ND Rank</a></th>
+       </tr>
+       <TMPL_LOOP Members>
+       <tr>
+       <td><TMPL_VAR NAME=Username></td>
+       <td><TMPL_VAR NAME=Total></td>
+       <td><TMPL_VAR NAME=Defense></td>
+       <td><TMPL_VAR NAME=Attack></td>
+       <td><TMPL_VAR NAME=Scan></td>
+       <td><TMPL_VAR NAME=Humor></td>
+       <td><TMPL_VAR NAME=Rank></td>
+       </tr>
+       </TMPL_LOOP>
+</table>
index 2d927c8712cbcffbb8b4611b5abf73859c77a0e5..f7ab88177f2f23020262ec91f8c604c775dc5d91 100644 (file)
@@ -16,7 +16,7 @@
                <TMPL_IF isMEMBER>
                <p>Member menu</p>
                <ul class="linkbar">
-                       <li><a href="index.pl?page=points.php">Top members</a></li>
+                       <li><a href="index.pl?page=points">Top members</a></li>
                        <li><a href="index.pl?page=addintel.php">Add intel/scans</a></li>
                        <li><a href="index.pl?page=launchConfirmation.php">Launch confirmation</a></li>
                        <li><a href="index.pl?page=covop.php">CovOp targets</a></li>