123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- require_once "utils.php";
-
- function check_token()
- {
- $token = check_table_field("Authorization", "tokens", "token");
- if ($token === false)
- error(401, "Invalid token");
- return $token;
- }
-
- function status_confirm($id)
- {
- check_token();
- }
-
- function status_create()
- {
- $token = check_token();
- $status = get_post("status");
- if (strlen($status) < 10)
- error(422, "Status too short");
- $latitude = get_post("latitude", false);
- $longitude = get_post("longitude", false);
- $u = database_exec("SELECT `id`, `username` FROM users WHERE `id` = ".
- "(SELECT `user` FROM tokens WHERE `token` = :token)",
- array(":token" => $token))->fetch();
- database_exec("INSERT INTO status (`status`, `user`) VALUES(:status, :user)",
- array(":status" => $status, ":user" => $u["id"]));
- $s = database_exec("SELECT * FROM status WHERE id = :id",
- array(":id" => database_get()->lastInsertId()))->fetch();
- echo json_encode(array("status" => $s["status"],
- "creation_date" => $s['date'],
- /*"nb_confirm_up" => intval($s["up"]),
- "nb_confirm_down" => intval($s["down"]),*/
- "latitude" => $s["latitude"] === null ? null : floatval($s["latitude"]),
- "longitude" => $s["longitude"] === null ? null : floatval($s["longitude"]),
- "media_url" => $s["media"],
- "id" => $s["id"],
- "user_id" => $u["id"]
- ));
- }
-
- function status_feed()
- {
- check_token();
- }
- ?>
|