From a3b9e6b63bed5b9b03b24cccb9adf91e7373f93f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 15 Dec 2013 17:26:55 +0100 Subject: [PATCH] Fix support for relative attachment folder in vB Fixes #11 --- files/lib/system/exporter/VB3or4xExporter.class.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/files/lib/system/exporter/VB3or4xExporter.class.php b/files/lib/system/exporter/VB3or4xExporter.class.php index 01e2819..a921404 100644 --- a/files/lib/system/exporter/VB3or4xExporter.class.php +++ b/files/lib/system/exporter/VB3or4xExporter.class.php @@ -177,7 +177,9 @@ class VB3or4xExporter extends AbstractExporter { if (in_array('com.woltlab.wbb.attachment', $this->selectedData)) { if ($this->readOption('attachfile') != self::ATTACHFILE_DATABASE) { - if (!is_dir($this->readOption('attachpath'))) return false; + $path = $this->readOption('attachpath'); + if (!StringUtil::startsWith($path, '/')) $path = realpath($this->fileSystemPath.$path); + if (!is_dir($path)) return false; } } @@ -946,11 +948,15 @@ class VB3or4xExporter extends AbstractExporter { file_put_contents($file, $row['filedata']); break; case self::ATTACHFILE_FILESYSTEM: - $file = FileUtil::addTrailingSlash($this->readOption('attachpath')); + $file = $this->readOption('attachpath'); + if (!StringUtil::startsWith($file, '/')) $file = realpath($this->fileSystemPath.$file); + $file = FileUtil::addTrailingSlash($file); $file .= $row['userid'].'/'.$row['attachmentid'].'.attach'; break; case self::ATTACHFILE_FILESYSTEM_SUBFOLDER: - $file = FileUtil::addTrailingSlash($this->readOption('attachpath')); + $file = $this->readOption('attachpath'); + if (!StringUtil::startsWith($file, '/')) $file = realpath($this->fileSystemPath.$file); + $file = FileUtil::addTrailingSlash($file); $file .= implode('/', str_split($row['userid'])).'/'.$row['attachmentid'].'.attach'; break; } -- 2.20.1