} else {
                     $code .= "\t" . 'Array()' . $br . ');';
                 }
                 $code = '<?' . $code . '?>';
                 $new_content .= $code;
             }
         }
     }
     $new_content .= CMain::EncodePHPTags(substr($content_, $end));
     $CONTENT = $new_content;
 } else {
     $CONTENT = CMain::EncodePHPTags($new_content);
 }
 // Get array of PHP scripts from original template src
 if (strlen($ID) > 0) {
     $templ = CSiteTemplate::GetByID($ID);
     if (!$templ->ExtractFields("str_")) {
         $strWarning = GetMessage('templ_create_err', array('#ID#' => $ID));
     }
 } else {
     $strWarning = GetMessage('templ_create_err1');
 }
 checkError($strWaring);
 $old_content = htmlspecialcharsback($str_CONTENT);
 $arPHP = PHPParser::ParseFile($old_content);
 $l = count($arPHP);
 $s1 = "";
 if ($l > 0) {
     $new_content = '';
     $end = 0;
     $php_count = 0;
Example #2
0
} elseif (!$io->DirectoryExists($documentRoot . $path)) {
    $popupWindow->ShowError(GetMessage("PAGE_NEW_FOLDER_NOT_FOUND") . " (" . htmlspecialcharsbx($path) . ")");
}
if (!$USER->CanDoFileOperation("fm_edit_existent_file", array($site, $path))) {
    $canEditNewPage = false;
}
//Lang
if (!isset($_REQUEST["lang"]) || strlen($_REQUEST["lang"]) <= 0) {
    $lang = LANGUAGE_ID;
}
//BackUrl
$back_url = isset($_REQUEST["back_url"]) ? $_REQUEST["back_url"] : "";
//Template ID
$templateID = false;
if (isset($_REQUEST["templateID"]) && strlen($_REQUEST["templateID"]) > 0) {
    $obTemplate = CSiteTemplate::GetByID($_REQUEST["templateID"]);
    if ($arSiteTemplate = $obTemplate->Fetch()) {
        $templateID = $_REQUEST["templateID"];
    }
}
if ($templateID === false) {
    //Get default template if templateID not set
    $obTemplate = CSite::GetTemplateList($site);
    while ($arSiteTemplate = $obTemplate->Fetch()) {
        if (strlen($arSiteTemplate["CONDITION"]) <= 0) {
            $templateID = $arSiteTemplate["TEMPLATE"];
            break;
        }
    }
}
//default edit groups - need to limit access
Example #3
0
 function GetAllTemplateParams($templateID, $site, $findcomponent = true, $arAdditionalParams = array())
 {
     global $APPLICATION;
     $db_templ = CSiteTemplate::GetByID($templateID);
     if (!($ar_templ = $db_templ->Fetch())) {
         $templateID = "";
         $db_site_templ = CSite::GetTemplateList($site);
         while ($ar_site_templ = $db_site_templ->Fetch()) {
             if (strlen($ar_site_templ["CONDITION"]) <= 0) {
                 $templateID = $ar_site_templ["TEMPLATE"];
                 break;
             }
         }
         if (strlen($templateID) > 0) {
             $db_templ = CSiteTemplate::GetByID($templateID);
             $ar_templ = $db_templ->Fetch();
         }
     }
     if ($ar_templ) {
         $arResult = array("ID" => $ar_templ["ID"], "NAME" => $ar_templ["NAME"]);
         if (is_set($ar_templ, "STYLES")) {
             // Fetch @import and include it to CSS - will include css from comments also :(.
             $pattern = '/^@import(.*)$/im';
             $matches = array();
             if (preg_match_all($pattern, $ar_templ["STYLES"], $matches)) {
                 for ($j = 0, $l = count($matches[0]); $j < $l; $j++) {
                     $str = $matches[0][$j];
                     $url = trim(trim($matches[1][$j]), '"\';');
                     $css = "";
                     if (substr($url, -5) != 'print') {
                         $url = trim(trim($url), ' "\';');
                         if (substr($url, 0, 4) == 'url(' && substr($url, -1) == ')') {
                             $url = trim(substr($url, 4, -1), ' "\'');
                         }
                         $url = trim(trim($url), '\'";');
                         if (substr($url, 0, 1) != '/' && file_exists($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/" . $ar_templ["ID"] . "/" . $url)) {
                             $css = "\n" . $APPLICATION->GetFileContent($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/" . $ar_templ["ID"] . "/" . $url) . "\n";
                         } else {
                             if (file_exists($_SERVER["DOCUMENT_ROOT"] . $url)) {
                                 $css = "\n" . $APPLICATION->GetFileContent($_SERVER["DOCUMENT_ROOT"] . $url) . "\n";
                             }
                         }
                     }
                     $ar_templ["STYLES"] = str_replace($matches[0][$j], $css, $ar_templ["STYLES"]);
                 }
             }
             $arResult["STYLES"] = $ar_templ["STYLES"];
             $arResult["STYLES_TITLE"] = $ar_templ["STYLES_TITLE"];
             $arResult["EDITOR_STYLES"] = $ar_templ["EDITOR_STYLES"];
         }
     } else {
         $arResult = array("ID" => ".default", "NAME" => GetMessage("FILEMAN_DDEF_TEMPLATE"));
         $templateID = "";
     }
     if (!is_set($arResult, "STYLES") || $arResult["STYLES"] == false) {
         if (file_exists($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/" . (strlen($site) <= 0 ? LANGUAGE_ID : $site) . "/styles.css")) {
             $arResult["STYLES"] = $APPLICATION->GetFileContent($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/" . (strlen($site) <= 0 ? LANGUAGE_ID : $site) . "/styles.css");
             $arResult["STYLES_TITLE"] = CSiteTemplate::__GetByStylesTitle($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/" . (strlen($site) <= 0 ? LANGUAGE_ID : $site) . "/.styles.php");
         } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/styles.css")) {
             $arResult["STYLES"] = $APPLICATION->GetFileContent($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/styles.css");
             $arResult["STYLES_TITLE"] = CSiteTemplate::__GetByStylesTitle($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/.styles.php");
         } else {
             $arResult["STYLES"] = $APPLICATION->GetFileContent($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/.default/styles.css");
             $arResult["STYLES_TITLE"] = CSiteTemplate::__GetByStylesTitle($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/.default/.styles.php");
         }
     }
     if (isset($arAdditionalParams['additionalCSS'])) {
         $additionalCSS = $arAdditionalParams['additionalCSS'];
         for ($i = 0, $l = count($additionalCSS); $i < $l; $i++) {
             $css_file_path = $additionalCSS[$i];
             $arResult["STYLES"] .= "\r\n" . $APPLICATION->GetFileContent($css_file_path);
         }
     }
     if (strlen($templateID) > 0 && file_exists($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/" . $templateID . "/editor.css")) {
         $arResult["STYLES"] .= "\r\n" . $APPLICATION->GetFileContent($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/" . $templateID . "/editor.css");
     } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/.default/editor.css")) {
         $arResult["STYLES"] .= "\r\n" . $APPLICATION->GetFileContent($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/.default/editor.css");
     } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/" . $site . "/editor.css")) {
         $arResult["STYLES"] .= "\r\n" . $APPLICATION->GetFileContent($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/" . (strlen($site) <= 0 ? LANGUAGE_ID : $site) . "/editor.css");
     } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/editor.css")) {
         $arResult["STYLES"] .= "\r\n" . $APPLICATION->GetFileContent($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/editor.css");
     }
     $arResult["STYLES"] = preg_replace("/\r\n/", " ", $arResult["STYLES"]);
     $arResult["STYLES"] = preg_replace("/\n/", " ", $arResult["STYLES"]);
     $arResult["SITE_TEMPLATE_PATH"] = getLocalPath('templates/' . $templateID, BX_PERSONAL_ROOT);
     return $arResult;
 }
Example #4
0
                $arAuthResult = $GLOBALS["USER"]->ChangePassword($_REQUEST["USER_LOGIN"], $_REQUEST["USER_CHECKWORD"], $_REQUEST["USER_PASSWORD"], $_REQUEST["USER_CONFIRM_PASSWORD"], $USER_LID);
            } elseif (COption::GetOptionString("main", "new_user_registration", "N") == "Y" && $_SERVER['REQUEST_METHOD'] == 'POST' && $_REQUEST["TYPE"] == "REGISTRATION" && (!defined("ADMIN_SECTION") || ADMIN_SECTION !== true)) {
                $arAuthResult = $GLOBALS["USER"]->Register($_REQUEST["USER_LOGIN"], $_REQUEST["USER_NAME"], $_REQUEST["USER_LAST_NAME"], $_REQUEST["USER_PASSWORD"], $_REQUEST["USER_CONFIRM_PASSWORD"], $_REQUEST["USER_EMAIL"], $USER_LID, $_REQUEST["captcha_word"], $_REQUEST["captcha_sid"]);
            }
        }
        $GLOBALS["APPLICATION"]->SetAuthResult($arAuthResult);
    } elseif (!$GLOBALS["USER"]->IsAuthorized()) {
        //Authorize by unique URL
        $GLOBALS["USER"]->LoginHitByHash();
    }
}
//define the site template
if (!defined("ADMIN_SECTION") || ADMIN_SECTION !== true) {
    if (array_key_exists("bitrix_preview_site_template", $_REQUEST) && $_REQUEST["bitrix_preview_site_template"] != "" && $GLOBALS["USER"]->CanDoOperation('view_other_settings')) {
        //preview of site template
        $aTemplates = CSiteTemplate::GetByID($_REQUEST["bitrix_preview_site_template"]);
        if ($template = $aTemplates->Fetch()) {
            define("SITE_TEMPLATE_ID", $template["ID"]);
        } else {
            define("SITE_TEMPLATE_ID", CSite::GetCurTemplate());
        }
    } else {
        define("SITE_TEMPLATE_ID", CSite::GetCurTemplate());
    }
    define("SITE_TEMPLATE_PATH", BX_PERSONAL_ROOT . '/templates/' . SITE_TEMPLATE_ID);
}
//magic parameters: show page creation time
if (isset($_GET["show_page_exec_time"])) {
    if ($_GET["show_page_exec_time"] == "Y" || $_GET["show_page_exec_time"] == "N") {
        $_SESSION["SESS_SHOW_TIME_EXEC"] = $_GET["show_page_exec_time"];
    }
 protected function setTheme($site_template_id)
 {
     if (strlen($site_template_id) > 0) {
         $result = \CSiteTemplate::GetByID($site_template_id);
         if ($templateFields = $result->Fetch()) {
             $template_path_header = \Bitrix\Main\Application::getDocumentRoot() . $templateFields['PATH'] . '/header.php';
             $template_path_footer = \Bitrix\Main\Application::getDocumentRoot() . $templateFields['PATH'] . '/footer.php';
             if ($templateFields['PATH'] != '' && IO\File::isFileExists($template_path_footer) && IO\File::isFileExists($template_path_header)) {
                 $this->themeStylesString .= $templateFields['TEMPLATE_STYLES'] . "\r\n";
                 $this->themeStylesString .= $templateFields['STYLES'] . "\r\n";
                 $this->setThemeProlog(IO\File::getFileContents($template_path_header));
                 $this->setThemeEpilog(IO\File::getFileContents($template_path_footer));
             }
         }
     }
 }
Example #6
0
    $appManager = \Bitrix\Main\Authentication\ApplicationManager::getInstance();
    if ($appManager->checkScope($applicationID) !== true) {
        CHTTP::SetStatus("403 Forbidden");
        die;
    }
}
//define the site template
if (!defined("ADMIN_SECTION") || ADMIN_SECTION !== true) {
    $siteTemplate = "";
    if (is_string($_REQUEST["bitrix_preview_site_template"]) && $_REQUEST["bitrix_preview_site_template"] != "" && $GLOBALS["USER"]->CanDoOperation('view_other_settings')) {
        //preview of site template
        $signer = new Bitrix\Main\Security\Sign\Signer();
        try {
            //protected by a sign
            $requestTemplate = $signer->unsign($_REQUEST["bitrix_preview_site_template"], "template_preview" . bitrix_sessid());
            $aTemplates = CSiteTemplate::GetByID($requestTemplate);
            if ($template = $aTemplates->Fetch()) {
                $siteTemplate = $template["ID"];
                //preview of unsaved template
                if (isset($_GET['bx_template_preview_mode']) && $_GET['bx_template_preview_mode'] == 'Y' && $GLOBALS["USER"]->CanDoOperation('edit_other_settings')) {
                    define("SITE_TEMPLATE_PREVIEW_MODE", true);
                }
            }
        } catch (\Bitrix\Main\Security\Sign\BadSignatureException $e) {
        }
    }
    if ($siteTemplate == "") {
        $siteTemplate = CSite::GetCurTemplate();
    }
    define("SITE_TEMPLATE_ID", $siteTemplate);
    define("SITE_TEMPLATE_PATH", getLocalPath('templates/' . SITE_TEMPLATE_ID, BX_PERSONAL_ROOT));
Example #7
0
                $_1134959765 = $GLOBALS["USER"]->SendPassword($_REQUEST["USER_LOGIN"], $_REQUEST["USER_EMAIL"], $_223205148);
            } elseif ($_SERVER["REQUEST_METHOD"] == "POST" && $_REQUEST["TYPE"] == "CHANGE_PWD") {
                $_1134959765 = $GLOBALS["USER"]->ChangePassword($_REQUEST["USER_LOGIN"], $_REQUEST["USER_CHECKWORD"], $_REQUEST["USER_PASSWORD"], $_REQUEST["USER_CONFIRM_PASSWORD"], $_223205148);
            } elseif (COption::GetOptionString("main", "new_user_registration", "N") == "Y" && $_SERVER["REQUEST_METHOD"] == "POST" && $_REQUEST["TYPE"] == "REGISTRATION" && (!defined("ADMIN_SECTION") || ADMIN_SECTION !== true)) {
                $_1134959765 = $GLOBALS["USER"]->Register($_REQUEST["USER_LOGIN"], $_REQUEST["USER_NAME"], $_REQUEST["USER_LAST_NAME"], $_REQUEST["USER_PASSWORD"], $_REQUEST["USER_CONFIRM_PASSWORD"], $_REQUEST["USER_EMAIL"], $_223205148, $_REQUEST["captcha_word"], $_REQUEST["captcha_sid"]);
            }
        }
        $GLOBALS["APPLICATION"]->SetAuthResult($_1134959765);
    } elseif (!$GLOBALS["USER"]->IsAuthorized()) {
        $GLOBALS["USER"]->LoginHitByHash();
    }
}
//end check permissions
if (!defined("ADMIN_SECTION") || ADMIN_SECTION !== true) {
    if (isset($_REQUEST["freetrix_preview_site_template"]) && $_REQUEST["freetrix_preview_site_template"] != "" && $GLOBALS["USER"]->CanDoOperation("view_other_settings")) {
        $_362846640 = CSiteTemplate::GetByID($_REQUEST["freetrix_preview_site_template"]);
        if ($_144660368 = $_362846640->Fetch()) {
            define("SITE_TEMPLATE_ID", $_144660368["ID"]);
        } else {
            define("SITE_TEMPLATE_ID", CSite::GetCurTemplate());
        }
    } else {
        define("SITE_TEMPLATE_ID", CSite::GetCurTemplate());
    }
    define("SITE_TEMPLATE_PATH", getLocalPath("templates/" . SITE_TEMPLATE_ID, FX_PERSONAL_ROOT));
}
if (isset($_GET["show_page_exec_time"])) {
    if ($_GET["show_page_exec_time"] == "Y" || $_GET["show_page_exec_time"] == "N") {
        $_SESSION["SESS_SHOW_TIME_EXEC"] = $_GET["show_page_exec_time"];
    }
}