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

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. require_once "utils.php";
  3. require_once "status.php";
  4. require_once "user.php";
  5. function check_api_key()
  6. {
  7. $headers = apache_request_headers();
  8. if (!isset($header["Authorization"]))
  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. ?>