123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- function starts_with($haystack, $needle)
- {
- return ($needle === ""
- || strrpos($haystack, $needle, -strlen($haystack)) !== false);
- }
-
- function ends_with($haystack, $needle)
- {
- return ($needle === ""
- || strpos($haystack, $needle, strlen($haystack) - strlen($needle))
- !== false);
- }
-
- function error($code, $message)
- {
- header("HTTP/ $code $message");
- die(json_encode(array("code" => intval($code), "message" => $message)));
- }
-
- function status_confirm($id)
- {
- }
-
- function status_create()
- {
- }
-
- function status_feed()
- {
- }
-
- function user_create()
- {
- }
-
- function user_login()
- {
- }
-
- function main()
- {
- $m_get = ($_SERVER['REQUEST_METHOD'] == "GET");
- $m_post = ($_SERVER['REQUEST_METHOD'] == "POST");
- $matches = array();
-
- $path = rtrim($_GET['_url'], "/");
- if ($path === "")
- $path = "/";
- echo hash_pbkdf2(
- if (preg_match($path, "^/status/([0-9]+)/confirm$", $matches) && $m_post)
- status_confirm($matches[1]);
- else if ($path === "/status" && $m_post)
- status_create();
- else if ($path === "/status/feed" && $m_get)
- status_feed();
- else if ($path === "/user" && $m_post)
- user_create();
- else if ($path === "/user/login" && $m_post)
- user_login();
- else
- error(501, "Not Implemented");
- }
-
- main();
- ?>
|