forked from jackcogdill/FB-hack-attack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
145 lines (133 loc) · 3.07 KB
/
index.php
File metadata and controls
145 lines (133 loc) · 3.07 KB
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
<?php
$up = "";
require_once("secure.php");
require_once("head_top.php");
?>
<link rel="stylesheet" href="css/home.css">
<?php
require_once("head_bottom.php");
require_once("header.php");
// User might be in ongoing match
// If so, redirect
$user = $_SESSION['user']['username'];
$ongo_stmt = $connect->prepare('
SELECT *
FROM ongoing
WHERE (
user1 = ? OR
user2 = ?
)
LIMIT 1
');
if ($ongo_stmt) {
$ongo_stmt->bind_param(
"ss",
$user,
$user
);
$ongo_stmt->execute();
$result = $ongo_stmt->get_result();
if ($result->num_rows === 1) {
header('Location: challenge/index.php');
die("Redirecting");
}
$ongo_stmt->close();
}
// Reset Waiting
// =====================
$delw_stmt = $connect->prepare('
DELETE FROM waiting
WHERE username = ?
');
if ($delw_stmt) {
$delw_stmt->bind_param(
"s",
$user
);
$delw_stmt->execute();
$delw_stmt->close();
}
// Delete from waiting
if (isset($_SESSION['user']['waiting'])) {
unset($_SESSION['user']['waiting']);
}
// =====================
$bad_notice = '';
if (isset($_GET['osu'])) {
$bad_notice = 'You cannot challenge yourself.';
}
elseif (isset($_GET['udne'])) {
$bad_notice = 'The user you challenged does not exist.';
}
elseif (isset($_GET['nod'])) {
$bad_notice = 'Please select a difficulty.';
}
elseif (isset($_GET['ce'])) {
$bad_notice = 'Challenge has ended.';
}
?>
<a class="mainlogo logo" href="../"> Hack Attack </a>
<hr class="underline">
<form action="challenge/index.php" method="post">
<div id="button-wrap">
<div>
<select class="difficulty" name="difficulty[]">
<option value="">Lvl</option>
<option value="1">1</option>
</select>
<button type="submit" name="language" value="Java">Java</button>
</div>
<div>
<select class="difficulty" name="difficulty[]">
<option value="">Lvl</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<button type="submit" name="language" value="Python">Python</button>
</div>
<div id="choose-opponent">
<div>
<?php
if (!empty($bad_notice)) {
?>
<div class="badnotice">
<?php echo $bad_notice; ?>
</div>
<?php
}
?>
Opponent's username:
<input type="text" name="specific-opponent" autocomplete="off" placeholder="Random" onkeydown="if (event.keyCode == 13) return false;">
</div>
</div>
<div>
<select class="difficulty" name="difficulty[]">
<option value="">Lvl</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
<button type="submit" name="language" value="Crypto">Crypto</button>
</div>
<div>
<select class="difficulty" name="difficulty[]">
<option value="">Lvl</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
<button type="submit" name="language" value="CTF">CTF</button>
</div>
</div>
</form>
<?php
require_once("footer.php");
?>