|
@@ -29,8 +29,8 @@ function status_create()
|
29
|
29
|
&& getimagesize($_FILES["media"]["tmp_name"]) !== false)
|
30
|
30
|
{
|
31
|
31
|
global $media_path;
|
32
|
|
- $media = $media_path . dechex(time());
|
33
|
|
- move_uploaded_file($_FILES["media"]["tmp_name"], $media);
|
|
32
|
+ $media = dechex(time());
|
|
33
|
+ move_uploaded_file($_FILES["media"]["tmp_name"], $media_path . $media);
|
34
|
34
|
}
|
35
|
35
|
|
36
|
36
|
$u = database_exec("SELECT `id`, `username` FROM users WHERE `id` = ".
|
|
@@ -59,9 +59,26 @@ function status_create()
|
59
|
59
|
function status_feed()
|
60
|
60
|
{
|
61
|
61
|
check_token();
|
62
|
|
- $page = get_get("page", false);
|
63
|
|
- $limit = get_get("limit", false);
|
64
|
|
- $sdatabase_exec("SELECT * FROM status ORDER BY id DESC LIMIT :begin, :count",
|
65
|
|
- array(":begin" => intval(($page - 1) * $limit), ":count" => $limit));
|
|
62
|
+ $limit = check_int(get_get("limit", false), 15);
|
|
63
|
+ if ($limit < 1)
|
|
64
|
+ $limit = 15;
|
|
65
|
+ $page = max((check_int(get_get("page", false), 1) - 1), 0) * $limit;
|
|
66
|
+ $s = database_query("SELECT * FROM status ORDER BY `id` DESC ".
|
|
67
|
+ "LIMIT $page, $limit");
|
|
68
|
+ $data = array();
|
|
69
|
+ global $media_url;
|
|
70
|
+ while (($u = $s->fetch()) !== false)
|
|
71
|
+ {
|
|
72
|
+ $date = new DateTime($u['date']);
|
|
73
|
+ $data[] = array("id" => intval($u["id"]), "status" => $u["status"],
|
|
74
|
+ "creation_date" => $date->format(DateTime::ISO8601),
|
|
75
|
+ "latitude" => $u["latitude"] === null ? null : floatval($u["latitude"]),
|
|
76
|
+ "longitude" => $u["longitude"] === null ? null : floatval($u["longitude"]),
|
|
77
|
+ "author_username" => "42",
|
|
78
|
+ "nb_confirm_up" => intval($u["up"]),
|
|
79
|
+ "nb_confirm_down" => intval($u["down"]),
|
|
80
|
+ "media_url" => ($u["media"] !== null ) ? $media_url . $u["media"] : null);
|
|
81
|
+ }
|
|
82
|
+ echo json_encode($data);
|
66
|
83
|
}
|
67
|
84
|
?>
|