-
Notifications
You must be signed in to change notification settings - Fork 15
/
main.php
403 lines (372 loc) · 11.9 KB
/
main.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
<?php
session_start();
include 'template/connection.php';
if(!isset($_SESSION['USERNAME']) || !isset($_SESSION['TEAM']) || !isset($_SESSION['TYPE'])){
header('location:index.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimal-ui" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Iceland|Orbitron" rel="stylesheet">
<link href="css/secgen.css" rel="stylesheet" type="text/css">
<link href="css/map.css" rel="stylesheet" type="text/css">
<script>
sessionStorage.clear();
var user = '<?php echo $_SESSION['USERNAME'];?>';
var tm1 = '<?php echo $_SESSION['TEAM'];?>';
</script>
<script src="js/dialog.js"></script>
<script src="js/jquery_form.js"></script>
<style>
.modal-content{
width:30%;
height:auto;
}
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-button {
width: 0px;
height: 0px;
}
::-webkit-scrollbar-thumb {
background: #ceb342;
border: 0px none #ffffff;
border-radius: 50px;
}
::-webkit-scrollbar-thumb:hover {
background: #faf434;
}
::-webkit-scrollbar-thumb:active {
background: #000000;
}
::-webkit-scrollbar-track {
background: #abd17d;
border: 0px none #ffffff;
border-radius: 90px;
}
::-webkit-scrollbar-track:hover {
background: #41a428;
}
::-webkit-scrollbar-track:active {
background: #ffff00;
}
::-webkit-scrollbar-corner {
background: transparent;
}
.hintok{
color:green;
}
.hintclose{
color:red;
}
</style>
</head>
<body id="main" style="background:url('images/bgadmin.png');">
<div id="wrapper">
<!-- Left Panel--->
<div class="floating_panel left_panel">
<h1>Submit Flags</h1>
<input type="text" id="flag-check" placeholder="Enter Flag and Press Enter" />
<script src="js/loginpopup.js"></script>
<div class="status">
<marquee><p id="flag-status-p"> </p></marquee>
</div>
</div>
<!-- Right Panel-->
<div class="floating_panel right_panel" id="right_panel">
<?php include 'template/announce.php';?>
</div>
<div class="dropdown">
<button class="dropbtn">View Teams</button>
<div class="dropdown-content">
<?php
include 'template/connection.php';
$center_panel_sql = "SELECT * FROM team";
$center_panel_result = mysqli_query($connection, $center_panel_sql);
while($center_row = mysqli_fetch_assoc($center_panel_result)){
$team = $center_row['TEAMNAME'];
$teamno = $center_row['TEAM'];
if(isset($_SESSION['TEAM'])){
$sess_team = $_SESSION['TEAM'];
if($teamno == $sess_team){
echo "<a class='my_team view_team_list' href='main.php?team=$sess_team'><span class='team_logo'><img class='team_logo' src='images/flag.svg'/></span>$team</a>";
}else{
echo "<a class='other_team view_team_list' href='main.php?team=$teamno'><span class='team_logo'><img class='team_logo' src='images/flag.svg'/></span>$team</a>";
}
}else{
}
}
?>
</div>
</div>
<div class="systems">
<?php
include 'template/connection.php';
if(isset($_GET['team'])){
$getTeam= preg_replace('[^0-9]', '', urldecode(stripslashes(htmlspecialchars(htmlentities(trim($_GET['team']))))));
$initTeamResult = mysqli_query($connection, "SELECT DISTINCT TEAM FROM secgenflag WHERE TEAM='".$getTeam."'");
if(mysqli_num_rows($initTeamResult) != 0){
if(mysqli_num_rows($initTeamResult) == 1){
$initTeam = $getTeam;
}else{
header('location:main.php?team='.$_SESSION['TEAM']);
}
}else{
header('location:html/initialise.php');
}
}else{
header('location:main.php?team='.$_SESSION['TEAM']);
}
$ssql = "SELECT DISTINCT VM, IP FROM secgenflag WHERE TEAM='$initTeam'";
$sresult = mysqli_query($connection, $ssql);
$ii = 0;
while($srow = mysqli_fetch_assoc($sresult)){
$vm = $srow['VM'];
$ip = $srow['IP'];
$ii+=1;
?>
<div class="grouper">
<div class="grouper_heading">
<p class="vm"><?php echo $vm; ?></p>
<p class="ip"><?php echo $ip; ?></p>
</div>
<div class="grouper_map" id="<?php echo "grouperId".$ii; ?>">
<?php
include 'template/connection.php';
$sChooseMapCountSql = "SELECT FLAG_POINTS FROM secgenflag WHERE VM='$vm' AND TEAM='$initTeam'";
$sChooseMapCountResult = mysqli_query($connection, $sChooseMapCountSql);
$sChooseMapCount = mysqli_num_rows($sChooseMapCountResult);
if($sChooseMapCount <= 16){
$sSelectMapDistinct = "SELECT DISTINCT W, H, X, Y FROM secgen WHERE C_NO='$sChooseMapCount'";
$sSelectMapDistinctResult = mysqli_query($connection, $sSelectMapDistinct);
while($sSelectMRow = mysqli_fetch_assoc($sSelectMapDistinctResult)){
$x = $sSelectMRow['X'];
$y = $sSelectMRow['Y'];
$w = $sSelectMRow['W'];
$h = $sSelectMRow['H'];
?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.2" viewBox="<?php echo $x." ".$y." ".$w." ".$h?>">
<g>
<?php
$sSelectMapSql = "SELECT * FROM secgen WHERE C_NO='$sChooseMapCount'";
$sSelectMapResult = mysqli_query($connection, $sSelectMapSql);
while($sChooseRow = mysqli_fetch_assoc($sSelectMapResult)){
$sC_ID = $sChooseRow['C_ID'];
$sC_COUNTRY= $sChooseRow['C_COUNTRY'];
$sC_TITLE = $sChooseRow['C_TITLE'];
$sC_D = $sChooseRow['C_D'];
$secgenQuery = mysqli_query($connection, "SELECT STATUS FROM secgenflag WHERE C_ID='$sC_ID' AND TEAM='$initTeam' AND VM='$vm'");
while($secgenStatusRow = mysqli_fetch_assoc($secgenQuery)){
$secgenStatus = $secgenStatusRow['STATUS'];
$session_team = $_SESSION['TEAM'];
if($secgenStatus == 0){
if($session_team == $initTeam){
echo "<path id='$sC_ID' title='$sC_COUNTRY' d='$sC_D' onclick='Alert.menu(\"$sC_ID\",\"$vm\",\"$session_team\");'/>";
}else{
echo "<path id='$sC_ID' title='$sC_COUNTRY' d='$sC_D'/>";
}
}else{
echo "<path fill='#abd17d' id='$sC_ID' title='$sC_COUNTRY' d='$sC_D'/>";
}
}
}
?>
</g>
</svg>
<?php
}
mysqli_close($connection);
}else{
echo "<p class='map_init' id='tssst'>Map Not Initialised (Exceeded Map Limit - Contact Admin)</p>";
}
?>
</div>
</div>
<?php
}
?>
</div>
</div>
<!--Dialog Code -->
<!-- Left Menu -->
<div id="info_menu" onclick="openNav()">
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰</span>
</div>
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<?php
if(isset($_SESSION['USERNAME']) && isset($_SESSION['TEAM']))
{
?>
<a href="template/logout.php" id="main_logout">Logout</a>
<div class="scores side_item">
<div class="side_heading">
<h1>Score Board</h1>
</div>
<span id="div1_inner_body_1"><?php include 'template/userscoreboard.php'; ?></span>
<span id="div1_inner_body_2"><?php include 'template/teamscoreboard.php'; ?></span>
</div>
<div class="logs side_item">
<div class="side_heading">
<h1>Team Activity</h1>
</div>
<div class="team_logs" id="team_logs_scroll">
<div id="div2_inner">
<div id="div2_inner_border">
<?php include 'template/viewlog.php'; ?>
</div>
</div>
</div>
</div>
<div class="chat side_item">
<div class="side_heading">
<h1>Team Chat</h1>
</div>
<div class="chat_history" id="chat_history_scroll">
<div id="div3_inner">
<div id="div3_inner_chat_history">
<?php include 'template/viewchat.php'; ?>
</div>
</div>
</div>
<div class="chat_input">
<input id="div3_chat_input" type="text" placeholder="Enter Message and Press Enter" />
</div>
</div>
<?php
}
?>
</div>
<div id="noooo"></div>
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<h3 id="dialog-id" class="modal_info"></h3>
<h3 id="dialog-title" class="modal_info"></h3>
</div>
<div class="modal-body">
<div id="moBody">
<h3 class="hintclose">Please wait...</h3>
</div>
<div id="dialog_flag_button">
<button type="fsubmit" id="fsubmit">Get Hint</button>
</div></br>
<div id="moBodyLocked">
</div>
</div>
<div class="modal-footer">
<h3 id="flag_hint">--</h3>
</div>
</div>
</div>
<script src="js/dialog.js"></script>
<script>
function alert(){
var modal = document.getElementById('myModal');
var span = document.getElementsByClassName("close")[0];
this.menu = function(cid,vm,teams) {
modal.style.display = "block";
document.getElementById('dialog-title').innerHTML = vm;
document.getElementById('dialog-id').innerHTML = cid;
//-------------------------------------------------------------------
if(checkSessionStorage() != "undefined"){
if (sessionStorage.getItem(cid+"-"+vm) == null){
$.ajax({
method: "POST",
url: "template/viewhint.php",
data: {cids: cid,team:teams,vms:vm},
success: function(status){
sessionStorage.setItem(cid+"-"+vm,status);
insertHint(status);
}
});
}else{
var status = sessionStorage.getItem(cid+"-"+vm);
insertHint(status);
}
}else{
$.ajax({
method: "POST",
url: "template/viewhint.php",
data: {cids: cid,team:teams,vms:vm},
success: function(status){
insertHint(status);
}
});
}
};
function insertHint(value){
var status = value;
$('#moBody').empty();
$('#moBodyLocked').empty();
var OCSplit = status.split("#~#");
for(var i=0; i<OCSplit.length;i++){
var split = OCSplit[i].split("~#~");
var cn = 0;
for(var e=0; e<split.length;e++){
if(i == OCSplit.length-1){
if(e == 0){
var str = split[0];
if(str == ""){
document.getElementById("fsubmit").innerHTML = "No Further Hints";
}else if(str == "No Further Hints"){
document.getElementById("fsubmit").innerHTML = "No Further Hints";
}else{
var res = str.replace("Hint Locked","");
document.getElementById("fsubmit").innerHTML = "Unlock Hint "+res;
}
}
var addh3 = document.createElement("h3");
var text = document.createTextNode(split[e]);
addh3.appendChild(text);
addh3.setAttribute("class","hintclose");
document.getElementById("moBodyLocked").appendChild(addh3);
}else{
cn++;
var addh3 = document.createElement("h3");
if(split[e] == ""){
var text = document.createTextNode(split[e]);
}else{
var text = document.createTextNode(cn+") "+split[e]);
}
addh3.appendChild(text);
addh3.setAttribute("class","hintok");
document.getElementById("moBody").appendChild(addh3);
}
}
}
}
function checkSessionStorage(){
return window.sessionStorage;
}
span.onclick = function() {
modal.style.display = "none";
var text = document.getElementById('flag_hint').innerText;
document.getElementById('flag_hint').innerHTML = " ";
};
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
var text = document.getElementById('flag_hint').innerText;
document.getElementById('flag_hint').innerHTML = " ";
}
};
}
var Alert = new alert();
</script>
<script src="js/main.js"></script>
<script src="noti/notify.js"></script>
<script src="noti/notify.min.js"></script>
</body>
</html>