Example #1
0
 private static function generateCookieName($name)
 {
     $cookiePrefix = \Freetrix\Main\Config\Option::get("main", "cookie_name", "FREETRIX_SM") . "_";
     if (strpos($name, $cookiePrefix) !== 0) {
         $name = $cookiePrefix . $name;
     }
     return $name;
 }
Example #2
0
	public static function RemoveOption($module_id, $name="", $site=false)
	{
		$filter = array();
		if (strlen($name) > 0)
			$filter["name"] = $name;
		if (strlen($site) > 0)
			$filter["site_id"] = $site;
		\Freetrix\Main\Config\Option::delete($module_id, $filter);
	}
Example #3
0
	public function getAnchorSchemes()
	{
		if($this->anchorSchemes === null)
		{
			static $schemes = null;
			if($schemes === null)
			{
				$schemes = \Freetrix\Main\Config\Option::get("main", "~parser_anchor_schemes", "http|https|news|ftp|aim|mailto|file");
			}
			$this->anchorSchemes = $schemes;
		}
		return $this->anchorSchemes;
	}
Example #4
0
 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", "Freetrix Site Manager (" . ($key == "DEMO" ? "DEMO" : md5("FREETRIX" . $key . "LICENCE")) . ")");
     if (Config\Option::get("main", "set_p3p_header", "Y") == "Y") {
         $this->addHeader("P3P", "policyref=\"/freetrix/p3p.xml\", CP=\"NON DSP COR CUR ADM DEV PSA PSD OUR UNR BUS UNI COM NAV INT DEM STA\"");
     }
 }
Example #5
0
 protected function getCurrentLanguage()
 {
     $request = $this->getRequest();
     $defaultLang = $request->get("lang");
     if (empty($defaultLang)) {
         $defaultLang = Config\Option::get("main", "admin_lid", 'en');
     }
     if (!empty($defaultLang)) {
         $recordset = LanguageTable::getById($defaultLang);
         if ($record = $recordset->fetch()) {
             return $record;
         }
     }
     $recordset = LanguageTable::getList(array('filter' => array('ACTIVE' => 'Y'), 'order' => array('DEF' => 'DESC', 'SORT' => 'ASC'), 'select' => array('*')));
     if ($record = $recordset->fetch()) {
         return $record;
     }
     throw new SystemException('Language is not found');
 }
Example #6
0
 public function isSystem()
 {
     if (preg_match("#/\\.#", $this->path)) {
         return true;
     }
     if (substr($this->path, 0, strlen($this->documentRoot)) === $this->documentRoot) {
         $relativePath = substr($this->path, strlen($this->documentRoot));
         $relativePath = ltrim($relativePath, "/");
         if (($pos = strpos($relativePath, "/")) !== false) {
             $s = substr($relativePath, 0, $pos);
         } else {
             $s = $relativePath;
         }
         $s = strtolower(rtrim($s, "."));
         $ar = array("freetrix" => 1, Main\Config\Option::get("main", "upload_dir", "upload") => 1, "urlrewrite.php" => 1);
         if (isset($ar[$s])) {
             return true;
         }
     }
     return false;
 }
Example #7
0
 private static function checkPath($path)
 {
     static $searchMasksCache = false;
     if (is_array($searchMasksCache)) {
         $arExc = $searchMasksCache["exc"];
         $arInc = $searchMasksCache["inc"];
     } else {
         $arExc = array();
         $arInc = array();
         $inc = Config\Option::get("main", "urlrewrite_include_mask", "*.php");
         $inc = str_replace("'", "\\'", str_replace("*", ".*?", str_replace("?", ".", str_replace(".", "\\.", str_replace("\\", "/", $inc)))));
         $arIncTmp = explode(";", $inc);
         foreach ($arIncTmp as $preg_mask) {
             if (strlen(trim($preg_mask)) > 0) {
                 $arInc[] = "'^" . trim($preg_mask) . "\$'";
             }
         }
         $exc = Config\Option::get("main", "urlrewrite_exclude_mask", "/freetrix/*;");
         $exc = str_replace("'", "\\'", str_replace("*", ".*?", str_replace("?", ".", str_replace(".", "\\.", str_replace("\\", "/", $exc)))));
         $arExcTmp = explode(";", $exc);
         foreach ($arExcTmp as $preg_mask) {
             if (strlen(trim($preg_mask)) > 0) {
                 $arExc[] = "'^" . trim($preg_mask) . "\$'";
             }
         }
         $searchMasksCache = array("exc" => $arExc, "inc" => $arInc);
     }
     $file = IO\Path::getName($path);
     if (substr($file, 0, 1) === ".") {
         return 0;
     }
     foreach ($arExc as $preg_mask) {
         if (preg_match($preg_mask, $path)) {
             return false;
         }
     }
     foreach ($arInc as $preg_mask) {
         if (preg_match($preg_mask, $path)) {
             return true;
         }
     }
     return false;
 }
