6 # Connects to the database holding the stats, and builds the web page
7 # for the previous day.
9 # start: First entry displayed
10 # limit: Number of entries. Defaults to 20.
13 # Copyright (C) 2001 Andreas Ulbrich, Ralf Ertzinger (ndccode@ndc.sh)
15 # This program is free software; you can redistribute it and/or modify
16 # it under the terms of the GNU General Public License as published by
17 # the Free Software Foundation; either version 2 of the License, or
18 # (at your option) any later version.
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 $sort = ($CGIquery->param("sort")?$CGIquery->param("sort"):0);
39 $limit = ($CGIquery->param("limit")?$CGIquery->param("limit"):20);
40 $back = ($CGIquery->param("back")?$CGIquery->param("back"):0);
41 $sort = ($back==1?0:($CGIquery->param("sort")?$CGIquery->param("sort"):0));
43 # Rebuild database, if necessary
44 open (FIRST, "< first.run") || die "Can't open first.run\n";
48 open (FIRST, "> first.run") || die "Can't open first.run\n";
51 {$update = `databasectrl.sh`}
57 $data_source = "DBI:mysql:$database";
60 $dbh = DBI->connect( $data_source, $username, $password) or die "Can't connect to $data_source\n"; #: $dbh->errstr\n";
62 $query = $dbh->prepare("SELECT nick FROM PlayerStats WHERE mapsplayed > 0");
67 $query = $dbh->prepare("SELECT nick ,skill, kills, victims, suicides, mapsplayed, mapswon, time, fph FROM PlayerStats WHERE mapsplayed > 0 ORDER by skill DESC LIMIT $start,$limit");
70 while ($row_hash = $query->fetchrow_hashref) {
71 $name = $row_hash->{nick};
73 $skill{$name} = $row_hash->{skill};
74 $kills{$name} = $row_hash->{kills};
75 $victims{$name} = $row_hash->{victims};
76 $suicides{$name} = $row_hash->{suicides};
77 $maps{$name} = $row_hash->{mapsplayed};
78 $wonmaps{$name} = $row_hash->{mapswon};
79 $time{$name} = $row_hash->{time};
80 $fph{$name} = $row_hash->{fph};
89 print "Content-Type: text/html\n\n\n";
92 ###### Sortieren #####
94 # By default, sort by rank
97 @sortkey = sort { $skill{$b} <=> $skill{$a} } (keys %nick);
99 $darstellung = "<IMG SRC=\"\/graphics\/formel.gif\" ALT=\"Formel\">";
105 @sortkey = sort { $nick{$a} cmp $nick{$b} } (keys %nick);
111 @sortkey = sort { $maps{$b} <=> $maps{$a} } (keys %maps);
112 $sortname = "gespielten Maps";
117 @sortkey = sort { $kills{$b} <=> $kills{$a} } (keys %kills);
123 @sortkey = sort { $victims{$b} <=> $victims{$a} } (keys %victims);
124 $sortname = "Victims";
129 @sortkey = sort { $suicides{$b} <=> $suicides{$a} } (keys %suicides);
130 $sortname = "Suicides";
135 @sortkey = sort { $fph{$b} <=> $fph{$a} } (keys %fph);
137 $darstellung = "\= Kills \/ \(Sec \/ 3600 \)";
141 @sortkey = sort { $time{$b} <=> $time{$a} } (keys %nick);
147 @sortkey = sort { $wonmaps{$b} <=> $wonmaps{$a} } (keys %nick);
148 $sortname = "gewonnenen Maps";
153 print '<HTML><HEAD><TITLE>Cardassia - Hall of Fame</TITLE>';
154 print '<META NAME="Andreas Ulbrich \+ Ralf Ertzinger">';
155 print '</HEAD><BODY BGCOLOR="#FFFFFF">';
156 print "\n<CENTER><img SRC=\"http\:\/\/www.ndc.sh\/graphics\/dailystatic_logo.jpg\" WIDTH=\"500\" HEIGHT=\"90\" BORDER=\"0\"ALT=\"\[SERVER Daily Static\]\"><\/CENTER>\n";
158 print "<CENTER><b>Anzahl der Spieler: $rows<\/B><BR>\n";
160 print "<b><a href =\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/dailystats.pl\?sort\=0\&limit\=$rows\&back\=1\">Alle Spieler anzeigen<\/A><\/B><\/CENTER><\/BR>\n";
163 print "<b><a href =\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/dailystats.pl\?sort\=0\&limit\=20\&back\=0\">Die ersten 20 anzeigen<\/A><\/B><\/CENTER><\/BR>\n";
167 ##### Sortiert nach sortkey ########
169 print "<P>\ \;<P><UL><b>Sortiert nach $sortname $darstellung<\/b>\n";
170 print "<table BORDER=\"0\">\n";
172 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b>Rang<\/b><\/td>
174 print "<td WIDTH=\"120\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/dailystats.pl\?sort\=1\&limit=$limit\&back=$back\">Name<\/a><\/b><\/td>\n";
175 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/dailystats.pl\?sort\=0\&limit=$limit\&back=$back\">Skill<\/a><\/b><\/td>\n";
176 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/dailystats.pl\?sort\=6\&limit=$limit\&back=$back\">FPH<\/a><\/b><\/td>\n";
177 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/dailystats.pl\?sort\=2\&limit=$limit\&back=$back\">Maps gespielt<\/a><\/b><\/td>\n";
178 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/dailystats.pl\?sort\=8\&limit=$limit\&back=$back\">Maps gewonnen<\/a><\/b><\/td>\n";
179 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/dailystats.pl\?sort\=3\&limit=$limit\&back=$back\">Kills<\/a><\/b><\/td>\n";
180 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/dailystats.pl\?sort\=4\&limit=$limit\&back=$back\">Victims<\/a><\/b><\/td>\n";
181 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/dailystats.pl\?sort\=5\&limit=$limit\&back=$back\">Suicides<\/a><\/b><\/td>\n";
182 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/dailystats.pl\?sort\=7\&limit=$limit\&back=$back\">Zeit (Min)<\/a><\/b><\/td>\n";
186 foreach $name (@sortkey)
191 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"+0\">$count<\/font><\/td>\n";
192 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#CCCCCC\"><font size =\"+0\">";
193 print "<a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/playerstats.pl\?nick\=";
194 print make_compatible($nick{$name});
196 print "<font color=\"#000000\">";
197 print make_html($nick{$name});
199 print "<\/a><\/font><\/td>\n";
200 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$skill{$name}<\/font><\/td>\n";
201 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$fph{$name}<\/font><\/td>\n";
203 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$maps{$name}<\/font><\/td>\n";
204 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$wonmaps{$name}<\/font><\/td>\n";
205 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$kills{$name}<\/font><\/td>\n";
206 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$victims{$name}<\/font><\/td>\n";
207 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$suicides{$name}<\/font><\/td>\n";
208 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$time{$name}<\/font><\/td>\n";
212 print "<\/TABLE><\/UL><P>\n";
215 print "<CENTER><TABLE BORDER=\"0\">\n";
217 print "<td WIDTH=\"200\" ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\">";
219 $start_prev = $start - $limit;
220 if ($start_prev < 0) {$start_prev = 0;}
221 print "<a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/dailystats.pl\?sort=$sort&start=$start_prev&limit=$limit&back=0\">";
228 print "<td WIDTH=\"200\" ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\">";
229 if ($start + $limit < $rows) {
230 $start_next = $start + $limit;
231 print "<a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/dailystats.pl\?sort=$sort&start=$start_next&limit=$limit&back=0\">";
239 print "<\/TABLE><\/CENTER>\n";
242 print "<P><FONT SIZE=\"-2\"><DIV ALIGN=right>Skripting by NDC Code<BR><A href=\"http://www.ndc.sh\" target=\"_top\">www.ndc.sh</A></DIV></FONT><BR>\n";
243 print '</BODY></HTML>';
246 ############### Subroutines ###########
251 # $input =~ s/&/und/g;
252 $input =~ s/</<\;/g;
253 $input =~ s/>/>\;/g;
254 $input =~ s/"/"\;/g;
255 $input =~ s/\x1c/·/g;
256 # $input =~ s/\|/pipe/g;
260 sub make_compatible {
264 $input =~ s/\+/%2B/g;
270 $input =~ s/\[/%5B/g;
271 $input =~ s/\]/%5D/g;
272 $input =~ s/\//%2F/g;
273 $input =~ s/\|/%7C/g;
274 $input =~ s/\?/%3F/g;
275 $input =~ s/\x1c/%1C/g;