require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
    die;
}
$filesrc_tmp = $APPLICATION->GetFileContent($abs_path);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!check_bitrix_sessid()) {
        $strError = GetMessage("TR_SESSION_EXPIRED");
        $bVarsFromForm = true;
    } else {
        $filesrc_for_save = $filesrc_tmp;
        if (isset($_POST['filesrc'])) {
            $filesrc_for_save = $_POST['filesrc'];
        }
    }
    if ($strError == '') {
        if (!TR_BACKUP($file)) {
            $strError = GetMessage("TR_CREATE_BACKUP_ERROR", array('%FILE%' => $file));
        } else {
            if (!$APPLICATION->SaveFileContent($abs_path, $filesrc_for_save)) {
                if ($APPLICATION->GetException()) {
                    $str_err = $APPLICATION->GetException();
                    if ($str_err && ($err = $str_err->GetString())) {
                        $strError = $err;
                    }
                }
                if ($strError == '') {
                    $strError = GetMessage("TR_FILE_SAVE_ERROR");
                }
            }
        }
        if ($strError == '') {
Example #2
0
						{
							$arTEXT[$arLangFiles[$ms_lang]][] = "";
						}
					}
				}
			}

			// collect all the variables and write to files
			while (list($fpath, $arM)=each($arTEXT))
			{
				$strContent = "";
				foreach ($arM as $M)
				{
					if (strlen($M)>0) $strContent .= "\n".$M.";";
				}
				if (!TR_BACKUP($fpath)) {
					$strError .= GetMessage("TR_CREATE_BACKUP_ERROR", array('%FILE%' => $fpath))."<br>\n";
				}
				else
				{
					if (strlen($strContent)>0)
					{
						RewriteFile($_SERVER["DOCUMENT_ROOT"].$fpath, "<?".$strContent."\n?".">");
					}
					else
					{
						if (file_exists($_SERVER["DOCUMENT_ROOT"].$fpath))
						{
							@chmod($_SERVER["DOCUMENT_ROOT"].$fpath, BX_FILE_PERMISSIONS);
							@unlink($_SERVER["DOCUMENT_ROOT"].$fpath);
						}
Example #3
0
function TSEARCH($file, &$count)
{
    global $arSearchParam, $APPLICATION, $USER;
    if (!$USER->CanDoOperation('edit_php')) {
        return false;
    }
    $_mess = __IncludeLang($file, true);
    if (!is_array($_mess)) {
        return false;
    }
    $_phrase = $phrase = $arSearchParam['search'];
    if (!$arSearchParam['bCaseSens']) {
        $_phrase = strtolower($arSearchParam['search']);
    }
    $I_PCRE_MODIFIER = $arSearchParam['bCaseSens'] ? '' : 'i';
    $_bMessage = true;
    $_bMnemonic = false;
    $_arSearchData = array();
    if ($arSearchParam['bSearchMessage'] && $arSearchParam['bSearchMnemonic']) {
        $_bMessage = true;
        $_bMnemonic = true;
    } elseif ($arSearchParam['bSearchMnemonic']) {
        $_bMnemonic = true;
    }
    $_bResult = false;
    $count = 0;
    foreach ($_mess as $_sMn => $_sMe) {
        $__sMe = $_sMe;
        $__sMn = $_sMn;
        if (!$arSearchParam['bCaseSens']) {
            $__sMe = strtolower($_sMe);
            $__sMn = strtolower($_sMn);
        }
        $_bSearch = false;
        if ($_bMessage) {
            if (strpos($__sMe, $_phrase) !== false) {
                $_bSearch = true;
            }
        }
        if ($_bMnemonic) {
            if (strpos($__sMn, $_phrase) !== false) {
                $_bSearch = true;
            }
        }
        if ($_bSearch) {
            $_bResult = true;
            $res = array();
            //Replace
            if ($arSearchParam['is_replace']) {
                $pattern = '/' . preg_quote($phrase, '/') . '/S' . $I_PCRE_MODIFIER . BX_UTF_PCRE_MODIFIER;
                TR_BACKUP($file);
                if ($_bMessage) {
                    preg_match_all($pattern, $_sMe, $res);
                    $count += count($res[0]);
                    $_sMe = preg_replace($pattern, $arSearchParam['replace'], $_sMe);
                }
                if ($_bMnemonic) {
                    preg_match_all($pattern, $_sMn, $res);
                    $count += count($res[0]);
                    $_sMn = preg_replace($pattern, $arSearchParam['replace'], $_sMn);
                }
            } else {
                $pattern = '/' . preg_quote($phrase, '/') . '/' . $I_PCRE_MODIFIER . BX_UTF_PCRE_MODIFIER;
                if ($_bMessage) {
                    preg_match_all($pattern, $_sMe, $res);
                    $count += count($res[0]);
                }
                if ($_bMnemonic) {
                    preg_match_all($pattern, $_sMn, $res);
                    $count += count($res[0]);
                }
            }
        }
        if ($arSearchParam['is_replace']) {
            $_arSearchData[] = "\$MESS[\"" . EscapePHPString($_sMn) . "\"] = \"" . EscapePHPString(str_replace("\r", "", $_sMe)) . "\"";
        }
    }
    if ($arSearchParam['is_replace'] && $_bResult) {
        $strContent = "";
        foreach ($_arSearchData as $M) {
            if (strlen($M) > 0) {
                $strContent .= "\n" . $M . ";";
            }
        }
        RewriteFile($file, "<?" . $strContent . "\n?" . ">");
    }
    return $_bResult;
}