/
players.php
executable file
·232 lines (204 loc) · 7.31 KB
/
players.php
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?php
ob_start();
session_start();
require_once('functions/load_config.php');
require_once('functions/quick_con.php');
$config = load_config('settings/config.dat');
$table_u = $config['user_table'];
$table_v = $config['var_table'];
$table_t = $config['time_table'];
$sql = my_quick_con($config) or die("MySQL problem");
// Set default time zone
$ret = mysql_query("SELECT zone FROM $table_t");
while($row = mysql_fetch_array($ret)){
date_default_timezone_set($row['zone']);
}
// update the starvation times and oz reveal (every 5 minutes, not on every page refresh)
$now = time();
$last_starvation_update = (isset($_SESSION['last_starvation_update'])) ? $_SESSION['last_starvation_update'] : $now;
if($last_starvation_update >= $now + 900) {
$ret = mysql_query("UPDATE $table_u SET state = -4 WHERE now() > feed + INTERVAL 2 day;");
$ret = mysql_query("UPDATE $table_u SET starved = feed + INTERVAL 2 day WHERE state = -4;");
$ret = mysql_query("UPDATE $table_u SET state = 0 WHERE state = -4;");
$ret = mysql_query("SELECT value FROM $table_v WHERE keyword='oz-revealed';");
$reveal_oz = mysql_fetch_assoc($ret);
$reveal_oz = $reveal_oz['value'];
$_SESSION['last_starvation_update'] = time();
$_SESSION['oz_revealed'] = $reveal_oz;
} else {
$reveal_oz = (isset($_SESSION['oz_revealed'])) ? $_SESSION['oz_revealed'] : 0;
}
$state_translate = array('-3'=>'horde', '-2'=>'horde (original)', '-1'=>'horde', '0'=>'deceased', '1'=>'resistance', '2'=>'resistance');
$admin = 0;
if(isset($_SESSION['pass_hash'])) $admin = 1;
if($_POST['mode'] == 'refresh') {
$post_faction_array = array('a'=>'1 = 1', 'r'=>'state > 0', 'h'=>'state < 0', 'd'=>'state = 0');
if(!$reveal_oz) {
$post_faction_array['r'] = 'state > 0 OR state = -2';
$post_faction_array['h'] = 'state = -1 OR state = -3';
}
$post_sort_by_array = array('ln'=>'lname', 'fn'=>'fname', 'ks'=>'kills', 'kd'=>'killed', 'fd'=>'feed', 'sd'=>'starved');
$post_order_array = array('a'=>'ASC', 'd'=>'DESC');
$faction = $post_faction_array[$_POST['faction']];
if(!isset($faction)) $faction = '1 = 2';
$sort_by = $post_sort_by_array[$_POST['sort_by']];
if(!isset($sort_by)) $sort_by = 'lname';
$order = $post_order_array[$_POST['order']];
if(!isset($order)) $order = 'DESC';
$show_pics = $_POST['show_pics'];
$show_kills = $_POST['show_kills'];
$show_killed = $_POST['show_killed'];
$show_feed = $_POST['show_feed'];
$show_starved = $_POST['show_starved'];
} else {
$faction = '';
$sort_by = 'lname';
$order = 'ASC';
$show_pics = 1;
$show_kills = 1;
$show_killed = 0;
$show_feed = 1;
$show_starved = 0;
$page = 1;
}
include('template_top.php'); ?>
<h3>Player List</h3>
<form name="playerListForm" action="players.php" method="post">
<input type="hidden" name="mode" value="refresh" />
<center>
<?php
$faction_array = array('a'=>'All', 'r'=>'Resistance', 'h'=>'Horde', 'd'=>'Deceased');
$sort_by_array = array('ln'=>'Last Name', 'fn'=>'First Name', 'ks'=>'Kills', 'kd'=>'Time Killed', 'fd'=>'Last Feeding', 'sd'=>'Time Starved');
$order_array = array('a'=>'Ascending', 'd'=>'Descending');
print "<select name='faction'>";
while(list($k,$v) = each($faction_array)) {
print "<option value='$k'";
if($_POST['faction'] == $k) print "selected";
print ">$v</option>";
}
print "</select><select name='sort_by'>";
while(list($k,$v) = each($sort_by_array)) {
print "<option value='$k'";
if($_POST['sort_by'] == $k) print " selected";
print ">$v</option>";
}
print "</select><select name='order'>";
while(list($k,$v) = each($order_array)) {
print "<option value='$k'";
if($_POST['order'] == $k) print "selected";
print ">$v</option>";
}
print "</select>";
?>
<input type='submit' value="Submit"><br>
<input type="hidden" name="faction_orig" value="<?php print (isset($_POST['faction'])) ? $_POST['faction'] : 'a'; ?>" />
<input type="hidden" name="sort_by_orig" value="<?php print (isset($_POST['sort_by'])) ? $_POST['sort_by'] : 'ln'; ?>" />
<input type="hidden" name="order_orig" value="<?php print (isset($_POST['order'])) ? $_POST['order'] : 'a'; ?>" />
<input type='checkbox' name='show_pics' value='1' <?php if($show_pics) print "checked"; ?>> Pictures
<input type='checkbox' name='show_kills' value='1' <?php if($show_kills) print "checked"; ?>> Kills
<input type='checkbox' name='show_killed' value='1' <?php if($show_killed) print "checked"; ?>> Time Killed
<input type='checkbox' name='show_feed' value='1' <?php if($show_feed) print "checked"; ?>> Last Fed
<input type='checkbox' name='show_starved' value='1' <?php if($show_starved) print "checked"; ?>> Time Starved
</center>
<br /><br />
<?php
// prepare the pagination values
$records = $config['page_records'];
$start = ($page - 1) * $records;
$limit = " LIMIT ".$start.", ".$records;
// player query
$player_query = "SELECT * FROM $table_u $faction ORDER BY $sort_by $order";
$ret = mysql_query($player_query.$limit);
// count query
$count_query = "SELECT COUNT(id) AS count FROM $table_u $faction ORDER BY $sort_by $order";
$count_ret = mysql_query($count_query);
$count = mysql_fetch_assoc($count_ret);
$count = $count['count'];
// get the total page count
$pages = ceil($count / $config['page_records']);
?>
<input type="hidden" name="page" value="<?php print $page; ?>" />
<? if($count_ret) include('pagination.php'); ?>
<table width="100%" cellspacing="0" class="data-table">
<tr>
<?php
if($show_pics) print "<td>picture</td>";
?>
<td>name</td>
<td>affiliation</td>
<?php
if($show_kills) print "<td>kills</td>";
if($show_killed) print "<td>time of death</td>";
if($show_feed) print "<td>last feeding time</td>";
if($show_starved) print "<td>time of starvation</td>";
if($admin) print "<td></td>";
?>
</tr>
<?php
// display the records
if($ret && ($rows = mysql_num_rows($ret)) > 0)
{
for($i = 0; $i < $rows; $i++) {
$row_id = ($i % 2) + 1;
print '<tr class="row'.$row_id.'">';
$row = mysql_fetch_assoc($ret);
if($show_pics) {
print '<td align="center">';
if(strlen($row['pic_path']) > 0) {
print '<img src="'.$row['pic_path'].'" class="player-pic '.$state_translate[$row['state']].'-pic">';
} else {
print "no image<br>available";
}
print "</td>";
}
print '<td align="center">'.$row['fname'].' '.$row['lname'].'</td>';
print '<td align="center">';
if($row['state'] == -2 && !$reveal_oz) {
print '<span class="resistance">resistance</span>';
} else {
print '<span class="'.$state_translate[$row['state']].'">'.$state_translate[$row['state']].'</span>';
}
print "</td>";
if($show_kills) {
print '<td align="center">';
if($row['state'] == -2 && !$reveal_oz) {
print "0";
} else {
print $row['kills'];
}
print "</td>";
}
if($show_killed) {
print '<td align="center">';
if($row['state'] <= 0 && ($row['state'] != -2 || $reveal_oz)) {
print $row['killed'];
}
print "</td>";
}
if($show_feed) {
print '<td align="center">';
if($row['state'] <= 0 && ($row['state'] != -2 || $reveal_oz)) {
print $row['feed'];
}
print "</td>";
}
if($show_starved) {
print '<td align="center">';
if($row['state'] == 0) {
print $row['starved'];
}
print "</td>";
}
print "</tr>";
}
} else {
print '<tr><td colspan="7" align="center"> There are no records to display</td></tr>';
}
?>
</table>
<center>
<? if($count_ret) include('pagination.php'); ?>
</center>
<? if($count_ret) include('pagination.php'); ?>
</form>
<?php include('template_bottom.php'); ?>