1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
<?php
function InvertSort($curr_field, $filter, $sort) {
if ($curr_field != $filter) return(($curr_field == "mapfile") ? "ASC" : "DESC");
if ($sort == 'ASC') return('DESC');
return('ASC');
}
function SortPic($curr_field, $filter, $sort) {
if ($curr_field != $filter) return;
$fname = 'images/s_'. strtolower($sort) .'.png';
if (!file_exists($fname)) return;
return(' <img src="'. $fname .'" border="0" width="11" height="9" alt="" class="tooltip" title="('.strtolower($sort).'ending)">');
}
// Get filter and set sorting
$filter = my_addslashes($_GET[filter]);
$sort = my_addslashes($_GET[sort]);
$q = my_addslashes($_GET[q]);
$gid = preg_replace('/\D/', '', $_GET[gid]);
IF (empty($filter) or (!in_array(strtolower($filter), array("mapfile", "matchcount", "frags", "matchscore", "gametime")))) {
$filter = "mapfile";
}
if (empty($sort) or ($sort != 'ASC' and $sort != 'DESC')) $sort = ($filter == "mapfile") ? "ASC" : "DESC";
if (isset($gid)) {
if ($gid != 0) {
$url_condition .= "&gid=".urlencode($gid);
$sql_condition = " WHERE gid = $gid";
}
}
else {
$gid = 0;
}
if (isset($q)) {
if ($gid != 0) {
$sql_condition .= ' AND mapfile LIKE "%' . $q . '%" ';
}
else {
$sql_condition .= ' WHERE mapfile LIKE "%' . $q . '%" ';
}
$url_condition .= "&q=".urlencode($q);
}
// Firstly we need to work out First Last Next Prev pages
$mcount = small_count("SELECT mapfile FROM uts_match" . $sql_condition . " GROUP BY mapfile");
$ecount = $mcount/25;
$ecount2 = number_format($ecount, 0, '.', '');
IF($ecount > $ecount2) {
$ecount2 = $ecount2+1;
}
$fpage = 0;
IF($ecount < 1) { $lpage = 0; }
else { $lpage = $ecount2-1; }
$cpage = preg_replace('/\D/', '', $_GET["page"]);
IF ($cpage == "") { $cpage = "0"; }
$qpage = $cpage*25;
$tfpage = $cpage+1;
$tlpage = $lpage+1;
$ppage = $cpage-1;
$ppageurl = "<a class=\"pages\" href=\"./?p=maps&filter=$filter&sort=$sort&page=$ppage".$url_condition."\">[Previous]</a>";
IF ($ppage < "0") { $ppageurl = "[Previous]"; }
$npage = $cpage+1;
$npageurl = "<a class=\"pages\" href=\"./?p=maps&filter=$filter&sort=$sort&page=$npage".$url_condition."\">[Next]</a>";
IF ($npage >= "$ecount") { $npageurl = "[Next]"; }
$fpageurl = "<a class=\"pages\" href=\"./?p=maps&filter=$filter&sort=$sort&page=$fpage".$url_condition."\">[First]</a>";
IF ($cpage == "0") { $fpageurl = "[First]"; }
$lpageurl = "<a class=\"pages\" href=\"./?p=maps&filter=$filter&sort=$sort&page=$lpage".$url_condition."\">[Last]</a>";
IF ($cpage == "$lpage") { $lpageurl = "[Last]"; }
echo'
<form NAME="mapfilter" METHOD="get" ACTION="">
<div class="pages">Page ['.$tfpage.'/'.$tlpage.'] Selection: '.$fpageurl.' / '.$ppageurl.' / '.$npageurl.' / '.$lpageurl.'</div>
<table class="zebra box" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<th class="heading" colspan="5" align="center">Unreal Tournament Maps List</th>
</tr>
<tr>
<th class="smheading" align="center" width="100%" colspan="5">
<input type = "hidden" name = "p" value = "maps">
<input type = "hidden" name = "sort" value = "'.$sort.'">
<input type = "hidden" name = "filter" value = "'.$filter.'">
Filter: ';
echo '<select class="searchform" name="gid">';
echo '<option value="0">*</option>';
$sql_game = "SELECT DISTINCT(p.gid), g.name FROM uts_player AS p, uts_games AS g WHERE p.gid = g.id ORDER BY g.name ASC";
$q_game = mysql_query($sql_game) or die(mysql_error());
while ($r_game = mysql_fetch_array($q_game)) {
$selected = ($r_game['gid'] == $gid) ? 'selected' : '';
echo '<option '.$selected.' value="'.$r_game['gid'].'">'. $r_game['name'] .'</option>';
}
echo '</select> ';
echo '<div class="darksearch">
<span><input type="text" class="search square" placeholder="Search maps..." name="q" value="'.htmlentities($q).'"><input class="searchbutton" type="submit" value="Search"></span></div>';
echo '
</th>
</tr>
<tr>
<th class="smheading" align="center" width="250"><a class="smheading" href="./?p=maps&filter=mapfile&sort='.InvertSort('mapfile', $filter, $sort).$url_condition.'">Map Name</a>'.SortPic('mapfile', $filter, $sort).'</th>
<th class="smheading" align="center" width="150"><a class="smheading" href="./?p=maps&filter=matchcount&sort='.InvertSort('matchcount', $filter, $sort).$url_condition.'">Matches</a>'.SortPic('matchcount', $filter, $sort).'</th>
<th class="smheading" align="center"><a class="smheading" href="./?p=maps&filter=frags&sort='.InvertSort('frags', $filter, $sort).$url_condition.'">Avg. Frags</a>'.SortPic('frags', $filter, $sort).'</th>
<th class="smheading" align="center" width="100"><a class="smheading" href="./?p=maps&filter=matchscore&sort='.InvertSort('matchscore', $filter, $sort).$url_condition.'">Avg. Score</a>'.SortPic('matchscore', $filter, $sort).'</th>
<th class="smheading" align="center" width="100"><a class="smheading" href="./?p=maps&filter=gametime&sort='.InvertSort('gametime', $filter, $sort).$url_condition.'">Time</a>'.SortPic('gametime', $filter, $sort).'</th>
</tr>';
$sql_maps = "SELECT IF(RIGHT(mapfile,4) LIKE '.unr', mapfile, CONCAT(mapfile, '.unr')) as mapfile, COUNT(id) AS matchcount, AVG(frags) AS frags, AVG(t0score+t1score+t2score+t3score) AS matchscore, SUM(gametime) AS gametime
FROM uts_match" . $sql_condition . " GROUP BY mapfile ORDER BY $filter $sort LIMIT $qpage,25";
$q_maps = mysql_query($sql_maps) or die(mysql_error());
while ($r_maps = mysql_fetch_array($q_maps)) {
$r_mapfile = un_ut($r_maps[mapfile]);
$myurl = urlencode($r_mapfile);
$r_gametime = GetMinutes($r_maps[gametime]);
echo'
<tr class="clickableRow" href="./?p=minfo&map='.$myurl.'">
<td align="center"><a href="./?p=minfo&map='.$myurl.'">'.$r_mapfile.'</a></td>
<td align="center">'.$r_maps[matchcount].'</td>
<td align="center">'.get_dp($r_maps[frags]).'</td>
<td align="center">'.get_dp($r_maps[matchscore]).'</td>
<td align="center">'.$r_gametime.'</td>
</tr>';
}
echo'
</tbody></table>
<div class="pages">Page ['.$tfpage.'/'.$tlpage.'] Selection: '.$fpageurl.' / '.$ppageurl.' / '.$npageurl.' / '.$lpageurl.'</div>
</form>';
?>
|