Respect uploadsPath setting (MyBB)
authorTim Düsterhus <timwolla@arcor.de>
Mon, 15 Jul 2013 20:21:10 +0000 (22:21 +0200)
committerTim Düsterhus <timwolla@arcor.de>
Mon, 15 Jul 2013 20:21:10 +0000 (22:21 +0200)
files/lib/system/exporter/MyBB1xExporter.class.php

index c4fd963c56f6058a42393d5e0ecdb7979533fc08..6d4c8efa3f92f8e062e639c4176172d3ceb9da12 100644 (file)
@@ -770,14 +770,25 @@ class MyBB1xExporter extends AbstractExporter {
         * Exports post attachments.
         */
        public function exportPostAttachments($offset, $limit) {
+               static $uploadsPath = null;
+               if ($uploadsPath === null) {
+                       // TODO: untested
+                       $sql = "SELECT  value
+                               FROM    ".$this->databasePrefix."settings
+                               WHERE   name = ?";
+                       $statement = $this->database->prepareStatement($sql);
+                       $statement->execute(array('uploadspath'));
+                       $row = $statement->fetchArray();
+                       $uploadsPath = $row['value'];
+                       if (!StringUtil::startsWith($uploadsPath, '/')) $uploadsPath = realpath($this->fileSystemPath.$uploadsPath);
+               }
                $sql = "SELECT          *
                        FROM            ".$this->databasePrefix."attachments
                        ORDER BY        aid ASC";
                $statement = $this->database->prepareStatement($sql, $limit, $offset);
                $statement->execute(array('post', 0));
                while ($row = $statement->fetchArray()) {
-                       // TODO: respect uploads/-setting of MyBB
-                       $fileLocation = $this->fileSystemPath.'uploads/'.$row['attachname'];
+                       $fileLocation = $uploadsPath.$row['attachname'];
                        
                        if ($imageSize = getimagesize($fileLocation)) {
                                $row['isImage'] = 1;