-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatches.php
373 lines (349 loc) · 17.9 KB
/
matches.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
<?php
// Start Session
session_start();
if(isset($_SESSION['email'])) {
$name = $_SESSION['name'];
$email = $_SESSION['email'];
$status = $_SESSION['status'];
}
include './config/conn.php';
if($name == "" || $email == "" || $status != "logged in")
{
header("Location: ./index.php");
exit();
}
$path = "./images/user_images/";
$type = "profile";
$stmt_profile = $conn->prepare("SELECT * FROM users WHERE name=:name");
$stmt_profile->bindValue(":name", $name);
// initialise an array for the results
$user = array();
if ($stmt_profile->execute()) {
while ($row = $stmt_profile->fetch(PDO::FETCH_ASSOC)) {
$user[] = $row;
$full_name = $row['fullname'];
$user_name = $row['name'];
$user_dob = $row['dateofbirth'];
$user_bio = $row['bio'];
$user_gender = $row['gender'];
$user_preference = $row['preference'];
$user_city = $row['city'];
$user_country = $row['country'];
$user_loginstatus = $row['loginstatus'];
$user_lastseen = $row['lastseen'];
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Matcha - Matches</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="./assets/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="./assets/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="./assets/css/animate.css">
<link rel="stylesheet" type="text/css" href="./assets/css/font.css">
<link rel="stylesheet" type="text/css" href="./assets/css/li-scroller.css">
<link rel="stylesheet" type="text/css" href="./assets/css/slick.css">
<link rel="stylesheet" type="text/css" href="./assets/css/jquery.fancybox.css">
<link rel="stylesheet" type="text/css" href="./assets/css/theme.css">
<link rel="stylesheet" type="text/css" href="./assets/css/style.css">
<!--[if lt IE 9]>
<script src="../assets/js/html5shiv.min.js"></script>
<script src="../assets/js/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div id="preloader">
<div id="status"> </div>
</div>
<a class="scrollToTop" href="#"><i class="fa fa-angle-up"></i></a>
<div class="container">
<header id="header">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="header_top">
<div class="header_top_left">
<ul class="top_nav">
<li><a href="./index.php">Home</a></li>
<li><div id="msg"><?php include './inc/newmsgs.php';?></div></li>
<li><a href="./updateprofile.php">Edit Profile</a></li>
<li><a href="./notifications.php"><div id="note"><?php include './inc/note.php';?></div></a></li>
<li><a href="./inc/logout.php">Logout</a></li>
</ul>
</div>
<div class="header_top_right">
<a href="./inc/logout.php"><p>Logout</p></a>
</div>
</div>
</div>
</div>
</header>
<section id="contentSection">
<h2>Matches</h2>
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="left_content">
<div style="height:350px; width:100%; overflow: auto; border:10px solid;">
<?php
$sortby = "";
$filtpop = "";
$city = "";
$interests = "";
$age = "";
$sortby = $_GET['sortby'];
$filtpop = $_GET['filtpop'];
$city = $_GET['city'];
$interests = $_GET['interests'];
$age = $_GET['age'];
//if(!($_GET['sortby'] == "" && $_GET['filtpop'] == "" && $_GET['city'] == "" && $_GET['interests'] == "" && $_GET['age'] == ""))
if(!($sortby == "" && $filtpop == "" && $city == "" && $interests == "" && $age == ""))
{
$sortby = $_GET['sortby'];
$filtpop = $_GET['filtpop'];
$city = $_GET['city'];
$interests = $_GET['interests'];
$age = $_GET['age'];
if ($sortby == ""){
//echo "No sort </br>";
//echo "sort:" . $sortby . "</br>";
//echo "filtpop:" . $filtpop . "</br>";
//echo "city:" . $city . "</br>";
//echo "interests:" . $interests . "</br>";
//echo "age:" . $age . "</br>";
$stmt_matches = $conn->prepare("SELECT * FROM users WHERE country=:country");
$stmt_matches->bindValue(":country", $user_country);
} elseif($sortby !== ""){
//echo "Sort </br>";
//echo "sort:" . $sortby . "</br>";
//echo "filtpop:" . $filtpop . "</br>";
//echo "city:" . $city . "</br>";
//echo "interests:" . $interests . "</br>";
//echo "age:" . $age . "</br>";
if($sortby == "dateofbirth"){
$stmt_matches = $conn->prepare("SELECT * FROM users WHERE country=:country ORDER BY dateofbirth");
}else if($sortby == "city"){
$stmt_matches = $conn->prepare("SELECT * FROM users WHERE country=:country ORDER BY city");
}else{
$stmt_matches = $conn->prepare("SELECT * FROM users WHERE country=:country ORDER BY rating");
}
$stmt_matches->bindValue(":country", $user_country);
} else {
$stmt_matches = $conn->prepare("SELECT * FROM users WHERE country=:country");
$stmt_matches->bindValue(":country", $user_country);
}
if ($stmt_matches->execute()) {
while ($row = $stmt_matches->fetch(PDO::FETCH_ASSOC)) {
$match_id = $row['id'];
$matchfull_name = $row['fullname'];
$match_name = $row['name'];
$match_dob = $row['dateofbirth'];
$match_bio = $row['bio'];
$match_rating = $row['rating'];
$match_gender = $row['gender'];
$match_interests = $row['interests'];
$match_preference = $row['preference'];
$match_city = $row['city'];
$match_country = $row['country'];
$match_loginstatus = $row['loginstatus'];
$match_lastseen = $row['lastseen'];
$path = "./images/user_images/";
$type = "profile";
$stmt_notificationprofilephoto = $conn->prepare("SELECT * FROM images WHERE image_creator=:image_creator AND image_type=:image_type ORDER BY image_timestamp DESC");
$stmt_notificationprofilephoto->bindValue(":image_creator", $match_name);
$stmt_notificationprofilephoto->bindValue(":image_type", $type);
// initialise an array for the results
$user_image = array();
if ($stmt_notificationprofilephoto->execute()) {
while ($row = $stmt_notificationprofilephoto->fetch(PDO::FETCH_ASSOC)) {
$user_image[] = $row;
$image_url = $row['image_name'];
$url = $path . $image_url;
}
}
if ($match_dob != ""){
$birthDate = explode("-", $match_dob);
$user_age = (date("md", date("U", mktime(0, 0, 0, $birthDate[1], $birthDate[2], $birthDate[0]))) > date("md")
? ((date("Y") - $birthDate[0]) - 1)
: (date("Y") - $birthDate[0]));
}
if ($filtpop != ""){
if ($filtpop == "newbie") {
$user_rating = 0;
$user_rating1 = 25;
} else if ($filtpop = "wildcard") {
$user_rating = 25;
$user_rating1 = 100;
} else if ($filtpop = "coolkid") {
$user_rating = 100;
$user_rating1 = 1000;
} else if ($filtpop = "prom") {
$user_rating = 1000;
$user_rating1 = 10000;
}
}
//strstr($the_string, $the_word)
//strstr($match_interests, $interests)
//strpos($interests, $match_interests)
$pos = strpos($match_interests, $interests);
if ($filtpop != "" && (($user_rating > $match_rating) && ($match_rating < $user_rating1))){
$search_pop = '%' . $filtpop . '%';
} else if ($city != "" && $match_city != $city){
$search_city = '%' . $city . '%';
} else if ($interests != "" && !($pos !== FALSE)){
$search_interests = '%' . $interests . '%';
} else if ($age != "" && $user_age != $age){
$search_age = '%' . $age . '%';
} else {
if ($user_preference == "undefined"){
echo '
<div class="media"> <a href="./profile.php?profile=' . $match_name . '" class="media-left"> <img src=" ' . $url . '" alt=""> </a>
<div class="media-body"> <a href="./profile.php?profile=' . $match_name . '" class="catg_title"><h6>' . $match_name . ' is a potential connection for you!</a></h6><a href="./profile.php?profile=' . $match_name . '" ><h2>View ' . $match_name . '</h2></a></div>
</div>
';
}else{
if ($user_preference == $match_gender && ($match_preference == "undefined" || $match_preference == $user_gender)){
echo '
<div class="media"> <a href="./profile.php?profile=' . $match_name . '" class="media-left"> <img src=" ' . $url . '" alt=""> </a>
<div class="media-body"> <a href="./profile.php?profile=' . $match_name . '" class="catg_title"><h6>' . $match_name . ' is a potential connection for you!</a></h6><a href="./profile.php?profile=' . $match_name . '" ><h2>View ' . $match_name . '</h2></a></div>
</div>
';
}
}
}
}
}
}else{
$stmt_matches = $conn->prepare("SELECT * FROM users WHERE city=:city AND country=:country");
$stmt_matches->bindValue(":city", $user_city);
$stmt_matches->bindValue(":country", $user_country);
if ($stmt_matches->execute()) {
while ($row = $stmt_matches->fetch(PDO::FETCH_ASSOC)) {
$match_id = $row['id'];
$matchfull_name = $row['fullname'];
$match_name = $row['name'];
$match_dob = $row['dateofbirth'];
$match_bio = $row['bio'];
$match_gender = $row['gender'];
$match_preference = $row['preference'];
$match_city = $row['city'];
$match_country = $row['country'];
$match_loginstatus = $row['loginstatus'];
$match_lastseen = $row['lastseen'];
$path = "./images/user_images/";
$type = "profile";
$stmt_notificationprofilephoto = $conn->prepare("SELECT * FROM images WHERE image_creator=:image_creator AND image_type=:image_type ORDER BY image_timestamp DESC");
$stmt_notificationprofilephoto->bindValue(":image_creator", $match_name);
$stmt_notificationprofilephoto->bindValue(":image_type", $type);
// initialise an array for the results
$user_image = array();
if ($stmt_notificationprofilephoto->execute()) {
while ($row = $stmt_notificationprofilephoto->fetch(PDO::FETCH_ASSOC)) {
$user_image[] = $row;
$image_url = $row['image_name'];
$url = $path . $image_url;
}
}
if ($match_dob != ""){
//date is in yyyy/mm/dd format;
//explode the date to get month, day and year
$birthDate = explode("-", $user_dob);
//get age from date or birthdate
$age = (date("md", date("U", mktime(0, 0, 0, $birthDate[1], $birthDate[2], $birthDate[0]))) > date("md")
? ((date("Y") - $birthDate[0]) - 1)
: (date("Y") - $birthDate[0]));
$user_age = $age;
}
if ($match_name == $name){
} else if ($match_city != $user_city){
} else if ($match_country != $user_country){
}
else {
if ($user_preference == "undefined"){
echo '
<div class="media"> <a href="./profile.php?profile=' . $match_name . '" class="media-left"> <img src=" ' . $url . '" alt=""> </a>
<div class="media-body"> <a href="./profile.php?profile=' . $match_name . '" class="catg_title"><h6>' . $match_name . ' is a potential connection for you!</a></h6><a href="./profile.php?profile=' . $match_name . '" ><h2>View ' . $match_name . '</h2></a></div>
</div>
';
}else{
if ($user_preference == $match_gender && ($match_preference == "undefined" || $match_preference == $user_gender)){
echo '
<div class="media"> <a href="./profile.php?profile=' . $match_name . '" class="media-left"> <img src=" ' . $url . '" alt=""> </a>
<div class="media-body"> <a href="./profile.php?profile=' . $match_name . '" class="catg_title"><h6>' . $match_name . ' is a potential connection for you!</a></h6><a href="./profile.php?profile=' . $match_name . '" ><h2>View ' . $match_name . '</h2></a></div>
</div>
';
}
}
}
}
}
}
?>
</div>
<div class="contact_area">
<h2>Quick Match Search</h2>
<form action="search.php" method="post" class="contact_form">
<div class="form-group">
<label for="">Sort By:</label>
<select name="sort">
<option value="">Sort By?</option>
<option value="dateofbirth">Age</option>
<option value="city">Location</option>
<option value="rating">Popularity</option>
</select>
</div>
<p><b>Filter Search:</b></p>
<div class="form-group">
<label for="">Filter By Popularity:</label>
<select name="filtpop">
<option value="">Filter By Popularity?</option>
<option value="newbie">Newbies</option>
<option value="wildcard">Wildcards</option>
<option value="coolkid">Cool Kids</option>
<option value="prom">Prom Kings/Queens</option>
</select>
</div>
<div class="form-group">
<label for="">City</label>
<input type="text" name="city" class="form-control" placeholder="Enter prefered city."/>
</div>
<div class="form-group">
<label for="">Interests</label>
<input type="text" name="interests" class="form-control" placeholder="Enter prefered interests."/>
</div>
<div class="form-group">
<label for="">Age</label>
<input type="number" name="age" class="form-control" placeholder="Enter prefered age."/>
</div>
<div class="form-group">
<input type="submit" name="btnSearch" class="btn btn-primary" value="Search"/>
</div>
</form>
</div>
</div>
</div>
</section>
<footer id="footer">
<div class="footer_bottom">
<p class="copyright">Copyright © 2017 <a href="index.php">Matcha</a></p>
<p class="developer">Developed By kmuvezwa</p>
</div>
</footer>
</div>
<script src="./assets/js/jquery.min.js"></script>
<script src="./assets/js/wow.min.js"></script>
<script src="./assets/js/bootstrap.min.js"></script>
<script src="./assets/js/slick.min.js"></script>
<script src="./assets/js/jquery.li-scroller.1.0.js"></script>
<script src="./assets/js/jquery.newsTicker.min.js"></script>
<script src="./assets/js/jquery.fancybox.pack.js"></script>
<script src="./assets/js/custom.js"></script>
<script>
setInterval(function(){
$('#msg').load("./inc/newmsgs.php").fadeIn("slow");
$('#note').load("./inc/notify.php").fadeIn("slow");
}, 8000);
</script>
</body>
</html>