-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
123 lines (94 loc) · 4.56 KB
/
index.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
<?php
include ('BlurModule.php');
include ('GetDistanceModule.php');
$completeMessage = 100;
$partialMessage = 10000;
$receiveMessage = 15000;
$db = new PDO('mysql:host=localhost;dbname=id19729685_messages' ,'id19729685_root','password');
if (isset($_POST['latitude']) AND isset($_POST['longitude']) AND !empty($_POST['latitude']) AND !empty($_POST['longitude']) )
{
$lat = $_POST['latitude'];
$long = $_POST['longitude'];
}
if (isset($_POST['pseudo']) AND isset($_POST['usermsg']) AND !empty($_POST['pseudo']) AND !empty($_POST['usermsg']) )
{
$username = htmlspecialchars( $_POST['pseudo']);
$message = htmlspecialchars( $_POST['usermsg']);
if (isset($_POST['latitude']) AND isset($_POST['longitude']) AND !empty($_POST['latitude']) AND !empty($_POST['longitude']))
{
$insertmsg = $db->prepare("INSERT INTO messages(pseudo, message, latitude, longitude) VALUES(?,?,?,?)");
$insertmsg->execute(array($username, $message, $lat, $long));
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Proximity Chat</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="./stylesheet.css" rel="stylesheet" />
</head>
<body>
<h1><span class="span-title">Proximity Chat</span></h1>
<p>This chat is a WIP, for the moment you can chat on it, but it will have some cool functionalities based on your location, stay tuned !!!</p>
<a href="https://clerical-chock.000webhostapp.com/admin_stuff/admin.php" >le site admin pour ceux qui peuvent</a></br>
<a href="https://www.poemes.co/le-galet.html" >poeme du galet.</a></br></br>
<form class="input-form" method="post" name="message" action="">
<input autocomplete="off" id="username-input" name="pseudo" type="text" size="63" placeholder="PSEUDO" value="<?php if(isset($username)) { echo $username; } ?>" /><br />
<input autocomplete="off" id="message-input" name="usermsg" type="text" size="63" placeholder="MESSAGE" value=""/><br/>
<input name="latitude" type="hidden" id="latitudetemp" value=""/>
<input name="longitude" type="hidden" id="longitudetemp" value=""/>
<input id="send-button" type="submit" name="submitbtn" value="Send"/>
</form>
<form class="reload-form" method="post" id="reload" name="status" action="">
<input name="pseudo" type="hidden" size="63" value="<?php if(isset($username)) { echo $username; } ?>" /><br />
<input name="latitude" type="hidden" id="test2" value=""/>
<input name="longitude" type="hidden" id="test3" value=""/>
</form>
<div class="messages-display">
<?php
$allmsg = $db->query('SELECT * FROM messages ORDER BY id DESC');
if (isset($lat) AND isset($long) AND !empty($lat) AND !empty($long))
{
while($msg = $allmsg->fetch())
{
$factor = 0;
$distance = getDistance($msg['latitude'], $msg['longitude'], $lat, $long);
if ($distance > $receiveMessage)
{
continue;
}
if ($distance > $partialMessage)
{
$factor = 1;
}
elseif ($distance < $completeMessage)
{
$factor = 0;
}
else
{
$factor = $distance / $partialMessage;
}
?>
<span class="username">
<?php echo $msg['pseudo'] ?> :
</span>
<span class="text-message">
<?php echo " " . blur($msg['message'],$factor)?>
</span>
<span class="distance">
<?php echo " (",$distance,")"?>
</span><br/>
<?php
}
}
else
{
echo "send a message to start chatting, spying on others isn't allowed... (and allow localisation, this is mandatory) AND do not spam otherwise the site will be broken for you and you'll have no friend :(";
}
?>
</div>
<script src="webscript.js"></script>
</body>
</html>