|
@@ -20,29 +20,40 @@ function status_create()
|
20
|
20
|
$status = get_post("status");
|
21
|
21
|
if (strlen($status) < 10)
|
22
|
22
|
error(422, "Status too short");
|
23
|
|
- $latitude = get_post("latitude", false);
|
24
|
|
- $longitude = get_post("longitude", false);
|
|
23
|
+
|
|
24
|
+ $lat = check_float(get_post("latitude", false));
|
|
25
|
+ $long = check_float(get_post("longitude", false));
|
|
26
|
+ $media = null;
|
|
27
|
+
|
25
|
28
|
$u = database_exec("SELECT `id`, `username` FROM users WHERE `id` = ".
|
26
|
29
|
"(SELECT `user` FROM tokens WHERE `token` = :token)",
|
27
|
30
|
array(":token" => $token))->fetch();
|
28
|
|
- database_exec("INSERT INTO status (`status`, `user`) VALUES(:status, :user)",
|
29
|
|
- array(":status" => $status, ":user" => $u["id"]));
|
|
31
|
+
|
|
32
|
+ database_exec("INSERT INTO status (`status`, `user`, `longitude`, ".
|
|
33
|
+ "`latitude`, `media`) VALUES(:status, :user, :long, :lat, :media)",
|
|
34
|
+ array(":status" => $status, ":user" => $u["id"], ":long" => $long,
|
|
35
|
+ ":lat" => $lat, ":media" => $media));
|
|
36
|
+
|
30
|
37
|
$s = database_exec("SELECT * FROM status WHERE id = :id",
|
31
|
38
|
array(":id" => database_get()->lastInsertId()))->fetch();
|
|
39
|
+
|
|
40
|
+ $date = new DateTime($s["date"]);
|
|
41
|
+
|
32
|
42
|
echo json_encode(array("status" => $s["status"],
|
33
|
|
- "creation_date" => $s['date'],
|
34
|
|
- /*"nb_confirm_up" => intval($s["up"]),
|
35
|
|
- "nb_confirm_down" => intval($s["down"]),*/
|
|
43
|
+ "creation_date" => $date->format(DateTime::ISO8601),
|
36
|
44
|
"latitude" => $s["latitude"] === null ? null : floatval($s["latitude"]),
|
37
|
45
|
"longitude" => $s["longitude"] === null ? null : floatval($s["longitude"]),
|
38
|
|
- "media_url" => $s["media"],
|
39
|
|
- "id" => $s["id"],
|
40
|
|
- "user_id" => $u["id"]
|
|
46
|
+ "id" => intval($s["id"]),
|
|
47
|
+ "user_id" => intval($u["id"])
|
41
|
48
|
));
|
42
|
49
|
}
|
43
|
50
|
|
44
|
51
|
function status_feed()
|
45
|
52
|
{
|
46
|
53
|
check_token();
|
|
54
|
+ $page = get_get("page", false);
|
|
55
|
+ $limit = get_get("limit", false);
|
|
56
|
+ $sdatabase_exec("SELECT * FROM status ORDER BY id DESC LIMIT :begin, :count",
|
|
57
|
+ array(":begin" => intval(($page - 1) * $limit), ":count" => $limit));
|
47
|
58
|
}
|
48
|
59
|
?>
|