1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
fileman_utils.php
См. документацию.
1<?php
2
4
6{
7 public static function InitScript($Params)
8 {
9 CUtil::InitJSCore(array('ajax', 'window'));
10
11 $arLangArray = array();
12 if ($Params['initSearch'])
13 $arLangArray[] = 'search';
14
15 if ($Params['initServerAccess'] ?? false)
16 $arLangArray[] = 'server_access';
17
18 if ($Params['initCopy'])
19 $arLangArray[] = 'copy';
20
21 if ($Params['initPack'])
22 $arLangArray[] = 'pack';
23
24 $arSites = Array();
25 $dbSitesList = CSite::GetList();
26 while($arSite = $dbSitesList->GetNext())
27 {
28 $arSites[] = array(
29 "id" => $arSite["ID"],
30 "dir" => $arSite["DIR"],
31 "text" => '['.$arSite["ID"].'] '.$arSite["~NAME"],
32 "current" => $arSite["ID"] == $Params['site']
33 );
34 }
35
36 $arArcTypes = array();
37 $arTypesTmp = CBXArchive::GetAvailableFormats();
38
39 foreach ($arTypesTmp as $key => $value)
40 {
41 $arArcTypes[] = array(
42 "id" => $key,
43 "text" => mb_strtoupper($key)
44 );
45 }
46
47 ?>
48 <script src="/bitrix/js/fileman/fileman_utils.js?v=<?=@filemtime($_SERVER['DOCUMENT_ROOT'].'/bitrix/js/fileman/fileman_utils.js')?>"></script>
49
50 <script>
51 <?CFilemanUtils::AppendLangMessages($arLangArray);?>
52
53 <?if ($Params['initSearch']):?>
54 // * * * Search / replace * * *
55 var oSearchDialog = new BX.CAdminDialog({
56 title : '<?= GetMessage('FILEMAN_SEARCH')?>',
57 height: 300,
58 width: 570,
59 resizable: false
60 });
61
62 oSearchDialog.SetButtons([
63 new BX.CWindowButton(
64 {
65 title: "<?= GetMessage("FM_UTIL_FIND")?>",
66 id: 'search',
67 name: 'search',
68 className: 'adm-btn-save',
69 action: function(){window.oFMSearch.Search();}
70 }),
71 new BX.CWindowButton(
72 {
73 title: "<?= GetMessage("FM_UTIL_COUNT")?>",
74 id: 'count',
75 name: 'count',
76 action: function(){window.oFMSearch.Count()}
77 }),
78 oSearchDialog.btnCancel
79 ]);
80
81 window.SearchReplaceRun = function(path, bSearch, ssess, lastValues)
82 {
83 BX.addClass(oSearchDialog.PARTS.CONTENT, "bx-fm-dialog-tabed");
84 oSearchDialog.Show();
85 oSearchDialog.adjustSizeEx();
86 oSearchDialog.PARTS.CONTENT_DATA.style.height = 'auto';
87
88 if (!window.oFMSearch || !window.oFMSearch.bInited)
89 {
90 window.oFMSearch = new BXFMSearch(
91 {
92 oSearchDialog: oSearchDialog,
93 lang: '<?= LANGUAGE_ID?>',
94 site: '<?= CUtil::JSEscape($Params['site'])?>',
95 sessid_get: '<?= bitrix_sessid_get()?>',
96 viewMsFilePath: '<?= CUtil::JSEscape($Params['viewMsFilePath'])?>',
97 viewMsFolderPath: '<?= CUtil::JSEscape($Params['viewMsFolderPath'])?>',
98 dateFormat: '<?= CLang::GetDateFormat("SHORT")?>',
101 arSites: <?= CUtil::PhpToJSObject($arSites)?>
102 });
103 }
104
105 window.oFMSearch.OnOpen({
106 path: path,
107 bSearch: bSearch,
108 ssess: ssess,
109 lastValues: lastValues || false
110 });
111 };
112 <?endif;?>
113
114 <?if ($Params['initCopy']):?>
115 // * * * Copy / Move * * *
116 var oCopyDialog = new BX.CDialog({
117 title : 'copy-move',
118 height: 160,
119 width: 500,
120 resizable: false
121 });
122
123 oCopyDialog.SetButtons([
124 new BX.CWindowButton(
125 {
126 title: "ok",
127 id: 'ok',
128 name: 'ok',
129 action: function(){window.oBXFMCopy.Process();}
130 }),
131 oCopyDialog.btnCancel
132 ]);
133
134 window.CopyMoveRun = function(arFiles, bCopy)
135 {
136 oCopyDialog.Show();
137
138 if (!window.oBXFMCopy || !window.oBXFMCopy.bInited)
139 {
140 window.oBXFMCopy = new BXFMCopy(
141 {
142 oCopyDialog: oCopyDialog,
143 lang: '<?= LANGUAGE_ID?>',
144 site: '<?= CUtil::JSEscape($Params['site'])?>',
145 sessid_get: '<?= bitrix_sessid_get()?>',
146 viewMsFilePath: '<?= CUtil::JSEscape($Params['viewMsFilePath'])?>',
147 viewMsFolderPath: '<?= CUtil::JSEscape($Params['viewMsFolderPath'])?>',
148 oUserConfig: <?= CUtil::PhpToJSObject(CFilemanCopy::GetConfig())?>,
150 arSites: <?= CUtil::PhpToJSObject($arSites)?>
151 });
152 }
153
154 window.oBXFMCopy.OnOpen({
155 path: BX('quick_path').value,
156 arFiles: arFiles,
157 bCopy: !!bCopy,
158 bSearch: <?= (($_GET['search'] ?? null) == "Y" ? 'true' : 'false')?>,
159 ssess: "<?= CFilemanSearch::SecureSearchSess(($_GET['ssess'] ?? null))?>"
160 });
161 };
162 <?endif;?>
163
164 <?
165 if ($Params['initPack']):?>
166 // * * * Pack / Unpack * * *
167 var oPackDialog = new BX.CDialog(
168 {
169 title : 'pack-unpack',
170 height: 160,
171 width: 500,
172 resizable: false
173 });
174
175 oPackDialog.SetButtons([
176 new BX.CWindowButton(
177 {
178 title: "ok",
179 id: 'ok-pack',
180 name: 'ok',
181 action: function(){window.oBXFMPack.Process();}
182 }),
183 new BX.CWindowButton(
184 {
185 title: "cancel",
186 id: 'cancel-pack',
187 name: 'cancel'
188 })
189 ]);
190
191 window.PackUnpackRun = function(arFiles, bPack, qPath)
192 {
193 oPackDialog.Show();
194
195 if (!window.oBXFMPack || !window.oBXFMPack.bInited)
196 {
197 window.oBXFMPack = new BXFMPack(
198 {
199 oPackDialog: oPackDialog,
200 lang: '<?= LANGUAGE_ID?>',
201 site: '<?= CUtil::JSEscape($Params['site'])?>',
202 sessid_get: '<?= bitrix_sessid_get()?>',
203 viewMsFilePath: '<?= CUtil::JSEscape($Params['viewMsFilePath'])?>',
204 viewMsFolderPath: '<?= CUtil::JSEscape($Params['viewMsFolderPath'])?>',
206 arSites: <?= CUtil::PhpToJSObject($arSites)?>,
207 //archive types
208 arTypes: <?= CUtil::PhpToJSObject($arArcTypes)?>
209 });
210 }
211
212 window.oBXFMPack.OnOpen({
213 path: BX('quick_path').value,
214 arFiles: arFiles,
215 bPack: !!bPack,
216 bSearch: <?= (($_GET['search'] ?? null) == "Y" ? 'true' : 'false')?>,
217 ssess: "<?= CFilemanSearch::SecureSearchSess(($_GET['ssess'] ?? null))?>"
218 });
219 };
220 <?endif;?>
221
222 // Init hot keys
223 BX.bind(BX.browser.IsIE() ? document.body : window, "keydown", function(e)
224 {
225 if (!e)
226 e = window.event;
227
228 <?if ($Params['initSearch']):?>
229 if (e.ctrlKey && !e.shiftKey && !e.altKey && e.keyCode == 70)
230 {
231 var js = BX('btn_fileman_search').getAttribute('href');
232 BX.evalGlobal(js.substr('javascript: '.length));
233 return BX.PreventDefault(e);
234 }
235 <?endif;?>
236 });
237 </script>
238 <?
239 }
240
241 public static function AppendLangMessages($Config)
242 {
243 $arLangMess = array();
244 if (in_array('search', $Config))
245 {
246 $arLangMess = array_merge($arLangMess, array(
247 'Count' => 'FM_UTIL_COUNT',
248 'Counted' => 'FM_UTIL_COUNTED',
249 'CountedFiles' => 'FM_UTIL_COUNTED_FILES',
250 'SearchProgress' => 'FM_UTIL_SEARCH_PROGRESS',
251 'ShowRes' => 'FM_UTIL_SHOW_RES',
252 'Stop' => 'FM_UTIL_STOP_SEARCH',
253 'SearchEnded' => 'FM_UTIL_SEARCH_ENDED',
254 'Path' => 'FM_UTIL_SEARCH_PATH',
255 'Size' => 'FM_UTIL_SEARCH_SIZE',
256 'Date' => 'FM_UTIL_SEARCH_DATE',
257 'CountProgress' => 'FM_UTIL_COUNT_PROGRESS',
258 'CountEnded' => 'FM_UTIL_COUNT_ENDED',
259 'Find' => 'FM_UTIL_FIND',
260 'Replace' => 'FM_UTIL_REPLACE',
261 'ReplProgress' => 'FM_UTIL_REPLACE_PROGRESS',
262 'ReplEnded' => 'FM_UTIL_REPLACE_ENDED',
263 'ReplCounted' => 'FM_UTIL_REPLACE_COUNTED',
264 'ReplCountInFiles' => 'FM_UTIL_REPLACE_COUNT_IN_FILES',
265 'ReplShowRes' => 'FM_UTIL_REPLACE_SHOW_RES',
266 'ReplInFileTitle' => 'FM_UTIL_REPLACE_IN_FILE_TITLE',
267 'ReplaceConfirm' => 'FM_UTIL_REPLACE_CONFIRM',
268 'ReplacePhraseWarn' => 'FM_UTIL_REPLACE_WARN',
269 'SearchInFileTitle' => 'FM_UTIL_SEARCH_IN_FILE_TITLE',
270 'CountLimitWarn' => 'FM_UTIL_RES_COUNT_LIMIT_WARN',
271 ));
272 }
273
274 if (in_array('server_access', $Config))
275 {
276 $arLangMess = array_merge($arLangMess, array(
277 'Ok' => 'FM_SA_OK',
278 'InProcess' => 'FM_SA_IN_PROC',
279 'Stop' => 'FM_UTIL_STOP_SEARCH',
280 'StopTitle' => 'FM_SA_STOP_TITLE',
281 'Return' => 'FM_SA_RETURN',
282 'ReturnTitle' => 'FM_SA_RETURN_TITLE',
283 'Stoped' => 'FM_SA_STOPED',
284 'Error' => 'FM_SA_ERROR',
285 ));
286 }
287
288 if (in_array('copy', $Config))
289 {
290 $arLangMess = array_merge($arLangMess, array(
291 'Copy' => 'FM_UTIL_COPY',
292 'Move' => 'FM_UTIL_MOVE',
293 'CopyTitle' => 'FM_UTIL_COPY_TITLE',
294 'MoveTitle' => 'FM_UTIL_MOVE_TITLE',
295 'More' => 'FM_UTIL_MORE',
296 'NoFolder' => 'FM_UTIL_NO_FOLDER',
297 'NoFolderNoAccess' => 'FM_UTIL_NO_FOLDER_NO_ACCESS',
298 'FileExist' => 'FM_UTIL_FILE_EXIST',
299 'Replace' => 'FM_COPY_REPLACE',
300 'Rename' => 'FM_COPY_RENAME',
301 'Skip' => 'FM_COPY_SKIP',
302 'ToAll' => 'FM_COPY_TO_ALL',
303 'FileExistTitle' => 'FM_UTIL_FILE_EXIST_1',
304 'FolderExistTitle' => 'FM_UTIL_FILE_EXIST_2',
305 'RenameTitle' => 'FM_COPY_RENAME_TITLE'
306 ));
307 }
308
309 if (in_array('pack', $Config))
310 {
311 $arLangMess = array_merge($arLangMess, array(
312 'Pack' => 'FM_UTIL_PACK',
313 'Unpack' => 'FM_UTIL_UNPACK',
314 'PackTitle' => 'FM_UTIL_PACK_TITLE',
315 'UnpackTitle' => 'FM_UTIL_UNPACK_TITLE',
316 'UnpackError' => 'FM_UTIL_UNPACK_ERROR',
317 'PackError' => 'FM_UTIL_PACK_ERROR',
318 'More' => 'FM_UTIL_MORE',
319 'NoFolder' => 'FM_UTIL_NO_FOLDER',
320 'NoFolderNoAccess' => 'FM_UTIL_NO_FOLDER_NO_ACCESS',
321 'FileExist' => 'FM_UTIL_FILE_EXIST',
322 'Replace' => 'FM_PACK_REPLACE',
323 'Rename' => 'FM_PACK_RENAME',
324 'Skip' => 'FM_PACK_SKIP',
325 'FileExistTitle' => 'FM_UTIL_FILE_EXIST_1',
326 'FolderExistTitle' => 'FM_UTIL_FILE_EXIST_2',
327 'AskNewName' => 'FM_PACK_ASK_NEW_NAME',
328 'PackPermsError' => 'FM_UTIL_PACK_PERMS_ERROR',
329 'PackFinishing' => 'FM_UTIL_PACK_FINISH',
330 'PackCancel' => 'FM_UTIL_PACK_CANCEL',
331 'PackFNameError' => 'FM_UTIL_PACK_FNAME_ERROR'
332 ));
333 }
334
335 if (count($arLangMess) > 0):
336?>
337var FM_MESS = {0:0<?foreach($arLangMess as $m1 => $m2){echo ', '.$m1." : '".addslashes(GetMessage($m2))."'";}?>};
338<?
339 endif;
340 }
341
342 public static function BuildDialogContent($site)
343 {
344 global $APPLICATION;
345 $actUri = $APPLICATION->GetCurPage()."?search=Y&ssess=".CFilemanSearch::GetSearchSess();
346
347 $s = DeleteParam(array('search', 'ssess'));
348 if ($s != '')
349 $actUri .= '&'.$s;
350
351 $defMask = COption::GetOptionString("fileman", "search_mask", "*.php");
352 // Search dialog
353 $aTabs[] = array("DIV" => "bx_fm_tab_search", "TAB" => GetMessage("FM_UTIL_FIND"), "ICON" => "", "TITLE" => GetMessage("FM_UTIL_FIND_TITLE"), "ONSELECT" => "window.oFMSearch.SetTab('search');");
354 $aTabs[] = array("DIV" => "bx_fm_tab_replace", "TAB" => GetMessage("FM_UTIL_REPLACE"), "ICON" => "", "TITLE" => GetMessage("FM_UTIL_REPLACE_TITLE"), "ONSELECT" => "window.oFMSearch.SetTab('replace');");
355
356 $searchTabControl = new CAdmintabControl("searchTabControl", $aTabs, false, true);
357 $searchTabControl->SetPublicMode('oSearchDialog');
358 $searchTabControl->Begin();
359 ?>
360 <?$searchTabControl->BeginNextTab();?>
361 <tr><td>
362 <div id="bx_search_cont" class="bxfm-search-cont"><form name="bx_search_form" action="<?= $actUri?>" method="POST">
363 <table id="bx_fms_tbl" class="bxfm-d-params bxfm-d-params-add-hide">
364 <tr id="bx_search_in_res_tr">
365 <td class="bxfm-d-label"><input id="bx_search_in_res" type="checkbox" value="Y" checked="checked" /></td>
366 <td class="bxfm-d-value"><label for="bx_search_in_res" style="font-weight: bold;"><?= GetMessage("FM_UTIL_IN_SEARCH_RESULT")?></label></td>
367 </tr>
368 <tr title='<?= GetMessage("FM_UTIL_FILE_NAME_TITLE")?>'>
369 <td class="bxfm-d-label"><label for="bx_search_file"><?= GetMessage("FM_UTIL_FILE_NAME")?>:</label></td>
370 <td class="bxfm-d-value"><input id="bx_search_file" name="bx_search_file" value="<?= htmlspecialcharsbx($defMask)?>" style="width: 220px;" type="text"/></td>
371 </tr>
372 <tr title="<?= GetMessage("FM_UTIL_PHRASE_TITLE")?>">
373 <td class="bxfm-d-label"><label for="bx_search_phrase"><?= GetMessage("FM_UTIL_PHRASE")?>:</label></td>
374 <td class="bxfm-d-value"><input id="bx_search_phrase" name="bx_search_phrase" value="" style="width: 220px;" type="text"/></td>
375 </tr>
376 <tr class="bxfm-d-only-replace" title="<?= GetMessage("FM_UTIL_REPLACE_INP_TITLE")?>">
377 <td class="bxfm-d-label"><label for="bx_replace_phrase"><?= GetMessage("FM_UTIL_REPLACE_INP")?>:</label></td>
378 <td class="bxfm-d-value"><input id="bx_replace_phrase" name="bx_replace_phrase" value="" style="width: 220px;" type="text"/></td>
379 </tr>
380
381 <tr title="<?= GetMessage("FM_UTIL_DIR_TITLE")?>">
382 <td class="bxfm-d-label"><label for="bx_search_dir"><?= GetMessage("FM_UTIL_DIR")?>:</label></td>
383 <td class="bxfm-d-value"><input id="bx_search_dir" name="bx_search_dir" value="" style="width: 220px;" type="text"/> <input id="bx_search_fd_but" type="button" value="..." title="<?= GetMessage('FD_OPEN_DIR')?>" onclick="FMFD_SearchDirOpen(true, {site: window.oFMSearch.oSiteSel.value, path: window.oFMSearch.pSearchDir.value});" /><span class="bxfm-site-sel" id="bx_search_site_sel"></span></td>
384 </tr>
385 <tr>
386 <td class="bxfm-d-label"><label for="bx_search_subdir"><?= GetMessage("FM_UTIL_INCLUDE_SUBFOLDER")?></label></td>
387 <td class="bxfm-d-value"><input id="bx_search_subdir" name="bx_search_subdir" type="checkbox" value="Y" checked="checked" /></td>
388 </tr>
389 <tr class="bxfm-d-title">
390 <td colSpan="2">
391 <a class="bxfm-add-link" id="bx_fms_add_lnk" href="javascript: void(0);"><?= GetMessage("FM_UTIL_ADDITIONAL")?> <span class="bxfm-d-span-hide">(<?= GetMessage("FM_UTIL_HIDE")?>)</span></a>
392 </td>
393 </tr>
394 <tr class="bxfm-add-hide" title="<?= GetMessage("FM_UTIL_DATE_TITLE")?>">
395 <td class="bxfm-d-label"><label for="bx_search_date_sel"><?= GetMessage("FM_UTIL_DATE")?>:</label></td>
396 <td class="bxfm-d-value">
397 <select id="bx_search_date_sel" name="bx_search_date_sel">
398 <option value=""> - <?= GetMessage("FM_UTIL_NO_VAL")?> - </option>
399 <option value="day"><?= GetMessage("FM_UTIL_DAY")?></option>
400 <option value="week"><?= GetMessage("FM_UTIL_WEEK")?></option>
401 <option value="month"><?= GetMessage("FM_UTIL_MONTH")?></option>
402 <option value="year"><?= GetMessage("FM_UTIL_YEAR")?></option>
403 <option value="set"><?= GetMessage("FM_UTIL_SET_EXACTLY")?></option>
404 </select>
405 <div id="bx_search_date_div" class="bxfm-d-adjust-div">
406 <?= GetMessage("FM_UTIL_FROM")?>: <input name="bx_search_date_from" id="bx_search_date_from" value="" style="width: 90px;" type="text"/><?= CAdminCalendar::Calendar("bx_search_date_from", "bx_search_form");?>
407 <?= GetMessage("FM_UTIL_TO")?>: <input name="bx_search_date_to" id="bx_search_date_to" value="" style="width: 90px;" type="text"/><?= CAdminCalendar::Calendar("bx_search_date_to", "bx_search_form");?>
408 </div>
409 </td>
410 </tr>
411 <tr class="bxfm-add-hide" title="<?= GetMessage("FM_UTIL_SIZE_TITLE")?>">
412 <td class="bxfm-d-label"><label for="bx_search_size_sel"><?= GetMessage("FM_UTIL_SIZE")?>:</label></td>
413 <td class="bxfm-d-value">
414 <select id="bx_search_size_sel" name="bx_search_size_sel">
415 <option value=""> - <?= GetMessage("FM_UTIL_NO_VAL")?> - </option>
416 <option value="100"><?= GetMessage("FM_UTIL_SIZE_100")?></option>
417 <option value="100_500"><?= GetMessage("FM_UTIL_SIZE_100_500")?></option>
418 <option value="500"><?= GetMessage("FM_UTIL_SIZE_500")?></option>
419 <option value="set"><?= GetMessage("FM_UTIL_SET_EXACTLY")?></option>
420 </select>
421 <div id="bx_search_size_div" class="bxfm-d-adjust-div">
422 <?= GetMessage("FM_UTIL_SIZE_FROM")?>: <input id="bx_search_size_from" name="bx_search_size_from" value="" style="width: 70px;" type="text"/><?= GetMessage("FM_UTIL_KB")?> &nbsp;
423 <?= GetMessage("FM_UTIL_SIZE_TO")?>: <input id="bx_search_size_to" name="bx_search_size_to" value="" style="width: 70px;" type="text"/><?= GetMessage("FM_UTIL_KB")?>
424 </div>
425 </td>
426 </tr>
427 <tr class="bxfm-add-hide bxfm-d-only-search">
428 <td class="bxfm-d-label"><label for="bx_search_dirs_too"><?= GetMessage("FM_UTIL_SEARCH_DIRS")?></label></td>
429 <td class="bxfm-d-value"><input id="bx_search_dirs_too" name="bx_search_dirs_too" type="checkbox" value="Y" checked="checked" /></td>
430 </tr>
431 <tr class="bxfm-add-hide-TEMP" style="display: none;">
432 <td class="bxfm-d-label"><label for="bx_search_entire"><?= GetMessage("FM_UTIL_ENTIRE")?></label></td>
433 <td class="bxfm-d-value"><input id="bx_search_entire" type="checkbox" value="Y" /></td>
434 </tr>
435 <tr class="bxfm-add-hide">
436 <td class="bxfm-d-label"><label for="bx_search_case"><?= GetMessage("FM_UTIL_CASE_SENS")?></td>
437 <td class="bxfm-d-value"><input id="bx_search_case" name="bx_search_case" type="checkbox" value="Y" /></label></td>
438 </tr>
439 </table>
440 <input type="hidden" name="search" value="Y" />
441 <div id="bx_search_res_cont"></div>
442<?
444 (
445 "event" => "FMFD_SearchDirOpen",
446 "arResultDest" => Array("ELEMENT_ID" => "bx_search_dir"),
447 "arPath" => Array("SITE" => $site, "PATH" => "/"),
448 "select" => 'D',
449 "operation" => 'O',// O - open, S - save
450 "showUploadTab" => false,
451 "showAddToMenuTab" => false,
452 "allowAllFiles" => false,
453 "SaveConfig" => true
454 )
455 );
456?>
457 </form></div>
458 </td></tr>
459 <?$searchTabControl->BeginNextTab();?>
460 <tr><td>
461 <div id="bx_replace_cont" class="bxfm-replace-cont"></div>
462 </td></tr>
463 <?
464 $searchTabControl->End();
465
466 // *** Copy / move dialog ***
467 ?>
468 <div id="bx_copy_dialog" class="bx-copy-cont">
469 <table class="bx-copy-cont-tbl bx-copy-cont-tbl-add-hide" id="bx_copy_table" style="width: 470px;">
470 <tr>
471 <td class="bxfm-d-label"><label for="bx_copy_file_list"><?= GetMessage("FM_UTIL_FILE")?>:</label></td>
472 <td class="bxfm-d-value"><div id="bx_copy_file_list" style="margin-top: 2px;"><div></td>
473 </tr>
474 <tr>
475 <td class="bxfm-d-label"><label for="bx_copy_to"><?= GetMessage("FM_COPY_TO")?>:</label></td>
476 <td class="bxfm-d-value">
477 <div style="width: 340px;">
478 <input id="bx_copy_to" style="width: 255px;" value="/" type="text" /><input type="button" value="..." title="<?= GetMessage('FD_OPEN_DIR')?>" onclick="FMFD_CopyMoveOpen(true, {site: window.oBXFMCopy.oSiteSel.value, path: window.oBXFMCopy.oCopyTo.pInput.value});" />
479 <span class="bxfm-site-sel" id="bx_copy_site_sel"></span>
480 </div>
481 </td>
482 </tr>
483
484 <tr class="bx-copy-d-title">
485 <td colSpan="2">
486 <a class="bx-copy-add-link" id="bx_copy_add_lnk" href="javascript: void(0);"><?= GetMessage("FM_UTIL_ADDITIONAL")?> <span class="bx-copy-d-span-hide">(<?= GetMessage("FM_UTIL_HIDE")?>)</span></a>
487 </td>
488 </tr>
489 <tr class="bxfm-add-hide">
490 <td colSpan="2" style="padding: 5px 0 5px 120px !important;"><?= GetMessage("FM_COPY_COINCID")?>:</td>
491 </tr>
492 <tr class="bxfm-add-hide">
493 <td class="bxfm-d-label">
494 <input id="bx_copy_ask_user" type="radio" name="bx_copy_coincidence" value="ask" checked="checked"/>
495 </td>
496 <td class="bxfm-d-value">
497 <label for="bx_copy_ask_user"><?= GetMessage("FM_COPY_ASK_USER")?></label>
498 </td>
499 </tr>
500 <tr class="bxfm-add-hide">
501 <td class="bxfm-d-label">
502 <input id="bx_copy_replace" type="radio" name="bx_copy_coincidence" value="replace" />
503 </td>
504 <td class="bxfm-d-value">
505 <label for="bx_copy_replace"><?= GetMessage("FM_COPY_REPLACE")?></label>
506 </td>
507 </tr>
508 <tr class="bxfm-add-hide">
509 <td class="bxfm-d-label">
510 <input id="bx_copy_auto_rename" type="radio" name="bx_copy_coincidence" value="auto_rename" />
511 </td>
512 <td class="bxfm-d-value">
513 <label for="bx_copy_auto_rename"><?= GetMessage("FM_COPY_AUTO_RENAME")?></label>
514 </td>
515 </tr>
516 <tr class="bxfm-add-hide">
517 <td class="bxfm-d-label">
518 <input id="bx_copy_skip" type="radio" name="bx_copy_coincidence" value="skip" />
519 </td>
520 <td class="bxfm-d-value">
521 <label for="bx_copy_skip"><?= GetMessage("FM_COPY_SKIP")?></label>
522 </td>
523 </tr>
524 </table>
525<?
527 (
528 "event" => "FMFD_CopyMoveOpen",
529 "arResultDest" => Array("ELEMENT_ID" => "bx_copy_to"),
530 "arPath" => Array("SITE" => $GLOBALS['site'], "PATH" => "/"),
531 "select" => 'D',
532 "operation" => 'O',// O - open, S - save
533 "showUploadTab" => false,
534 "showAddToMenuTab" => false,
535 "allowAllFiles" => false,
536 "SaveConfig" => true
537 )
538);
539?>
540 </div>
541 <div id="bx_copy_ask_dialog" class="bx-copy-cont">
542 <div style="margin: 0 70px 0 70px; width: 460px; padding: 10px 0 5px;">
543 <?= GetMessage("FM_UTIL_FILE_EXIST", array("#NAME#" => "<span id='bx_copy_ask_file_name'>#NAME#</span>", "#FOLDER#" => "<span id='bx_copy_ask_folder'>#FOLDER#</span>"))?>:
544 </div>
545 <div style="margin: 0 50px;">
546 <table class="bx-copy-compare-tbl">
547 <tr class="bx-copy-title">
548 <td><?= GetMessage("FM_UTIL_NEW_FILE")?>:</td>
549 <td rowSpan="4" class="bx-copy-sep-td"></td>
550 <td><?= GetMessage("FM_UTIL_ORIGINAL_FILE")?>:</td>
551 </tr>
552 <tr>
553 <td>
554 <div class="bx-copy-name-cnt">
555 <a id="bx_copy_ask_file1" href="javascript:void();">file1</a>
556 <div id="bxc_ask_nn_cont1" class="bx-copy-new-name bxcnn-0"></div>
557 </div>
558 </td>
559 <td>
560 <div class="bx-copy-name-cnt"><a id="bx_copy_ask_file2" href="javascript:void();">file2</a></div>
561 </td>
562 </tr>
563 <tr id="bx_copy_ask_size_row">
564 <td><?= GetMessage("FM_UTIL_SIZE")?>: <span id="bx_copy_ask_size1"></span></td>
565 <td><?= GetMessage("FM_UTIL_SIZE")?>: <span id="bx_copy_ask_size2"></span></td>
566 </tr>
567 <tr class="bx-copy-bottom">
568 <td><?= GetMessage("FM_UTIL_DATE")?>: <span id="bx_copy_ask_date1"></span></td>
569 <td><?= GetMessage("FM_UTIL_DATE")?>: <span id="bx_copy_ask_date2"></span></td>
570 </tr>
571 </table>
572 </div>
573 </div>
574 <?
575 $searchTabControl->BeginNextTab();
576
577 // *** Pack / unpack dialog ***
578 ?>
579 <div id="bx_pack_dialog" class="bx-pack-cont">
580 <table class="bx-pack-cont-tbl bx-pack-cont-tbl-add-hide" id="bx_pack_table" style="width: 470px;">
581 <tr>
582 <td class="bxfm-d-label"><label for="bx_pack_file_list"><?= GetMessage("FM_PACK_FILE")?>:</label></td>
583 <td class="bxfm-d-value"><div id="bx_pack_file_list" style="margin-top: 2px;"><div></td>
584 </tr>
585 <tr id="bxfm-arctype-line">
586 <td class="bxfm-d-label"><label for="bx_pack_arc_type"><?= GetMessage("FM_PACK_ARC_TYPE")?>:</label></td>
587 <td class="bxfm-d-value"><div id="bx_pack_arc_type" class="bxfm-arctype-sel" style="margin-top: 4px;"><div></td>
588 </tr>
589 <tr>
590 <!-- if pack "to archive", if not - "to folder" -->
591 <td class="bxfm-d-label"><label for="bx_pack_to"><?= GetMessage("FM_PACK_TO")?>:</label></td>
592 <td class="bxfm-d-value">
593 <div style="width: 340px;">
594 <input id="bx_pack_to" style="width: 260px;" value="/" type="text"/>&nbsp;<input type="button" value="..." title="<?= GetMessage('FD_OPEN_DIR')?>" onclick="FMFD_PackUnpackOpen(true, {site: window.oBXFMPack.oSiteSel.value, path: window.oBXFMPack.GetFolderPath(window.oBXFMPack.oPackTo.pInput.value)});" />
595 <span class="bxfm-site-sel" id="bx_pack_site_sel"></span>
596 </div>
597 </td>
598 </tr>
599 <tr class="bx-pack-d-title" id="bx-pack-d-title-label">
600 <td></td>
601 <td><?=GetMessage("FM_PACK_ADDITIONAL")?></td>
602 </tr>
603 <!--<tr class="bxfm-add-hide" id="bxfm-pack-option-ask">
604 <td class="bxfm-d-label">
605 <input id="bx_pack_ask_user" type="radio" name="bx_pack_coincidence" value="ask" checked="checked"/>
606 </td>
607 <td class="bxfm-d-value">
608 <label for="bx_pack_ask_user"><?= GetMessage("FM_PACK_ASK_USER")?></label>
609 </td>
610 </tr>-->
611 <tr class="bxfm-add-hide" id="bxfm-pack-option-replace">
612 <td class="bxfm-d-label">
613 <input id="bx_pack_replace" type="radio" name="bx_pack_coincidence" value="replace" />
614 </td>
615 <td class="bxfm-d-value">
616 <label for="bx_pack_replace"><?= GetMessage("FM_PACK_REPLACE")?></label>
617 </td>
618 </tr>
619 <!--<tr class="bxfm-add-hide" id="bxfm-pack-option-rename">
620 <td class="bxfm-d-label">
621 <input id="bx_pack_auto_rename" type="radio" name="bx_pack_coincidence" value="auto_rename" />
622 </td>
623 <td class="bxfm-d-value">
624 <label for="bx_pack_auto_rename"><?= GetMessage("FM_PACK_AUTO_RENAME")?></label>
625 </td>
626 </tr>-->
627 <tr class="bxfm-add-hide" id="bxfm-pack-option-skip">
628 <td class="bxfm-d-label">
629 <input id="bx_pack_skip" type="radio" name="bx_pack_coincidence" value="skip" />
630 </td>
631 <td class="bxfm-d-value">
632 <label for="bx_pack_skip"><?= GetMessage("FM_PACK_SKIP")?></label>
633 </td>
634 </tr>
635 </table>
636<?
638 (
639 "event" => "FMFD_PackUnpackOpen",
640 "arResultDest" => Array("FUNCTION_NAME" => "MakeArchivePathFromFolderPath"),
641 "arPath" => Array("SITE" => $GLOBALS['site'], "PATH" => "/"),
642 "select" => 'D',
643 "operation" => 'O',// O - open, S - save
644 "showUploadTab" => false,
645 "showAddToMenuTab" => false,
646 "allowAllFiles" => false,
647 "SaveConfig" => true
648 )
649);
650?>
651 </div>
652 <script>
653 function MakeArchivePathFromFolderPath(filename, path, site)
654 {
655 var
656 oldArchivePath = BX('bx_pack_to').value,
657 newArchivePath,
658 archiveName;
659
660 archiveName = oldArchivePath.substr(oldArchivePath.lastIndexOf('/') + 1);
661 newArchivePath = "/" + path + "/" + filename + "/" + archiveName;
662
663 newArchivePath = newArchivePath.replace(/[\/]+$/g, "");
664 newArchivePath = newArchivePath.replace(/[\/]+/g, '/');
665 newArchivePath = newArchivePath.replace(/[\\]+/g, '/');
666
667 if (newArchivePath == '')
668 newArchivePath = '/';
669
670 BX('bx_pack_to').value = newArchivePath;
671 }
672 </script>
673 <div id="bx_pack_ask_dialog" class="bx-pack-cont">
674 <div style="margin: 0 20px 0 20px; width: 450px; padding: 10px 0 5px;">
675 <?= GetMessage("FM_UTIL_FILE_EXIST", array("#NAME#" => "<span id='bx_pack_ask_file_name'>#NAME#</span>", "#FOLDER#" => "<span id='bx_pack_ask_folder'>#FOLDER#</span>"))?>:
676 </div>
677 <table style="margin: 0 20px 0 20px">
678 <tr>
679 <td>
680 <div class="bx-pack-name-cnt">
681 <a id="bx_pack_ask_file2" href="javascript:void('');">file1</a>
682 <div id="bxc_ask_nn_cont2" class="bx-pack-new-name bxcnn-0"></div>
683 </div>
684 </td>
685 </tr>
686 <tr id="bx_pack_ask_size_row">
687 <td><?= GetMessage("FM_UTIL_SIZE")?>: <span id="bx_pack_ask_size2"></span></td>
688 </tr>
689 <tr class="bx-pack-bottom">
690 <td><?= GetMessage("FM_UTIL_DATE")?>: <span id="bx_pack_ask_date2"></span></td>
691 </tr>
692 </table>
693 <br/>
694 </div><?
695 }
696
697 public static function Request($action, $site)
698 {
699 global $USER;
700 if (!$USER->CanDoOperation('fileman_view_file_structure'))
701 return;
702
704
705 switch($action)
706 {
707 case "count":
708 case "search":
709 case "replace":
710
711 $oSearch = new CFilemanSearch;
712 $oSearch->Init(array(
713 'lastPath' => isset($_POST['last_path']) ? $_POST['last_path'] : false,
714 'bCount' => $action == "count",
715 'bReplace' => $action == "replace",
716 "fileName" => trim($_POST['file']),
717 "phrase" => trim($_POST['phrase']),
718 "replacePhrase" => trim($_POST['replace_phrase']),
719 "dir" => CFilemanUtils::NormalizePath($_POST['dir']),
720 "bSubdir" => $_POST['subdir'],
721 "dateFrom" => $_POST['date_from'],
722 "dateTo" => $_POST['date_to'],
723 "sizeFrom" => intval($_POST['size_from']),
724 "sizeTo" => intval($_POST['size_to']),
725 "entire" => $_POST['entire'],
726 "bCaseSens" => $_POST['case_sens'],
727 "bDirsToo" => $_POST['dirs_too'],
728 "ssess" => ($_POST['ssess'] ?? null),
729 "bInResult" => $_POST['in_result'],
730 "site" => CFileMan::__CheckSite($_GET['fu_site'])
731 //"site" => $site
732 ));
733
735 break;
736
737 case "clean_old":
739 break;
740
741 case "search_save_config":
743 "advMode" => (boolean) $_POST['adv_mode'],
744 "bSubdir" => (boolean) $_POST['subdir'],
745 "entire" => (boolean) $_POST['entire'],
746 "bCaseSens" => (boolean) $_POST['case_sens'],
747 "bDirsToo" => (boolean) $_POST['dirs_too']
748 ));
749 break;
750
751 case "copy_save_config":
753 "advMode" => (boolean) $_POST['adv_mode'],
754 "caseOption" => $_POST['case_option']
755 ));
756 break;
757
758 case "copy":
759 case "move":
760 $oCopy = new CFilemanCopy;
761 $oCopy->Init(array(
762 "bCopy" => $action == "copy",
763 "caseOption" => $_POST['case_option'],
764 "arFiles" => $_POST['files'],
765 "copyTo" => $_POST['copy_to'],
766 "createCopyTo" => ($_POST['create_copy_to'] ?? null) == "Y",
767
768 "userCaseAnswer" => isset($_POST['uc_answer']) ? $_POST['uc_answer'] : false,
769 "userCaseToAll" => isset($_POST['uc_to_all']) ? $_POST['uc_to_all'] : false,
770 "userCaseLastPath" => isset($_POST['uc_last_path']) ? $_POST['uc_last_path'] : false,
771
772 "bSearch" => ($_POST['search'] ?? null) == "Y",
773 "ssess" => ($_POST['ssess'] ?? null),
774 "siteTo" => CFileMan::__CheckSite($_GET['fu_site'])
775 ));
776
777 CFileMan::SaveLastPath($_POST['copy_to']);
778 break;
779
780 case "get_last_pathes":
781 ?>
782 <script>window.bx_last_pathes = <?= CUtil::PhpToJSObject(CFilemanUtils::GetLastPathes())?>;</script>
783 <?
784 break;
785 case "pack":
786
787 if (isset($_POST["startFile"]))
788 $startFile = trim($_POST["startFile"]);
789
790 if (isset($_POST["quickPath"]))
791 $quickPath = trim($_POST["quickPath"]);
792
793 if (isset($_POST["packTo"]))
794 {
795 if (mb_substr($_POST["packTo"], 0, 1) == "/")
796 $pack_to = $_POST["packTo"];
797 else
798 $pack_to = "/".$_POST["packTo"];
799 }
800
801 $siteTo = CFileMan::__CheckSite($_POST['siteTo']);
802 $docRootTo = CSite::GetSiteDocRoot($siteTo) ? CSite::GetSiteDocRoot($siteTo) : '';
803 $siteFrom = CFileMan::__CheckSite($site);
804 $docRootFrom = CSite::GetSiteDocRoot($siteFrom);
805
806 if (!$USER->IsAdmin())
807 $pack_to = RemoveScriptExtension($pack_to);
808
809 //check writing permissions
810 if (!$USER->CanDoFileOperation('fm_create_new_file', array($siteTo, $pack_to)))
811 {
812 ?>
813 <script>
814 window.BXFM_archivePermsError = true;
815 </script>
816 <?
817 return;
818 }
819
820 if(IsFileUnsafe($docRootTo.$pack_to) || CFileMan::CheckFileName(GetFileName($pack_to)) !== true)
821 {
822 ?>
823 <script>
824 window.BXFM_archiveFNameError = true;
825 </script>
826 <?
827 return;
828 }
829
830 //ask if the file already exists
831 if (file_exists($io->GetPhysicalName($docRootTo.$pack_to)))
832 {
833 if (empty($startFile))
834 {
835 if (($_POST["bPackReplace"] ?? null) != "replace")
836 {
837 ?>
838 <script>
839 window.BXFM_archiveExists = {
840 fileOld:
841 {
842 name: "<?= CUtil::JSEscape(basename($pack_to))?>",
843 path: "<?= CUtil::JSEscape($pack_to)?>",
844 site: "<?= CUtil::JSEscape($siteTo)?>",
845 size: "<?= CFile::FormatSize(filesize($io->GetPhysicalName($docRootTo.$pack_to)))?>",
846 date: "<?= date(CDatabase::DateFormatToPHP(CLang::GetDateFormat('FULL')), filemtime($io->GetPhysicalName($docRootTo.$pack_to))+CTimeZone::GetOffset())?>"
847 }
848 };
849 </script>
850 <?
851 return;
852 }
853 }
854 }
855
856 $packarc = CBXArchive::GetArchive($docRootTo.$pack_to, trim($_POST['arcType']));
857
858 if ($packarc instanceof IBXArchive)
859 {
860 //this set of options is common for every archive type
861 $packarc->SetOptions(
862 array(
863 "COMPRESS" => true,
864 "STEP_TIME" => COption::GetOptionString("fileman", "archive_step_time", 30),
865 "ADD_PATH" => false,
866 "REMOVE_PATH" => $docRootFrom.$quickPath,
867 "CHECK_PERMISSIONS" => $USER->IsAdmin() ? false : true
868 )
869 );
870
871 $arPackFiles = array();
872 foreach ($_POST["files"] as $path2file)
873 {
874 $arPackFiles[] = $docRootFrom.$path2file['path'];
875 }
876
877 @set_time_limit(0);
878
879 $pRes = $packarc->Pack($arPackFiles, $startFile);
880
881 switch ($pRes)
882 {
884 ?>
885 <script>
886 window.fmPackTimeout = true;
887 window.fmPackLastFile = '<?= CUtil::JSEscape($packarc->GetStartFile())?>';
888 </script>
889 <?
890 break;
892 ?>
893 <script>
894 window.fmPackTimeout = false;
895 window.fmPackLastFile = '';
896 window.fmPackSuccess = true;
897 </script>
898 <?
899 break;
901 $arErrors = $packarc->GetErrors();
902 ?>
903 <script>
904 window.fmPackTimeout = false;
905 window.fmPackSuccess = false;
906 window.fmPackErrors = <?=CUtil::PhpToJSObject($arErrors)?>;
907 </script>
908 <?
909 break;
910 }
911 }
912 else
913 {
914 ?>
915 <script>
916 window.fmPackSuccess = false;
917 window.fmPackErrors = <?=CUtil::PhpToJsObject(GetMessage("FM_UTIL_ARC_ERROR"))?>;
918 </script>
919 <?
920 }
921 break;
922 case "unpack":
923
924 global $USER;
925
926 if (isset($_POST["packTo"]))
927 {
928 if (mb_substr($_POST["packTo"], 0, 1) == "/")
929 $pack_to = $_POST["packTo"];
930 else
931 $pack_to = "/".$_POST["packTo"];
932 }
933
934 $siteFrom = CFileMan::__CheckSite($_GET['site']);
935 $siteTo = CFileMan::__CheckSite($_POST['siteTo']);
936 $docRootFrom = CSite::GetSiteDocRoot($siteFrom);
937 $docRootTo = CSite::GetSiteDocRoot($siteTo);
938
939 if (!($USER->CanDoFileOperation('fm_create_new_file', array($siteTo, $_POST["packTo"])) ||
940 $USER->CanDoFileOperation('fm_create_new_folder', array($siteTo, $_POST["packTo"]))))
941 {
942 ?>
943 <script>
944 window.BXFM_archivePermsError = true;
945 </script>
946 <?
947 return;
948 }
949
950 $bReplaceFiles = $_POST["case_option"] == "replace" ? true : false;
951
952 $arc = CBXArchive::GetArchive($docRootFrom.$_POST["files"][0]);
953
954 if ($arc instanceof IBXArchive)
955 {
956 global $USER;
957
958 $arc->SetOptions
959 (
960 array(
961 "REMOVE_PATH" => $docRootFrom,
962 "UNPACK_REPLACE" => $bReplaceFiles,
963 "CHECK_PERMISSIONS" => $USER->IsAdmin() ? false : true
964 )
965 );
966
967 $uRes = $arc->Unpack($docRootTo.$pack_to);
968
969 if (!$uRes)
970 {
971 $uErrors = $arc->GetErrors();
972 ?>
973 <script>
974 window.fmUnpackSuccess = false;
975 window.fmUnpackErrors = <?=CUtil::PhpToJSObject($uErrors)?>
976 </script>
977 <?
978 }
979 else
980 {
981 ?>
982 <script>
983 window.fmUnpackSuccess = true;
984 </script>
985 <?
986 }
987 }
988 else
989 {
990 ?>
991 <script>
992 window.fmUnpackSuccess = false;
993 window.fmUnpackErrors = <?=CUtil::PhpToJsObject(GetMessage("FM_UTIL_ARC_ERROR"))?>;
994 </script>
995 <?
996 }
997 break;
998 }
999 }
1000
1001 public static function GetTimeout()
1002 {
1003 return COption::GetOptionString("fileman", "search_time_step", 5);
1004 }
1005
1006 public static function NormalizePath($path)
1007 {
1009 $path = rtrim($path, '/');
1010 return $path;
1011 }
1012
1013 public static function TrimPath($path, $docRoot = false)
1014 {
1015 if ($docRoot === false)
1016 $docRoot = $_SERVER["DOCUMENT_ROOT"];
1017 $l = mb_strlen($docRoot);
1018 return mb_strlen($path) > $l? mb_substr($path, $l) : '/';
1019 }
1020
1021 public static function GetLastPathes()
1022 {
1024 $arRes = array(
1025 array("name" => "/", "desc" => GetMessage("FM_UTIL_ROOT_DIR"))
1026 );
1027 for($i = 0, $l = count($arPathes); $i < $l; $i++)
1028 $arRes[] = array("name" => $arPathes[$i]);
1029
1030 return $arRes;
1031 }
1032
1033 public static function GetModifyTime($path)
1034 {
1036
1037 if (file_exists($path))
1038 {
1039 $stat = stat($path);
1040 return $stat["mtime"];
1041 }
1042
1043 return null;
1044 }
1045}
1046
1047//
1049{
1050 private $maxFileOpenSize;
1051 private $maxResultCount;
1052 private $startTime;
1053 private $Params;
1054 private $Result;
1055 private $docRoot;
1056 private $bSkip;
1057 private $sSess;
1058 private bool $bReplace;
1059
1060 public function Init($Params)
1061 {
1062 $this->maxFileOpenSize = 1024 * COption::GetOptionString("fileman", "search_max_open_file_size", 1024);
1063 $this->maxResultCount = COption::GetOptionString("fileman", "search_max_res_count", false);
1064
1065 $this->startTime = time();
1066 $this->Params = $Params;
1067 $this->Result = array();
1068 $this->docRoot = CSite::GetSiteDocRoot($Params['site']);
1069
1070 $this->bSkip = $this->Params['lastPath'] ? true : false;
1071 if ($this->bSkip)
1072 {
1073 $this->Params['lastPath'] = Rel2Abs("/", $this->Params['lastPath']);
1074 $this->Params['lastPath'] = $this->docRoot.$this->Params['lastPath'];
1075 }
1076
1077 $this->sSess = $this->Params['ssess'] ? $this->Params['ssess'] : false;
1078 $this->bReplace = $this->Params['bReplace'] && $this->Params['phrase'] <> '';
1079
1080 if ($this->bReplace)
1081 {
1082 $this->Params['bDirsToo'] = false;
1083 }
1084
1085 $bSuccess = false;
1086 $bBreak = false;
1087 $nextPath = '';
1088
1089 // Search in results of the previous search
1090 if ($this->Params['bInResult'])
1091 {
1092 $searchRes = CFilemanSearch::GetSearchResult($this->Params['ssess'], array('id', 'asc'));
1093 for($i = 0, $l = count($searchRes); $i < $l; $i++)
1094 {
1095 $path = $this->docRoot.$searchRes[$i]['path'];
1096 if ($this->CheckBreak())
1097 {
1098 $bBreak = true;
1099 $nextPath = $path;
1100 break;
1101 }
1102 else
1103 {
1104 $this->Search($path);
1105 }
1106 }
1107 $bSuccess = true;
1108 $bStoped = false;
1109 }
1110 else
1111 {
1112 $path = Rel2Abs("/", $this->Params["dir"]);
1113 $path = $this->docRoot.$path;
1114 $oDir = new CFilemanUtilDir($path, array(
1115 'obj' => $this,
1116 'site' => $Params['site'],
1117 'callBack' => "Search",
1118 'checkBreak' => "CheckBreak",
1119 'checkSubdirs' => $this->Params["bSubdir"]
1120 ));
1121 $bSuccess = $oDir->Start();
1122
1123 $bBreak = $oDir->bBreak;
1124 $nextPath = $oDir->nextPath;
1125 $bStoped = $oDir->bStoped;
1126
1127 if ($bStoped)
1128 $bBreak = false;
1129 }
1130
1131 if ($bSuccess)
1132 {
1133?>
1134<script>
1135<?if ($bBreak): // Execution breaks on timeout?>
1136 window.fmsBtimeout = true;
1137 window.fmsLastPath = '<?= CUtil::JSEscape(CFilemanUtils::TrimPath($nextPath, $this->docRoot))?>';
1138<? else: ?>
1139 window.fmsBtimeout = false;
1140<? endif; ?>
1141
1142<?if ($bStoped): // Execution breaks on timeout?>
1143 window.fmsBstoped = true;
1144<? else: ?>
1145 window.fmsBstoped = false;
1146<? endif; ?>
1147
1148<? if ($this->Params['bCount']): ?>
1149 window.fmsResult = <?= count($this->Result)?>;
1150<? else: ?>
1151 window.fmsResult = <?= CUtil::PhpToJSObject($this->Result)?>;
1152<? endif; ?>
1153</script>
1154<?
1155 }
1156 else
1157 {
1158?>
1159<script>
1160<? if ($this->Params['bCount']): ?>
1161 window.fmsResult = 0;
1162<? else: ?>
1163 window.fmsResult = [];
1164<? endif; ?>
1165</script>
1166<?
1167 }
1168 }
1169
1170 public function Search($file)
1171 {
1172 global $APPLICATION, $USER;
1173
1174 if ($this->maxResultCount && count($this->Result) >= $this->maxResultCount)
1175 return "stop";
1176
1177 if ($this->bSkip)
1178 {
1179 if ($file == $this->Params['lastPath'])
1180 $this->bSkip = false; // continue handle files from last path
1181 else
1182 return; // Files was handled earlier
1183 }
1184
1186
1187 $bIsDir = $io->DirectoryExists($file);
1188 $replFileCount = 0;
1189 if ($bIsDir && !$this->Params['bDirsToo'])
1190 return;
1191
1192 $entity = $bIsDir ? $io->GetDirectory($file) : $io->GetFile($file);
1193
1194 $path = CFilemanUtils::TrimPath($file, $this->docRoot);
1195 $arPath = array($this->Params['site'], $path);
1196
1197 // Check access
1198 if (!$USER->CanDoFileOperation('fm_view_file', $arPath))
1199 return;
1200
1201 $name = CFileman::GetFileName($file); // Name of file or dir
1202
1203 // Check filename
1204 if ($this->Params['fileName'] != "")
1205 {
1206 if (!$this->Params['bCaseSens'])
1207 {
1208 $name = mb_strtolower($name);
1209 $this->Params['fileName'] = mb_strtolower($this->Params['fileName']);
1210 }
1211
1212 // Simple find in file name
1213 if (mb_strpos($this->Params['fileName'], "*") === false)
1214 {
1215 if (mb_strpos($name, $this->Params['fileName']) === false)
1216 return;
1217 }
1218 else // name pattern with "*"
1219 {
1220 $pattern = str_replace('.', '\.',$this->Params['fileName']);
1221 $pattern = str_replace('/', '', $pattern);
1222 $pattern = str_replace('*', '.*', $pattern);
1223 if (!preg_match('/^'.$pattern.'$/i', $io->ExtractNameFromPath($file)))
1224 return;
1225 }
1226 }
1227
1228 if (!$bIsDir)
1229 {
1230 // Check filesize
1231 $size = $entity->GetFileSize();
1232 // Filesize limits in Kb
1233 if (
1234 ($this->Params['sizeFrom'] > 0 && $size < $this->Params['sizeFrom'] * 1024)
1235 ||
1236 ($this->Params['sizeTo'] > 0 && $size > $this->Params['sizeTo'] * 1024)
1237 )
1238 return;
1239 }
1240 else
1241 {
1242 $size = 0;
1243 }
1244
1245 // Check filetime
1246 $time = $entity->GetModificationTime()+CTimeZone::GetOffset();
1247 if (
1248 ($this->Params['dateFrom'] && $time < MakeTimeStamp($this->Params['dateFrom'], CLang::GetDateFormat("FULL")))
1249 ||
1250 ($this->Params['dateTo'] && $time > MakeTimeStamp($this->Params['dateTo'], CLang::GetDateFormat("FULL")))
1251 )
1252 return;
1253
1254 if ($this->Params['phrase'] != "")
1255 {
1256 // File size limits or it's dir or access denied
1257 if ($size > $this->maxFileOpenSize || $bIsDir || ($this->bReplace && !$USER->CanDoFileOperation('fm_edit_existent_file', $arPath)))
1258 return;
1259
1260 $fTmp = $io->GetFile($file);
1261
1262 $phrase = $this->Params['phrase'];
1263 $fileContent = str_replace("\r\n","\n", $fTmp->GetContents());
1264 $origFileContent = $fileContent;
1265 $isPHP = CFileman::IsPHP($fileContent) || HasScriptExtension($path) || mb_substr($name, 0, 1) == ".";
1266
1267 if (!$this->Params['bCaseSens'])
1268 {
1269 $phrase = mb_strtolower($phrase);
1270 $fileContent = mb_strtolower($fileContent);
1271 }
1272
1273 $I_PCRE_MODIFIER = $this->Params['bCaseSens'] ? '' : 'i';
1274
1275 // TODO: Add check Entire word
1276 //$this->Params['entire']
1277
1278 if (mb_strpos($fileContent, $phrase) === false)
1279 return;
1280
1281 if ($this->bReplace) // Replace
1282 {
1283 if ($isPHP && !$USER->CanDoOperation('edit_php'))
1284 return; // User can't write PHP files
1285
1286 $pattern = '/'.preg_quote($this->Params['phrase'], '/').'/u'.$I_PCRE_MODIFIER;
1287
1288 $res = array();
1289 preg_match_all($pattern, $origFileContent, $res);
1290 $origFileContent = preg_replace($pattern, $this->Params['replacePhrase'], $origFileContent);
1291 $replFileCount = count($res[0]);
1292
1293 $APPLICATION->SaveFileContent($file, $origFileContent);
1294 }
1295 else
1296 {
1297 if ($isPHP && !($USER->CanDoOperation('edit_php') || $USER->CanDoFileOperation('fm_lpa', $arPath)))
1298 return; // User can't read PHP files
1299
1300 $pattern = '/'.preg_quote($this->Params['phrase'], '/').'/u'.$I_PCRE_MODIFIER;
1301
1302 // Only for LPA. All php fragments will be cutted off
1303 if ($USER->CanDoFileOperation('fm_lpa', $arPath) && !$USER->CanDoOperation('edit_php'))
1304 $origFileContent = CMain::ProcessLPA($origFileContent, '');
1305
1306 $res = array();
1307 preg_match_all($pattern, $origFileContent, $res);
1308 $replFileCount = count($res[0]);
1309 }
1310 }
1311
1312 $this->Result[] = array(
1313 'path' => $path,
1314 'size' => $size,
1315 'b_dir' => $bIsDir,
1316 'time' => $time,
1317 'str_date' => date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL")), $time),
1318 'str_size' => $bIsDir ? "" : CFile::FormatSize($size),
1319 'type_src' => "/bitrix/images/fileman/types/".($bIsDir ? "folder" : CFileMan::GetFileTypeEx($file)).".gif",
1320 'repl_count' => $replFileCount // used only in replace-mode to count matches
1321 );
1322 }
1323
1324 public function CheckBreak()
1325 {
1326 return time() - $this->startTime > CFilemanUtils::GetTimeout();
1327 }
1328
1329 public static function trimPath($path, $docRoot = false)
1330 {
1331 if ($docRoot === false)
1332 $docRoot = $_SERVER["DOCUMENT_ROOT"];
1333 $l = mb_strlen($docRoot);
1334 return mb_strlen($path) > $l? mb_substr($path, $l) : '/';
1335 }
1336
1337 public static function CheckSearchSess($searchSess)
1338 {
1339 global $DB;
1340
1341 switch($DB->type)
1342 {
1343 case "MYSQL":
1344 $res = $DB->Query("SELECT * FROM b_file_search WHERE SESS_ID='".$DB->ForSql($searchSess)."' LIMIT 1", false);
1345 break;
1346 case "MSSQL":
1347 $res = $DB->Query("SELECT TOP 1 * FROM b_file_search WHERE SESS_ID='".$DB->ForSql($searchSess)."'", false);
1348 break;
1349 case "ORACLE":
1350 $res = $DB->Query("SELECT * FROM b_file_search WHERE SESS_ID='".$DB->ForSql($searchSess)."' AND ROWNUM <= 1", false);
1351 break;
1352 }
1353
1354 return !$res->Fetch();
1355 }
1356
1357 public static function GetSearchResult($searchSess = '', $arOrder = array('date', 'desc'))
1358 {
1359 global $DB;
1360
1361 $q = "SELECT * FROM b_file_search WHERE SESS_ID='".$DB->ForSql($searchSess)."'";
1362
1363 $strOrderBy = '';
1364 if ($arOrder[0] == 'timestamp')
1365 $by = 'F_TIME';
1366 else if ($arOrder[0] == 'size')
1367 $by = 'F_SIZE';
1368 else if ($arOrder[0] == 'name')
1369 $by = 'F_PATH';
1370 else if ($arOrder[0] == 'id')
1371 $by = 'ID';
1372 else
1373 $by = false;
1374
1375 $order = mb_strtolower($arOrder[1]);
1376 if ($by)
1377 {
1378 $strOrderBy = $by.' '.($order == 'desc' ? 'desc'.($DB->type == "ORACLE" ? " NULLS LAST" : "") : 'asc'.($DB->type == "ORACLE" ? " NULLS FIRST":""));
1379 }
1380
1381 if($strOrderBy != "")
1382 $q .= " ORDER BY ".$strOrderBy;
1383
1384 $res = $DB->Query($q, false);
1385
1386 $searchRes = array();
1387 while($arRes = $res->Fetch())
1388 {
1389 $searchRes[] = array(
1390 'path' => $arRes['F_PATH'],
1391 'b_dir' => $arRes['B_DIR'],
1392 'time' => $arRes['F_TIME'],
1393 'size' => $arRes['F_SIZE']
1394 );
1395 }
1396
1397 return $searchRes;
1398 }
1399
1400 public static function SetSearchResult($searchRes, $searchSess, $bClean = true)
1401 {
1402 global $DB;
1403 $DB->Query("DELETE FROM b_file_search WHERE SESS_ID='".$DB->ForSql($searchSess)."'", false);
1404
1405 for ($i = 0, $l = count($searchRes); $i < $l; $i++)
1406 {
1407 $arFields = array(
1408 'SESS_ID' => $searchSess,
1409 'F_PATH' => $searchRes[$i]['path'],
1410 'B_DIR' => $searchRes[$i]['b_dir'] ?? null,
1411 'F_TIME' => $searchRes[$i]['time'] ?? null,
1412 'F_SIZE' => $searchRes[$i]['size'] ?? null,
1413 );
1414
1415 unset($arFields['NEW']);
1416 $DB->Add("b_file_search", $arFields);
1417 }
1418 return $searchRes;
1419 }
1420
1421 public static function DelFromSearchResult($searchSess, $path)
1422 {
1423 global $DB;
1424 return $DB->Query("DELETE FROM b_file_search WHERE SESS_ID='".$DB->ForSql($searchSess)."' AND F_PATH='".$DB->ForSql($path)."'", false);
1425 }
1426
1427 public static function RenameInSearchResult($searchSess, $pathFrom, $pathTo)
1428 {
1429 global $DB;
1430
1431 $strSql =
1432 "UPDATE b_file_search SET ".
1433 $DB->PrepareUpdate("b_file_search", array('F_PATH' => $pathTo)).
1434 " WHERE SESS_ID='".$DB->ForSql($searchSess)."' AND F_PATH='".$DB->ForSql($pathFrom)."'";
1435
1436 return $DB->Query($strSql);
1437 }
1438
1439 public static function SecureSearchSess($ssess = '')
1440 {
1441 return preg_replace("/[^a-z0-9]/i", "", $ssess ?? '');
1442 }
1443
1444 public static function GetSearchSess()
1445 {
1446 return md5($GLOBALS["USER"]->GetID()."+".uniqid(rand(), true));
1447 }
1448
1449 // Delete all results older than 2 days
1450 public static function CleanOldSearchResult()
1451 {
1452 global $DB;
1453 $d = date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL")), mktime(0, 0, 0, date("m") , date("d") - 2, date("Y")));
1454 $q = "DELETE FROM b_file_search WHERE TIMESTAMP_X<=".$DB->CharToDateFunction($d, "SHORT")."";
1455 $DB->Query($q, false);
1456 }
1457
1458 public static function SaveConfig($arConfig)
1459 {
1460 CUserOptions::SetOption("fileman", "file_search_config", serialize($arConfig));
1461 }
1462
1463 public static function GetConfig()
1464 {
1465 $arConfig = array();
1466 $strAr = CUserOptions::GetOption("fileman", "file_search_config", false);
1467 if ($strAr && CheckSerializedData($strAr))
1468 $arConfig = unserialize($strAr, ['allowed_classes' => false]);
1469 return $arConfig;
1470 }
1471}
1472
1474{
1475 var $checkBreak = '';
1476 var $bBreak = false;
1477 var $bStoped = false;
1478 var $bFound = false;
1479 var $nextPath = '';
1480 var $startPath = '';
1481 var $dir;
1484 var $bSkipSymLinks = true;
1485 var $bDirFirst = false;
1486 var $err = array();
1487 var $cntDir = 0;
1488 var $cntFile = 0;
1489 private $obj;
1490 private $site;
1491 private $docRoot;
1492 private $checkSubdirs;
1493 private $callBack;
1494
1495 public function __construct($dir, $Params)
1496 {
1497 $this->dir = str_replace('\\','/',$dir);
1498 $this->obj = $Params['obj'];
1499 $this->site = $Params['site'];
1500 $this->docRoot = CSite::GetSiteDocRoot($Params['site']);
1501 $this->checkSubdirs = isset($Params['checkSubdirs']) ? $Params['checkSubdirs'] : true;
1502 $this->callBack = isset($Params['callBack']) ? $Params['callBack'] : false;
1503 $this->checkBreak = isset($Params['checkBreak']) ? $Params['checkBreak'] : false;
1504 $this->processDir = isset($Params['processDir']) ? $Params['processDir'] : false;
1505 }
1506
1507 public function Start($dir = false)
1508 {
1509 if ($dir)
1510 $this->dir = str_replace('\\','/',$dir);
1511
1513
1514 if ($io->DirectoryExists($this->dir))
1515 {
1516 if ($this->Recursion($this->dir))
1517 {
1518 if ($this->startPath && !$this->bFound)
1519 {
1520 $this->err[] = 'Error: start path not found!';
1521 return false;
1522 }
1523 return true;
1524 }
1525 return false;
1526 }
1527
1528 $r = $this->CallMethod($this->callBack, $this->dir);
1529 if ($r === false)
1530 $this->err[] = 'Error on entry: '.$this->dir;
1531
1532 return $r;
1533 }
1534
1535 public function Recursion($dir)
1536 {
1537 //error_reporting(0);
1538 global $USER;
1539
1541
1542 if ($this->bDirFirst && $this->processDir && (!$this->startPath || $this->bFound))
1543 if (!$this->CallMethod($this->processDir, $dir))
1544 {
1545 $this->err[] = 'Error on dir: '.$dir;
1546 return false;
1547 }
1548
1549 $dTmp = $io->GetDirectory($dir);
1550 $arChildren = $dTmp->GetChildren();
1551
1552 $arItems = array();
1553 foreach ($arChildren as $child)
1554 $arItems[] = $child->GetName();
1555
1556 sort($arItems);
1557 $s_dir = CFilemanUtils::TrimPath($dir, $this->docRoot);
1558
1559 foreach($arItems as $item)
1560 {
1561 $f = $dir."/".$item;
1562 if ($this->startPath && !$this->bFound)
1563 {
1564 if ($this->startPath == $f)
1565 $this->bFound = true;
1566 elseif (mb_substr($this->startPath, 0, mb_strlen($f) + 1) != $f.'/')
1567 continue;
1568 }
1569
1570 $arPath = array($this->site, $s_dir."/".$item);
1571 $this->nextPath = $f;
1572
1573 if ($this->checkBreak && $this->CallMethod($this->checkBreak))
1574 {
1575 $this->bBreak = true;
1576 return true;
1577 }
1578
1579 if ($this->bSkipSymLinks && is_link($f))
1580 continue;
1581
1582 if ($io->DirectoryExists($f))
1583 {
1584 if (!$USER->CanDoFileOperation('fm_view_listing', $arPath)) // access
1585 continue;
1586
1587 $r = $this->CallMethod($this->callBack, $f);
1588 if ($r == 'stop')
1589 {
1590 $this->bBreak = true;
1591 $this->bStoped = true;
1592 return true;
1593 }
1594
1595 if ($this->checkSubdirs)
1596 {
1597 $r = $this->Recursion($f);
1598 if ($this->bBreak)
1599 return $r;
1600 if ($r===false)
1601 return false;
1602 }
1603 }
1604 elseif ($this->callBack)
1605 {
1606 $r = $this->CallMethod($this->callBack, $f);
1607 if ($r == 'stop')
1608 {
1609 $this->bBreak = true;
1610 $this->bStoped = true;
1611 return true;
1612 }
1613
1614 if ($r===false)
1615 {
1616 $this->err[] = 'Error on file: <b>'.$f.'</b>';
1617 return false;
1618 }
1619 $this->cntFile++;
1620 }
1621 }
1622
1623 if ($this->processDir && !$this->bDirFirst)
1624 {
1625 if (!$this->CallMethod($this->processDir, $dir))
1626 {
1627 $this->err[] = 'Error on folder: '.$dir;
1628 return false;
1629 }
1630 }
1631 return true;
1632 }
1633
1634 public function CallMethod($method = '', $param = false)
1635 {
1636 $obj = $this->obj;
1637 if ($param)
1638 return $obj->$method($param);
1639
1640 return $obj->$method();
1641 }
1642}
1643
1645{
1646 public function Init($Params)
1647 {
1648 $this->value = $Params['value'];
1649 $this->startTime = time();
1650 $this->Params = $Params;
1651 $this->Result = array();
1652
1653 $this->bSkip = $this->Params['lastPath'] ? true : false;
1654 if ($this->bSkip)
1655 {
1656 $this->Params['lastPath'] = Rel2Abs("/", $this->Params['lastPath']);
1657 $this->Params['lastPath'] = $_SERVER["DOCUMENT_ROOT"].$this->Params['lastPath'];
1658 }
1659 }
1660
1661 public function CheckBreak()
1662 {
1663 return time() - $this->startTime > CFilemanUtils::GetTimeout();
1664 }
1665
1666 public function Chmod($file)
1667 {
1668 if ($this->bSkip)
1669 {
1670 if ($file == $this->Params['lastPath'])
1671 $this->bSkip = false; // continue handle files from last path
1672 else
1673 return; // Files was handled earlier
1674 }
1675
1676 $this->Result[] = array(CFilemanUtils::TrimPath($file), false);
1677 }
1678}
1679
1681{
1682 public function Init($Params)
1683 {
1684 global $USER;
1685 $arWarnings = array();
1686
1687 if (!$USER->CanDoOperation('fileman_admin_files') && !$USER->CanDoOperation('fileman_admin_folders'))
1688 $arWarnings[] = GetMessage('FM_UTIL_ACCESS_DENIED');
1689
1691
1692 $log = $log ?? null;
1693 if (count($arWarnings) == 0)
1694 {
1695 $pathTo = trim($Params['copyTo'], " /");
1696 $site = CFileMan::__CheckSite($_GET['site']);
1697 $siteTo = $Params['siteTo'] ? $Params['siteTo'] : $site;
1698 $pathTo = $pathTo == "" ? "/" : "/".$pathTo."/";
1699
1700 $absPathTo = CSite::GetSiteDocRoot($siteTo).$pathTo;
1701 $docRootFrom = CSite::GetSiteDocRoot($site);
1702
1703 if (!$io->DirectoryExists($absPathTo))
1704 {
1705 // Create destination directory
1706 $bAccess = $USER->CanDoOperation('fileman_admin_folders') && $USER->CanDoFileOperation('fm_create_new_folder',$pathTo);
1707
1708 if ($Params['createCopyTo'])
1709 {
1710 if ($bAccess)
1711 CFileMan::CreateDir(Array($siteTo, $pathTo));
1712 }
1713 else // Ask to user - create destination folder or no?
1714 {
1715 ?><script>window.BXFM_NoCopyToDir = "<?= ($bAccess ? "ask_user" : "access_denied")?>";</script><?
1716 return;
1717 }
1718 }
1719
1720 foreach ($Params['arFiles'] as $file)
1721 {
1722 $filePath = $file['path'];
1723 $caseOption = $Params['caseOption'];
1724
1725 if($Params["userCaseLastPath"])
1726 {
1727 if ($Params["userCaseLastPath"] != $filePath)
1728 continue;
1729
1730 $caseOption = $Params['userCaseAnswer'];
1731 if ($Params["userCaseToAll"])
1732 $Params['caseOption'] = $caseOption;
1733
1734 $Params["userCaseLastPath"] = false;
1735 }
1736
1737 $arPath_i = Array($site, $filePath);
1738 $absPath_i = $docRootFrom.$filePath;
1739 $bDir_i = $io->DirectoryExists($absPath_i);
1740 $name_i = CFileman::GetFileName($filePath);
1741 $strWarn = "";
1742
1743 // Check if file already exists in destination folder
1744 if ($io->FileExists($absPathTo.$name_i) || ( $bDir_i == $io->DirectoryExists($absPathTo.$name_i) && $bDir_i))
1745 {
1746 $fTmp = $io->GetFile($absPathTo.$name_i);
1747 $fTmp1 = $io->GetFile($absPath_i);
1748 $altName = CFilemanCopy::GetAltFileName($absPathTo, $name_i, $bDir_i);
1749
1750 if ($caseOption == 'ask')
1751 {
1752 ?><script>
1753 window.BXFM_fileExist = {
1754 fileOld: {
1755 name: "<?= CUtil::JSEscape($name_i)?>",
1756 path: "<?= CUtil::JSEscape($pathTo.$name_i)?>",
1757 site: "<?= CUtil::JSEscape($siteTo)?>",
1758 bDir: <?= $bDir_i ? "true" : "false"?>,
1759 size: "<?= $bDir_i ? '-' : CFile::FormatSize($fTmp->GetFileSize())?>",
1760 date: "<?= date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL")), CFilemanUtils::GetModifyTime($absPathTo.$name_i)+CTimeZone::GetOffset())?>"
1761 },
1762 fileNew: {
1763 alt_name: "<?= CUtil::JSEscape($altName)?>",
1764 name: "<?= CUtil::JSEscape($name_i)?>",
1765 path: "<?= CUtil::JSEscape($filePath)?>",
1766 site: "<?= CUtil::JSEscape($site)?>",
1767 bDir: <?= $bDir_i ? "true" : "false"?>,
1768 size: "<?= $bDir_i ? '-' : CFile::FormatSize($fTmp1->GetFileSize())?>",
1769 date: "<?= date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL")), CFilemanUtils::GetModifyTime($absPath_i)+CTimeZone::GetOffset())?>"
1770 }
1771 };
1772 </script><?
1773 return;
1774 }
1775 elseif ($caseOption == 'replace')
1776 {
1777 // We don't need to replace, couse it's one file
1778 if (CFileMan::NormalizePath($pathTo."/".$name_i) == $filePath)
1779 continue;
1780
1781 $strWarn = CFileMan::CopyEx($arPath_i, Array($siteTo, CFileMan::NormalizePath($pathTo."/".$name_i)), !$Params['bCopy'], true);
1782
1783 if ($strWarn != "")
1784 {
1785 $arWarnings[] = $strWarn;
1786 $log = false;
1787 }
1788 elseif ($Params['bSearch'] && $Params['ssess'] && !$Params['bCopy'])
1789 CFilemanSearch::DelFromSearchResult($Params['ssess'], $filePath);
1790 }
1791 elseif ($caseOption == 'auto_rename')
1792 {
1793 $strWarn = CFileMan::CopyEx($arPath_i, Array($siteTo, CFileMan::NormalizePath($pathTo."/".$altName)), !$Params['bCopy']);
1794
1795 if ($strWarn != "")
1796 {
1797 $arWarnings[] = $strWarn;
1798 $log = false;
1799 }
1800 elseif ($Params['bSearch'] && $Params['ssess'] && !$Params['bCopy'])
1801 CFilemanSearch::DelFromSearchResult($Params['ssess'], $filePath);
1802 }
1803 elseif ($caseOption == 'skip')
1804 {
1805 continue;
1806 }
1807 }
1808 else // File not exist
1809 {
1810 $strWarn = CFileMan::CopyEx($arPath_i, Array($siteTo, CFileMan::NormalizePath($pathTo."/".$name_i)), !$Params['bCopy']);
1811
1812 if ($strWarn != "")
1813 {
1814 $arWarnings[] = $strWarn;
1815 $log = false;
1816 }
1817 elseif ($Params['bSearch'] && $Params['ssess'] && !$Params['bCopy'])
1818 CFilemanSearch::DelFromSearchResult($Params['ssess'], $filePath);
1819 }
1820
1821 $module_id = "fileman";
1822 if(COption::GetOptionString($module_id, "log_page", "Y")=="Y" && $log)
1823 {
1824 $res_log['copy_to'] = mb_substr($pathTo, 1);
1825 $res_log['path'] = mb_substr($filePath, 1);
1826 if ($Params['bCopy'] == "copy")
1827 {
1828 if (!$bDir_i)
1830 "content",
1831 "FILE_COPY",
1832 "fileman",
1833 "",
1834 serialize($res_log)
1835 );
1836 else
1838 "content",
1839 "SECTION_COPY",
1840 "fileman",
1841 "",
1842 serialize($res_log)
1843 );
1844 }
1845 else
1846 {
1847 if (!$bDir_i)
1849 "content",
1850 "FILE_MOVE",
1851 "fileman",
1852 "",
1853 serialize($res_log)
1854 );
1855 else
1857 "content",
1858 "SECTION_MOVE",
1859 "fileman",
1860 "",
1861 serialize($res_log)
1862 );
1863 }
1864 }
1865 }
1866 }
1867
1868 $arWarnings
1869 ?><script>
1870 window.BXFM_result = {
1871 status: "<?= (count($arWarnings) > 0 ? 'errors' : 'ok')?>",
1872 errors: <?= (count($arWarnings) > 0 ? CUtil::PhpToJSObject($arWarnings) : '{}')?>
1873 };
1874 </script><?
1875 }
1876
1877 public static function SaveConfig($arConfig)
1878 {
1879 CUserOptions::SetOption("fileman", "file_copy_move_config", serialize($arConfig));
1880 }
1881
1882 public static function GetConfig()
1883 {
1884 $arConfig = array();
1885 $strAr = CUserOptions::GetOption("fileman", "file_copy_move_config", false);
1886 if ($strAr && CheckSerializedData($strAr))
1887 $arConfig = unserialize($strAr, ['allowed_classes' => false]);
1888
1889 return $arConfig;
1890 }
1891
1892 public static function GetAltFileName($absPath, $name, $bDir = false)
1893 {
1895 for ($i=1; $i <= 9999; $i++)
1896 {
1897 $dotPos = mb_strpos($name, ".");
1898 if ($bDir || $dotPos === false)
1899 $new_name = $name."(".$i.")";
1900 else
1901 $new_name = mb_substr($name, 0, $dotPos)."(".$i.")".mb_substr($name, $dotPos);
1902
1903 if (!$io->FileExists($absPath.$new_name) && !$io->DirectoryExists($absPath.$new_name))
1904 break;
1905 }
1906 return $new_name;
1907 }
1908}
1909
1911{
1912 public static function Init($Params)
1913 {
1914 echo CUtil::InitJSCore(array('translit'), true);
1915?>
1916<script>
1917function InitTranslitInputs(params)
1918{
1919 var
1920 bLinked = params.bLinked !== false,
1921 translitTimeout,
1922 fromInput = params.fromInput,
1923 toInput = params.toInput,
1924 prevValue = fromInput,
1925 translit = function()
1926 {
1927 if (prevValue != fromInput.value)
1928 BX.translit(fromInput.value, {
1929 max_len : params.max_len,
1930 change_case : params.change_case,
1931 replace_space : params.replace_space,
1932 replace_other : params.replace_other,
1933 delete_repeat_replace : params.delete_repeat_replace,
1934 use_google : params.use_google,
1935 callback : function(result)
1936 {
1937 if (params.ext && params.ext)
1938 result = result + "." + params.ext;
1939 toInput.value = result;
1940 prevValue = fromInput.value;
1941 }
1942 });
1943 };
1944
1945 if (params.bLinkInputs)
1946 {
1947 if (!params.unlinkedTitle)
1948 params.unlinkedTitle = '';
1949 if (!params.linkedTitle)
1950 params.linkedTitle = '';
1951
1952 var
1953 pLink1 = BX.create("IMG", {props: {src: "/bitrix/images/1.gif", className: "bxfm-linked", title: params.linkedTitle}}),
1954 pLink2 = BX.create("IMG", {props: {src: "/bitrix/images/1.gif", className: "bxfm-linked", title: params.linkedTitle}});
1955
1956 if (fromInput.nextSibling)
1957 fromInput.parentNode.insertBefore(pLink1, fromInput.nextSibling);
1958 else
1959 fromInput.parentNode.appendChild(pLink1);
1960
1961 if (toInput.nextSibling)
1962 toInput.parentNode.insertBefore(pLink2, toInput.nextSibling);
1963 else
1964 toInput.parentNode.appendChild(pLink2);
1965
1966 pLink1.onclick = pLink2.onclick = function()
1967 {
1968 pLink1.className = pLink2.className = bLinked ? "bxfm-unlinked" : "bxfm-linked";
1969 pLink1.title = pLink2.title = bLinked ? params.unlinkedTitle : params.linkedTitle;
1970 bLinked = !bLinked;
1971 if (params.pLinked)
1972 params.pLinked.value = bLinked ? "Y" : "N";
1973 if (bLinked)
1974 translit();
1975 };
1976
1977 if (!bLinked)
1978 {
1979 bLinked = true;
1980 pLink1.onclick();
1981 }
1982 }
1983
1984 fromInput.onmousedown =
1985 fromInput.onkeydown =
1986 fromInput.onchange = function()
1987 {
1988 if (bLinked)
1989 {
1990 if (translitTimeout)
1991 clearTimeout(translitTimeout);
1992 translitTimeout = setTimeout(translit, 150);
1993 }
1994 }
1995
1996 if (bLinked)
1997 translit();
1998}
1999
2000InitTranslitInputs({
2001 fromInput: BX('<?= CUtil::JSEscape($Params['fromInputId'])?>'),
2002 toInput: BX('<?= CUtil::JSEscape($Params['toInputId'])?>'),
2003 pLinked: BX('<?= CUtil::JSEscape($Params['linkedId'] ?? null)?>'),
2004 bLinkInputs: true,
2005 bLinked: <?= $Params['linked'] ? 'true' : 'false'?>,
2006 linkedTitle : '<?= CUtil::JSEscape($Params['linkedTitle'])?>',
2007 unlinkedTitle: '<?= CUtil::JSEscape($Params['unlinkedTitle'])?>',
2008 ext: '<?= CUtil::JSEscape($Params['ext'] ?? null)?>',
2009 max_len : 100,
2010 change_case : 'L',
2011 replace_space : '-',
2012 replace_other : '-',
2013 delete_repeat_replace : true,
2014 use_google : <?= COption::GetOptionString("fileman", "use_translit_google", true) ? 'true' : 'false'?>
2015});
2016</script>
2017<?
2018 }
2019}
$path
Определения access_edit.php:21
return select
Определения access_edit.php:440
$arSites
Определения options.php:15
$arPathes
Определения options.php:293
global $APPLICATION
Определения include.php:80
$module_id
Определения options.php:6
static Calendar($sFieldName, $sFromName="", $sToName="", $bTime=false)
Определения admin_calendar.php:60
static ShowScript($arConfig)
Определения file_dialog.php:9
static GetOptionString($module_id, $name, $def="", $site=false, $bExactSite=false)
Определения option.php:8
static GetAvailableFormats()
Определения archive.php:79
static GetArchive($strArcName, $strType="")
Определения archive.php:26
static ConvertCharset($string, $direction=1, $skipEvents=false)
Определения virtual_io_filesystem.php:17
static GetInstance()
Определения virtual_io.php:60
static Log($SEVERITY, $AUDIT_TYPE_ID, $MODULE_ID, $ITEM_ID, $DESCRIPTION=false, $SITE_ID=false)
Определения event_log.php:32
static CreateDir($path)
Определения fileman.php:348
static SecurePathVar($str)
Определения fileman.php:2111
static CopyEx($path_from, $path_to, $bDeleteAfterCopy=false, $bOverride=false)
Определения fileman.php:544
static NormalizePath($path)
Определения fileman.php:538
static SaveLastPath($path)
Определения fileman.php:2163
static __CheckSite($site)
Определения fileman.php:772
static GetFileTypeEx($fileName)
Определения fileman.php:810
static CheckFileName($str)
Определения fileman.php:2069
static GetLastPathes()
Определения fileman.php:2180
Init($Params)
Определения fileman_utils.php:1646
CheckBreak()
Определения fileman_utils.php:1661
Chmod($file)
Определения fileman_utils.php:1666
Определения fileman_utils.php:1681
Init($Params)
Определения fileman_utils.php:1682
static GetAltFileName($absPath, $name, $bDir=false)
Определения fileman_utils.php:1892
static GetConfig()
Определения fileman_utils.php:1882
static SaveConfig($arConfig)
Определения fileman_utils.php:1877
Search($file)
Определения fileman_utils.php:1170
Init($Params)
Определения fileman_utils.php:1060
static CheckSearchSess($searchSess)
Определения fileman_utils.php:1337
static CleanOldSearchResult()
Определения fileman_utils.php:1450
static SecureSearchSess($ssess='')
Определения fileman_utils.php:1439
static DelFromSearchResult($searchSess, $path)
Определения fileman_utils.php:1421
static SetSearchResult($searchRes, $searchSess, $bClean=true)
Определения fileman_utils.php:1400
static GetSearchSess()
Определения fileman_utils.php:1444
static GetSearchResult($searchSess='', $arOrder=array('date', 'desc'))
Определения fileman_utils.php:1357
static RenameInSearchResult($searchSess, $pathFrom, $pathTo)
Определения fileman_utils.php:1427
static GetConfig()
Определения fileman_utils.php:1463
CheckBreak()
Определения fileman_utils.php:1324
static SaveConfig($arConfig)
Определения fileman_utils.php:1458
static trimPath($path, $docRoot=false)
Определения fileman_utils.php:1329
static Init($Params)
Определения fileman_utils.php:1912
$bDirFirst
Определения fileman_utils.php:1485
$bStoped
Определения fileman_utils.php:1477
$processDir
Определения fileman_utils.php:1483
$checkBreak
Определения fileman_utils.php:1475
__construct($dir, $Params)
Определения fileman_utils.php:1495
$cntDir
Определения fileman_utils.php:1487
$startPath
Определения fileman_utils.php:1480
Recursion($dir)
Определения fileman_utils.php:1535
$cntFile
Определения fileman_utils.php:1488
$nextPath
Определения fileman_utils.php:1479
$bBreak
Определения fileman_utils.php:1476
CallMethod($method='', $param=false)
Определения fileman_utils.php:1634
$callback
Определения fileman_utils.php:1482
Start($dir=false)
Определения fileman_utils.php:1507
$bFound
Определения fileman_utils.php:1478
$bSkipSymLinks
Определения fileman_utils.php:1484
Определения fileman_utils.php:6
static Request($action, $site)
Определения fileman_utils.php:697
static BuildDialogContent($site)
Определения fileman_utils.php:342
static NormalizePath($path)
Определения fileman_utils.php:1006
static TrimPath($path, $docRoot=false)
Определения fileman_utils.php:1013
static InitScript($Params)
Определения fileman_utils.php:7
static GetTimeout()
Определения fileman_utils.php:1001
static AppendLangMessages($Config)
Определения fileman_utils.php:241
static GetLastPathes()
Определения fileman_utils.php:1021
static GetModifyTime($path)
Определения fileman_utils.php:1033
static PhpToJSObject($arData, $bWS=false, $bSkipTilda=false, $bExtType=false)
Определения util.php:66
$f
Определения component_props.php:52
$arFields
Определения dblapprove.php:5
& nbsp
Определения epilog_main_admin.php:38
$arPath
Определения file_edit.php:72
hidden PROPERTY[<?=$propertyIndex?>][CODE]<?=htmlspecialcharsEx( $propertyCode)?> height
Определения file_new.php:759
bx popup label bx width30 PAGE_NEW_MENU_NAME text width
Определения file_new.php:677
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$fileContent
Определения file_property.php:47
$res
Определения filter_act.php:7
$entity
Определения archive.php:4
const StatusSuccess
Определения archive.php:6
const StatusError
Определения archive.php:5
const StatusContinue
Определения archive.php:7
$docRoot
Определения options.php:20
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
global $USER
Определения csv_new_run.php:40
$aTabs
Определения csv_new_setup.php:238
$io
Определения csv_new_run.php:98
endif
Определения csv_new_setup.php:990
$l
Определения options.php:783
CheckSerializedData($str, $max_depth=200)
Определения tools.php:4949
IsFileUnsafe($name)
Определения tools.php:3016
DeleteParam($ParamNames)
Определения tools.php:4548
RemoveScriptExtension($check_name)
Определения tools.php:2939
HasScriptExtension($check_name)
Определения tools.php:2956
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
Rel2Abs($curdir, $relpath)
Определения tools.php:3297
GetMessage($name, $aReplace=null)
Определения tools.php:3397
GetFileName($path)
Определения tools.php:3001
MakeTimeStamp($datetime, $format=false)
Определения tools.php:538
$name
Определения menu_edit.php:35
$order
Определения payment.php:8
$time
Определения payment.php:61
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
<? endif;?> window document title
Определения prolog_main_admin.php:76
if(empty($signedUserToken)) $key
Определения quickway.php:257
lang
Определения options.php:182
$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
$method
Определения index.php:27
if(!Loader::includeModule('sale')) $pattern
Определения index.php:20
$arRes
Определения options.php:104
path
Определения template_copy.php:201
$action
Определения file_dialog.php:21
$GLOBALS['_____370096793']
Определения update_client.php:1
$site
Определения yandex_run.php:614