From a522a2207eac77cbf4a7bf980ad9535ea8edf7f6 Mon Sep 17 00:00:00 2001 From: zero Date: Thu, 19 Jul 2007 23:01:04 +0000 Subject: [PATCH] =?UTF-8?q?=EC=8D=B8=EB=84=A4=EC=9D=BC=20=EC=B6=94?= =?UTF-8?q?=EC=B6=9C=20=EB=B0=A9=EB=B2=95=20=EB=B3=80=EA=B2=BD.=20?= =?UTF-8?q?=EC=B2=A8=EB=B6=80=ED=8C=8C=EC=9D=BC=EB=B6=80=ED=84=B0=20?= =?UTF-8?q?=EC=B0=BE=EA=B3=A0=20=EB=A7=81=ED=81=AC=EB=90=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=EB=A5=BC=20=EC=B0=BE=EC=95=84=EC=84=9C=20?= =?UTF-8?q?=EC=8D=B8=EB=84=A4=EC=9D=BC=20=EB=A7=8C=EB=93=A4=EA=B3=A0=20?= =?UTF-8?q?=EA=B8=8D=EB=A6=90=20=EC=88=98=EC=A0=95=EC=8B=9C=EA=B0=84?= =?UTF-8?q?=EC=9D=B4=20=EB=8B=AC=EB=9D=BC=EC=A7=80=EB=A9=B4=20=EC=83=88?= =?UTF-8?q?=EB=A1=9C=20=EC=83=9D=EC=84=B1=20=EC=8B=9C=EB=8F=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://xe-core.googlecode.com/svn/trunk@1960 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- modules/document/document.item.php | 53 +++++++++++++++++------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/modules/document/document.item.php b/modules/document/document.item.php index 9b81cbf83..d9bdb8485 100644 --- a/modules/document/document.item.php +++ b/modules/document/document.item.php @@ -190,37 +190,46 @@ } function getThumbnail($width = 80) { - if(!preg_match('!]*?)(\/){0,1}>!is',$this->get('content'),$matches)) return; - - $document_path = sprintf('files/attach/images/%d/%d/',$this->get('module_srl'), $this->get('document_srl')); + $document_path = sprintf('./files/attach/images/%d/%d/',$this->get('module_srl'), $this->get('document_srl')); if(!is_dir($document_path)) FileHandler::makeDir($document_path); $thumbnail_file = sprintf('%sthumbnail_%d.gif', $document_path, $width); + $tmp_file = sprintf('%sthumbnail_%d.tmp.gif', $document_path, $width); + + if(file_exists($thumbnail_file)) { + $modified_time = $this->get('last_update'); + $hour = (int)substr($modified_time,8,2); + $min = (int)substr($modified_time,10,2); + $sec = (int)substr($modified_time,12,2); + $year = (int)substr($modified_time,0,4); + $month = (int)substr($modified_time,4,2); + $day = (int)substr($modified_time,6,2); + $modified_time = mktime($hour, $min, $sec, $month?$month:1, $day?$day:1, $year); + + if($modified_time > filectime($thumbnail_file)) unlink($thumbnail_file); + } if(!file_exists($thumbnail_file)) { - - $tmp_file = sprintf('%sthumbnail_%d.tmp.gif', $document_path, $width); - - preg_match('!src=("|\'){0,1}([^"|^\'|^\ ]*)("|\'| ){0,1}!is', $matches[0], $src_matches); - $src = str_replace(getUrl(),'',$src_matches[2]); - - // 첨부된 파일일 경우 - if(eregi("^files", $src)) { - copy("./".$src, $tmp_file); - - // 웹에서 링크한 경우 - } else { - FileHandler::getRemoteFile($src, $tmp_file); - } - FileHandler::writeFile($thumbnail_file, '', 'w'); - if(file_exists($tmp_file)) { - // 파일정보를 보아서 가로/세로크기가 64보다 작으면 무시시킴 - list($s_width, $s_height, $s_type, $s_attrs) = @getimagesize($tmp_file); + $content = $this->get('content'); - if($s_width > 64 || $s_height > 64) FileHandler::createImageFile($tmp_file, $thumbnail_file, $width, $width, 'gif'); + // 첨부된 파일부터 찾아봄 (DB말고 내용에서 추출) + preg_match_all("!(\"|')files\/([^ ^\"^']*?)\.(jpg|png|gif|jpeg)!is", $content, $matches); + $attached_file_list = $matches[0]; + + if(count($attached_file_list)) { + $src = preg_replace("!^(\"|')!is","",$attached_file_list[0]); + copy("./".$src, $tmp_file); + + // 첨부된 파일이 없으면 http로 시작하는 경로를 찾음 + } else { + preg_match('!src=("|\'){0,1}([^"|^\'|^\ ]*)("|\'| ){0,1}!is', $content, $matches); + $src = $matches[2]; + if($src) FileHandler::getRemoteFile($src, $tmp_file); + else return; } + FileHandler::createImageFile($tmp_file, $thumbnail_file, $width, $width, 'gif'); @unlink($tmp_file); }