Update UserController.php

This commit is contained in:
Julian Prieber 2024-10-08 16:39:08 +02:00
parent 0d4caa7110
commit 434e6bbd7a
1 changed files with 6 additions and 11 deletions

View File

@ -748,17 +748,12 @@ class UserController extends Controller
$files = scandir($folder);
foreach ($files as $file) {
if ($file !== '.' && $file !== '..') {
if (preg_match($regex, $file)) {
$new_file = preg_replace($regex, '', $file);
File::copyDirectory($folder . '/' . $file, $folder . '/' . $new_file);
$dirname = $folder . '/' . $file;
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
system('rmdir ' . escapeshellarg($dirname) . ' /s /q');
} else {
system("rm -rf " . escapeshellarg($dirname));
}
}
$basename = basename($file);
if (preg_match($regex, $basename)) {
$newBasename = preg_replace($regex, '', $basename);
$newPath = $folder . '/' . $newBasename;
File::copyDirectory($file, $newPath);
File::deleteDirectory($file);
}
}
}