-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
546 lines (345 loc) · 18.9 KB
/
admin.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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
<?php
// ___ ___ ___ ___ ___ __ _______ ________
// |" \ /" |" \/" | |" | /""\ | _ "\ /" )
// \ \ // / \ \ / || | / \ (. |_) :(: \___/
// \\ \/. ./ \\ \/ |: | /' /\ \ |: \/ \___ \
// \. // /\. \ \ |___ // __' \ (| _ \\ __/ \\
// \\ / / \ \ ( \_|: \ / / \\ \|: |_) :)/" \ :)
// \__/ |___/\___| \_______(___/ \___(_______/(_______/
//
// Unapproved use, modification and redistribution of this code and respective product is strictly prohibited.
// Copyright© 2017 Keanu Ashwell all rights are reserved to the author, creator, registered
// and licensed owners of this product and it's content
if(session_id() != $_COOKIE['PHPSESSID'] || !$_COOKIE['PHPSESSID']) {
session_start();
}
// Require
require_once('mysql.php');
?>
<html>
<head>
<link rel="stylesheet" href="css/admin.css">
<link rel="stylesheet" href="css/globals.css">
<script src="javascript/script.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script defer src="https://use.fontawesome.com/releases/v5.0.7/js/all.js"></script>
<script src="ajax/adminLoad.js"></script>
<title>VX KotH</title>
</head>
<body>
<!-- Container -->
<div id="grid-container">
<!-- Header -->
<div id="grid-header">
<!-- Top Header -->
<div id="grid-header-top">
<!-- VX KOTH Container -->
<div id="grid-vxkoth-container">
<a href="index.php">
<h3 id="grid-vx">VX</h3>
<h3 id="grid-koth">KOTH</h3>
</a>
</div>
<?php
// If cookie exists and is set
if(isset($_COOKIE['USERNAME'])) {
// Query
$QUERY_ALL_USERS = mysqli_query($conn, "
SELECT
vx.accounts.id,
vx.accounts.username,
vx.accounts.ip
FROM vx.accounts
WHERE vx.accounts.username = '" . $_COOKIE['USERNAME'] . "';
");
// Fetch the results
$RESULT_ALL_USERS = mysqli_fetch_array($QUERY_ALL_USERS);
if($RESULT_ALL_USERS[0] == $_SESSION['USERID']) {
echo '
<div id="grid-account-options">
<p id="grid-myaccount" class="grid-account-managment"><a href="account.php">My Account</a></p>
<p id="grid-logout" class="grid-account-managment">Logout</p>
</div>
';
} else {
// No session userid set
echo '
<div id="grid-account-options">
<p id="grid-register" class="grid-account-managment"><a href="register.php">Register</a></p>
</div>
';
}
} else {
// Cookie either doesnt exist or isnt set
echo '
<div id="grid-account-options">
<p id="grid-register" class="grid-account-managment"><a href="register.php">Register</a></p>
</div>
';
}
?>
</div>
<!-- News -->
<div id="grid-header-news">
<marquee>Latest News From VX</marquee>
</div>
<!-- Bottom Header -->
<div id="grid-header-bottom">
<?php
// If cookie exists and is set
if($_COOKIE['USERNAME']) {
// User exists
// Query
$QUERY_ALL_USERS = mysqli_query($conn, "
SELECT
vx.accounts.id,
vx.accounts.username,
vx.accounts.ip,
vx.accounts.admin,
vx.accounts.permissionArray
FROM vx.accounts
WHERE vx.accounts.username = '" . $_COOKIE['USERNAME'] . "';
");
// Fetch the results
$RESULT_ALL_USERS = mysqli_fetch_array($QUERY_ALL_USERS);
// User is an admin and ip matches as well as account id for extra security
if($RESULT_ALL_USERS[3] == 1 && $RESULTS_ALL_USERS[2] = $_SERVER['REMOTE_ADDR'] && $_SESSION['USERID'] == $RESULT_ALL_USERS[0]) {
echo '
<p class="grid-user-display">Logged in as: ' . $_COOKIE['USERNAME'] . ' <a href="admin.php">(Admin)</a></p>
';
} else {
// User is not an admin
// Check the user
if($RESULT_ALL_USERS[1] == $_COOKIE['USERNAME'] && $_SESSION['USERID'] == $RESULT_ALL_USERS[0]) {
// Redirect
header('Location: index.php');
}
}
} else {
// Cookie either doesnt exist or isnt set
// Redirect
header('Location: index.php');
}
?>
</div>
<?php
// Query
$QUERY_ALL_USERS = mysqli_query($conn, "
SELECT
vx.accounts.id,
vx.accounts.username,
vx.accounts.ip
FROM vx.accounts
WHERE vx.accounts.username = '" . $_COOKIE['USERNAME'] . "';
");
// Fetch the results
$RESULT_ALL_USERS = mysqli_fetch_array($QUERY_ALL_USERS);
if(!isset($_COOKIE['USERNAME']) || $RESULT_ALL_USERS[0] != $_SESSION['USERID']) {
// Redirect to index.php
header('Location: index.php');
// Make sure post fields arent empty
if(!empty($_POST['USERNAME']) && !empty($_POST['PASSWORD'])) {
// Make sure both post fields are set
if(isset($_POST['USERNAME']) && isset($_POST['PASSWORD'])) {
// Query accounts
$QUERY_ALL_USERS = mysqli_query($conn, "
SELECT
vx.accounts.id,
vx.accounts.username,
vx.accounts.email,
vx.accounts.password
FROM vx.accounts
");
// Fetch the results
$RESULT_ALL_USERS = mysqli_fetch_array($QUERY_ALL_USERS);
// Check account actually exists
if(
$RESULT_ALL_USERS[1] == $_POST['USERNAME']
|| $RESULT_ALL_USERS[2] == $_POST['USERNAME']
&& $RESULT_ALL_USERS[3] == md5($_POST['PASSWORD'])
) {
// Account exists
// If post username was email
if($_POST['USERNAME'] == $RESULT_ALL_USERS[2]) {
// Set the cookie
setcookie("USERNAME", $RESULT_ALL_USERS[1], time() + (86400 * 30), "/");
// Set session user id
$_SESSION['USERID'] = $RESULT_ALL_USERS[0];
} else if($RESULT_ALL_USERS[1] == $_POST['USERNAME']) {
// Set the cookie
setcookie("USERNAME", $RESULT_ALL_USERS[1], time() + (86400 * 30), "/");
// Set session user id
$_SESSION['USERID'] = $RESULT_ALL_USERS[0];
}
// Redirect to make sure the cookie is loaded to the client
header('Location: index.php');
} else {
// Account doesnt exist
}
} else {
// Fields arent set
}
} else {
// Posts are empty
}
}
?>
</div>
<!-- Content -->
<div id="grid-content">
<?php
// Query
$QUERY_USER_CLAN = mysqli_query($conn, "
SELECT
vx.accounts.username,
vx.accounts.clanID,
vx.accounts.clanRankID,
vx.clans.name,
vx.clans.abbreviation,
vx.clanRanks.name
FROM vx.accounts
INNER JOIN vx.clans ON vx.accounts.clanID = (
SELECT
vx.accounts.clanID
FROM vx.accounts
WHERE vx.accounts.id = '" . $_SESSION['USERID'] . "'
AND vx.accounts.username = '" . $_COOKIE['USERNAME'] . "'
)
INNER JOIN vx.clanRanks ON vx.accounts.clanRankID = (
SELECT DISTINCT
vx.accounts.clanRankID
FROM vx.accounts
WHERE vx.accounts.id = '" . $_SESSION['USERID'] . "'
AND vx.accounts.username = '" . $_COOKIE['USERNAME'] . "'
AND vx.accounts.clanRankID = vx.clanRanks.id
)
LIMIT 1;
");
// Fetch results
$RESULT_USER_CLAN = mysqli_fetch_array($QUERY_USER_CLAN);
// If they have a clan
if(isset($RESULT_USER_CLAN[1])) {
// They are part of a community
// Check to make sure they're not just a member
if(
$RESULT_USER_CLAN[2] <= 1
|| $RESULT_USER_CLAN[5] == "Member"
) {
// Redirect
header('Location: index.php');
}
echo '
<h3 id="grid-welcome">Welcome ' . $RESULT_USER_CLAN[0] . ' [' . $RESULT_USER_CLAN[4] . ']</h3>
<h3 id="grid-clanrank">' . $RESULT_USER_CLAN[5] . 's Panel</h3>
<!-- Headings -->
<div id="grid-heading-options">';
// Community staff checks
if($RESULT_USER_CLAN[2] == 2) {
// Recruiter
echo '
<p id="grid-heading-memberships" class="grid-headings">Memberships</p>
<p id="grid-heading-events" class="grid-headings">Events</p>
<div id="grid-heading-underline"></div>
';
}
if($RESULT_USER_CLAN[2] == 3) {
// Game Admin
echo '
<p id="grid-heading-memberships" class="grid-headings">Memberships</p>
<p id="grid-heading-events" class="grid-headings">Events</p>
<p id="grid-heading-vxbans" class="grid-headings">VX Bans</p>
<div id="grid-heading-underline"></div>
';
}
if($RESULT_USER_CLAN[2] == 4) {
// Server Admin
echo '
<p id="grid-heading-memberships" class="grid-headings">Memberships</p>
<p id="grid-heading-events" class="grid-headings">Events</p>
<p id="grid-heading-vxbans" class="grid-headings">VX Bans</p>
<p id="grid-heading-servers" class="grid-headings">Servers</p>
<div id="grid-heading-underline"></div>
';
}
if($RESULT_USER_CLAN[2] == 5) {
// Senior Admin
echo '
<p id="grid-heading-memberships" class="grid-headings">Memberships</p>
<p id="grid-heading-events" class="grid-headings">Events</p>
<p id="grid-heading-vxbans" class="grid-headings">VX Bans</p>
<p id="grid-heading-servers" class="grid-headings">Servers</p>
<p id="grid-heading-administration" class="grid-headings">Administration</p>
<div id="grid-heading-underline"></div>
';
}
if($RESULT_USER_CLAN[2] == 6) {
// Owner
echo '
<p id="grid-heading-memberships" class="grid-headings">Memberships</p>
<p id="grid-heading-events" class="grid-headings">Events</p>
<p id="grid-heading-vxbans" class="grid-headings">VX Bans</p>
<p id="grid-heading-servers" class="grid-headings">Servers</p>
<p id="grid-heading-administration" class="grid-headings">Administration</p>
<div id="grid-heading-underline"></div>
';
}
echo '
</div>
<div id="grid-data"></div>
';
}
?>
</div>
<?php
// Server/Database modifications are done in here.
// jQuery .load only returns html not php so unable to do database and table alterations unless a result is found in that script
// Alter server name
?>
<!-- Footer -->
<div id="grid-footer">
<!-- Logos and Association-->
<img id="grid-footer-vx-logo" src="img/VXLogo.png">
<img id="grid-footer-armahosts-logo" src="img/ArmaHosts.png">
<!-- General Information -->
<div id="grid-footer-information">
<!-- Headings -->
<h3 id="grid-footer-heading-general" class="grid-footer-headings">GENERAL</h3>
<h3 id="grid-footer-heading-misc" class="grid-footer-headings">MISC</h3>
<h3 id="grid-footer-heading-break" class="grid-footer-headings">LEGAL</h3>
<!-- General -->
<p id="grid-footer-general-home" class="grid-footer-links"><a href="index.php">Home</a></p>
<p id="grid-footer-general-player" class="grid-footer-links"><a href="player.php">Player Panel</a></p>
<!-- Legal -->
<p id="grid-footer-legal-contact" class="grid-footer-links"><a href="legal.php?part=Contact">Contact</a></p>
<p id="grid-footer-legal-copyright" class="grid-footer-links"><a href="legal.php?part=Copyright">Copyright</a></p>
<p id="grid-footer-legal-privacy" class="grid-footer-links"><a href="legal.php?part=Privacy">Privacy</a></p>
<!-- Misc -->
<p id="grid-footer-misc-vxgaming" class="grid-footer-links"><a href="https://www.vxkoth.com/">VX KOTH</a></p>
<p id="grid-footer-misc-faq" class="grid-footer-links"><a href="https://www.vxkoth.com/faqs">FAQ</a></p>
<p id="grid-footer-misc-sitrep" class="grid-footer-links"><a href="https://www.vxkoth.com/blog">Sitreps</a></p>
</div>
<!-- Social Media -->
<div id="grid-footer-media">
<img id="grid-footer-facebook-logo" class="grid-footer-logos" src="img/FacebookLogo.png">
<img id="grid-footer-twitter-logo" class="grid-footer-logos" src="img/TwitterLogo.png">
<img id="grid-footer-youtube-logo" class="grid-footer-logos" src="img/YoutubeLogo.png">
<img id="grid-footer-discord-logo" class="grid-footer-logos" src="img/DiscordLogo.png">
<p id="grid-footer-misc-disclaimer">This website is not affiliated or authorized by Bohemia Interactive. Bohemia Interactive, ARMA, DAYZ and all associated logos and designs are trademarks of Bohemia Interactive</p>
</div>
</div>
</div>
<?php
// Nightmode settings
// Check cookie value
if($_COOKIE['NIGHTMODE'] == 'true') {
echo '
<script src="javascript/clientNightmode.js"></script>
';
} else if($_COOKIE['NIGHTMODE'] == 'false') {
echo '
<script src="javascript/clientLightmode.js"></script>
';
}
?>
</body>
</html>