require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php"); require_once($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/prolog.php"); IncludeModuleLangFile(__FILE__); die('Еще не сделано'); CModule::IncludeModule('seo'); //Site ID $site = SITE_ID; if (isset($_REQUEST["site"]) && strlen($_REQUEST["site"]) > 0) { $obSite = CSite::GetByID($_REQUEST["site"]); if ($arSite = $obSite->Fetch()) $site = $_REQUEST["site"]; } $dbRes = CSite::GetByID($site); if ($arRes = $dbRes->Fetch()) $server_name = $arRes['SERVER_NAME']; if (strlen($server_name) <= 0) $server_name = COption::GetOptionString('main', 'server_name', ''); if (strlen($_REQUEST['title_changer_name'])) { $titleChangerName = $_REQUEST['title_changer_name']; } if (strlen($_REQUEST['title_changer_icons'])) { $arTitleChangerIcons = unserialize($_REQUEST['title_changer_icons']); } if (strlen($_REQUEST['title_final'])) { $titleFinal = $_REQUEST['title_final']; } /* properties */ if (IsModuleInstalled("fileman")) { if (!$USER->CanDoOperation('fileman_admin_files') && !$USER->CanDoOperation('fileman_edit_existent_files')) { // $popupWindow->ShowError(GetMessage("PAGE_PROP_ACCESS_DENIED")); } } //Page path $path = "/"; if (isset($_REQUEST["path"]) && strlen($_REQUEST["path"]) > 0) { $path = $_REQUEST["path"]; $path = Rel2Abs("/", $path); } //Lang if (!isset($_REQUEST["lang"]) || strlen($_REQUEST["lang"]) <= 0) $lang = LANGUAGE_ID; //BackUrl $back_url = (isset($_REQUEST["back_url"]) ? $_REQUEST["back_url"] : ""); $documentRoot = CSite::GetSiteDocRoot($site); $absoluteFilePath = $documentRoot.$path; //Check permissions if (!is_file($absoluteFilePath)) { //$popupWindow->ShowError(GetMessage("PAGE_PROP_FILE_NOT_FOUND")." (".htmlspecialchars($path).")"); } elseif (!$USER->CanDoFileOperation('fm_edit_existent_file',Array($site, $path))) { //$popupWindow->ShowError(GetMessage("PAGE_PROP_ACCESS_DENIED")); } if (false !== ($pos = strrpos($absoluteFilePath, '/'))) { $absoluteDirPath = substr($absoluteFilePath, 0, $pos); } $fileContent = $APPLICATION->GetFileContent($absoluteFilePath); /**************************************************************************************/ $strWarning = ''; //Save page settings if ($_SERVER["REQUEST_METHOD"] == "POST" && !check_bitrix_sessid()) { CUtil::JSPostUnescape(); $strWarning = GetMessage("MAIN_SESSION_EXPIRED"); } elseif ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_REQUEST["save"])) { //Title if (isset($_POST["pageTitle"]) && strlen($_POST["pageTitle"]) > 0) { $fileContent = SetPrologTitle($fileContent, $_POST["pageTitle"]); } //Title $prop_code = COption::GetOptionString('seo', 'property_window_title', 'title'); if (isset($_POST["property_".$prop_code])) { $fileContent = SetPrologProperty($fileContent, $prop_code, $_POST["property_".$prop_code]); } //Properties if (isset($_POST["PROPERTY"]) && is_array($_POST["PROPERTY"])) { foreach ($_POST["PROPERTY"] as $arProperty) { $arProperty["CODE"] = (isset($arProperty["CODE"]) ? trim($arProperty["CODE"]) : ""); $arProperty["VALUE"] = (isset($arProperty["VALUE"]) ? trim($arProperty["VALUE"]) : ""); if (preg_match("/[a-zA-Z_-~]+/i", $arProperty["CODE"])) { $fileContent = SetPrologProperty($fileContent, $arProperty["CODE"], $arProperty["VALUE"]); } } } $prop_code = COption::GetOptionString('seo', 'property_internal_keywords', 'keywords_inner'); if ($arProperty = explode(",", $_POST["property_".$prop_code."_local"])) { array_walk($arProperty, 'trim'); $fileContent = SetPrologProperty($fileContent, $prop_code, implode(', ', $arProperty)); } $success = $APPLICATION->SaveFileContent($absoluteFilePath, $fileContent); if ($success) { if (isset($_POST["property_".$prop_code."_section"])) { $arProperty = explode(",", $_POST["property_".$prop_code."_section"]); if (!is_array($arProperty)) $arProperty = array(); array_walk($arProperty, 'trim'); $arDirProperties = array(); $sSectionName = ''; if (file_exists($_SERVER['DOCUMENT_ROOT'].$absoluteDirPath."/.section.php")) require($_SERVER['DOCUMENT_ROOT'].$absoluteDirPath."/.section.php"); $arDirProperties[$prop_code] = implode(', ', $arProperty); $strSectionName = '$sSectionName = "'.EscapePHPString($sSectionName).'";'; $strDirProperties = "\$arDirProperties = Array(\n"; $bNeedComma = false; foreach ($arDirProperties as $prop_code => $value) { if (strlen($value) > 0 && preg_match("/[a-zA-Z_-~]+/i", $prop_code) ) { if($bNeedComma) $strDirProperties .= ",\n"; $strDirProperties .= " \"".EscapePHPString($prop_code)."\" => \"".EscapePHPString($value)."\""; $bNeedComma = true; } } $strDirProperties .= "\n);\n"; $APPLICATION->SaveFileContent($absoluteDirPath."/.section.php", "<"."?\n".$strSectionName."\n".$strDirProperties."?".">"); } } if ($success === false && ($exception = $APPLICATION->GetException())) $strWarning = $exception->msg; else LocalRedirect("/".ltrim($back_url, "/")); die(); } if ($strWarning != "") { CAdminMessage::ShowMessage($strWarning); die(); } //Properties from fileman settings $arFilemanProperties = Array(); if (CModule::IncludeModule("fileman") && is_callable(Array("CFileMan", "GetPropstypes"))) $arFilemanProperties = CFileMan::GetPropstypes($site); //Properties from page $arDirProperties = Array(); if ($strWarning != "") { //Restore post values if error occured $pageTitle = (isset($_POST["pageTitle"]) && strlen($_POST["pageTitle"]) > 0 ? $_POST["pageTitle"] : ""); if (isset($_POST["PROPERTY"]) && is_array($_POST["PROPERTY"])) { foreach ($_POST["PROPERTY"] as $arProperty) { if (isset($arProperty["VALUE"]) && strlen($arProperty["VALUE"]) > 0) $arDirProperties[$arProperty["CODE"]] = $arProperty["VALUE"]; } } } else { $arPageSlice = ParseFileContent($fileContent); $arDirProperties = $arPageSlice["PROPERTIES"]; $pageTitle = $arPageSlice["TITLE"]; } //All properties for file. Includes properties from root folders $arInheritProperties = $APPLICATION->GetDirPropertyList(Array($site, $path)); if ($arInheritProperties === false) $arInheritProperties = Array(); //Delete equal properties $arGlobalProperties = Array(); foreach ($arFilemanProperties as $propertyCode => $propertyDesc) { if (array_key_exists($propertyCode, $arDirProperties)) $arGlobalProperties[$propertyCode] = $arDirProperties[$propertyCode]; else $arGlobalProperties[$propertyCode] = ""; unset($arDirProperties[$propertyCode]); unset($arInheritProperties[strtoupper($propertyCode)]); } foreach ($arDirProperties as $propertyCode => $propertyValue) unset($arInheritProperties[strtoupper($propertyCode)]); $counters = COption::GetOptionString('seo', 'counters', SEO_COUNTERS_DEFAULT); //HTML output $aTabs = array( array("DIV" => "edit1", "TAB" => 'Страница', "ICON" => "main_settings", "TITLE" => 'Страница '.$back_url), array("DIV" => "edit5", "TAB" => 'Управление', "ICON" => "main_settings", "TITLE" => 'Управление свойствами'), array("DIV" => "edit2", "TAB" => 'Индексация', "ICON" => "main_settings", "TITLE" => 'Индексация'), array("DIV" => "edit3", "TAB" => 'Переходы', "ICON" => "main_settings", "TITLE" => 'Переходы с поисковиков'), array("DIV" => "edit4", "TAB" => 'Ссылающиеся сайты', "ICON" => "main_settings", "TITLE" => 'Ссылающиеся сайты'), ); $tabControl = new CAdminTabControl("tabControl", $aTabs); $APPLICATION->SetTitle('Инструменты SEO для страницы'); require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); ?>