_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 . "/rda/" .$this->_subdomain. $_SERVER["REQUEST_URI"]; if (strpos($_SERVER["REQUEST_URI"], "news/") == 1) { $news_url = rtrim(str_replace("/news/", "", $_SERVER["REQUEST_URI"]), "/"); if ($news_url != "") { if (!isset($_SESSION["view"]["news"][$news_url])) { $_SESSION["view"]["news"][$news_url] = true; $view_json = json_encode(array("news" => $news_url)); } } } elseif (strpos($_SERVER["REQUEST_URI"], "petition/") == 1) { $petition_id = (int) rtrim(str_replace("/petition/", "", $_SERVER["REQUEST_URI"]), "/"); if (!isset($_SESSION["view"]["petition"][$petition_id])) { $_SESSION["view"]["petition"][$petition_id] = true; $view_json = json_encode(array("petition" => $petition_id)); } } elseif (strpos($_SERVER["REQUEST_URI"], "doc/") == 1) { $doc_id = (int) rtrim(str_replace("/doc/", "", $_SERVER["REQUEST_URI"]), "/"); if (!isset($_SESSION["view"]["doc"][$doc_id])) { $_SESSION["view"]["doc"][$doc_id] = true; $view_json = json_encode(array("doc" => $doc_id)); } } $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if (isset($_SESSION["appeal_user"]) or isset($_SESSION["petition_user"]) or isset($_SESSION["hash"]) or isset($view_json)) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, "appeal_user=".@$_SESSION["appeal_user"]["id"]."&petition_user=".@$_SESSION["petition_user"]["id"]."&hash=".$_SESSION["hash"]."&view_json=".@$view_json); } 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();