-
Notifications
You must be signed in to change notification settings - Fork 1
/
people.php
218 lines (197 loc) · 10.1 KB
/
people.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
<?php
include "db.php";
session_start();
$friends = DB::query("SELECT * FROM users WHERE id != %s", $_GET["id"]);
$me = $_GET["id"];
$f = [];
$myLikes = DB::query("SELECT DISTINCT genre FROM likes WHERE who_likes=%s", $_GET["id"]);
foreach ($myLikes as $elt) {
array_push($f, $elt["genre"]);
}
$myLikes = DB::query("SELECT DISTINCT artist FROM likes WHERE who_likes=%s", $_GET["id"]);
foreach ($myLikes as $elt) {
array_push($f, $elt["artist"]);
}
$g = DB::query("SELECT DISTINCT who_likes FROM likes WHERE (genre IN %ls OR artist IN %ls) AND who_likes != %s", $f, $f, $_GET["id"]);
$k = [];
foreach ($g as $h) {
array_push($k, DB::queryFirstRow("SELECT * FROM users WHERE id=%s", $h["who_likes"]));
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<link rel="apple-touch-icon" sizes="180x180" href="./apple-touch-icon.png?v=RyMwR3jE6k">
<link rel="icon" type="image/png" sizes="32x32" href="./favicon-32x32.png?v=RyMwR3jE6k">
<link rel="icon" type="image/png" sizes="194x194" href="./favicon-194x194.png?v=RyMwR3jE6k">
<link rel="icon" type="image/png" sizes="192x192" href="./android-chrome-192x192.png?v=RyMwR3jE6k">
<link rel="icon" type="image/png" sizes="16x16" href="./favicon-16x16.png?v=RyMwR3jE6k">
<link rel="manifest" href="./manifest.json?v=RyMwR3jE6k">
<link rel="mask-icon" href="./safari-pinned-tab.svg?v=RyMwR3jE6k" color="#ef394f">
<link rel="shortcut icon" href="./favicon.ico?v=RyMwR3jE6k">
<meta name="apple-mobile-web-app-title" content="Capella">
<meta name="application-name" content="Capella">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-TileImage" content="./mstile-144x144.png?v=RyMwR3jE6k">
<meta name="theme-color" content="#292929">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/flickity.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link rel="stylesheet" href="https://anandchowdhary.github.io/ionicons-3-cdn/icons.css" integrity="sha384-+iqgM+tGle5wS+uPwXzIjZS5v6VkqCUV7YQ/e/clzRHAxYbzpUJ+nldylmtBWCP0" crossorigin="anonymous">
<link rel="stylesheet" href="default.css">
<title>Capella</title>
<meta name="description" content="...">
<meta name="twitter:site" content="@AnandChowdhary">
<link rel="author" href="//plus.google.com/+AnandChowdhary">
<meta property="og:author" content="//facebook.com/AnandChowdhary">
<script> var host="capella.tk"; host == window.location.host && "https:" != window.location.protocol && (window.location.protocol = "https"); </script>
</head>
<body>
<a href="#content" class="sr-only sr-only-focusable">Skip to main content</a>
<header id="masthead">
<div class="title">People</div>
<button onclick='emergency();' class="btn btn-outline-danger top-right-button"><i class="ion ion-ios-alert"></i></button>
</header>
<main id="content">
<section>
<p class="mb-4">Discover new people with matching music tastes as you.</p>
<!-- <div class="main-carousel" data-flickity='{ "cellAlign": "left", "contain": true }'> -->
<div class="row">
<?php foreach ($k as $friend) { if (!DB::queryFirstRow("SELECT * FROM friends WHERE friend1=%s AND friend2=%s OR friend1=%s AND friend2=%s", $_GET["id"], $friend["id"], $friend["id"], $_GET["id"])) { ?>
<!-- <div class="carousel-cell">
<img onclick="getUserLocation('<?php echo $friend["id"]; ?>');" alt="" src="<?php echo $friend["avatar"]; ?>" class="rounded-circle">
<div class="text-center mt-2"><?php echo $friend["name"]; ?></div>
</div> -->
<div class="col-4 mb-4">
<a href="profile.php?id=<?php echo $me; ?>&user=<?php echo $friend["id"]; ?>"><img onclick="$('.friend-card').slideToggle();" alt="" src="<?php echo $friend["avatar"]; ?>" class="rounded-circle"></a>
<div class="text-center mt-2"><?php echo $friend["name"]; ?></div>
</div>
<?php } } ?>
</div>
</section>
</main>
<footer id="colophon">
<div class="container-fluid">
<div class="row">
<a href="./?id=<?php echo $_GET["id"]; ?>" class="col">
<i class="ion ion-ios-home"></i>
<div class="label">Home</div>
</a>
<a href="./taste.php?id=<?php echo $_GET["id"]; ?>" class="col">
<i class="ion ion-ios-musical-notes"></i>
<div class="label">Taste</div>
</a>
<a href="./search.php?id=<?php echo $_GET["id"]; ?>" class="col">
<i class="ion ion-ios-search"></i>
<div class="label">Search</div>
</a>
<a href="./people.php?id=<?php echo $_GET["id"]; ?>" class="col active">
<i class="ion ion-ios-people"></i>
<div class="label">People</div>
</a>
<a href="./settings.php?id=<?php echo $_GET["id"]; ?>" class="col">
<i class="ion ion-ios-settings"></i>
<div class="label">Settings</div>
</a>
</div>
</div>
</footer>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal2" hidden>
Launch demo modal
</button>
<div class="modal fade" id="exampleModal2" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel2" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content bg-dark">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel2"><i class="ion ion-md-alert mr-2"></i>Emergency</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Do you need immediate assistance? Select one of the options below:</p>
<button class="btn btn-block btn-lg btn-secondary mr-2" data-dismiss="modal" onclick="<?php foreach ($friends as $friend) { if ($friend["id"] != $_GET["id"]) { echo "pingUser('" . $friend["id"] . "', 'emergency');"; } } ?>"><i class="ion ion-md-map mr-2"></i>Share Location with Friends</button>
<a href="tel:112" target="_blank" class="btn btn-block btn-lg lookingMap btn-danger"><i class="ion ion-ios-call mr-2"></i>Call Emergency Services</a>
</div>
</div>
</div>
</div>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" hidden>
Launch demo modal
</button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content bg-dark">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"><i class="ion ion-md-alert mr-2"></i><span class="lookingName"></span> is searching for you</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p><?php echo DB::queryFirstRow("SELECT name FROM users WHERE id=%s", $me)["name"]; ?>, your friend <span class="lookingName"></span> is looking for you. If you're lost, you can click on "Navigate" and we'll take you to <span class="lookingName"></span>.</p>
<img alt="" class="lookingImg">
</div>
<div class="modal-footer">
<a href="tel:+31644691056" class="btn btn-secondary mr-2" data-dismiss="modal"><i class="ion ion-ios-call mr-2"></i>Call</a>
<a href="#" target="_blank" class="btn lookingMap btn-danger"><i class="ion ion-md-map mr-2"></i>Navigate</a>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<script src="https://unpkg.com/[email protected]/dist/flickity.pkgd.min.js"></script>
<script>
$(function() {
if (navigator.geolocation) {
function doFunction() {
navigator.geolocation.getCurrentPosition(function(position) {
var $cords = JSON.stringify([position.coords.latitude, position.coords.longitude]);
$.post("savelocation.php", {
cords: $cords,
id: <?php echo $_GET["id"]; ?>
}, function(response) {
response = JSON.parse(response);
if (response.isSomeoneLookingForMe == 1) {
console.log(response);
$('[data-target="#exampleModal"]').click();
$(".lookingName").text(response.who_is_looking_name);
$(".lookingImg").attr("src", "https://maps.googleapis.com/maps/api/staticmap?zoom=18&size=400x250&maptype=roadmap&markers=" + JSON.parse(response.location)[0] + "," + JSON.parse(response.location)[1] + "&key=AIzaSyCuiZevIb1G87KAoLRSECEdWNBQ06JCMjU");
$(".lookingMap").attr("href", "http://maps.google.com/maps?f=d&daddr=" + (JSON.parse(response.location)[0]).toFixed(9) + "," + (JSON.parse(response.location)[1]).toFixed(9));
window.navigator.vibrate(3000);
if (response.need_help != null) {
console.log("HELP MESSAGE");
$(".lookingName").eq(1).parent().html('Your friend, ' + response.who_is_looking_name + ' needs your immediate assistance. Reach his location ASAP or contact him immediately.');
$(".lookingName").first().parent().html('<i class="ion ion-md-alert mr-2"></i>' + response.who_is_looking_name + ' is in an emergency!');
}
} else {
console.log("We're good to go");
}
})
});
}
doFunction();
setInterval(function() {
doFunction();
}, 5000);
}
});
function pingUser(user, type) {
if (!type) { type = null }
$("#pingText").text("Pinging...");
$("#pingText").css("opacity", 0.5);
$.get("pingme.php?id=<?php echo $_GET["id"]; ?>&user=" + user + "&type=" + type, function() {
$("#pingText").text("Ping");
$("#pingText").css("opacity", 1);
});
}
function emergency() {
$('[data-target="#exampleModal2"]').click();
}
</script>
</body>
</html>