forked from lovemachinej/Hackzone-tunisia-CTF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
challenges.php
219 lines (201 loc) · 7.94 KB
/
challenges.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
<?php
session_start();
require_once('./config/connection.php');
if (!isset($_SESSION['SESS_USERNAME']))header("location: index.php");
else
{
$id_member=$_SESSION['SESS_MEMBER_ID'];
$user = mysql_query("SELECT * FROM member where id='$id_member'" );
while ($user_row = mysql_fetch_assoc($user)) $img=$user_row['img'];
$n=0 ;
$qr="SELECT hint FROM challenges ";
$re=mysql_query($qr);
while($r=mysql_fetch_array($re))
{
if ($r[0]!="no hint")
{
$n++;
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Challenges</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" type="image/png" href="favicon.ico">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/challenges.js"></script>
<!-- google recaptcha -->
<script src='https://www.google.com/recaptcha/api.js'></script>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
</head>
<body style="background:#f2f2f2;">
<div class="container" >
<div class="row clearfix">
<div class="col-md-12 column">
<div class="col-md-12 column">
<nav class="navbar navbar-default navbar-inverse navbar-fixed-top" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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="index.php"><span ><img src="img/logo-hack.png" alt="logo" height="25" width="25" class="profile-image img-circle"/>Hack-Zone</span></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li >
<a href="index.php"><span class="glyphicon glyphicon-home">Home</span></a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<?php
if (isset($_SESSION['SESS_USERNAME']))
{
$name=$_SESSION['SESS_USERNAME'];
echo '
<li >
<a href="rules.php"><span class="glyphicon glyphicon-lock" >Rules</span></a>
</li>
<li >
<a href="scoreboard.php"><span class="glyphicon glyphicon-signal">Scoreboard</span></a>
</li>
<li class="active">
<a href="challenges.php"><span class="glyphicon glyphicon-flag">Challenges</span></a>
</li>
<li >
<a href="irc.php"><span class="glyphicon glyphicon-check">Irc</span></a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="'.$img.'" height="20" width="20" class="profile-image img-circle"> '.$name.' <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="profile.php"><i class="fa fa-square"></i> Profile</a></li>
<li class="divider"></li>
<li><a href="signout.php"><i class="fa fa-sign-out"></i> Sign-out</a></li>
</ul>
</li>
<li margin-left:20px;>/<li>';
}
else
echo '
<li >
<a href="scoreboard.php"><span class="glyphicon glyphicon-signal">Scoreboard</span></a>
</li> <li >
<a href="rules.php"><span class="glyphicon glyphicon-lock" >Rules</span></a>
</li>
<li >
<a href="contact.php"><span class="glyphicon glyphicon-comment">Contact</span></a>
</li>
<li >
<a href="sponsors.php"><span class="glyphicon glyphicon-shopping-cart">Sponsors</span></a>
</li>
<li >
<a href="media.php"><span class="glyphicon glyphicon-camera">Media</span></a>
</li>
<li margin-left:10px;>
<a id="modal-signup" href="#modal-container-signup" role="button" class="btn" data-toggle="modal">SIGN UP</a>
</li>
<li margin-right:20px;>
<a id="modal-login" href="#modal-container-login" role="button" class="btn" data-toggle="modal">LOGIN</a>
</li>
<li>/<li>';
?>
</ul>
</div>
</nav>
</div>
</div><br><br><br>
</div>
<!-- dialog flag -->
<div class="modal fade" id="flag_modal" role="dialog" aria-labelledby="signup" aria-hidden="true">
<div class="modal-dialog" >
<div class="modal-content">
<div class="modal-header" style="background-color:#000000;" >
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 style="color:#FFFFFF; " class="modal-title"id="taskname"></h4>
<p style="color:#FFFFFF; " id="taskscore"></p>
</div>
<div class="modal-body">
<p id="taskmiss"></p><br>
<p id="taskhint"></p >
<form class="form-inline" id="form_flag" action="taskinfo.php" method="post">
<div class="form-group">
<input style="width: 400px" name="answer" id="answer" class="form-control" value="" type="text" placeholder="submit flag" />
<input name="taskid" id="taskid" class="form-control" value="O" type="hidden" />
</div>
<div class="form-group">
<button class="btn btn-labeled btn-success" id="btn_flag">Submit</button>
</div>
</form>
<br><div id="div_flag_response" class="alert alert-info alert-dismissable" style="display: none;" >
<i id="flag_response" class="fa fa-coffee"></i>
</div><br>
</div>
</div>
</div>
</div>
<br><br>
<h2>Challenges:</h2>
<div class="panel panel-default target" >
<div class="row clearfix" >
<div class="col-md-2 column">
</div>
<div class="col-md-6 column">
<br><br>
<?php
if (isset($_SESSION['SESS_USERNAME'])) $id_member=$_SESSION['SESS_MEMBER_ID'];
require_once('./config/connection.php');
$catge = mysql_query("SELECT * FROM categories order by id" );
if (mysql_num_rows($catge)==0)
echo "No categories" ;
else
while ($row_catge = mysql_fetch_assoc($catge)) {
$name_categ=$row_catge["name"];
echo '<table>
<tbody><tr>
<td><a class="btn btn-default btn-lg" style="background-color:#000000;height:80px;width:150px;" disabled>
<strong style=" color:#800000;"">'.$name_categ.'</strong>
</a></td>
' ;
$result = mysql_query("SELECT * FROM challenges WHERE categ='$name_categ' order by id" );
if (mysql_num_rows($result)!=0)
while ($row = mysql_fetch_assoc($result)) {
$surname=$row['surname'];
$score=$row['score'];
$categ=$row['categ'];
$id_task=$row['id'];
$miss=$row['miss'];
$hint=$row['hint'];
$dis= mysql_query("SELECT * FROM solved
where team_id='$id_member' AND id_task='$id_task'" );
if (mysql_num_rows($dis)==0) $color="#FFFFFF";
else $color="#008000";
echo '<td><a id="task'.$id_task.'"
class="btn btn-default btn-lg" href="#flag_modal"
onclick="openflag('.$id_task.')" role="button" data-toggle="modal" style="background-color:'.$color.';height:80px;width:150px;">
<strong style="color:#000000;">'.$surname.'</strong>
</a>
</td>';
}mysql_free_result($result);
echo '</tr></tbody>
</table>';
}mysql_free_result($catge);
?>
</div>
<div class="col-md-4 column">
</div>
</div><br><br>
</div>
<br><br>
</div>
</body>
</html>