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 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. function starts_with($haystack, $needle)
  3. {
  4. return ($needle === ""
  5. || strrpos($haystack, $needle, -strlen($haystack)) !== false);
  6. }
  7. function ends_with($haystack, $needle)
  8. {
  9. return ($needle === ""
  10. || strpos($haystack, $needle, strlen($haystack) - strlen($needle))
  11. !== false);
  12. }
  13. function error($code, $message)
  14. {
  15. header("HTTP/ $code $message");
  16. die(json_encode(array("code" => intval($code), "message" => $message)));
  17. }
  18. function status_confirm($id)
  19. {
  20. }
  21. function status_create()
  22. {
  23. }
  24. function status_feed()
  25. {
  26. }
  27. function user_create()
  28. {
  29. }
  30. function user_login()
  31. {
  32. }
  33. function main()
  34. {
  35. $m_get = ($_SERVER['REQUEST_METHOD'] == "GET");
  36. $m_post = ($_SERVER['REQUEST_METHOD'] == "POST");
  37. $matches = array();
  38. $path = rtrim($_GET['_url'], "/");
  39. if ($path === "")
  40. $path = "/";
  41. echo hash_pbkdf2(
  42. if (preg_match($path, "^/status/([0-9]+)/confirm$", $matches) && $m_post)
  43. status_confirm($matches[1]);
  44. else if ($path === "/status" && $m_post)
  45. status_create();
  46. else if ($path === "/status/feed" && $m_get)
  47. status_feed();
  48. else if ($path === "/user" && $m_post)
  49. user_create();
  50. else if ($path === "/user/login" && $m_post)
  51. user_login();
  52. else
  53. error(501, "Not Implemented");
  54. }
  55. main();
  56. ?>