Example #8
0
		}

		if($arSite['SERVER_NAME'] != '')
			$arSite['DOMAINS'][] = $arSite['SERVER_NAME'];

		$dbDomains = Freetrix\Main\SiteDomainTable::getList(
			array(
				'filter' => array('LID' => $SITE_ID),
				'select'=>array('DOMAIN')
			)
		);
		while($arDomain = $dbDomains->fetch())
		{
			$arSite['DOMAINS'][] = $arDomain['DOMAIN'];
		}
		$arSite['DOMAINS'][] = \Freetrix\Main\Config\Option::get('main', 'server_name', '');
		$arSite['DOMAINS'] = array_unique($arSite['DOMAINS']);
	}
}

if(strlen($SITE_ID) <= 0)
{
	require($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/include/prolog_admin_after.php");
	ShowError(Loc::getMessage("SEO_ERROR_SITEMAP_NO_SITE"));
	require($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/include/epilog_admin.php");
}

$aTabs = array(
	array("DIV" => "seo_sitemap_common", "TAB" => Loc::getMessage('SEO_SITEMAP_COMMON'), "ICON" => "main_settings", "TITLE" => Loc::getMessage('SEO_SITEMAP_COMMON_TITLE')),
	array("DIV" => "seo_sitemap_files", "TAB" => Loc::getMessage('SEO_SITEMAP_FILES'), "ICON" => "main_settings", "TITLE" => Loc::getMessage('SEO_SITEMAP_FILES_TITLE')),
);
Example #9
0
 public static function setAuthentication(CurrentUser $user, $isPersistent = false)
 {
     /** @var $context \Freetrix\Main\HttpContext */
     $context = \Freetrix\Main\Application::getInstance()->getContext();
     $context->setUser($user);
     static::copyToSession($user);
     /** @var $response \Freetrix\Main\HttpResponse */
     $response = $context->getResponse();
     if (!$user->isAuthenticated()) {
         $cookie = new \Freetrix\Main\Web\Cookie("UIDH", "", time() - 3600);
         $response->addCookie($cookie);
         return;
     }
     $connection = \Freetrix\Main\Application::getDbConnection();
     $sqlHelper = $connection->getSqlHelper();
     $connection->queryExecute("UPDATE b_user SET " . "   STORED_HASH = NULL, " . "   LAST_LOGIN = "******", " . "   TIMESTAMP_X = TIMESTAMP_X,  " . "   LOGIN_ATTEMPTS = 0, " . "   TIME_ZONE_OFFSET = " . \CTimeZone::getOffset() . " " . "WHERE ID = " . $user->getUserId() . " ");
     $cookie = new \Freetrix\Main\Web\Cookie("LOGIN", $user->getLogin(), time() + 60 * 60 * 24 * 30 * 60);
     $cookie->setSpread(\Freetrix\Main\Config\Option::get("main", "auth_multisite", "N") == "Y" ? \Freetrix\Main\Web\Cookie::SPREAD_SITES : \Freetrix\Main\Web\Cookie::SPREAD_DOMAIN);
     $response->addCookie($cookie);
     if ($isPersistent || \Freetrix\Main\Config\Option::get("main", "auth_multisite", "N") == "Y") {
         $hash = $user->getSessionHash();
         /** @var $request \Freetrix\Main\HttpRequest */
         $request = $context->getRequest();
         if ($isPersistent) {
             $cookie = new \Freetrix\Main\Web\Cookie("UIDH", $hash, time() + 60 * 60 * 24 * 30 * 60);
         } else {
             $cookie = new \Freetrix\Main\Web\Cookie("UIDH", $hash, 0);
         }
         $cookie->setSecure(\Freetrix\Main\Config\Option::get("main", "use_secure_password_cookies", "N") == "Y" && $request->isHttps());
         $response->addCookie($cookie);
         $storedId = static::getStoredHashId($user, $hash);
         if ($storedId) {
             $connection->queryExecute("UPDATE b_user_stored_auth SET " . "\tLAST_AUTH = " . $sqlHelper->getCurrentDateTimeFunction() . ", " . "\t" . ($user->getAuthType() === static::AUTHENTICATED_BY_HASH ? "" : "TEMP_HASH='" . ($isPersistent ? "N" : "Y") . "', ") . " " . "\tIP_ADDR = '" . sprintf("%u", ip2long($request->getRemoteAddress())) . "' " . "WHERE ID = " . intval($storedId));
         } else {
             $sqlTmp1 = "";
             $sqlTmp2 = "";
             if ($connection->getType() === "oracle") {
                 $storedId = $connection->getIdentity("sq_b_user_stored_auth");
                 $sqlTmp1 = "ID, ";
                 $sqlTmp2 = intval($storedId) . ", ";
             }
             $sql = "INSERT INTO b_user_stored_auth (" . $sqlTmp1 . "USER_ID, DATE_REG, LAST_AUTH, TEMP_HASH, " . "   IP_ADDR, STORED_HASH) " . "VALUES (" . $sqlTmp2 . intval($user->getUserId()) . ", " . $sqlHelper->getCurrentDateTimeFunction() . ", " . "   " . $sqlHelper->getCurrentDateTimeFunction() . ", '" . ($isPersistent ? "N" : "Y") . "', " . "   '" . $sqlHelper->forSql(sprintf("%u", ip2long($request->getRemoteAddress()))) . "', " . "   '" . $sqlHelper->forSql($hash) . "')";
             $connection->queryExecute($sql);
             if ($connection->getType() !== "oracle") {
                 $storedId = $connection->getIdentity();
             }
         }
         $user->setStoredAuthId($storedId);
     }
     $event = new Main\Event("main", "OnUserLogin", array("USER" => $user));
     $event->send();
     if (\Freetrix\Main\Config\Option::get("main", "event_log_login_success", "N") === "Y") {
         \CEventLog::log("SECURITY", "USER_AUTHORIZE", "main", $user->getUserId());
     }
 }
Example #10
0
 /**
  * OnBeforeEndBufferContent handler
  */
 public function onBeforeEndBufferContent()
 {
     global $APPLICATION;
     $frame = self::getInstance();
     $params = array();
     if ($frame->getUseAppCache()) {
         $manifest = \Freetrix\Main\Data\AppCacheManifest::getInstance();
         $params = $manifest->OnBeforeEndBufferContent();
         $params["CACHE_MODE"] = "APPCACHE";
         $params["PAGE_URL"] = \Freetrix\Main\Context::getCurrent()->getServer()->getRequestUri();
     } elseif ($frame->getUseHTMLCache()) {
         $staticHTMLCache = \Freetrix\Main\Data\StaticHtmlCache::getInstance();
         if ($staticHTMLCache->isCacheable()) {
             $params["CACHE_MODE"] = "HTMLCACHE";
             if (\Freetrix\Main\Config\Option::get("main", "~show_composite_banner", "Y") == "Y") {
                 $options = \CHTMLPagesCache::GetOptions();
                 $params["banner"] = array("url" => GetMessage("COMPOSITE_BANNER_URL"), "text" => GetMessage("COMPOSITE_BANNER_TEXT"), "bgcolor" => isset($options["BANNER_BGCOLOR"]) ? $options["BANNER_BGCOLOR"] : "", "style" => isset($options["BANNER_STYLE"]) ? $options["BANNER_STYLE"] : "");
             }
         } else {
             return;
         }
     }
     $params["storageBlocks"] = array();
     foreach ($frame->dynamicIDs as $id => $dynamicData) {
         if ($dynamicData["use_browser_storage"]) {
             $realId = isset($this->containers[$id]) ? $this->containers[$id] : "bxdynamic_" . $id;
             $params["storageBlocks"][] = $realId;
         }
     }
     $frame->injectedJS = $frame->getInjectedJs($params);
     $APPLICATION->AddHeadString($this->injectedJS["start"], false, "BEFORE_CSS");
     //When dynamic hit we'll throw spread cookies away
     if ($frame->getUseHTMLCache() && $staticHTMLCache->isCacheable()) {
         $APPLICATION->GetSpreadCookieHTML();
         \CJSCore::GetCoreMessagesScript();
     }
 }
Example #11
0
 /**
  * @param array $cookies
  * @return array
  */
 protected function prepareCookie(array $cookies)
 {
     static $cookiePrefix = null;
     if ($cookiePrefix === null) {
         $cookiePrefix = Config\Option::get("main", "cookie_name", "FREETRIX_SM") . "_";
     }
     $cookiePrefixLength = strlen($cookiePrefix);
     $cookiesNew = array();
     foreach ($cookies as $name => $value) {
         if (strpos($name, $cookiePrefix) !== 0) {
             continue;
         }
         $cookiesNew[substr($name, $cookiePrefixLength)] = $value;
     }
     return $cookiesNew;
 }
Example #12
0
 /**
  * @return string
  */
 protected function getDefaultKey()
 {
     static $defaultKey = null;
     if ($defaultKey === null) {
         $defaultKey = Option::get('main', 'signer_default_key', false);
         if (!$defaultKey) {
             $defaultKey = hash('sha512', uniqid(rand(), true));
             Option::set('main', 'signer_default_key', $defaultKey, '');
         }
     }
     return $defaultKey;
 }