-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlead.php
More file actions
50 lines (44 loc) · 1.08 KB
/
Copy pathlead.php
File metadata and controls
50 lines (44 loc) · 1.08 KB
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
<?php
header('Content-Type: text/javascript; charset=utf8');
try
{
@$username = $_POST['username']; # TODO: get/confirm username from session cookie for better security
$followProperties = array(
'username',
'img',
'sess',
'zoom',
'cenx',
'ceny',
'rotation',
'bookmarks',
'curx',
'cury'
);
# note: all field data are recieved as strings and will be stored in the database as strings
$followData = array();
foreach ($followProperties as $prop)
{
if (array_key_exists($prop, $_POST))
{
$followData[$prop] = $_POST[$prop];
}
else
{
throw new Exception($prop . " not found in lead.php data");
}
}
$followData['timestamp'] = new MongoDate();
require_once("config.php"); # get $server and $database
$conn = new Mongo('mongodb://' . $server);
$collection = $conn->selectDB($database)->selectCollection("follow");
$collection->update(array("username" => $username), $followData, array('upsert' => true));
}
# Error handling
catch (Exception $e)
{
# TODO: send a better failure response to client
header("HTTP/1.1 400 Bad Request");
return;
}
?>