-
Notifications
You must be signed in to change notification settings - Fork 1
/
board18Players.php
317 lines (312 loc) · 11.4 KB
/
board18Players.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
<?php
/*
* The board18Players.php page displays a paginated list of all
* players in the "players" table. This page is available only
* to "admin" players. This page facilitates the administration
* of players. Including item such as:
* - Showing the status and activity of all players.
* - Deleting a player.
* - Sending a email to a specific player.
* - Sending a broadcast email to all players.
* - Granting "admin" or "author" level to a player.
*
* Copyright (c) 2015 Richard E. Price under the The MIT License.
* A copy of this license can be found in the LICENSE.text file.
*/
require_once('php/auth.php');
if ($playerlevel != 'admin') {
$_SESSION['SESS_HEADER_MESSAGE'] = 'You are not an admin level player.';
session_write_close();
header("location: board18Main.php");
exit;
}
require_once('php/config.php');
$status = 'ok';
$link = @mysqli_connect(DB_HOST, DB_USER,
DB_PASSWORD, DB_DATABASE);
if (mysqli_connect_error()) {
$logMessage = 'MySQL Error 1: ' . mysqli_connect_error();
error_log($logMessage);
$status = 'fail';
exit;
}
mysqli_set_charset($link, "utf-8");
//Function to sanitize values received from the form.
//Prevents SQL injection
function clean($link, $str) {
$str = @trim($str);
return mysqli_real_escape_string($link, $str);
}
//Check for transfer from board18Games.php and
//sanitize the POST value if it is a transfer.
$xfer = 0;
if(!empty($_REQUEST['login'])) {
$xfer = clean($link, $_REQUEST['login']);
}
//Get count of player records.
$qry1 = "SELECT COUNT(*) FROM players";
$result1 = mysqli_query($link, $qry1);
if ($result1) {
$row = mysqli_fetch_row($result1);
$totalcount = $row[0];
} else {
error_log("SELECT COUNT(*) FROM players - Query failed");
error_log($logMessage);
$status = 'fail';
exit;
}
$pagesize = 10;
$pagecount = ceil((float)$totalcount/(float)$pagesize);
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>BOARD18 - Remote Play Tool For 18xx Style Games</title>
<link rel="shortcut icon" href="images/favicon.ico" >
<link rel="stylesheet" href="style/board18com-160521.css" />
<link rel="stylesheet" href="style/board18Players.css" />
<script type="text/javascript" src="scripts/jquery.js">
</script>
<script type="text/javascript" src="scripts/board18com.js">
</script>
<script type="text/javascript" src="scripts/board18Players1.js">
</script>
<script type="text/javascript" src="scripts/board18Players2.js">
</script>
<script type="text/javascript" >
$(function() {
BD18.totalcount = <?php echo $totalcount; ?>;
BD18.pagecount = <?php echo $pagecount; ?>;
BD18.pagesize = <?php echo $pagesize; ?>;
BD18.curpage = 1;
BD18.player = {};
BD18.player.update = 'no';
doPageList();
doPageLinks();
var playerselect = '<?php echo $xfer; ?>';
if (playerselect != 0) { // Do not use "!==", it does not work here.
doPlayer(playerselect);
playerselect = 0;
}
$("#pagelinks").on("click", ".pagor", function() {
BD18.curpage = $(".pagor").index(this) + 1;
BD18.player.update = 'no';
doPageList();
doPageLinks();
}); // end first pagelinks.click
$("#pagelinks").on("click", ".thegame", function() {
var gamename = $(this).html();
$.each(BD18.player.games,function(index,gameInfo) {
if (gameInfo.gname === gamename) {
var gid = gameInfo.gameid;
window.location = "board18Games.php?gameid=" + gid;
}
}); // end of each
}); // end second pagelinks.click
$("#players").on("click", ".playerid", function() {
doPlayer($(this).html());
}); // end players.click
$('#button1').click(function() {
BD18.player.update = 'no';
updatePlayer();
return false;
}); // end button1 click
$('#button2').click(function() {
BD18.player.update = 'no';
paintPlayer();
return false;
}); // end button2 click
$('#button3').click(function() {
$('#gamelist').remove();
$('#theplayer').slideUp(300);
doPageLinks();
BD18.player.update = 'no';
return false;
}); // end button3 click
$('#button4').click(function() {
$('#theplayer').slideUp(300);
$('#gamelist').remove();
$('.error').hide();
$('#oneto').html(BD18.player.login);
$('#onemail').slideDown(300);
BD18.player.update = 'no';
return false;
}); // end button4 click
$('#button11').click(function() {
doEmail();
return false;
}); // end button11 click
$('#button12').click(function() {
$('.error').hide();
$("#subject1").val('');
$("#body1").val('');
return false;
}); // end button12 click
$('#button13').click(function() {
$('#onemail').slideUp(300);
$('#theplayer').slideDown(300);
playerGames();
return false;
}); // end button13 click
$('#button21').click(function() {
sendBroadcast();
return false;
}); // end button21 click
$('#button22').click(function() {
$('.error').hide();
$("#subject2").val('');
$("#body2").val('');
return false;
}); // end button22 click
$('#button23').click(function() {
$('#allmail').slideUp(300);
return false;
}); // end button23 click
}); // end ready
</script>
</head>
<body onclick="$('.menu').hide();">
<div id="topofpage">
<div id="logo">
<img src="images/logo.png" alt="Logo"/>
</div>
<div id="heading">
<h1>BOARD18 - Remote Play Tool For 18xx Style Games</h1>
</div>
<div>
<span id="newmainmenu" onclick="$('#traymenu').hide();
$('#mainmenu').toggle();event.stopPropagation();"> MENU </span>
<p id="lognote"><?php echo "$welcomename: $headermessage"; ?>
<span style="font-size: 70%">
Click <a href="index.html">here</a>
if you are not <?php echo "$welcomename"; ?>.
</span>
</p>
<div id="mainmenu" class="menu">
<ul class="bigMenu">
<li onclick="$('#theplayer').slideUp(300);$('#gamelist').remove();
$('.error').hide();$('#allmail').slideDown(300);
BD18.player.update = 'no';">Send Broadcast</li>
<li onclick="window.location = 'board18Admin.php';">Return to Admin</li>
<li onclick="window.location = 'board18Main.php';">Main Page</li>
<li onclick="$.post('php/logout.php', logoutOK);">Log Out</li>
<li onclick="window.open(BD18.help, 'HelpGuide');">Help</li>
<li onclick="$('.menu').hide();aboutBoard18();">About BOARD18</li>
</ul>
</div>
</div>
</div>
<div id="leftofpage">
<div id="pagelinks">
</div>
</div>
<div id="rightofpage">
<div id="content">
<p style="margin-left: 10px">Select the player that you wish to manage.
</p>
<div id="players">
</div>
</div>
<div id="theplayer" class="hidediv">
<div id="playerinfo"></div>
<form name="theplayer" class="playerform" action="">
<fieldset>
<p>
<label for="login">Change Player ID:</label>
<input type="text" name="login" id="login" class="reg"
value="">
<label class="error" for="login" id="login_error">
This field is required.</label>
</p>
<p>
<label for="email">Change Email Address: </label>
<input type="text" name="email" id="email" class="reg"
value="">
<label class="error" for="email" id="email_error">
This field is required.</label>
</p>
<p>
<label for="fname">Change First Name: </label>
<input type="text" name="fname" id="fname" class="reg"
value="">
</p>
<p>
<label for="lname">Change Last Name: </label>
<input type="text" name="lname" id="lname" class="reg"
value="">
</p>
<p id="levelselect">
</p>
<p>
<input type="button" name="updatebutton" class="pwbutton"
id="button1" value="Update Player" >
<input type="button" name="resbutton" class="pwbutton"
id="button2" value="Reset Form" >
<input type="button" name="canbutton" class="pwbutton"
id="button3" value="Exit" >
<input type="button" name="mailbutton" class="pwbutton"
id="button4" value="Send Email" >
</p>
</fieldset>
</form>
</div>
<div id="onemail" class="hidediv">
<form name="onemail" class="playerform" action="">
<fieldset>
<p>
Send an administrative Email to <span id="oneto">dummy</span>.
</p>
<p>
<label for="subject" style="width: 80px;">Subject:</label>
<input type="text" name="subject" id="subject1" value="">
<label class="error" for="subject" id="subject1_error">
This field is required.</label>
</p>
<p>
<label for="body" style="width: 80px; vertical-align:top;">
Body: </label>
<textarea name="body" id="body1" cols=60 rows=10></textarea>
</p>
<p>
<input type="button" name="emailonebutton" class="pwbutton"
id="button11" value="Send Email" >
<input type="button" name="resbutton" class="pwbutton"
id="button12" value="Reset Form" >
<input type="button" name="canbutton" class="pwbutton"
id="button13" value="Exit" >
</p>
</fieldset>
</form>
</div>
<div id="allmail" class="hidediv">
<form name="allmail" class="playerform" action="">
<fieldset>
<p>
Send an administrative Email to all players.
</p>
<p>
<label for="subject" style="width: 80px;">Subject:</label>
<input type="text" name="subject" id="subject2" value="">
<label class="error" for="subject" id="subject2_error">
This field is required.</label>
</p>
<p>
<label for="body" style="width: 80px; vertical-align:top;">
Body: </label>
<textarea name="body" id="body2" cols=60 rows=10></textarea>
</p>
<p>
<input type="button" name="emailonebutton" class="pwbutton"
id="button21" value="Send Email" >
<input type="button" name="resbutton" class="pwbutton"
id="button22" value="Reset Form" >
<input type="button" name="canbutton" class="pwbutton"
id="button23" value="Exit" >
</p>
</fieldset>
</form>
</div>
</div>
</body>
</html>