현재 그누보드는 에디터로 첨부한 이미지는 글 삭제시에도 함께 삭제되지 않고 서버에 남아있습니다.
아래 코드를 적용하시면 에디터로 첨부한 이미지가 있는 글을 삭제할 경우 해당 이미지도 삭제하게 됩니다.
/lib/common.lib.php 에서 기존
// 에디터 썸네일 삭제
function delete_editor_thumbnail($contents)
함수 내용을 아래와 같이 변경한다.
// 에디터 썸네일 삭제
function delete_editor_thumbnail($contents)
{
if(!$contents)
return;
// $contents 중 img 태그 추출
$matchs = get_editor_image($contents, false);
if(!$matchs)
return;
for($i=0; $i<count($matchs[1]); $i++) {
// 이미지 path 구함
$imgurl = @parse_url($matchs[1][$i]);
if(strpos($imgurl['path'], "/data/") != 0) {
$data_path = preg_replace("/^\/.*\/data/", "/data", $imgurl['path']);
} else {
$data_path = $imgurl['path'];
}
$is_destfile = false;
if(preg_match('/(gif|jpe?g|bmp|png)$/i', strtolower(end(explode('.', $data_path))))){
$destfile = ( ! preg_match('/\w+\/\.\.\//', $data_path) ) ? G5_PATH.$data_path : '';
if($destfile && preg_match('/\/data\/editor\/[A-Za-z0-9_]{1,20}\//', $destfile) && is_file($destfile)) {
$is_destfile = true;
}
}
if($is_destfile) {
//원본파일 삭제
@chmod($destfile, G5_FILE_PERMISSION);
@unlink($destfile);
//썸네일파일 삭제
$files = glob(dirname($destfile).'/thumb-'.preg_replace("/\.[^\.]+$/i", "", basename($imgurl['path'])).'*');
//return $files;
if (is_array($files)) {
foreach($files as $filename)
unlink($filename);
}
}
}
}
댓글 14개
게시글 목록
| 번호 | 제목 |
|---|---|
| 24149 | |
| 24140 | |
| 24133 | |
| 24125 | |
| 24119 | |
| 24109 | |
| 24105 | |
| 24101 | |
| 24093 | |
| 24089 | |
| 24077 | |
| 24074 | |
| 24071 | |
| 24070 | |
| 24067 | |
| 24056 | |
| 24050 | |
| 24046 | |
| 24043 | |
| 24040 | |
| 24037 | |
| 24036 | |
| 24035 | |
| 24034 | |
| 24021 | |
| 24017 | |
| 24005 | |
| 24002 | |
| 23990 | |
| 23980 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기