-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
165 lines (132 loc) · 6.16 KB
/
search.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
<?php
include('assets/php/config.php');
include('vimeo_setup.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>REAH | Résultats de recherche</title>
<link rel="stylesheet" href="assets/css/styles.css">
<link rel="stylesheet" href="assets/css/fil_actu.css">
<link rel="stylesheet" href="assets/css/fil_actu2.css">
<link rel="stylesheet" href="assets/css/saved.css">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;900&display=swap"
rel="stylesheet">
<script src="assets/js/libraries/svg-inject-master/src/svg-inject.js"></script>
<script src="https://player.vimeo.com/api/player.js"></script>
</head>
<body>
<?php
// include("ressources/pop_up_film_information.php");
include("ressources/pop_up_connexion.php");
// include("ressources/pop_up_share.php");
?>
<!-- Navigation menu -->
<nav class="menu_nav">
<!-- Logo Réah -->
<a href="fil_actu.php" class="reah_logo"></a>
<!-- Search bar -->
<form action="search.php" method="GET" class="form_search_bar">
<input class="search_bar" name="research" 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>
<!-- Defi icon -->
<a href='defis.php' class='defi_icon'></a>
<!-- Profile photo -->
<img src='database/profile_pictures/".$row['user_profile_picture']."' class='menu_pp' onclick='toggleBurgerMenu()'>
</div>";
} 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>
<!-- Defi icon -->
<a href='defis.php' class='defi_icon'></a>
<!-- Profile photo -->
<div class='se-connecter menu_pp_icon' onclick='redirect(`login.php`)' onload='SVGInject(this)'>
</div>";
}
?>
</nav>
<!-- Menu -->
<?php
require("ressources/menu.php");
?>
<main class="main_content">
<?php
$research = htmlspecialchars($_GET['research']);
# Non définitif, la requête finale incluera l'ensemble des tables.
# Se référer au modèle conceptuel sur le drive
$query = "SELECT * FROM defis WHERE defi_name LIKE '%$research%' AND defi_verified = '1';";
$stmt = $db->prepare($query);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if(count($rows) > 0 ){
echo '<h2 class="omg_im_centered">Défis</h2>';
foreach($rows as $row){
echo '<a href="defi_details.php?defi='.$row['defi_id'].'" class="result omg_im_centered">
<img src="database/defis_img/'.$row['defi_image'].'" alt="" class="defi_img">
<section>
<h4>'.$row['defi_name'].'</h4>
</section>
</a>';
}
}
$query = "SELECT * FROM videos, users WHERE video_title LIKE '%$research%' AND video_user_id = user_id;";
$stmt = $db->prepare($query);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if(count($rows) > 0 ){
echo '<h2 class="omg_im_centered" style="margin-top: 50px;">Courts-métrages</h2>';
foreach($rows as $row){
echo '<a href="profil.php?id='.$row['video_user_id'].'" class="result omg_im_centered">
<iframe src="https://player.vimeo.com/video/'.$row['video_url'].'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen id="video_'.$row['video_id'].'"></iframe>
<section>
<h4>'.$row['video_title'].'</h4>
<p class="video_synopsis">'.nl2br($row['video_synopsis']).'</p>
<p> Réalisé par '.$row['user_username'].'</p>
</section>
</a>';
}
}
$query = "SELECT * FROM users WHERE user_username LIKE '%$research%';";
$stmt = $db->prepare($query);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if(count($rows) > 0 ){
echo' <h2 class="omg_im_centered" style="margin-top: 50px;">Membres</h2>';
foreach($rows as $row){
echo '<a href="profil.php?id='.$row['user_id'].'" class="result omg_im_centered">
<img src="database/profile_pictures/'.$row["user_profile_picture"] . '" alt="" class="profile_picture">
<section>
<h4>'.$row['user_username'].'</h4>
<p class="profile_description">'.$row['user_name'].'</p>
</section>
</a>';
};
}
?>
</main>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script src="assets/js/app2.js"></script>
<script src="assets/js/functions.js"></script>
<script>
if($('.main_content').text().length <= '48'){
$('.main_content').append("<p class='void'>Aucun résultat trouvé.</p>");
}
</script>
</body>
</html>