게시글 삭제시 썸네일 삭제 코드 추가

This commit is contained in:
chicpro
2013-02-20 18:51:40 +09:00
parent 0eab17d05d
commit ec295b169c
2 changed files with 31 additions and 4 deletions

View File

@ -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);
?>

View File

@ -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']}' ");