-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmembers.php
executable file
·132 lines (108 loc) · 4.41 KB
/
members.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
<?php // Example 26-9: members.php
require_once 'header.php';
error_reporting(0);
$ip = $_REQUEST['REMOTE_ADDR']; // the IP address to query
$query = @unserialize(file_get_contents('http://ip-api.com/php/'.$ip));
if (!$loggedin) die();
echo "<div class='container'>";
if (isset($_GET['view']))
{
$view = sanitizeString($_GET['view']);
if ($view == $user) $name = "Your";
else $name = "$view's";
echo "<h3>$name Profile</h3><form method = 'post' class='form-horizontal'><div class='row'>";
?>
<div id ="indexProfile"><div class="col-sm-4" style = 'color: #2d94b5;'>
<?php
showProfile($view);
if($query && $query['status'] == 'success') {
echo $query['country'].', '.$query['city'];
} else {
echo 'Location unavailable';
}
$date = date('Y-m-d h:i:s');
if(isset($_POST['submit']) && isset($_SESSION['lat']) && isset($_SESSION['lat']))
{
$lat = $_SESSION['lat'];
$long = $_SESSION['long'];
$shareLocation = $_POST['shareLocation'];
queryMysql("INSERT INTO track_location VALUES ('$view', '$long', '$lat', '$date' , '$shareLocation')");
}if(isset($_SESSION['lat']) && isset($_SESSION['lat'])){
$lat = $_SESSION['lat'];
$long = $_SESSION['long'];
$shareLocation = '1';
queryMysql("INSERT INTO track_location VALUES ('$view', '$long', '$lat', '$date' , '$shareLocation')");
}
echo "<div class='form-group'>".
"<div class='col-sm-10'>" .
"<a class='btn btn-info' href='messages.php?view=$view'>" .
"<span class='glyphicon glyphicon-envelope' style='margin-right: 0.5em'></span>View $name messages</a><br><br>" .
"</div>".
"</div></div></div><div class='col-sm-8'>".
"<div id=\"location\" style = 'color: #2d94b5;'><b>Current Location: </b>" .
"<div class='radio-inline'>".
"<label><input type='radio' name='shareLocation' value= '0' >Public</label>".
"</div>".
"<div class='radio-inline'>".
"<label><input type='radio' name='shareLocation' value= '1' checked='checked' >Private </label>".
"</div><input type='submit' name='submit' class='btn btn-default' value='Share'/></div>".
"<div id = \"showMap\" style= \"width:100%;height:500px\"></div></div>";
die("</div></div></form></body></html>");
}
if (isset($_GET['add']))
{
$add = sanitizeString($_GET['add']);
$result = queryMysql("SELECT * FROM friends WHERE user='$add' AND friend='$user'");
if (!$result->num_rows)
queryMysql("INSERT INTO friends VALUES ('$add', '$user')");
}
elseif (isset($_GET['remove']))
{
$remove = sanitizeString($_GET['remove']);
queryMysql("DELETE FROM friends WHERE user='$remove' AND friend='$user'");
}
$result = queryMysql("SELECT user FROM members ORDER BY user");
$num = $result->num_rows;
echo "<div class='row'><h3>Other Members</h3><div class='mainList'><ul>";
echo "<div id =id=\"otherMember\" ><div class='col-sm-10'>";
for ($j = 0 ; $j < $num ; ++$j)
{
$row = $result->fetch_array(MYSQLI_ASSOC);
if ($row['user'] == $user) continue;
echo "<li><a href='members.php?view=" .
$row['user'] . "'>" . $row['user'] . "</a>";
$follow = "follow";
$result1 = queryMysql("SELECT * FROM friends WHERE
user='" . $row['user'] . "' AND friend='$user'");
$t1 = $result1->num_rows;
$result1 = queryMysql("SELECT * FROM friends WHERE
user='$user' AND friend='" . $row['user'] . "'");
$t2 = $result1->num_rows;
if (($t1 + $t2) > 1) echo " ↔ is a mutual friend";
elseif ($t1) echo " ← you are following";
elseif ($t2) { echo " → is following you";
$follow = "recip"; }
if (!$t1) echo " [<a href='members.php?add=" .$row['user'] . "'>$follow</a>]";
else echo " [<a href='members.php?remove=".$row['user'] . "'>drop</a>]";
}
echo "</ul></div>" .
"<div class='col-sm-8'><div id =\"memberMap\" style= \"width:100%;height:500px\">" .
"</div></div></div>";
?>
</div></div></div>
</body>
<script type="text/javascript">
function getCurrentPosition() {
if (geoPosition.init()) {
geoPosition.getCurrentPosition(successCallback, failPosition, {
enableHighAccuracy: true,
timeout: 5 * 60 * 10000,
maximumAge: 60 * 000
//positionOptions.enableHighAccuracy: false
});
} else {
window.onload = ipLocation();
}
}
</script>
</html>