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.

58 lines
2.0 KiB

8 years ago
8 years ago
8 years ago
  1. <?php
  2. chdir('..');
  3. include('vendor/autoload.php');
  4. use Errbit\Errbit;
  5. if(Config::$errbitHost) {
  6. Errbit::instance()
  7. ->configure(array(
  8. 'api_key' => Config::$errbitKey,
  9. 'host' => Config::$errbitHost,
  10. 'port' => 443,
  11. 'secure' => true
  12. ))
  13. ->start();
  14. }
  15. initdb();
  16. use Symfony\Component\HttpFoundation\Request;
  17. use Symfony\Component\HttpFoundation\Response;
  18. $router = new League\Route\RouteCollection;
  19. $templates = new League\Plates\Engine(dirname(__FILE__).'/../views');
  20. $router->addRoute('GET', '/', 'Controller::index');
  21. $router->addRoute('GET', '/dashboard', 'Controller::dashboard');
  22. $router->addRoute('GET', '/api', 'Controller::api');
  23. $router->addRoute('GET', '/webmention/{code}/details', 'Controller::webmention_details');
  24. $router->addRoute('GET', '/dashboard/send', 'Controller::dashboard_send');
  25. $router->addRoute('POST', '/dashboard/get_outgoing_links.json', 'Controller::get_outgoing_links');
  26. $router->addRoute('POST', '/dashboard/discover_endpoint.json', 'Controller::discover_endpoint');
  27. $router->addRoute('POST', '/webmention', 'API::webmention');
  28. $router->addRoute('POST', '/superfeedr/{token}', 'API::superfeedr_tracker');
  29. $router->addRoute('GET', '/webmention/{code}', 'API::webmention_status');
  30. $router->addRoute('GET', '/login', 'Auth::login');
  31. $router->addRoute('GET', '/logout', 'Auth::logout');
  32. $router->addRoute('POST', '/login/start', 'Auth::login_start');
  33. $router->addRoute('GET', '/login/callback', 'Auth::login_callback');
  34. $dispatcher = $router->getDispatcher();
  35. $request = Request::createFromGlobals();
  36. try {
  37. $response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
  38. $response->send();
  39. } catch(League\Route\Http\Exception\NotFoundException $e) {
  40. $response = new Response;
  41. $response->setStatusCode(404);
  42. $response->setContent("Not Found\n");
  43. $response->send();
  44. } catch(League\Route\Http\Exception\MethodNotAllowedException $e) {
  45. $response = new Response;
  46. $response->setStatusCode(405);
  47. $response->setContent("Method not allowed\n");
  48. $response->send();
  49. }