6 # Connects to the server holding the stats, and builds a web page
7 # of yesterdays players
9 # start: First entry displayed
10 # limit: Number of entries. Defaults to 10.
12 # Copyright (C) 2001 Andreas Ulbrich, Ralf Ertzinger (ndccode@ndc.sh)
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 $start = ($CGIquery->param("start")?$CGIquery->param("start"):0);
37 $limit = ($CGIquery->param("limit")?$CGIquery->param("limit"):10);
39 # Rebuild database, if necessary
42 $data_source = "DBI:mysql:$database";
45 $dbh = DBI->connect( $data_source, $username, $password) or die "Can't connect to $data_source\n"; #: $dbh->errstr\n";
47 $query = $dbh->prepare("SELECT nick FROM PlayerStats WHERE mapsplayed > 0");
52 $query = $dbh->prepare("SELECT nick ,skill FROM PlayerStats WHERE mapsplayed > 0 ORDER by skill DESC LIMIT $start,$limit");
55 while ($row_hash = $query->fetchrow_hashref) {
56 $name = $row_hash->{nick};
58 $skill{$name} = $row_hash->{skill};
64 @sortkey = sort { $skill{$b} <=> $skill{$a} } (keys %nick);
66 print "Content-Type: text/vnd.wap.wml\n\n";
70 print '<?xml version="1.0"?>' . "\n";
71 print '<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">' . "\n\n";
74 print "<card id=\"card1\" title=\"Gestern\">\n";
76 if (($start + 10) < $rows) {
77 $start_next=$start + 10;
78 print "<do type=\"accept\" label=\"Weiter\">\n";
79 print "<go href=\"\/cgi-bin\/quake\/dailystats_wap.pl\?start=$start_next\"\/>\n";
86 print "<table columns=\"3\">\n";
87 print "<tr><td>P.<\/td><td>Name<\/td><td>Skill<\/td><\/tr>\n";
90 foreach $name (@sortkey)
94 print "<td>$count<\/td>\n";
96 print make_html($nick{$name});
98 print "<td>$skill{$name}<\/td>\n";
102 print "<\/table></small>\n";
108 ############### Subroutines ###########
113 # $input =~ s/&/und/g;
114 $input =~ s/</<\;/g;
115 $input =~ s/>/>\;/g;
116 $input =~ s/"/"\;/g;
117 # $input =~ s/\|/pipe/g;
121 sub make_compatible {
125 $input =~ s/\+/%2B/g;
131 $input =~ s/\[/%5B/g;
132 $input =~ s/\]/%5D/g;
133 $input =~ s/\//%2F/g;
134 $input =~ s/\|/%7C/g;
135 $input =~ s/\?/%3F/g;