Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //title: Распакова архивов
- $collectionDir = $_SERVER["DOCUMENT_ROOT"]."/upload/collection_images/";
- $dir = opendir($collectionDir);
- $zipFilesDir = [];
- while($collection = readdir($dir))
- {
- if (is_dir($collectionDir.$collection) && $collection != '.' && $collection != '..')
- {
- $section = opendir($collectionDir.$collection);
- while($file = readdir($section))
- {
- if($file != '.' && $file != '..' && strpos($file, '.zip') !== false)
- $zipFilesDir[$collectionDir.$collection.'/'][] = $file;
- }
- }
- }
- // Параметры распаковки
- $arUnpackOptions = Array(
- "REMOVE_PATH" => $_SERVER["DOCUMENT_ROOT"],
- "UNPACK_REPLACE" => false
- );
- $arResult = [];
- foreach($zipFilesDir as $zipDir => $zipFiles)
- {
- $sFilePathDst = $zipDir;
- foreach($zipFiles as $zipFile)
- {
- $sFilePathArc = $zipDir.$zipFile;
- $resArchiver = CBXArchive::GetArchive($sFilePathArc);
- $resArchiver->SetOptions($arUnpackOptions);
- $uRes = $resArchiver->Unpack($sFilePathDst);
- if (!$uRes) {
- $arResult[$zipDir][$zipFile] = $arc->GetErrors();
- } else {
- $arResult[$zipDir][$zipFile] = 'success';
- }
- }
- }
- print_r($arResult);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement