Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

status.php 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. require_once "utils.php";
  3. function check_token()
  4. {
  5. $token = check_table_field("Authorization", "tokens", "token");
  6. if ($token === false)
  7. error(401, "Invalid token");
  8. return $token;
  9. }
  10. function status_confirm($id)
  11. {
  12. check_token();
  13. }
  14. function status_create()
  15. {
  16. $token = check_token();
  17. $status = get_post("status");
  18. if (strlen($status) < 10)
  19. error(422, "Status too short");
  20. $latitude = get_post("latitude", false);
  21. $longitude = get_post("longitude", false);
  22. $u = database_exec("SELECT `id`, `username` FROM users WHERE `id` = ".
  23. "(SELECT `user` FROM tokens WHERE `token` = :token)",
  24. array(":token" => $token))->fetch();
  25. database_exec("INSERT INTO status (`status`, `user`) VALUES(:status, :user)",
  26. array(":status" => $status, ":user" => $u["id"]));
  27. $s = database_exec("SELECT * FROM status WHERE id = :id",
  28. array(":id" => database_get()->lastInsertId()))->fetch();
  29. echo json_encode(array("status" => $s["status"],
  30. "creation_date" => $s['date'],
  31. /*"nb_confirm_up" => intval($s["up"]),
  32. "nb_confirm_down" => intval($s["down"]),*/
  33. "latitude" => $s["latitude"] === null ? null : floatval($s["latitude"]),
  34. "longitude" => $s["longitude"] === null ? null : floatval($s["longitude"]),
  35. "media_url" => $s["media"],
  36. "id" => $s["id"],
  37. "user_id" => $u["id"]
  38. ));
  39. }
  40. function status_feed()
  41. {
  42. check_token();
  43. }
  44. ?>