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.

index.php 890B

123456789101112131415161718192021222324252627282930313233343536373839
  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. $m_get = ($_SERVER['REQUEST_METHOD'] == "GET");
  14. $m_post = ($_SERVER['REQUEST_METHOD'] == "POST");
  15. $matches = array();
  16. $path = rtrim($_GET['_url'], "/");
  17. if ($path === "")
  18. $path = "/";
  19. if (preg_match($path, "^/status/([0-9]+)/confirm$", $matches) && $m_post)
  20. status_confirm($matches[1]);
  21. else if ($path === "/status" && $m_post)
  22. status_create();
  23. else if ($path === "/status/feed" && $m_get)
  24. status_feed();
  25. else if ($path === "/user" && $m_post)
  26. user_create();
  27. else if ($path === "/user/login" && $m_post)
  28. user_login();
  29. else
  30. error(501, "Not implemented");
  31. }
  32. check_api_key();
  33. main();
  34. ?>