private function createStandardHeaders() { $server = $this->context->getServer(); if ($server->get("REDIRECT_STATUS") != null && $server->get("REDIRECT_STATUS") == 404) { if (Config\Option::get("main", "header_200", "N") == "Y") { $this->setStatus("200 OK"); } } $dispatcher = Application::getInstance()->getDispatcher(); $key = $dispatcher->getLicenseKey(); $this->addHeader("X-Powered-CMS", "Bitrix Site Manager (" . ($key == "DEMO" ? "DEMO" : md5("BITRIX" . $key . "LICENCE")) . ")"); if (Config\Option::get("main", "set_p3p_header", "Y") == "Y") { $this->addHeader("P3P", "policyref=\"/bitrix/p3p.xml\", CP=\"NON DSP COR CUR ADM DEV PSA PSD OUR UNR BUS UNI COM NAV INT DEM STA\""); } }
protected function getHtmlToSpreadCookiesOverSites() { static $firstExecution = true; if (!$firstExecution) { throw new NotSupportedException("getHtmlToSpreadCookiesOverSites() must be called only once"); } if (Config\Option::get("main", "ALLOW_SPREAD_COOKIE", "Y") !== "Y") { return ""; } $result = ""; $context = $this->getContext(); /** @var $response HttpResponse */ $response = $context->getResponse(); $params = ""; foreach ($response->getCookies() as $cookie) { /** @var $cookie \Bitrix\Main\Web\Cookie */ if ($cookie->getSpread() & Web\Cookie::SPREAD_SITES) { $params .= $cookie->getName() . chr(1) . $cookie->getValue() . chr(1) . $cookie->getExpires() . chr(1) . $cookie->getPath() . chr(1) . '' . chr(1) . $cookie->getSecure() . chr(2); } } if (isset($_SESSION['SPREAD_COOKIE']) && is_array($_SESSION['SPREAD_COOKIE']) && !empty($_SESSION['SPREAD_COOKIE'])) { reset($_SESSION['SPREAD_COOKIE']); while (list($cookieName, $cookieData) = each($_SESSION['SPREAD_COOKIE'])) { $cookieData["D"] = ""; // domain must be empty $params .= $cookieName . chr(1) . $cookieData["V"] . chr(1) . $cookieData["T"] . chr(1) . $cookieData["F"] . chr(1) . $cookieData["D"] . chr(1) . $cookieData["S"] . chr(2); } unset($_SESSION['SPREAD_COOKIE']); } if (!empty($params)) { $server = $context->getServer(); /** @var $request HttpRequest */ $request = $context->getRequest(); $versionFile = new IO\File(IO\Path::convertRelativeToAbsolute("/bitrix/modules/main/classes/general/version.php")); $salt = $request->getRemoteAddress() . "|" . $versionFile->getModificationTime() . "|" . LICENSE_KEY; $params = "s=" . urlencode(base64_encode($params)) . "&k=" . urlencode(md5($params . $salt)); $domainList = array(); $domainList[] = $server->getHttpHost(); $recordset = SiteTable::getList(array('filter' => array('ACTIVE' => 'Y'))); while ($record = $recordset->Fetch()) { $siteDomainsList = explode("\n", str_replace("\r", "\n", $record["DOMAINS"])); if (is_array($siteDomainsList) && count($siteDomainsList) > 0) { foreach ($siteDomainsList as $d) { $d = trim($d); if (!empty($d)) { $domainList[] = $d; } } } } if (count($domainList) > 0) { $uniqueDomainList = array(); $domainList = array_unique($domainList); $domainList2 = array_unique($domainList); foreach ($domainList as $domain1) { $goodDomain = true; foreach ($domainList2 as $domain2) { if (strlen($domain1) > strlen($domain2) && substr($domain1, -(strlen($domain2) + 1)) == "." . $domain2) { $goodDomain = false; break; } } if ($goodDomain) { $uniqueDomainList[] = $domain1; } } $protocol = $request->isHttps() ? "https://" : "http://"; $host = $server->getHttpHost(); $requestUri = $request->getRequestUri(); $currentUri = new Web\Uri($protocol . $host . "/" . $requestUri, Web\UriType::ABSOLUTE); $currentUriParts = $currentUri->parse(); foreach ($uniqueDomainList as $domain) { $uriString = $protocol . $domain . "/bitrix/spread.php?" . $params; $domainUri = new Web\Uri($uriString, Web\UriType::ABSOLUTE); $domainUriParts = $domainUri->parse(); if ($currentUriParts["host"] != $domainUriParts["host"]) { $result .= '<img src="' . Text\String::htmlspecialchars($uriString) . '" alt="" style="width:0px; height:0px; position:absolute; left:-1px; top:-1px;" />' . "\n"; } } } } $firstExecution = false; return $result; }
/** * Function checks if cacheing is enabled in component parameters * @return boolean */ protected final function getCacheNeed() { return intval($this->arParams['CACHE_TIME']) > 0 && $this->arParams['CACHE_TYPE'] != 'N' && Config\Option::get("main", "component_cache_on", "Y") == "Y"; }