From: Tim Düsterhus Date: Fri, 19 Nov 2021 13:25:08 +0000 (+0100) Subject: vB 5: Add support for file system attachments X-Git-Tag: 5.5.0_RC_3~3^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e127e245216a2b1d669b7603e9d54fd0b93ccb90;p=GitHub%2FWoltLab%2Fcom.woltlab.wcf.exporter.git vB 5: Add support for file system attachments --- diff --git a/files/lib/system/exporter/VB5xExporter.class.php b/files/lib/system/exporter/VB5xExporter.class.php index 60f8709..048f0f4 100644 --- a/files/lib/system/exporter/VB5xExporter.class.php +++ b/files/lib/system/exporter/VB5xExporter.class.php @@ -159,8 +159,13 @@ class VB5xExporter extends AbstractExporter if (\in_array('com.woltlab.wbb.attachment', $this->selectedData)) { if ($this->readOption('attachfile') != self::ATTACHFILE_DATABASE) { - // TODO: Not yet supported - return false; + $path = $this->readOption('attachpath'); + if (!\str_starts_with($path, '/')) { + $path = \realpath($this->fileSystemPath . $path); + } + if (!\is_dir($path)) { + return false; + } } } @@ -982,6 +987,22 @@ class VB5xExporter extends AbstractExporter $file = FileUtil::getTemporaryFilename('attachment_'); \file_put_contents($file, $row['filedata']); break; + case self::ATTACHFILE_FILESYSTEM: + $file = $this->readOption('attachpath'); + if (!StringUtil::startsWith($file, '/')) { + $file = \realpath($this->fileSystemPath . $file); + } + $file = FileUtil::addTrailingSlash($file); + $file .= $row['userid'] . '/' . $row['filedataid'] . '.attach'; + break; + case self::ATTACHFILE_FILESYSTEM_SUBFOLDER: + $file = $this->readOption('attachpath'); + if (!StringUtil::startsWith($file, '/')) { + $file = \realpath($this->fileSystemPath . $file); + } + $file = FileUtil::addTrailingSlash($file); + $file .= \implode('/', \str_split($row['userid'])) . '/' . $row['filedataid'] . '.attach'; + break; } // unable to read file -> abort