diff --git a/bbs/delete.php b/bbs/delete.php index 9d38fda5e..b2df50c36 100644 --- a/bbs/delete.php +++ b/bbs/delete.php @@ -79,8 +79,22 @@ while ($row = sql_fetch_array($result)) // 업로드된 파일이 있다면 파일삭제 $sql2 = " select * from {$g4['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$row['wr_id']}' "; $result2 = sql_query($sql2); - while ($row2 = sql_fetch_array($result2)) + while ($row2 = sql_fetch_array($result2)) { @unlink(G4_DATA_PATH.'/file/'.$bo_table.'/'.$row2['bf_file']); + // 썸네일삭제 + $dir = G4_DATA_PATH.'/file/'.$bo_table; + if($dh = opendir($dir)) { + while(($file = readdir($dh)) !== false) { + if($file == "." || $file == "..") + continue; + + $filename = preg_replace("/\.[^\.]+$/i", "", $row2['bf_file']); + if(strstr($file, $filename) && strpos($file, $filename) != 0) { + @unlink($dir.'/'.$file); + } + } + } + } // 파일테이블 행 삭제 sql_query(" delete from {$g4['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$row['wr_id']}' "); @@ -121,7 +135,5 @@ if ($count_write > 0 || $count_comment > 0) @include_once($board_skin_path.'/delete.tail.skin.php'); -delete_cache_latest($bo_table); - goto_url('./board.php?bo_table='.$bo_table.'&page='.$page.$qstr); ?> diff --git a/bbs/delete_all.php b/bbs/delete_all.php index 06ae7bfbf..de4d0905e 100644 --- a/bbs/delete_all.php +++ b/bbs/delete_all.php @@ -90,10 +90,25 @@ for ($i=count($tmp_array)-1; $i>=0; $i--) // 업로드된 파일이 있다면 $sql2 = " select * from {$g4['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$row['wr_id']}' "; $result2 = sql_query($sql2); - while ($row2 = sql_fetch_array($result2)) + while ($row2 = sql_fetch_array($result2)) { // 파일삭제 @unlink(G4_DATA_PATH.'/file/'.$bo_table.'/'.$row2['bf_file']); + // 썸네일삭제 + $dir = G4_DATA_PATH.'/file/'.$bo_table; + if($dh = opendir($dir)) { + while(($file = readdir($dh)) !== false) { + if($file == "." || $file == "..") + continue; + + $filename = preg_replace("/\.[^\.]+$/i", "", $row2['bf_file']); + if(strstr($file, $filename) && strpos($file, $filename) != 0) { + @unlink($dir.'/'.$file); + } + } + } + } + // 파일테이블 행 삭제 sql_query(" delete from {$g4['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$row['wr_id']}' ");