6 # Connects to the database holding the stats, and builds a WAP-Page
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
37 $start = ($CGIquery->param("start")?$CGIquery->param("start"):0);
38 $limit = ($CGIquery->param("limit")?$CGIquery->param("limit"):10);
40 # Rebuild database, if necessary
43 $data_source = "DBI:mysql:$database";
46 $dbh = DBI->connect( $data_source, $username, $password) or die "Can't connect to $data_source\n"; #: $dbh->errstr\n";
48 $query = $dbh->prepare("SELECT nick FROM PlayerStats WHERE fe_skill > 0");
53 $query = $dbh->prepare("SELECT nick ,skill FROM PlayerStats WHERE fe_skill > 0 ORDER by fe_skill DESC LIMIT $start,$limit");
56 while ($row_hash = $query->fetchrow_hashref) {
57 $name = $row_hash->{nick};
59 $skill{$name} = $row_hash->{skill};
65 @sortkey = sort { $skill{$b} <=> $skill{$a} } (keys %nick);
67 print "Content-Type: text/vnd.wap.wml\n\n\n";
73 print '<?xml version="1.0"?>' . "\n";
74 print '<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">' . "\n";
77 print "<card id=\"card1\" title=\"Ewige Stats\">\n";
79 $start_prev=$start - 10;
80 if ($start_prev<0) {$start_prev=0;}
81 print "<do type=\"accept\" label=\"Zurück\">\n";
82 print "<go href=\"\/cgi-bin\/quake\/foreverstats_wap.pl\?start=$start_prev\"\/>\n";
86 if (($start + 10) < $rows) {
87 $start_next=$start + 10;
88 print "<do type=\"accept\" label=\"Weiter\">\n";
89 print "<go href=\"\/cgi-bin\/quake\/foreverstats_wap.pl\?start=$start_next\"\/>\n";
93 print "<do type=\"accept\" label=\"Gestern\">\n";
94 print "<go href=\"\/cgi-bin\/quake\/dailystats_wap.pl\"\/>\n";
97 print "<do type=\"accept\" label=\"Navigation\">\n";
98 print "<go href=\"\/nav.wml\"\/>\n";
101 print "<do type=\"accept\" label=\"Hauptseite\">\n";
102 print "<go href=\"\/\"\/>\n";
108 print "<table columns=\"3\">\n";
109 print "<tr><td>P.<\/td><td>Name<\/td><td>Skill<\/td><\/tr>\n";
112 foreach $name (@sortkey)
116 print "<td>$count<\/td>\n";
118 print make_html($nick{$name});
120 print "<td>$skill{$name}<\/td>\n";
124 print "<\/table></small>\n";
130 ############### Subroutines ###########
135 # $input =~ s/&/und/g;
136 $input =~ s/</<\;/g;
137 $input =~ s/>/>\;/g;
138 $input =~ s/"/"\;/g;
139 # $input =~ s/\|/pipe/g;
143 sub make_compatible {
147 $input =~ s/\+/%2B/g;
153 $input =~ s/\[/%5B/g;
154 $input =~ s/\]/%5D/g;
155 $input =~ s/\//%2F/g;
156 $input =~ s/\|/%7C/g;
157 $input =~ s/\?/%3F/g;