12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- require_once "utils.php";
- require_once "status.php";
- require_once "user.php";
- require_once "sql.php";
-
- function check_api_key()
- {
- if (check_table_field("Api-Key", "api_keys", "key") === false)
- error(401, "Bad API key");
- }
-
- function main()
- {
- header("Content-Type: application/json");
- check_api_key();
- $m_get = ($_SERVER['REQUEST_METHOD'] == "GET");
- $m_post = ($_SERVER['REQUEST_METHOD'] == "POST");
- $matches = array();
-
- $path = rtrim($_GET["_url"], "/");
- if ($path === "")
- $path = "/";
-
- if (preg_match('(^\/status\/([0-9]+)\/confirm$)', $path, $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();
- ?>
|