| 1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace Tools;
- class Router
- {
- private $rootPath;
- private $rootUrl;
- public function __construct()
- {
- $pos = strrpos($_SERVER["SCRIPT_NAME"], "/");
- $relativePath = (($pos === FALSE) ? "" : substr($_SERVER["SCRIPT_NAME"], 0, $pos));
- $this->rootPath = $_SERVER["DOCUMENT_ROOT"] . $relativePath . "/";
- $this->rootUrl = $_SERVER["REQUEST_SCHEME"] . "://" . $_SERVER["HTTP_HOST"] . $relativePath ."/";
- }
- public function init()
- {
- $siteUrl = \Entity\Config::getConfig(null, "siteUrl");
- if ($siteUrl != $_SERVER["HTTP_HOST"])
- {
- header("location: http://{$siteUrl}{$_SERVER['REQUEST_URI']}");
- die;
- }
- }
- public function getModulesPath()
- { return $this->rootPath . "content/modules/"; }
- public function serveUrl()
- {
- }
- }
|