Router.php 733 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace Tools;
  3. class Router
  4. {
  5. private $rootPath;
  6. private $rootUrl;
  7. public function __construct()
  8. {
  9. $siteUrl = \Entity\Config::getConfig(null, "siteUrl");
  10. if ($siteUrl != $_SERVER["HTTP_HOST"])
  11. {
  12. header("location: http://{$siteUrl}{$_SERVER['REQUEST_URI']}");
  13. die;
  14. }
  15. $pos = strrpos($_SERVER["SCRIPT_NAME"], "/");
  16. $relativePath = (($pos === FALSE) ? "" : substr($_SERVER["SCRIPT_NAME"], 0, $pos));
  17. $this->rootPath = $_SERVER["DOCUMENT_ROOT"] . $relativePath . "/";
  18. $this->rootUrl = $_SERVER["REQUEST_SCHEME"] . "://" . $_SERVER["HTTP_HOST"] . $relativePath ."/";
  19. }
  20. public function init($context)
  21. {
  22. }
  23. }