6 # Connects to the database holding the statistic data and builds
8 # This is old code. The HTML is inlined in it. Hard to read,
9 # almost impossible to maintain.
11 # start: First entry displayed
12 # limit: Number of entries. Defaults to 20.
15 # Copyright (C) 2001 Andreas Ulbrich, Ralf Ertzinger (ndccode@ndc.sh)
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 2 of the License, or
20 # (at your option) any later version.
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write to the Free Software
29 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40 $sort = ($CGIquery->param("sort")?$CGIquery->param("sort"):'0');
41 $limit = ($CGIquery->param("limit")?$CGIquery->param("limit"):'20');
42 $start = ($CGIquery->param("start")?$CGIquery->param("start"):'0');
43 $back = ($CGIquery->param("back")?$CGIquery->param("back"):'0');
45 # Rebuild database, if necessary
46 open (FIRST, "< first.run") || die "Can't open first.run\n";
50 open (FIRST, "> first.run") || die "Can't open first.run\n";
53 {$update = `databasectrl.sh`}
59 $data_source = "DBI:mysql:$database";
62 $dbh = DBI->connect( $data_source, $username, $password) or die "Can't connect to $data_source\n"; #: $dbh->errstr\n";
64 $query = $dbh->prepare("SELECT nick FROM PlayerStats WHERE fe_skill > 0");
70 $query = $dbh->prepare("SELECT nick FROM PlayerStats");
72 $rowsall = $query->rows;
77 $query = $dbh->prepare("SELECT nick ,fe_skill, fe_kills, fe_victims, fe_suicides, fe_mapsplayed, fe_mapswon, fe_time, fe_fph, date_format(LastSeen, '%d.%m.%Y') as date_europe FROM PlayerStats WHERE fe_skill > 0 ORDER by fe_skill DESC LIMIT $start,$limit");
80 while ($row_hash = $query->fetchrow_hashref) {
81 $name = $row_hash->{nick};
83 $skill{$name} = $row_hash->{fe_skill};
84 $kills{$name} = $row_hash->{fe_kills};
85 $victims{$name} = $row_hash->{fe_victims};
86 $suicides{$name} = $row_hash->{fe_suicides};
87 $maps{$name} = $row_hash->{fe_mapsplayed};
88 $wonmaps{$name} = $row_hash->{fe_mapswon};
89 $time{$name} = $row_hash->{fe_time};
90 $fph{$name} = $row_hash->{fe_fph};
91 $lastseen{$name} = $row_hash->{date_europe};
92 unless(defined($lastseen{$name})) { $lastseen{$name} = '--.--.--'; }
99 print "Content-Type: text/html\n\n\n";
102 ###### Sortieren #####
104 # By default, sort by rank
107 @sortkey = sort { $skill{$b} <=> $skill{$a} } (keys %nick);
109 $darstellung = "\= Kills \/ \( 1 \+ Victims \+ Suicides \) \* \( 1 \+ \( Maps-won \/ Maps-played \)";
115 @sortkey = sort { $nick{$a} cmp $nick{$b} } (keys %nick);
121 @sortkey = sort { $maps{$b} <=> $maps{$a} } (keys %maps);
122 $sortname = "gespielten Maps";
127 @sortkey = sort { $kills{$b} <=> $kills{$a} } (keys %kills);
133 @sortkey = sort { $victims{$b} <=> $victims{$a} } (keys %victims);
134 $sortname = "Victims";
139 @sortkey = sort { $suicides{$b} <=> $suicides{$a} } (keys %suicides);
140 $sortname = "Suicides";
145 @sortkey = sort { $fph{$b} <=> $fph{$a} } (keys %fph);
147 $darstellung = "\= Kills \/ \(Sec \/ 3600 \)";
151 @sortkey = sort { $time{$b} <=> $time{$a} } (keys %nick);
157 @sortkey = sort { $wonmaps{$b} <=> $wonmaps{$a} } (keys %nick);
158 $sortname = "gewonnenen Maps";
163 print '<HTML><HEAD><TITLE>Cardassia - Hall of Fame</TITLE>';
164 print '<META NAME="Andreas Ulbrich \+ Ralf Ertzinger">';
165 print '</HEAD><BODY BGCOLOR="#FFFFFF">';
166 print "\n<CENTER><img SRC=\"http\:\/\/www.ndc.sh\/graphics\/halloffame_logo.jpg\" WIDTH=\"500\" HEIGHT=\"90\" BORDER=\"0\"ALT=\"\[SERVER Hall of Fame\]\"><\/CENTER>\n";
168 print "<CENTER><b>Erfasste Spieler gesamt: $rowsall <BR>Anzahl der Spieler mit mehr als 10 Maps: $rows<\/B><BR>\n";
170 print "<b><a href =\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/foreverstats2.pl\?sort\=0\&limit\=$rows\&back\=1\">$rows Spieler anzeigen<\/A><\/B><\/CENTER><\/BR>\n";
173 print "<b><a href =\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/foreverstats2.pl\?sort\=0\&limit\=20\&back\=0\">Die ersten 20 anzeigen<\/A><\/B><\/CENTER><\/BR>\n";
177 ##### Sortiert nach sortkey ########
179 print "<P>\ \;<P><UL><b>Sortiert nach $sortname $darstellung<\/b>\n";
180 print "<table BORDER=\"0\">\n";
182 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b>Rang<\/b><\/td>
184 print "<td WIDTH=\"120\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/foreverstats2.pl\?sort\=1\&limit=$limit\&back=$back\">Name<\/a><\/b><\/td>\n";
185 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/foreverstats2.pl\?sort\=0\&limit=$limit\&back=$back\">Skill<\/a><\/b><\/td>\n";
186 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/foreverstats2.pl\?sort\=6\&limit=$limit\&back=$back\">FPH<\/a><\/b><\/td>\n";
187 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/foreverstats2.pl\?sort\=2\&limit=$limit\&back=$back\">Maps gespielt<\/a><\/b><\/td>\n";
188 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/foreverstats2.pl\?sort\=8\&limit=$limit\&back=$back\">Maps gewonnen<\/a><\/b><\/td>\n";
189 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/foreverstats2.pl\?sort\=3\&limit=$limit\&back=$back\">Kills<\/a><\/b><\/td>\n";
190 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/foreverstats2.pl\?sort\=4\&limit=$limit\&back=$back\">Victims<\/a><\/b><\/td>\n";
191 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/foreverstats2.pl\?sort\=5\&limit=$limit\&back=$back\">Suicides<\/a><\/b><\/td>\n";
192 print "<td WIDTH=\"50\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b><a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/foreverstats2.pl\?sort\=7\&limit=$limit\&back=$back\">Zeit (Min)<\/a><\/b><\/td>\n";
193 print "<td WIDTH=\"100\" ALIGN=\"CENTER\" BGCOLOR=\"\#FFFFCC\"><b>Zuletzt gespielt<\/b><\/td>\n";
197 foreach $name (@sortkey)
202 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"+0\">$count<\/font><\/td>\n";
203 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#CCCCCC\"><font size =\"+0\">";
204 print "<a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/playerstats.pl\?nick\=";
205 print make_compatible($nick{$name});
207 print "<font color\=\"#000000\">";
208 print make_html($nick{$name});
210 print "<\/a><\/font><\/td>\n";
211 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$skill{$name}<\/font><\/td>\n";
212 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$fph{$name}<\/font><\/td>\n";
214 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$maps{$name}<\/font><\/td>\n";
215 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$wonmaps{$name}<\/font><\/td>\n";
216 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$kills{$name}<\/font><\/td>\n";
217 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$victims{$name}<\/font><\/td>\n";
218 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$suicides{$name}<\/font><\/td>\n";
219 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$time{$name}<\/font><\/td>\n";
220 print "<td ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\"><font size =\"-1\">$lastseen{$name}<\/font><\/td>\n";
224 print "<\/TABLE><\/UL><P>\n";
227 print "<CENTER><TABLE BORDER=\"0\">\n";
229 print "<td WIDTH=\"200\" ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\">";
231 $start_prev = $start - $limit;
232 if ($start_prev < 0) {$start_prev = 0;}
233 print "<a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/foreverstats2.pl\?sort=$sort&start=$start_prev&limit=$limit&back=0\">";
240 print "<td WIDTH=\"200\" ALIGN=\"CENTER\" BGCOLOR=\"\#EEEEEE\">";
241 if ($start + $limit < $rows) {
242 $start_next = $start + $limit;
243 print "<a href=\"http\:\/\/www.ndc.sh\/cgi-bin\/quake\/foreverstats2.pl\?sort=$sort&start=$start_next&limit=$limit&back=0\">";
251 print "<\/TABLE><\/CENTER>\n";
254 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";
255 print '</BODY></HTML>';
258 ############### Subroutines ###########
263 # $input =~ s/&/und/g;
264 $input =~ s/</<\;/g;
265 $input =~ s/>/>\;/g;
266 $input =~ s/"/"\;/g;
267 $input =~ s/\x1c/·/g;
268 # $input =~ s/\|/pipe/g;
272 sub make_compatible {
276 $input =~ s/\+/%2B/g;
282 $input =~ s/\[/%5B/g;
283 $input =~ s/\]/%5D/g;
284 $input =~ s/\//%2F/g;
285 $input =~ s/\|/%7C/g;
286 $input =~ s/\?/%3F/g;
287 $input =~ s/\x1c/%1C/g;