Commit 653f3b3217ec997e35d4f71d3e758bed483b3fcb
1 parent
ccf64b4c
Second attempt at a method to ensure thumbnail paths are correct for creation
Committed by: Paul Barrett
Showing
1 changed file
with
33 additions
and
5 deletions
plugins/thumbnails/thumbnails.php
| @@ -158,9 +158,22 @@ class thumbnailGenerator extends BaseProcessor | @@ -158,9 +158,22 @@ class thumbnailGenerator extends BaseProcessor | ||
| 158 | $pdfFile = str_replace('/', '\\', $pdfFile); | 158 | $pdfFile = str_replace('/', '\\', $pdfFile); |
| 159 | 159 | ||
| 160 | $thumbnaildir = $default->internalVarDirectory.DIRECTORY_SEPARATOR.'thumbnails'; | 160 | $thumbnaildir = $default->internalVarDirectory.DIRECTORY_SEPARATOR.'thumbnails'; |
| 161 | - $thumbnaildir = str_replace('/', '\\', $thumbnaildir); | ||
| 162 | - $thumbnailfile = $thumbnaildir.DIRECTORY_SEPARATOR.$this->document->iId.'.jpg'; | 161 | + if (WINDOWS_OS) { |
| 162 | + $thumbnaildir = str_replace('/', '\\', $thumbnaildir); | ||
| 163 | + } | ||
| 163 | 164 | ||
| 165 | + if (!preg_match('/' . str_replace('/', '\/', str_replace('\\', '\\\\', KT_DIR)) . '/', $thumbnaildir)) | ||
| 166 | + { | ||
| 167 | + if (WINDOWS_OS) { | ||
| 168 | + $thumbnaildir = KT_DIR . '\\' . trim($thumbnaildir, '\\'); | ||
| 169 | + } | ||
| 170 | + else { | ||
| 171 | + $thumbnaildir = KT_DIR . '/' . trim($thumbnaildir, '/'); | ||
| 172 | + } | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + $thumbnailfile = $thumbnaildir.DIRECTORY_SEPARATOR.$this->document->iId.'.jpg'; | ||
| 176 | + | ||
| 164 | //if thumbail dir does not exist, generate one and add an index file to block access | 177 | //if thumbail dir does not exist, generate one and add an index file to block access |
| 165 | if (!file_exists($thumbnaildir)) { | 178 | if (!file_exists($thumbnaildir)) { |
| 166 | mkdir($thumbnaildir, 0755); | 179 | mkdir($thumbnaildir, 0755); |
| @@ -225,16 +238,31 @@ class ThumbnailViewlet extends KTDocumentViewlet { | @@ -225,16 +238,31 @@ class ThumbnailViewlet extends KTDocumentViewlet { | ||
| 225 | global $default; | 238 | global $default; |
| 226 | $varDir = $default->internalVarDirectory; | 239 | $varDir = $default->internalVarDirectory; |
| 227 | $thumbnailfile = $varDir . '/thumbnails/'.$documentId.'.jpg'; | 240 | $thumbnailfile = $varDir . '/thumbnails/'.$documentId.'.jpg'; |
| 241 | + | ||
| 242 | + if (WINDOWS_OS) { | ||
| 243 | + $varDir = str_replace('/', '\\', $varDir); | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + if (!preg_match('/' . str_replace('/', '\/', str_replace('\\', '\\\\', KT_DIR)) . '/', $thumbnaildir)) | ||
| 247 | + { | ||
| 248 | + if (WINDOWS_OS) { | ||
| 249 | + $varDir = KT_DIR . '\\' . trim($varDir, '\\'); | ||
| 250 | + } | ||
| 251 | + else { | ||
| 252 | + $varDir = KT_DIR . '/' . trim($varDir, '/'); | ||
| 253 | + } | ||
| 254 | + } | ||
| 255 | + | ||
| 256 | + $thumbnailCheck = $varDir . '/thumbnails/'.$documentId.'.jpg'; | ||
| 228 | 257 | ||
| 229 | // if the thumbnail doesn't exist try to create it | 258 | // if the thumbnail doesn't exist try to create it |
| 230 | - if (!file_exists($thumbnailfile)){ | 259 | + if (!file_exists($thumbnailCheck)){ |
| 231 | $thumbnailer = new thumbnailGenerator(); | 260 | $thumbnailer = new thumbnailGenerator(); |
| 232 | $thumbnailer->setDocument($this->oDocument); | 261 | $thumbnailer->setDocument($this->oDocument); |
| 233 | $thumbnailer->processDocument(); | 262 | $thumbnailer->processDocument(); |
| 234 | 263 | ||
| 235 | - $thumbcheck = $thumbnailfile; | ||
| 236 | // if it still doesn't exist, return an empty string | 264 | // if it still doesn't exist, return an empty string |
| 237 | - if (!file_exists($thumbcheck)) { | 265 | + if (!file_exists($thumbnailCheck)) { |
| 238 | return ''; | 266 | return ''; |
| 239 | } | 267 | } |
| 240 | } | 268 | } |