* Returns the temp folder for the installation.
*/
public static function getInstallTempFolder(): string {
- $dir = __DIR__ . '/WCFSetup-' . TMP_FILE_PREFIX . '/';
+ $dir = INSTALL_SCRIPT_DIR . '/WCFSetup-' . TMP_FILE_PREFIX . '/';
@mkdir($dir);
self::makeWritable($dir);
SessionHandler::getInstance()->update();
// Delete tmp files
- $iterator = new \RecursiveIteratorIterator(
- new \RecursiveDirectoryIterator(
- TMP_DIR . '/',
- \RecursiveDirectoryIterator::CURRENT_AS_FILEINFO | \RecursiveDirectoryIterator::SKIP_DOTS
- ),
- \RecursiveIteratorIterator::CHILD_FIRST
- );
- foreach ($iterator as $path) {
- if ($path->isDir()) {
- \rmdir($path);
- } else {
- \unlink($path);
+ foreach (new \DirectoryIterator(\INSTALL_SCRIPT_DIR) as $fileInfo) {
+ if (!$fileInfo->isDir()) {
+ continue;
+ }
+
+ if (!\preg_match('/^WCFSetup-[0-9a-f]{16}$/', $fileInfo->getBasename())) {
+ continue;
+ }
+
+ $tmpDirectory = $fileInfo->getPathname();
+
+ $tmpDirectoryIterator = new \RecursiveIteratorIterator(
+ new \RecursiveDirectoryIterator(
+ $tmpDirectory,
+ \RecursiveDirectoryIterator::CURRENT_AS_FILEINFO | \RecursiveDirectoryIterator::SKIP_DOTS
+ ),
+ \RecursiveIteratorIterator::CHILD_FIRST
+ );
+ foreach ($tmpDirectoryIterator as $tmpFile) {
+ if ($tmpFile->isDir()) {
+ \rmdir($tmpFile);
+ } else {
+ \unlink($tmpFile);
+ }
}
+ \rmdir($tmpDirectory);
}
- \rmdir(TMP_DIR . '/');
return $output;
}