_url = $_SERVER["HTTP_HOST"]; return $this; } public function prepareUrl() { $subdomain = str_replace(self::SITE_HOST, "", $this->_url); $subdomain = substr($subdomain, 0, -1); $this->_subLen = strlen($subdomain); return $this; } public function getFile() { if ($this->_subLen != 0) { $url = "https://" . self::SITE_HOST . "/rada/" .$this->_subdomain. $_SERVER["REQUEST_URI"]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if ($_SESSION["appeal_user"]) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, "appeal_user=".$_SESSION["appeal_user"]["id"]); } curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]); $res = curl_exec($ch); if (strpos($res,"Error 404")) { header("HTTP/1.0 404 Not Found"); } echo $res; } else { header("Location: https://".self::SITE_HOST); } } } $redirector = new Redirector(); $redirector->getUrl()->prepareUrl()->getFile();