diff --git a/plugins/thumbnails/thumbnails.php b/plugins/thumbnails/thumbnails.php index 98f9af6..aaa6d53 100755 --- a/plugins/thumbnails/thumbnails.php +++ b/plugins/thumbnails/thumbnails.php @@ -155,25 +155,21 @@ class thumbnailGenerator extends BaseProcessor $pdfFile = $pdfDir .DIRECTORY_SEPARATOR. $this->document->iId.'.pdf'; } - $pdfFile = str_replace('/', '\\', $pdfFile); - $thumbnaildir = $default->internalVarDirectory.DIRECTORY_SEPARATOR.'thumbnails'; - if (WINDOWS_OS) { + + if (stristr(PHP_OS,'WIN')) { $thumbnaildir = str_replace('/', '\\', $thumbnaildir); + $pdfFile = str_replace('/', '\\', $pdfFile); } if (!preg_match('/' . str_replace('/', '\/', str_replace('\\', '\\\\', KT_DIR)) . '/', $thumbnaildir)) { - if (WINDOWS_OS) { + if (stristr(PHP_OS,'WIN')) { $thumbnaildir = KT_DIR . '\\' . trim($thumbnaildir, '\\'); } - else { - $thumbnaildir = KT_DIR . '/' . trim($thumbnaildir, '/'); - } } $thumbnailfile = $thumbnaildir.DIRECTORY_SEPARATOR.$this->document->iId.'.jpg'; - //if thumbail dir does not exist, generate one and add an index file to block access if (!file_exists($thumbnaildir)) { mkdir($thumbnaildir, 0755); @@ -186,7 +182,6 @@ class thumbnailGenerator extends BaseProcessor $default->log->debug('Thumbnail Generator Plugin: PDF file does not exist, cannot generate a thumbnail'); return false; } - // if a previous version of the thumbnail exists - delete it if (file_exists($thumbnailfile)) { @unlink($thumbnailfile); @@ -196,13 +191,12 @@ class thumbnailGenerator extends BaseProcessor $pathConvert = (!empty($default->convertPath)) ? $default->convertPath : 'convert'; // windows path may contain spaces - if (WINDOWS_OS) { + if (stristr(PHP_OS,'WIN')) { $cmd = "\"{$pathConvert}\" -size 200x200 \"{$pdfFile}[0]\" -resize 200x200 \"$thumbnailfile\""; } else { $cmd = "{$pathConvert} -size 200x200 {$pdfFile}[0] -resize 200x200 $thumbnailfile"; } - $result = KTUtil::pexec($cmd); return true; //}else{ @@ -239,18 +233,15 @@ class ThumbnailViewlet extends KTDocumentViewlet { $varDir = $default->internalVarDirectory; $thumbnailfile = $varDir . '/thumbnails/'.$documentId.'.jpg'; - if (WINDOWS_OS) { + if (stristr(PHP_OS,'WIN')) { $varDir = str_replace('/', '\\', $varDir); } if (!preg_match('/' . str_replace('/', '\/', str_replace('\\', '\\\\', KT_DIR)) . '/', $thumbnaildir)) { - if (WINDOWS_OS) { + if (stristr(PHP_OS,'WIN')) { $varDir = KT_DIR . '\\' . trim($varDir, '\\'); } - else { - $varDir = KT_DIR . '/' . trim($varDir, '/'); - } } $thumbnailCheck = $varDir . '/thumbnails/'.$documentId.'.jpg'; @@ -294,4 +285,4 @@ class ThumbnailViewlet extends KTDocumentViewlet { } } -?> \ No newline at end of file +?>