/
index.php
439 lines (342 loc) · 17.5 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="theme-color" content="#337ab7">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="keywords" content="oregon tech gaming community">
<meta name="description" content="The Official Oregon Tech Gaming Community Website. The place to find event times, locations, and announcements.">
<meta name="author" content="Ian Murphy">
<link rel="icon" href="/assets/media/cog128.png">
<title>Event Standings</title>
<!-- Bootstrap core CSS -->
<link href="/assets/stylesheets/bootstrap.min.css" rel="stylesheet">
<link href="/assets/stylesheets/add.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<!-- PHP ================== -->
<?php
include_once("/var/www/php/sql_connect.php");
if(isset($_COOKIE["token"]))
{
$token = $_COOKIE["token"];
}
include("/var/www/web_classes/DHunter.php");
$hunter = new DHunter($token);
$quarry = $hunter->Quarry();
if(isset($_FILES["hpic"]))
{
$tmpdir = tempnam("/var/www/sites/oitgaming/uploads", "img_");
// unlink($tmpdir);
$tmpdir = $tmpdir;
$path = explode("oitgaming", $tmpdir);
if($_FILES["hpic"]["type"] === "image/jpeg" and $_FILES["hpic"]["size"] < 10*1024*1024)
{
if(move_uploaded_file($_FILES["hpic"]["tmp_name"], $tmpdir))
{
fixOrientation($tmpdir);
$img_text = $hunter->ChangeAvatar($path[1]);
}
}
else
{
$img_text = "That's not a jpeg or it is over 6MB";
}
}
else
{
$img_text = "";
}
?>
<style>
.jumbotron-vert{
background-color: #FCFCFC;
border: 1px solid lightgrey;
border-radius: 3px;
margin-top: 5%;
margin-bottom: 5%;
margin-right: auto;
margin-left: auto;
max-width: 400px;
min-height: 400px;
box-shadow: 0px 2px 7px 2px lightgrey;
overflow:hidden;
}
.glyphicon-refresh-animate {
-animation: spin .7s infinite linear;
-webkit-animation: spin2 .7s infinite linear;
}
@-webkit-keyframes spin2 {
from { -webkit-transform: rotate(0deg);}
to { -webkit-transform: rotate(360deg);}
}
@keyframes spin {
from { transform: scale(1) rotate(0deg);}
to { transform: scale(1) rotate(360deg);}
}
.left{
font-size: 10px;
color: #AAA;
/*width: 30%;
float: left;
text-align: right;
padding-right: 2%;*/
}
.right{
/* width: 70%;
float: left;
text-align: left;
padding-left: 2%;*/
}
</style>
<!-- NAVBAR================================================== -->
<body>
<div id="adjust"><br></div>
<div class="container">
<nav id="nav" class="navbar navbar-inverse">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">My Profile</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="/">Home</a></li>
<li><a href="/#events">Upcoming Events</a></li>
<li><a href="/#gotw">Game of the Week</a></li>
<li><a href="/picker">GOTW Pool</a></li>
<li><a href="mailto:gaming@oit.edu">Contact</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="leaderboard" >Leaderboard and Log</a>
</li>
</ul>
</div>
</nav>
</div>
<!-- END NAVBAR -->
<!-- BODY CONTAINER -->
<div id="fill" class="container">
<?php
if($hunter->Email() != NULL)
{
if(isset($quarry))
{
$quarry = getQuarryStats($quarry);
}
else
{
$quarry[2] = "No Quarry Assigned";
$quarry[4] = "/uploads/null.jpg";
}
if($hunter->ElimBy() != NULL)
{
$elimBy = getQuarryStats($result[8]);
$elimBy = $elimBy[2];
$elimBy = "Eliminated by " . $elimBy;
}
else
{
$elimBy = "Not yet eliminated.";
}
if($hunter->HID() == NULL)
{
echo "<center><button class='btn btn-default btn-lg' onclick='addUserToEvent()'>Participate in the Event</button>";
}
#user has already entered
else
{
?>
<div class="container-fluid">
<div class="row">
<div class="col-lg-6">
<h3><center>You:</h3>
<div class="jumbotron-vert" style="">
<center>
<div style="max-height: 80vw; height: 400px; width: 100%; overflow: hidden; background: url('<?=$hunter->Avatar()?>') no-repeat; background-size: cover; background-position: center center">
</div>
<?php
if($hunter->Quarry() == NULL)
{
?>
<a href="javascript:void(0)" data-toggle="collapse" data-target="#img_new"><h6>Change Image</a>
<div id="picerr" style="color: red"><?=$img_text?></div>
<div id="img_new" class="collapse" style="text-align: left; padding: 5%">
Image must be a jpeg no larger than 6MB. Upload a high enough resolution image that other players can identify you.
<br><br>
A square image works best as the above display area is a square.
<center>
<form role="form" action="index.php" method="POST" enctype="multipart/form-data">
<input class="btn" type="file" name="hpic">
<br />
<button class="btn btn-default">Confirm Choice</button>
</form>
</div>
<?php
}
?>
<div class="" style="text-align: center; margin: 10%;">
<div class="row flex">
<div style="float: left; text-align: center; min-width: 50%">
<div class="left">Name:</div>
<div class="right"><h3 style="margin:0"><?=$hunter->FirstName()?></div>
<br>
<div class="left">Player ID:</div>
<div class="right"><?=$hunter->HID()?></div>
</div>
<div style="float: right; ">
<div class="left">Current Score:</div>
<div class="right"><h1 style="margin: 0;"><?=$hunter->Points()?></h1></div>
points
</div>
</div>
<!-- <hr class="featurette-divider">
<div class="row">
<div class="left">Status</div>
<div class="right"><?=$elimBy?></div>
</div> -->
</div>
<br>
<div>
<a href="mailto:event-issues@oitgaming.com">Problems?</a>
</div>
</div>
</div>
<!-- Quarry -->
<div class="col-lg-6">
<h3><center>Your Target:</h3>
<div class="flip">
<div id="quarry" class="card">
<div class="face front">
<div id="qCard" class="inner jumbotron-vert" style="height: 460px;">
<center>
<div style="max-height: 80vw; height: 400px; width: 100%; overflow: hidden; background: url('<?=$quarry[4]?>') no-repeat; background-size: cover; background-position: center center">
</div>
<div class="row">
<h3>
<center><?=$quarry[2]?></center>
</h3>
</div>
</div>
</div>
<div class="face back">
<div class=" jumbotron-vert" style="height: 460px; padding-top: 100px;">
<h1>Redeem:</h1>
<center>
<form style="width: 40%">
<label style="color: grey">Enter your target's 4 character ID and click submit.</label>
<br><br>
<input id="qID" class="form-control" type='text' placeholder="Quarry ID">
<br>
<button id="qRedeem" class="btn btn-default" type=button>Submit</button>
</form>
<br>
<div id="qErr" style="color:red"></div>
</div>
</div>
</div>
<br>
<button id="bFlip" class="btn btn-default">FLIP CARD</button>
</div>
</div>
</div>
</div>
<?php
}
}
else
{
?>
<center><button onclick="document.location = '/login'" class='btn btn-default btn-lg'>Sign in</button>
<?php
}
?>
</div>
<div id="err" style="color:red; text-align: center; font-size: 2em">
</div>
<!-- END JUMBOTRON AND SIGNUP FORM -->
<?php
include("/var/www/snippets/event_footer.php");
?>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="/assets/js/jquery.min.js"></script>
<script src="/assets/js/bootstrap.min.js"></script>
<script>
$(document).ready(function()
{
if( $(window).width() < 1000)
{
$("#nav").toggleClass("navbar-fixed-top");
$("#adjust").html("<br><br><br>");
}
// getUser();
});
$('#bFlip').click(function(){
$("#quarry").toggleClass('flipped');
});
$('#newQuarry').click(function(){
if(confirm("Requesting a new contract will remove your current contract. You can only request a new contract every 24 hours. Click OK to continue with this request."))
{
$.post("getNewQuarry.php", {token: "<?=$token?>", quarry: "NEW"}, function(data)
{
if(data === "TRUE")
{
setTimeout(function(){$("#quarry").toggleClass('flipped');}, 700);
setTimeout(function(){window.location = "/event";}, 1000);
}
else if(data[0] === "T")
{
document.getElementById("err").innerHTML = data;
}
else{
document.getElementById("err").innerHTML = "You must wait " + data + " more hours before requesting a new contract";
}
});
}
});
$("#qRedeem").click(function(){
var quarryID = document.getElementById("qID").value;
document.getElementById("qErr").innerHTML = "<span class='glyphicon glyphicon-refresh glyphicon-refresh-animate'></span>";
$.post("getNewQuarry.php", {token: "<?=$token?>", quarry: quarryID}, function(data)
{
document.getElementById("qErr").innerHTML = data;
if(data === "Contract Redeemed")
{
setTimeout(function(){$("#quarry").toggleClass('flipped');}, 700);
setTimeout(function(){window.location = "/event";}, 1000);
}
});
});
$(document).ready(function()
{
});
function capitalizeFirstLetter(string)
{
return string.charAt(0).toUpperCase() + string.slice(1);
};
function addUserToEvent()
{
$.post("enrollUser.php", {token: "<?=$token?>"}, function(data)
{
document.getElementById("err").innerHTML = data;
if(data === "User enrolled successfully.")
{
window.location = "/event"
}
});
};
</script>
</body>
</html>