/** Удаляет старые временные папки, оставляя последние $iCnt **/ function EraseOldFolders($iCnt = 1) { $iCnt = IntVal($iCnt); $path = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates"; $arFolders = array(); if ($handle = @opendir($path)) { while (($file = readdir($handle)) !== false) { if ($file == "." || $file == "..") continue; if (is_dir($path."/".$file) && substr($file, 0, strlen("update_m"))=="update_m") { $arFolders[] = array($file, IntVal(substr($file, strlen("update_m")))); } } } @closedir($handle); if (count($arFolders) > $iCnt) { for ($i = 0; $i < count($arFolders) - 1; $i++) { for ($j = $i + 1; $j < count($arFolders); $j++) { if ($arFolders[$i][1] < $arFolders[$j][1]) { $tmp = $arFolders[$i]; $arFolders[$i] = $arFolders[$j]; $arFolders[$j] = $tmp; } } } for ($i = $iCnt; $i < count($arFolders); $i++) { CUpdateSystem::DeleteDirFilesEx($path."/".$arFolders[$i][0]); } } }
<?php if (IsModuleInstalled('fileman')) { $updater->CopyFiles("install/admin", "admin"); $updater->CopyFiles("install/js", "js"); } if ($updater->CanUpdateKernel()) { $arToDelete = array("modules/fileman/install/js/fileman/light_editor/le_table.js"); foreach ($arToDelete as $file) { CUpdateSystem::DeleteDirFilesEx($_SERVER["DOCUMENT_ROOT"] . $updater->kernelPath . "/" . $file); } }