function GetCurTemplate() { $err_mess = CSite::err_mess() . "<br>Function: GetCurTemplate<br>Line: "; global $DB, $APPLICATION, $USER, $CACHE_MANAGER; if (CACHED_b_site_template === false) { $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\t" . CMain::__GetConditionFName() . ",\n\t\t\t\t\tTEMPLATE\n\t\t\t\tFROM\n\t\t\t\t\tb_site_template\n\t\t\t\tWHERE\n\t\t\t\t\tSITE_ID='" . SITE_ID . "'\n\t\t\t\tORDER BY\n\t\t\t\t\tCASE\n\t\t\t\t\t\twhen " . CMain::__GetConditionFName() . " is null then 2\n\t\t\t\t\t\telse 1\n\t\t\t\t\tEND,\n\t\t\t\t\tSORT\n\t\t\t\t"; $dbr = $DB->Query($strSql, false, $err_mess . __LINE__); while ($ar = $dbr->Fetch()) { $strCondition = trim($ar["CONDITION"]); if (strlen($strCondition) > 0 && !@eval("return " . $strCondition . ";")) { continue; } if (file_exists($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/templates/" . $ar["TEMPLATE"]) && is_dir($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/templates/" . $ar["TEMPLATE"])) { return $ar["TEMPLATE"]; } } } else { if ($CACHE_MANAGER->Read(CACHED_b_site_template, "b_site_template")) { $arSiteTemplateBySite = $CACHE_MANAGER->Get("b_site_template"); } else { $dbr = $DB->Query("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t" . CMain::__GetConditionFName() . ",\n\t\t\t\t\t\tTEMPLATE,\n\t\t\t\t\t\tSITE_ID\n\t\t\t\t\tFROM\n\t\t\t\t\t\tb_site_template\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\tSITE_ID, CASE WHEN " . CMain::__GetConditionFName() . " IS NULL THEN 2 ELSE 1 END, SORT\n\t\t\t\t"); while ($ar = $dbr->Fetch()) { $arSiteTemplateBySite[$ar['SITE_ID']][] = $ar; } $CACHE_MANAGER->Set("b_site_template", $arSiteTemplateBySite); } foreach ($arSiteTemplateBySite[SITE_ID] as $ar) { $strCondition = trim($ar["CONDITION"]); if (strlen($strCondition) > 0 && !@eval("return " . $strCondition . ";")) { continue; } if (file_exists($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/templates/" . $ar["TEMPLATE"]) && is_dir($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/templates/" . $ar["TEMPLATE"])) { return $ar["TEMPLATE"]; } } } return ".default"; }