From: Tim Düsterhus Date: Sun, 15 Dec 2013 16:26:55 +0000 (+0100) Subject: Fix support for relative attachment folder in vB X-Git-Tag: 2.0.1~7 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a3b9e6b63bed5b9b03b24cccb9adf91e7373f93f;p=GitHub%2FWoltLab%2Fcom.woltlab.wcf.exporter.git Fix support for relative attachment folder in vB Fixes #11 --- 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; }