-
Notifications
You must be signed in to change notification settings - Fork 0
/
defis.php
300 lines (237 loc) · 11.1 KB
/
defis.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
<?php
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
include('assets/php/config.php');
// include("ressources/pop_up_film_information.php");
include("ressources/pop_up_connexion.php");
// include("ressources/pop_up_share.php");
// include('vimeo_setup.php');
if (isset($_POST['send']) && isset($_POST['title']) && isset($_POST['constraints'])) {
$title = $_POST['title'];
if ($title == ' ') {
$message = 'Le nom choisi est invalide.';
} else {
// $title = $_POST['title'];
// $constraints = $_POST['constraints'];
// $requete = "INSERT INTO defis (defi_name, defi_description, defi_timestamp, defi_poster) VALUES ($title, $constraints, NULL, NULL)";
// $stmt=$db->query($requete);
$sql = "INSERT INTO defis (defi_name, defi_description, defi_timestamp, defi_image, defi_user_id, defi_verified, defi_current) VALUES (:title, :constraints, default, NULL, :user, 0, 0)";
$attributes = array(
'title' => addslashes($_POST['title']),
'constraints' => addslashes($_POST['constraints']),
'user' => $_COOKIE['userid']
);
$stmt = $db->prepare($sql);
$stmt->execute($attributes);
header('Location: defis.php?success=true');
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>REAH | Défis</title>
<link rel="stylesheet" href="assets/css/styles.css">
<link rel="stylesheet" href="assets/css/fil_actu.css">
<link rel="stylesheet" href="assets/css/defis.css">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;900&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="assets/css/fullpage.css" />
</head>
<body>
<main class="main_content">
<?php if (isset($message)) {
echo '<p class="message_true_container">' . $message . '</p>';
}
if (isset($_GET['success'])) {
echo '
<p class="message_true_container">
Ton défi a bien été pris en compte !
</p>';
}
?>
<!-- Navigation menu -->
<nav>
<!-- Logo Réah -->
<a href="fil_actu.php" class="reah_logo"></a>
<div class="menu_nav">
<!-- Categories's title -->
<div class="menu_category">
<p class="category_title category_title1" number="1" number1="2">Défis du moment</p>
<p class="category_title category_title2" number="2" number1="1">Défis à découvrir</p>
<div class="red_line underline"></div>
<div class="fb_jsb ai-c category_list">
<p class="category_list_title">Catégories</p>
<div class="category_triangle"></div>
</div>
</div>
<!-- Search bar -->
<form action="search.php" method="GET" class="form_search_bar">
<input class="search_bar" type="text" placeholder="Défis, courts-métrages, utilisateurs..." oninput="searchEngine(this.value)">
</form>
<?php
if (func::checkLoginState($db)) { # If the user is connected
$query = "SELECT * FROM users WHERE user_id = " . $_COOKIE['userid'] . ";";
$stmt = $db->prepare($query);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
echo "<div class='menu_profile'>
<!-- Fil actu icon -->
<form action='fil_actu.php' method='GET'>
<button type='submit' name='accueil' class='fil_actu_icon' value='true'></button>
</form>
<!-- Profile photo -->
<img src='database/profile_pictures/".$row['user_profile_picture']."' class='menu_pp' onclick='toggleBurgerMenu()'>
</div>
</nav>";
} else {
echo "<div class='menu_profile'>
<!-- Fil actu icon -->
<form action='fil_actu.php' method='GET'>
<button type='submit' name='accueil' class='fil_actu_icon' value='true'></button>
</form>
<!-- Profile photo -->
<div class='se-connecter' onclick='redirect(`login.php`)'>
<div class='se-connecter menu_pp_icon' onclick='redirect(`login.php`)' onload='SVGInject(this)'>
</div>
</div>
</nav>";
}
?>
</div>
</nav>
<!-- Category list -->
<div class="category_list_container">
<p class="category_list_category category_list_category1" number="1" number1="2">Défis du moment</p>
<p class="category_list_category category_list_category2" number="2" number1="1">Défis à découvrir</p>
</div>
<!-- Menu -->
<?php
require("ressources/menu.php");
?>
<!-- "Ajout récent" catégory -->
<div class="first_category">
<div class="add_defi_btn_container">
<!-- Category title -->
<h1 id="title1">
<div class="red_line title_line"></div>
<div id='days'></div>
DÉFIS DU MOMENT
<div class='help_icon_container'>
<img src='sources/img/help_icon.png' alt='' class='help_icon'>
<p class='help_message'>La catégorie "Défis du moment" présente les deux défis auxquels tu peux participer. Les défis du moment changent tous les mois.</p>
</div>
</h1>
<!-- Add defi btn -->
<?php
if (func::checkLoginState($db)) { # If the user is connected
echo '
<div class="btn add_defi_btn" onclick="popupAddDefi()">
<img class="add_defi_icon" src="sources/img/add_defi_icon.svg" alt="">
Proposer un défi
</div>';
} else { # If the user is an asshole
echo '
<div class="btn add_defi_btn" onclick="popupConnexion()">
<img class="add_defi_icon" src="sources/img/add_defi_icon.svg" alt="">
Proposer un défi
</div>';
}
?>
</div>
<!-- Challenges container -->
<div class="defi_container ">
<?php
$query = "SELECT * FROM defis WHERE defi_verified='1' AND defi_current='1'";
$stmt = $db->prepare($query);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row) {
echo '
<a href="defi_details.php?defi=' . $row['defi_id'] . '" class="defi_content">
<img src="database/defis_img/'.$row['defi_image'].'" alt="" class="defi_img defi1_img">
<p class="defi_time">Temps restant : <span id="time" time='.$row['defi_date_end'].'></span></p>
</a>';
}
?>
<!-- -->
</div>
</div>
<div class="second_category" id="category">
<!-- prev arrow -->
<div class="arrow_prev_container fp-controlArrow fp-prev">
</div>
<!-- Category content -->
<div class="category_content">
<!-- Category title -->
<h1 id="title2">
<div class="red_line title_line"></div>
À DÉCOUVRIR
<div class='help_icon_container'>
<img src='sources/img/help_icon.png' alt='' class='help_icon'>
<p class='help_message'>La catégorie "À découvrir" présente tous les défis de REAH.</p>
</div>
</h1>
<div class="defi_pop_container ">
<?php
$query = "SELECT * FROM defis WHERE defi_verified='1' ORDER BY RAND()";
$stmt = $db->prepare($query);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row) {
echo '
<a href="defi_details.php?defi=' . $row['defi_id'] . '" class="defi_pop_content">
<img src="database/defis_img/'.$row['defi_image'].'" alt="" class="defi_img defi1_img">
</a>';
}
?>
<!-- <p class="defi_pop_title">'. strtoupper($row['defi_name']) .'</p> -->
</div>
</div>
<!-- next arrow -->
<div class="arrow_next_container fp-controlArrow fp-next">
</div>
</div>
<?php
require("ressources/footer.php");
?>
</main>
<!-- Pop up add defi -->
<div class="dark_filter" onclick="closePopupAddDefi()"></div>
<div class="pop_up_container add_defi_container">
<form action="defis.php" method=POST>
<div class="pop_up_header">
<h2>Proposer un défi</h2>
<img src='sources/img/close_icon.svg' class='close_icon' alt='' onclick="closePopupAddDefi()">
</div>
<div class="pop_up_text">
<!-- Inputs -->
<div class="add_defi_input">
<div class="input_container">
<label for="title">
<span>Titre</span>
<input type="text" class="input_connexion" id="title" name="title" required>
</label>
</div>
<div class="input_container input_constraints_container">
<label for="constraints">
<span>Contraintes</span>
<textarea class="input_connexion input_constraints" id="constraints" name="constraints" cols="30" rows="10" required></textarea>
</label>
</div>
</div>
</div>
<input type="submit" class="pop_up_btn btn send_btn" name="send" value="Envoyer"></input>
</form>
</div>
<?php
?>
<script type="text/javascript" src="assets/js/libraries/jquery/jquery.min.js"></script>
<!-- <script src="assets/js/app.js"></script> -->
<!-- <script src="assets/js/register.js"></script> -->
<script src="assets/js/defis.js"></script>
<script src="assets/js/app2.js"></script>
<script src="assets/js/functions.js"></script>
</body>
</html>