PageRenderTime 63ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/engine/handlers/page_handler.php

http://github.com/Elgg/Elgg
PHP | 52 lines | 13 code | 6 blank | 33 comment | 2 complexity | dc6ee6b6b873c9c12e4dfa5b633ff6f1 MD5 | raw file
Possible License(s): LGPL-3.0, MIT, GPL-2.0, BSD-3-Clause, LGPL-2.1, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /**
  3. * Pages handler.
  4. *
  5. * This file dispatches pages. It is called via a URL rewrite in .htaccess
  6. * from http://site/handler/page1/page2. The first element after site/ is
  7. * the page handler name as registered by {@link elgg_register_page_handler()}.
  8. * The rest of the string is sent to {@link page_handler()}.
  9. *
  10. * Note that the following handler names are reserved by elgg and should not be
  11. * registered by any plugins:
  12. * * action
  13. * * cache
  14. * * services
  15. * * export
  16. * * js
  17. * * css
  18. * * rewrite.php
  19. * * tag (deprecated, reserved for backwards compatibility)
  20. * * pg (deprecated, reserved for backwards compatibility)
  21. *
  22. * These additionally are reserved for the xml-rpc plugin
  23. * * mt
  24. * * xml-rpc.php
  25. *
  26. * {@link page_handler()} explodes the pages string by / and sends it to
  27. * the page handler function as registered by {@link elgg_register_page_handler()}.
  28. * If a valid page handler isn't found, plugins have a chance to provide a 404.
  29. *
  30. * @package Elgg.Core
  31. * @subpackage PageHandler
  32. * @link http://docs.elgg.org/Tutorials/PageHandlers
  33. */
  34. // Permanent redirect to pg-less urls
  35. $url = $_SERVER['REQUEST_URI'];
  36. $new_url = preg_replace('#/pg/#', '/', $url, 1);
  37. if ($url !== $new_url) {
  38. header("HTTP/1.1 301 Moved Permanently");
  39. header("Location: $new_url");
  40. }
  41. require_once(dirname(dirname(__FILE__)) . "/start.php");
  42. $handler = get_input('handler');
  43. $page = get_input('page');
  44. if (!page_handler($handler, $page)) {
  45. forward('', '404');
  46. }