您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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. ?>