1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
file_edit_src.php
См. документацию.
1<?
2define('BX_PUBLIC_MODE', true);
3
4require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
5require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_js.php");
6
7// lpa is not allowed!
8if (!($USER->CanDoOperation('edit_php')))
9 $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
10
12
13require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/fileman/include.php");
14
15IncludeModuleLangFile(__FILE__);
16
18
20
22if ($filename <> '' && ($mess = CFileMan::CheckFileName($filename)) !== true)
23{
24 $filename2 = $filename;
25 $filename = '';
26 $strWarning = $mess;
27 $bVarsFromForm = true;
28}
29
31 $AUTOSAVE = new CAutoSave();
32
33$path = $io->CombinePath("/", urldecode($path));
35if(!$site)
36 $site = CSite::GetSiteByFullPath($_SERVER["DOCUMENT_ROOT"].$path);
37
38$DOC_ROOT = CSite::GetSiteDocRoot($site);
39$abs_path = $io->CombinePath($DOC_ROOT, $path);
40
41if($new <> '' && $filename <> '')
42 $abs_path = $io->CombinePath($abs_path, $filename);
43
44if(($new == '' || $filename == '') && !$io->FileExists($abs_path))
45{
46 $p = mb_strrpos($path, "/");
47 if($p!==false)
48 {
49 $new = "Y";
50 $filename = mb_substr($path, $p + 1);
51 $path = mb_substr($path, 0, $p);
52 }
53}
54
55if($new <> '' && $filename <> '' && ($io->FileExists($abs_path) || $io->DirectoryExists($abs_path))) // если мы хотим создать новый файл, но уже такой есть - ругаемся
56{
57 $strWarning = GetMessage("FILEMAN_FILEEDIT_FILE_EXISTS")." ";
58 $bEdit = false;
59 $bVarsFromForm = true;
60}
62{
63 if ($filename == '')
64 $strWarning = GetMessage("FILEMAN_FILEEDIT_FILENAME_EMPTY")." ";
65 $bEdit = false;
66}
67else
68{
69 if(!$io->FileExists($abs_path))
70 $strWarning = GetMessage("FILEMAN_FILEEDIT_FOLDER_EXISTS")." ";
71 else
72 $bEdit = true;
73}
74
75if($strWarning == '')
76{
77 if($bEdit)
78 {
79 $f = $io->GetFile($abs_path);
80 $filesrc_tmp = $f->GetContents();
81 }
82 else
83 {
84 $site_template = false;
86 while($arSiteTemplate = $rsSiteTemplates->Fetch())
87 {
88 if($arSiteTemplate["CONDITION"] == '')
89 {
90 $site_template = $arSiteTemplate["TEMPLATE"];
91 break;
92 }
93 }
94
95 $arTemplates = CFileman::GetFileTemplates(LANGUAGE_ID, array($site_template));
96 if($template <> '')
97 {
98 for ($i=0; $i<count($arTemplates); $i++)
99 {
100 if($arTemplates[$i]["file"] == $template)
101 {
102 $filesrc_tmp = CFileman::GetTemplateContent($arTemplates[$i]["file"], LANGUAGE_ID, array($site_template));
103 break;
104 }
105 }
106 }
107 else
108 $filesrc_tmp = CFileman::GetTemplateContent($arTemplates[0]["file"], LANGUAGE_ID, array($site_template));
109 }
110
111 if($_SERVER['REQUEST_METHOD']=="POST" && $save <> '')
112 {
114 {
115 $strWarning = GetMessage("FILEMAN_SESSION_EXPIRED");
116 $bVarsFromForm = true;
117 }
118
119 // lpa was denied earlier, so use file src as is
120 $filesrc_for_save = $_POST['filesrc'];
121
122 if($strWarning == '')
123 {
124 if (!CFileMan::CheckOnAllowedComponents($filesrc_for_save))
125 {
126 $str_err = $APPLICATION->GetException();
127 if($str_err && ($err = $str_err ->GetString()))
128 $strWarning .= $err;
129 $bVarsFromForm = true;
130 }
131 }
132
133 if($strWarning == '')
134 {
135 $f = $io->GetFile($abs_path);
136 $arUndoParams = array(
137 'module' => 'fileman',
138 'undoType' => 'edit_file',
139 'undoHandler' => 'CFileman::UndoEditFile',
140 'arContent' => array(
141 'absPath' => $abs_path,
142 'content' => $f->GetContents()
143 )
144 );
145
146 if(!$APPLICATION->SaveFileContent($abs_path, $filesrc_for_save))
147 {
148 if (($str_err = $APPLICATION->GetException()))
149 {
150 if (($err = $str_err->GetString()))
151 {
152 $strWarning = $err;
153 }
154
155 $bVarsFromForm = true;
156 }
157
158 if (empty($strWarning))
159 {
160 $strWarning = GetMessage("pub_src_edit_err");
161 }
162 }
163 else
164 {
165 $bEdit = true;
166 CUndo::ShowUndoMessage(CUndo::Add($arUndoParams));
167
168 if(COption::GetOptionString("fileman", "log_page", "Y")=="Y")
169 {
170 CEventLog::Log("content", "PAGE_EDIT", "fileman", $path, false, $_REQUEST["site"] ?? false);
171 }
172
173 if (CAutoSave::Allowed())
174 $AUTOSAVE->Reset();
175 }
176
177 if($strWarning == '')
178 {
179?>
180<script bxrunfirst="true">
181top.BX.showWait();
182top.BX.reload('<?=CUtil::JSEscape($_REQUEST["back_url"])?>', true);
183top.<?=$obJSPopup->jsPopup?>.Close();
184</script>
185<?
186 die();
187 }
188
189 $filesrc_tmp = $filesrc_for_save;
190 }
191 }
192}
193
194if ($strWarning <> '')
195 $obJSPopup->ShowValidationError($strWarning);
196
198{
199 if(!$bEdit && $filename == '')
200 $filename = "untitled.php";
201
202 $filesrc = $filesrc_tmp;
203}
204else
205 $filesrc = $_POST['filesrc'];
206
207/*************************************************/
208
209$obJSPopup->ShowTitlebar(($bEdit ? GetMessage("FILEMAN_FILEEDIT_PAGE_TITLE") : GetMessage("FILEMAN_NEWFILEEDIT_TITLE")).": ".htmlspecialcharsbx($path));
210
211$obJSPopup->StartDescription();
212
213echo '<a href="/bitrix/admin/fileman_file_edit.php?path='.urlencode($path).'&amp;full_src=Y&amp;site='.$site.'&amp;lang='.LANGUAGE_ID.'&amp;back_url='.urlencode($_GET["back_url"]).(!$bEdit? '&amp;new=Y&amp;filename='.urlencode($filename).'&amp;template='.urlencode($template):'').($_REQUEST["templateID"]<>''? '&amp;templateID='.urlencode($_REQUEST["templateID"]):'').'" title="'.htmlspecialcharsbx($path).'">'.GetMessage("public_file_edit_edit_cp").'</a>';
214
215$obJSPopup->StartContent();
217{
218 echo CJSCore::Init(array('autosave'), true);
219 $AUTOSAVE->Init();
220?><script>BX.WindowManager.Get().setAutosave();</script><?
221}
222?>
223
224<input type="hidden" name="site" value="<?= htmlspecialcharsbx($site) ?>">
225<input type="hidden" name="path" value="<?= htmlspecialcharsbx(urlencode($path)) ?>">
226<input type="hidden" name="save" value="Y">
227<input type="hidden" name="lang" value="<?echo LANGUAGE_ID ?>">
228<input type="hidden" name="save" value="Y">
229<input type="hidden" name="template" value="<?echo htmlspecialcharsbx($template)?>">
230<input type="hidden" name="back_url" value="<?=htmlspecialcharsbx($back_url)?>">
231<input type="hidden" name="templateID" value="<?=htmlspecialcharsbx($_REQUEST["templateID"])?>">
232
234
235<?if(!$bEdit):?>
236<div id="bx_additional_params">
237 <input type="hidden" name="new" value="y">
238 <?echo GetMessage("FILEMAN_FILEEDIT_NAME")?><br>
239 <?
240 if (isset($filename2))
241 $filename = $filename2;
242 ?>
243 <input type="text" name="filename" style="width:100%" size="40" maxlength="255" value="<?echo htmlspecialcharsbx($filename)?>"><br><br>
244</div>
245<?endif;?>
246
247<textarea id="bx-filesrc" name="filesrc" style="height: 99%; width: 100%;"><?= htmlspecialcharsbx($filesrc)?></textarea>
248
249<?
250$ceid = false;
251if(COption::GetOptionString('fileman', "use_code_editor", "Y") == "Y" && CModule::IncludeModule('fileman'))
252{
253 $forceSyntax = false;
254 if ($path)
255 {
256 $ext = mb_strtolower(CFileMan::GetFileExtension($path));
257 if ($ext == 'sql')
258 $forceSyntax = 'sql';
259 elseif($ext == 'js')
260 $forceSyntax = 'js';
261 elseif($ext == 'css')
262 $forceSyntax = 'css';
263 }
264 $ceid = CCodeEditor::Show(array('textareaId' => 'bx-filesrc', 'forceSyntax' => $forceSyntax));
265}
266?>
267<script>
268var border = null, ta = null, wnd = BX.WindowManager.Get();
269
270function TAResize(data)
271{
272 <?if ($ceid):?>
273 var CE = window.BXCodeEditors['<?= $ceid?>'];
274 if (CE && CE.Resize)
275 {
276 CE.Resize(data.width - 10, data.height - 60);
277 return;
278 }
279 <?endif;?>
280
281 if (null == ta)
282 ta = BX('bx-filesrc');
283 if (null == border)
284 border = parseInt(BX.style(ta, 'border-left-width')) + parseInt(BX.style(ta, 'border-right-width'));
285 if (isNaN(border))
286 border = 0;
287
288 var add = BX('bx_additional_params');
289
290 if (data.height)
291 ta.style.height = (data.height - border - wnd.PARTS.HEAD.offsetHeight - (add ? add.offsetHeight : 0) - 35) + 'px';
292 if (data.width)
293 ta.style.width = (data.width - border - 10) + 'px';
294}
295
296BX.addCustomEvent(wnd, 'onWindowResizeExt', TAResize);
297TAResize(wnd.GetInnerPos());
298
299<?if ($ceid):?>
300BX.addCustomEvent(window, 'OnCodeEditorReady', function(){TAResize(wnd.GetInnerPos());});
301<?endif;?>
302</script>
303
304<?
305$obJSPopup->StartButtons();
306$obJSPopup->ShowStandardButtons(array('save', 'cancel'));
307$obJSPopup->EndButtons();
308
309require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin_js.php");
310?>
$path
Определения access_edit.php:21
$AUTOSAVE
Определения autosave.php:12
global $APPLICATION
Определения include.php:80
if($canUseYandexMarket) $strWarning
Определения options.php:74
static GetTemplateList($site_id)
Определения site.php:540
Определения undo.php:238
static Allowed()
Определения undo.php:441
static GetInstance()
Определения virtual_io.php:60
static Show($params)
Определения code_editor.php:5
static Log($SEVERITY, $AUDIT_TYPE_ID, $MODULE_ID, $ITEM_ID, $DESCRIPTION=false, $SITE_ID=false)
Определения event_log.php:32
static CheckOnAllowedComponents($str)
Определения fileman.php:1940
static __CheckSite($site)
Определения fileman.php:772
static GetFileExtension($path)
Определения fileman.php:795
static CheckFileName($str)
Определения fileman.php:2069
static Init($arExt=array(), $bReturn=false)
Определения jscore.php:66
Определения jspopup.php:10
static ShowUndoMessage($ID)
Определения undo.php:187
static Add($params=array())
Определения undo.php:9
$abs_path
Определения component_props2.php:76
$f
Определения component_props.php:52
$filesrc
Определения component_props.php:53
$rsSiteTemplates
Определения file_edit.php:32
$filename
Определения file_edit.php:47
$DOC_ROOT
Определения file_edit.php:66
$new
Определения file_edit.php:48
$bVarsFromForm
Определения file_edit.php:44
$site_template
Определения file_edit.php:31
$template
Определения file_edit.php:49
else $bEdit
Определения file_edit_src.php:72
$strWarning
Определения file_edit_src.php:17
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
bx_acc_lim_group_list limitGroupList[] multiple<?=$group[ 'ID']?> ID selected margin top
Определения file_new.php:657
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
$p
Определения group_list_element_edit.php:23
$save
Определения iblock_catalog_edit.php:365
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $USER
Определения csv_new_run.php:40
$io
Определения csv_new_run.php:98
endif
Определения csv_new_setup.php:990
bitrix_sessid_post($varname='sessid', $returnInvocations=false)
Определения tools.php:4700
check_bitrix_sessid($varname='sessid')
Определения tools.php:4686
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
die
Определения quickway.php:367
$i
Определения factura.php:643
font style
Определения invoice.php:442
font size
Определения invoice.php:442
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$obJSPopup
Определения settings_admin_form.php:102
$site
Определения yandex_run.php:614