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.

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