1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
file_delete.php
См. документацию.
1<?
2require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
3
4//Functions
6{
8
9 $f = $io->GetFile($absoluteFilePath);
10 $f->MarkWritable();
11
12 if (COption::GetOptionInt("main", "disk_space") > 0)
13 {
14 $file_size = $f->GetFileSize();
15 $quota = new CDiskQuota();
16 $quota->UpdateDiskQuota("file", $file_size, "delete");
17 }
18
19 $sucess = $io->Delete($absoluteFilePath);
20
21 if (!$sucess)
22 return false;
23
24 if (COption::GetOptionString("fileman", "log_page", "Y")=="Y")
25 {
26 CEventLog::Log("content", "PAGE_DELETE", "fileman", $path);
27 }
28
29 $GLOBALS["APPLICATION"]->RemoveFileAccessPermission(Array($site, $path));
30
31 if (CModule::IncludeModule("search"))
32 CSearch::DeleteIndex("main", $site."|".$path);
33
34 //Delete from rewrite rule
37
38 return true;
39}
40
42{
43 if (!CModule::IncludeModule("fileman"))
44 return false;
45
46 if (!$GLOBALS["USER"]->CanDoOperation("fileman_edit_menu_elements") || !$GLOBALS["USER"]->CanDoOperation("fileman_edit_existent_files"))
47 return false;
48
49 $arMenuTypes = GetMenuTypes($site);
50 if (empty($arMenuTypes))
51 return false;
52
54 $result = array();
55
57
58 while (true)
59 {
60 $currentPath = rtrim($currentPath, "/");
61
62 if ($currentPath == '')
63 {
64 $currentPath = "/";
65 $slash = "";
66 }
67 else
68 {
69 //Find parent folder
70 $position = mb_strrpos($currentPath, "/");
71 if ($position === false)
72 break;
73 $currentPath = mb_substr($currentPath, 0, $position);
74 $slash = "/";
75 }
76
77 foreach ($arMenuTypes as $menuType => $menuDesc)
78 {
79 $menuFile = $currentPath.$slash.".".$menuType.".menu.php";
80
81 if ($io->FileExists($documentRoot.$menuFile) && $GLOBALS["USER"]->CanDoFileOperation("fm_edit_existent_file", Array($site, $menuFile)))
82 {
83 $arFound = BXDeleteFromMenuFile($menuFile, $documentRoot, $site, $path);
84 if ($arFound)
85 $result[] = $arFound;
86 }
87 }
88
89 if ($currentPath == '')
90 break;
91 }
92
93 return $result;
94}
95
97{
98 $arMenu = CFileman::GetMenuArray($documentRoot.$menuFile);
99 if (empty($arMenu["aMenuLinks"]))
100 return false;
101
102 $arFound = false;
103 foreach ($arMenu["aMenuLinks"] as $menuIndex => $arItem)
104 {
105 if (!isset($arItem[1]))
106 continue;
107
108 $menuLink = $arItem[1];
109 $position = mb_strpos($menuLink, "?");
110 if ($position !== false)
111 $menuLink = mb_substr($menuLink, 0, $position);
112
113 if ($menuLink != "/")
114 $menuLink = rtrim($menuLink, "/");
115
116 $filename = basename($path);
117 $dirName = str_replace("\\", "/", dirname($path));
118
119 if ($menuLink == $path || ($filename == "index.php" && $menuLink == $dirName))
120 {
121 $arFound = array(
122 'menuFile' => $menuFile,
123 'menuIndex' => $menuIndex,
124 'menuItem' => $arItem
125 );
126 unset($arMenu["aMenuLinks"][$menuIndex]);
127 }
128 }
129
130 if ($arFound)
131 {
132 CFileMan::SaveMenu(Array($site, $menuFile), $arMenu["aMenuLinks"], $arMenu["sMenuTemplate"]);
133
134 if(COption::GetOptionString("fileman", "log_page", "Y")=="Y")
135 {
136 CEventLog::Log("content", "MENU_EDIT", "fileman", $menuFile);
137 }
138 }
139 return $arFound;
140}
141
142IncludeModuleLangFile(__FILE__);
143
144$popupWindow = new CJSPopup(GetMessage("PAGE_DELETE_WINDOW_TITLE"), array("SUFFIX"=>($_GET['subdialog'] == 'Y'? 'subdialog':'')));
145
146if (IsModuleInstalled("fileman"))
147{
148 if (!$USER->CanDoOperation('fileman_admin_files'))
149 $popupWindow->ShowError(GetMessage("PAGE_DELETE_ACCESS_DENIED"));
150}
151
153
154//Page path
155$path = "/";
156if (isset($_REQUEST["path"]) && $_REQUEST["path"] <> '')
157 $path = $io->CombinePath("/", $_REQUEST["path"]);
158
159//Lang
160if (!isset($_REQUEST["lang"]) || $_REQUEST["lang"] == '')
161 $lang = LANGUAGE_ID;
162
163//BackUrl
164$back_url = ($_REQUEST["back_url"] ?? "");
165if ($back_url == "")
166 $back_url = ($io->ExtractNameFromPath($path) == "index.php" ? "/" : str_replace("\\", "/", dirname($path)));
167
168//Site ID
170if (isset($_REQUEST["site"]) && $_REQUEST["site"] <> '')
171{
172 $obSite = CSite::GetByID($_REQUEST["site"]);
173 if ($arSite = $obSite->Fetch())
174 $site = $_REQUEST["site"];
175}
176
177$documentRoot = CSite::GetSiteDocRoot($site);
179
180//Check permissions
181if (!$io->FileExists($absoluteFilePath) || preg_match("~\/\.access\.php$~i", $path))
182 $popupWindow->ShowError(GetMessage("PAGE_DELETE_FILE_NOT_FOUND")." (".htmlspecialcharsbx($path).")");
183elseif (!$USER->CanDoFileOperation('fm_delete_file',Array($site, $path)))
184 $popupWindow->ShowError(GetMessage("PAGE_DELETE_ACCESS_DENIED"));
185
186//Check post values
189if ($_SERVER["REQUEST_METHOD"] == "POST")
190{
191 $deleteFromMenu = (isset($_REQUEST["delete_from_menu"]) && $_REQUEST["delete_from_menu"] == "Y");
192 if (!check_bitrix_sessid())
193 $strWarning = GetMessage("MAIN_SESSION_EXPIRED");
194}
195else
196{
197 if ($io->ExtractNameFromPath($path) == "index.php")
198 $strNotice = GetMessage("PAGE_DELETE_INDEX_WARNING");
200}
201
202//Delete File
203if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_REQUEST["save"]) && $strWarning == "")
204{
205 CModule::IncludeModule("fileman");
206
207 $f = $io->GetFile($absoluteFilePath);
208
209 $arUndoParams = array(
210 'module' => 'fileman',
211 'undoType' => 'delete_file',
212 'undoHandler' => 'CFileman::UndoFileDelete',
213 'arContent' => array(
214 'path' => $path,
215 'content' => $f->GetContents(),
216 'site' => $site,
217 'perm' => CFileMan::FetchFileAccessPerm(Array($site, $path)),
218 'SEF' => \Bitrix\Main\UrlRewriter::getList($site, array("PATH" => $path)),
219 )
220 );
221
223 if ($success)
224 {
225 if ($deleteFromMenu)
226 $arUndoParams['arContent']['menu'] = BXDeleteFromMenu($documentRoot, $path, $site);
227
228 if (isset($_GET['subdialog']) && $_GET['subdialog'] == 'Y')
229 echo "<script>structReload('".urlencode($_REQUEST["path"])."');</script>";
230
231 $ID = CUndo::Add($arUndoParams);
232
234
235 //CUndo::Escape($ID);
236
237 $popupWindow->Close($bReload=($_GET['subdialog'] <> 'Y'), $back_url);
238 }
239 else
240 {
241 $strWarning = GetMessage("PAGE_DELETE_ERROR_OCCURED");
242 }
243}
244
245//HTML Output
246$popupWindow->ShowTitlebar(GetMessage("PAGE_DELETE_WINDOW_TITLE"));
247$popupWindow->StartDescription("bx-delete-page");
248?>
249<p><?=str_replace("#FILENAME#", htmlspecialcharsbx($path), GetMessage("PAGE_DELETE_CONFIRM_TEXT"))?></p>
250<?
251$popupWindow->EndDescription("bx-delete-page");
252$popupWindow->StartContent();
253if (isset($strWarning) && $strWarning != "")
254 $popupWindow->ShowValidationError($strWarning);
255?>
256<?if (IsModuleInstalled("fileman")):?>
257 <input type="checkbox" name="delete_from_menu" value="Y" id="bx_delete_from_menu" <?=($deleteFromMenu ? "checked" : "")?>> <label for="bx_delete_from_menu"><?=GetMessage("PAGE_DELETE_FROM_MENU")?></label>
258<?
259if (isset($strNotice) && $strNotice != '')
260 CAdminMessage::ShowMessage(array("MESSAGE" => $strNotice, "TYPE" => "ERROR"))
261?>
262<?endif?>
263
264
265<?$popupWindow->StartButtons();?>
266
267<input name="btn_popup_save" type="button" value="<?=GetMessage("PAGE_DELETE_BUTTON_YES")?>" title="<?=GetMessage("PAGE_DELETE_BUTTON_YES")?>" onclick="BXDeletePage();"/>
268&nbsp;&nbsp;&nbsp;<input name="btn_popup_close" type="button" value="<?=GetMessage("PAGE_DELETE_BUTTON_NO")?>" onclick="<?=$popupWindow->jsPopup?>.CloseDialog()" title="<?=GetMessage("PAGE_DELETE_BUTTON_NO")?>" />
269
270<?$popupWindow->EndButtons();?>
271
272<script>
273window.BXDeletePage = function()
274{
275 var params = 'save=Y&<?=bitrix_sessid_get()?>';
276 var deleteFromMenu = document.getElementById("bx_delete_from_menu");
277 if (deleteFromMenu)
278 params += "&delete_from_menu=" + (deleteFromMenu.checked ? "Y" : "N");
279
280 <?=$popupWindow->jsPopup?>.PostParameters(params);
281}
282</script>
283
284<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin_js.php");?>
$path
Определения access_edit.php:21
$popupWindow
Определения access_edit.php:10
$back_url
Определения access_edit.php:50
$currentPath
Определения access_edit.php:61
if($canUseYandexMarket) $strWarning
Определения options.php:74
static deleteByFilter($filter)
Определения parameters.php:99
static delete($siteId, $filter)
Определения urlrewriter.php:262
static ShowMessage($message)
Определения admin_lib.php:2351
static DeleteIndex($MODULE_ID, $ITEM_ID=false, $PARAM1=false, $PARAM2=false, $SITE_ID=false)
Определения search.php:2922
static GetInstance()
Определения virtual_io.php:60
Определения quota.php:6
static Log($SEVERITY, $AUDIT_TYPE_ID, $MODULE_ID, $ITEM_ID, $DESCRIPTION=false, $SITE_ID=false)
Определения event_log.php:32
static FetchFileAccessPerm($path)
Определения fileman.php:1015
static SaveMenu($path, $aMenuLinksTmp, $sMenuTemplateTmp="")
Определения fileman.php:258
Определения jspopup.php:10
static IncludeModule($module_name)
Определения module.php:151
static ShowUndoMessage($ID)
Определения undo.php:187
static Add($params=array())
Определения undo.php:9
$f
Определения component_props.php:52
& nbsp
Определения epilog_main_admin.php:38
BXDeleteFromMenuFile($menuFile, $documentRoot, $site, $path)
Определения file_delete.php:96
$deleteFromMenu
Определения file_delete.php:199
$absoluteFilePath
Определения file_delete.php:178
BXDeleteFromSystem($absoluteFilePath, $path, $site)
Определения file_delete.php:5
$strNotice
Определения file_delete.php:188
BXDeleteFromMenu($documentRoot, $path, $site)
Определения file_delete.php:41
$filename
Определения file_edit.php:47
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$menuType
Определения file_new.php:209
$arMenu
Определения file_new.php:216
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
$result
Определения get_property_values.php:14
if($ajaxMode) $ID
Определения get_user.php:27
$_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
$success
Определения mail_entry.php:69
foreach(['Bitrix\\Main'=> '/lib', 'Psr\\Container'=> '/vendor/psr/container/src', 'Psr\\Log'=> '/vendor/psr/log/src', 'Psr\\Http\\Message'=> '/vendor/psr/http-message/src', 'Psr\\Http\\Client'=> '/vendor/psr/http-client/src', 'Http\\Promise'=> '/vendor/php-http/promise/src', 'PHPMailer\\PHPMailer'=> '/vendor/phpmailer/phpmailer/src', 'GeoIp2'=> '/vendor/geoip2/geoip2/src', 'MaxMind\\Db'=> '/vendor/maxmind-db/reader/src/MaxMind/Db', 'PhpParser'=> '/vendor/nikic/php-parser/lib/PhpParser', 'Recurr'=> '/vendor/simshaun/recurr/src/Recurr',] as $namespace=> $namespacePath) $documentRoot
Определения autoload.php:27
if(!defined('SITE_ID')) $lang
Определения include.php:91
check_bitrix_sessid($varname='sessid')
Определения tools.php:4686
GetMenuTypes($site=false, $default_value=false)
Определения tools.php:4728
IsModuleInstalled($module_id)
Определения tools.php:5301
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
<? endif;?> window document title
Определения prolog_main_admin.php:76
const SITE_ID
Определения sonet_set_content_view.php:12
$GLOBALS['_____370096793']
Определения update_client.php:1
$site
Определения yandex_run.php:614