-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathladder.php
More file actions
163 lines (137 loc) · 6 KB
/
Copy pathladder.php
File metadata and controls
163 lines (137 loc) · 6 KB
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
session_start();
require('conf/variables.php');
require_once 'autologin.inc.php';
require('top.php');
include 'include/avatars.inc.php';
if (isset($_GET['personalladder'])) {
$personalladder = $_GET['personalladder'];
} else {
$personalladder = "";
}
$archivemsg = '';
if (isset($_GET['archive'])) {
// If player wants to view an archived version of the ladder we need to fetch anoither table and perhaps get it from another database. The table name is the date when the ranking is from in the following format: YYYY_MM_DD
$standingscachetable = $historydatabasename . "." . $_GET['archive'];
$archivemsg = " on " . $_GET['archive'];
// Clean up the info...
$archivemsg = str_replace("_", " ", $archivemsg);
}
?>
<script type="text/javascript">
$(document).ready(function () {
$("#ladder").tablesorter({sortList: [[0, 0]], widgets: ['zebra']});
}
);
</script>
<?php
// Get everyones ranking for the ladderfrom the standings cache table. There is no need for narrowing down the sql more with criterion for minimum elo and games played in total etc since the cache table has already taken care of all that.
$myrank = '';
// Fetch players rank...
if (isset($_GET['personalladder'])) {
$result = mysqli_query($db, "SELECT *
FROM $standingscachetable
WHERE recently_played > '0'
AND rank != '0' AND name = '" . $_GET['personalladder'] . "'
ORDER BY rank ASC");
$personalrow = mysqli_fetch_array($result);
$myrank = $personalrow['rank'];
}
// If player is not ranked the custom version of the ladder sholdn't be displayed...
if ($myrank == "") {
$personalladder = "";
}
?>
<h2><?php echo $personalladder . " Ladder Standings $archivemsg</h2>"; ?>
<table id="ladder" class="tablesorter">
<thead>
<tr>
<th align="left" width='10%'>No.</th>
<th align="left">Avatar </th>
<th align="left">Player </th>
<th align="center">Rating </th>
<th align="center">Wins% </th>
<th align="center">Wins </th>
<th align="center">Losses </th>
<th align="center">Total </th>
<th align="center">Streak </th>
</tr>
</thead>
<tbody>
<?php
// Reset the result set
// @mysqli_data_seek($result, 0);
$RanksAfterMe = "99999999";
if ($personalladder != "") {
$RanksBeforeMe = $myrank - 1 - RANKED_ABOVE_PERSONAL_LADDER;
$RanksAfterMe = $myrank + RANKED_BELOW_PERSONAL_LADDER;
}
// Fetch the full ladder rankings list for everyone... also join it with the players table in order to get some crap info like what avatar etc they use.
$result = mysqli_query($db, "SELECT *
FROM $standingscachetable
JOIN $playerstable
ON($standingscachetable.name=$playerstable.name)
WHERE rank > 0 AND recently_played > 0
ORDER BY rank ASC LIMIT $RanksAfterMe");
// If player wants to see a more personal and relevant ladder we need to tell mysql to start displaying the table from another position...
if ($personalladder != "") {
@mysqli_data_seek($result, $RanksBeforeMe);
}
// $ladderrow = mysqli_fetch_array($result);
// If I don't have a rank, and requesting a personal ladder, display a message to that effect.
if (!isset($myrank) && isset($_GET['personalladder'])) {
echo "<p>You are not ranked. Default ladder will be shown instead of the personal.</p>";
}
while ($ladderrow = mysqli_fetch_array($result)) {
/*
if (isset($myrank) && ($cur < ($myrank - 10) || $cur > ($myrank + 10))) {
$cur++;
continue;
}
*/
// Set graphics for streak....
if ($ladderrow['streak'] >= $hotcoldnum) {
$picture = 'images/streakplusplus.gif';
} else if ($ladderrow['streak'] <= -$hotcoldnum) {
$picture = 'images/streakminusminus.gif';
} else if ($ladderrow['streak'] > 0) {
$picture = 'images/streakplus.gif';
} else if ($ladderrow['streak'] < 0) {
$picture = 'images/streakminus.gif';
} else {
$picture = 'images/streaknull.gif';
}
//deb echo "session name: ". $_SESSION['username'] . " and ladderrow name: ". $ladderrow[name] . "<br>";
if (isset($_SESSION['username']) && $_SESSION['username'] == $ladderrow['name']) {
echo '<tr class="myrow">';
} else {
?>
<tr>
<?php
}
?>
<td><?php echo $ladderrow['rank']; ?></td>
<td class="avatar"><?php echo WlAvatar::image($ladderrow['Avatar']) ?></td>
<td><a href="profile.php?name=<?php echo $ladderrow['name']; ?>"><?php echo $ladderrow['name']; ?> </a></td>
<td><?php echo $ladderrow['rating']; ?></td>
<td><?php printf("%.0f", $ladderrow['wins'] / $ladderrow['games'] * 100); ?></td>
<td><?php echo $ladderrow['wins'] ?> </td>
<td><?php echo $ladderrow['losses'] ?></td>
<td><?php echo $ladderrow['games']; ?></td>
<td><?php echo $ladderrow['streak'] ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<br>
<p class="copyleft">To get a ranking and compete on the ladder a player needs > <?php echo "$gamestorank"; ?> games,
an Elo rating of >= <?php echo "$ladderminelo"; ?> & have played >= <?php echo " " . GAMES_FOR_ACTIVE . " "; ?>
within <?php echo "$passivedays"; ?> days. Don't worry if you haven't played for a while. All it takes is one
game to become active again. Your rating doesn't decay while you are gone. 1500 is the rating of a <i>skilled
average</i> player, new players will have less and vets more.</p>
<br>
<?php
require('bottom.php');
?>