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 994B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. $headers = apache_request_headers();
  9. if (!isset($header["Authorization"]))
  10. return false;
  11. return true;
  12. }
  13. function check_api_key()
  14. {
  15. if (!check_api_key_())
  16. error(500, "Database Fail");
  17. }
  18. function main()
  19. {
  20. $m_get = ($_SERVER['REQUEST_METHOD'] == "GET");
  21. $m_post = ($_SERVER['REQUEST_METHOD'] == "POST");
  22. $matches = array();
  23. $path = rtrim($_GET['_url'], "/");
  24. if ($path === "")
  25. $path = "/";
  26. if (preg_match($path, "^/status/([0-9]+)/confirm$", $matches) && $m_post)
  27. status_confirm($matches[1]);
  28. else if ($path === "/status" && $m_post)
  29. status_create();
  30. else if ($path === "/status/feed" && $m_get)
  31. status_feed();
  32. else if ($path === "/user" && $m_post)
  33. user_create();
  34. else if ($path === "/user/login" && $m_post)
  35. user_login();
  36. else
  37. error(501, "Not Implemented");
  38. }
  39. check_api_key();
  40. main();
  41. ?>