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.

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