Merge branch 'master' of github.com:gnuboard/g4s

This commit is contained in:
whitedot
2013-02-22 10:44:19 +09:00
5 changed files with 35 additions and 43 deletions

View File

@ -83,25 +83,12 @@ while ($row = sql_fetch_array($result))
@unlink(G4_DATA_PATH.'/file/'.$bo_table.'/'.$row2['bf_file']);
// 썸네일삭제
if(preg_match("/\.({$config['cf_image_extension']})$/i", $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);
}
}
closedir($dh);
}
delete_board_thumbnail($bo_table, $row2['bf_file']);
}
}
// 에디터 썸네일 삭제
echo delete_editor_thumbnail($row['wr_content']);
delete_editor_thumbnail($row['wr_content']);
// 파일테이블 행 삭제
sql_query(" delete from {$g4['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$row['wr_id']}' ");

View File

@ -96,23 +96,13 @@ for ($i=count($tmp_array)-1; $i>=0; $i--)
// 썸네일삭제
if(preg_match("/\.({$config['cf_image_extension']})$/i", $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);
}
}
closedir($dh);
}
delete_board_thumbnail($bo_table, $row2['bf_file']);
}
}
// 에디터 썸네일 삭제
delete_editor_thumbnail($row['wr_content']);
// 파일테이블 행 삭제
sql_query(" delete from {$g4['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$row['wr_id']}' ");

View File

@ -188,6 +188,10 @@ for ($i=0; $i<count($_FILES['bf_file']['name']); $i++) {
$row = sql_fetch(" select bf_file from {$g4['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '{$i}' ");
@unlink(G4_DATA_PATH.'/file/'.$bo_table.'/'.$row['bf_file']);
// 썸네일삭제
if(preg_match("/\.({$config['cf_image_extension']})$/i", $row['bf_file'])) {
delete_board_thumbnail($bo_table, $row['bf_file']);
}
}
else
$upload[$i]['del_check'] = false;
@ -239,20 +243,7 @@ for ($i=0; $i<count($_FILES['bf_file']['name']); $i++) {
@unlink(G4_DATA_PATH.'/file/'.$bo_table.'/'.$row['bf_file']);
// 이미지파일이면 썸네일삭제
if(preg_match("/\.({$config['cf_image_extension']})$/i", $row['bf_file'])) {
$dir = G4_DATA_PATH.'/file/'.$bo_table;
if($dh = opendir($dir)) {
while(($entry = readdir($dh)) !== false) {
if($entry == "." || $entry == "..")
continue;
$fname = preg_replace("/\.[^\.]+$/i", "", $row['bf_file']);
if(strstr($entry, $fname) && strpos($entry, $fname) != 0) {
@unlink($dir.'/'.$entry);
}
}
closedir($dh);
}
delete_board_thumbnail($bo_table, $row['bf_file']);
}
}

View File

@ -1721,9 +1721,24 @@ function delete_cache_latest($bo_table)
}
}
// 게시판 첨부파일 썸네일 삭제
function delete_board_thumbnail($bo_table, $file)
{
if(!$bo_table || !$file)
return;
$fn = preg_replace("/\.[^\.]+$/i", "", basename($file));
foreach(glob(G4_DATA_PATH.'/file/'.$bo_table.'/thumb-'.$fn.'*') as $file) {
unlink($file);
}
}
// 에디터 이미지 얻기
function get_editor_image($contents)
{
if(!$contents)
return false;
// $contents 중 img 태그 추출
$pattern = "/<img[^>]*src=[\'\"]?([^>\'\"]+".str_replace(".", "\.", $_SERVER['HTTP_HOST'])."[^>\'\"]+)[\'\"]?[^>]*>/";
preg_match_all($pattern, $contents, $matchs);
@ -1734,9 +1749,15 @@ function get_editor_image($contents)
// 에디터 썸네일 삭제
function delete_editor_thumbnail($contents)
{
if(!$contents)
return;
// $contents 중 img 태그 추출
$matchs = get_editor_image($contents);
if(!$matchs)
return;
for($i=0; $i<count($matchs[1]); $i++) {
// 이미지 path 구함
$imgurl = parse_url($matchs[1][$i]);

View File

@ -32,6 +32,9 @@ function get_view_thumbnail($contents)
// $contents 중 img 태그 추출
$matchs = get_editor_image($contents);
if(!$matchs)
return $contents;
for($i=0; $i<count($matchs[1]); $i++) {
// 이미지 path 구함
$imgurl = parse_url($matchs[1][$i]);