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.

64 lines
2.3 KiB

9 years ago
9 years ago
9 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', '/send-a-webmention', 'Controller::send_a_webmention');
  23. $router->addRoute('GET', '/site/new', 'Controller::new_site');
  24. $router->addRoute('GET', '/site/edit', 'Controller::new_site');
  25. $router->addRoute('POST', '/site/save', 'Controller::save_site');
  26. $router->addRoute('GET', '/api', 'Controller::api');
  27. $router->addRoute('GET', '/superfeedr', 'Controller::superfeedr');
  28. $router->addRoute('GET', '/webmention/{code}/details', 'Controller::webmention_details');
  29. $router->addRoute('GET', '/dashboard/send', 'Controller::dashboard_send');
  30. $router->addRoute('POST', '/dashboard/get_outgoing_links.json', 'Controller::get_outgoing_links');
  31. $router->addRoute('POST', '/dashboard/discover_endpoint.json', 'Controller::discover_endpoint');
  32. $router->addRoute('POST', '/webmention', 'API::webmention');
  33. $router->addRoute('POST', '/superfeedr/{token}', 'API::superfeedr_tracker');
  34. $router->addRoute('GET', '/webmention/{code}', 'API::webmention_status');
  35. $router->addRoute('GET', '/login', 'Auth::login');
  36. $router->addRoute('GET', '/logout', 'Auth::logout');
  37. $router->addRoute('POST', '/login/start', 'Auth::login_start');
  38. $router->addRoute('GET', '/login/callback', 'Auth::login_callback');
  39. $dispatcher = $router->getDispatcher();
  40. $request = Request::createFromGlobals();
  41. try {
  42. $response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
  43. $response->send();
  44. } catch(League\Route\Http\Exception\NotFoundException $e) {
  45. $response = new Response;
  46. $response->setStatusCode(404);
  47. $response->setContent("Not Found\n");
  48. $response->send();
  49. } catch(League\Route\Http\Exception\MethodNotAllowedException $e) {
  50. $response = new Response;
  51. $response->setStatusCode(405);
  52. $response->setContent("Method not allowed\n");
  53. $response->send();
  54. }