You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.php 944B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. require_once "utils.php";
  3. require_once "status.php";
  4. require_once "user.php";
  5. require_once "sql.php";
  6. function check_api_key()
  7. {
  8. if (check_table_field("Api-Key", "api_keys", "key") === false)
  9. error(401, "Bad API key");
  10. }
  11. function main()
  12. {
  13. header("Content-Type: application/json");
  14. check_api_key();
  15. $m_get = ($_SERVER['REQUEST_METHOD'] == "GET");
  16. $m_post = ($_SERVER['REQUEST_METHOD'] == "POST");
  17. $matches = array();
  18. $path = rtrim($_GET["_url"], "/");
  19. if ($path === "")
  20. $path = "/";
  21. if (preg_match('(^\/status\/([0-9]+)\/confirm$)', $path, $matches)
  22. && $m_post)
  23. status_confirm($matches[1]);
  24. else if ($path === "/status" && $m_post)
  25. status_create();
  26. else if ($path === "/status/feed" && $m_get)
  27. status_feed();
  28. else if ($path === "/user" && $m_post)
  29. user_create();
  30. else if ($path === "/user/login" && $m_post)
  31. user_login();
  32. else
  33. error(501, "Not implemented");
  34. }
  35. main();
  36. ?>