From 83799ee4c8dfc475d550adf5559f07deab44404f Mon Sep 17 00:00:00 2001 From: chicpro Date: Tue, 3 Jun 2014 13:06:40 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=EC=8D=B8=EB=84=A4=EC=9D=BC=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=EA=B4=80=EB=A0=A8=20=EC=BD=94=EB=93=9C=20=EC=A0=95?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/thumbnail.lib.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/thumbnail.lib.php b/lib/thumbnail.lib.php index f8db59dd8..a338770f9 100644 --- a/lib/thumbnail.lib.php +++ b/lib/thumbnail.lib.php @@ -161,6 +161,9 @@ function get_view_thumbnail($contents, $thumb_width=0) else $thumb_file = $filename; + if(!$thumb_file) + continue; + if ($width) { $thumb_tag = ''.$alt.''; } else { @@ -169,7 +172,7 @@ function get_view_thumbnail($contents, $thumb_width=0) // $img_tag에 editor 경로가 있으면 원본보기 링크 추가 $img_tag = $matches[0][$i]; - if(strpos($img_tag, 'data/editor') && preg_match("/\.({$config['cf_image_extension']})$/i", $filename)) { + if(strpos($img_tag, G5_DATA_DIR.'/'.G5_EDITOR_DIR) && preg_match("/\.({$config['cf_image_extension']})$/i", $filename)) { $imgurl = str_replace(G5_URL, "", $src); $thumb_tag = ''.$thumb_tag.''; } @@ -204,6 +207,10 @@ function thumbnail($filename, $source_path, $target_path, $thumb_width, $thumb_h @chmod($target_path, G5_DIR_PERMISSION); } + // 디렉토리가 존재하지 않거나 쓰기 권한이 없으면 썸네일 생성하지 않음 + if(!(is_dir($target_path) && is_writable($target_path))) + return ''; + // Animated GIF는 썸네일 생성하지 않음 if($size[2] == 1) { if(is_animated_gif($source_file)) From 4a145385645234cca78af1855396b263a3bdeb2f Mon Sep 17 00:00:00 2001 From: chicpro Date: Tue, 3 Jun 2014 14:57:26 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=EC=9D=BC=EC=A0=95=20=EA=B8=B0=EA=B0=84=20?= =?UTF-8?q?=EC=A7=80=EB=82=9C=20DB=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adm/admin.lib.php | 20 -------------- adm/config_form.php | 5 ++++ bbs/db_table.optimize.php | 57 +++++++++++++++++++++++++++++++++++++++ common.php | 4 +++ install/gnuboard5.sql | 1 + lib/common.lib.php | 19 +++++++++++++ 6 files changed, 86 insertions(+), 20 deletions(-) create mode 100644 bbs/db_table.optimize.php diff --git a/adm/admin.lib.php b/adm/admin.lib.php index 44ea31f1f..061f7992d 100644 --- a/adm/admin.lib.php +++ b/adm/admin.lib.php @@ -57,26 +57,6 @@ function get_skin_dir($skin, $skin_path=G5_SKIN_PATH) } -// 회원 삭제 -function member_delete($mb_id) -{ - global $config; - global $g5; - - $sql = " select mb_name, mb_nick, mb_ip, mb_recommend, mb_memo, mb_level from {$g5['member_table']} where mb_id= '".$mb_id."' "; - $mb = sql_fetch($sql); - if ($mb['mb_recommend']) { - $row = sql_fetch(" select count(*) as cnt from {$g5['member_table']} where mb_id = '".addslashes($mb['mb_recommend'])."' "); - if ($row['cnt']) - insert_point($mb['mb_recommend'], $config['cf_recommend_point'] * (-1), $mb_id.'님의 회원자료 삭제로 인한 추천인 포인트 반환', "@member", $mb['mb_recommend'], $mb_id.' 추천인 삭제'); - } - - // 회원자료는 정보만 없앤 후 아이디는 보관하여 다른 사람이 사용하지 못하도록 함 : 061025 - $sql = " update {$g5['member_table']} set mb_password = '', mb_level = 1, mb_email = '', mb_homepage = '', mb_tel = '', mb_hp = '', mb_zip1 = '', mb_zip2 = '', mb_addr1 = '', mb_addr2 = '', mb_birth = '', mb_sex = '', mb_signature = '', mb_memo = '".date('Ymd', G5_SERVER_TIME)." 삭제함\n{$mb['mb_memo']}', mb_leave_date = '".date('Ymd', G5_SERVER_TIME)."' where mb_id = '{$mb_id}' "; - sql_query($sql); -} - - // 회원권한을 SELECT 형식으로 얻음 function get_member_level_select($name, $start_id=0, $end_id=10, $selected="", $event="") { diff --git a/adm/config_form.php b/adm/config_form.php index 642768f32..8b7b7120d 100644 --- a/adm/config_form.php +++ b/adm/config_form.php @@ -162,6 +162,11 @@ if(!isset($config['cf_lg_mid'])) { ADD `cf_lg_mert_key` varchar(255) NOT NULL DEFAULT '' AFTER `cf_lg_mid` ", true); } +if(!isset($config['cf_optimize_date'])) { + sql_query(" ALTER TABLE `{$g5['config_table']}` + ADD `cf_optimize_date` date NOT NULL default '0000-00-00' AFTER `cf_popular_del` ", true); +} + if(!$config['cf_faq_skin']) $config['cf_faq_skin'] = "basic"; if(!$config['cf_mobile_faq_skin']) $config['cf_mobile_faq_skin'] = "basic"; diff --git a/bbs/db_table.optimize.php b/bbs/db_table.optimize.php new file mode 100644 index 000000000..f676ce4ef --- /dev/null +++ b/bbs/db_table.optimize.php @@ -0,0 +1,57 @@ += G5_TIME_YMD) + return; + +// 설정일이 지난 접속자로그 삭제 +if($config['cf_visit_del'] > 0) { + $tmp_before_date = date("Y-m-d", G5_SERVER_TIME - ($config['cf_visit_del'] * 86400)); + $sql = " delete from {$g5['visit_table']} where vi_date < '$tmp_before_date' "; + sql_query($sql); + sql_query(" OPTIMIZE TABLE `{$g5['visit_table']}`, `{$g5['visit_sum_table']}` "); +} + +// 설정일이 지난 인기검색어 삭제 +if($config['cf_popular_del'] > 0) { + $tmp_before_date = date("Y-m-d", G5_SERVER_TIME - ($config['cf_popular_del'] * 86400)); + $sql = " delete from {$g5['popular_table']} where pp_date < '$tmp_before_date' "; + sql_query($sql); + sql_query(" OPTIMIZE TABLE `{$g5['popular_table']}` "); +} + +// 설정일이 지난 최근게시물 삭제 +if($config['cf_new_del'] > 0) { + $sql = " delete from {$g5['board_new_table']} where (TO_DAYS('".G5_TIME_YMDHIS."') - TO_DAYS(bn_datetime)) > '{$config['cf_new_del']}' "; + sql_query($sql); + sql_query(" OPTIMIZE TABLE `{$g5['board_new_table']}` "); +} + +// 설정일이 지난 쪽지 삭제 +if($config['cf_memo_del'] > 0) { + $sql = " delete from {$g5['memo_table']} where (TO_DAYS('".G5_TIME_YMDHIS."') - TO_DAYS(me_send_datetime)) > '{$config['cf_memo_del']}' "; + sql_query($sql); + sql_query(" OPTIMIZE TABLE `{$g5['memo_table']}` "); +} + +// 탈퇴회원 자동 삭제 +if($config['cf_leave_day'] > 0) { + $sql = " select mb_id from {$g5['member_table']} where (TO_DAYS('".G5_TIME_YMDHIS."') - TO_DAYS(mb_leave_date)) > '{$config['cf_leave_day']}' "; + $result = sql_query($sql); + while ($row=sql_fetch_array($result)) + { + // 회원자료 삭제 + member_delete($row['mb_id']); + } +} + +// 실행일 기록 +if(isset($config['cf_optimize_date'])) { + sql_query(" update {$g5['config_table']} set cf_optimize_date = '".G5_TIME_YMD."' "); +} +?> \ No newline at end of file diff --git a/common.php b/common.php index 0ba43ce95..3e12011eb 100644 --- a/common.php +++ b/common.php @@ -471,6 +471,10 @@ if (G5_IS_MOBILE) { include_once(G5_BBS_PATH.'/visit_insert.inc.php'); +// 일정 기간이 지난 DB 데이터 삭제 및 최적화 +include_once(G5_BBS_PATH.'/db_table.optimize.php'); + + // common.php 파일을 수정할 필요가 없도록 확장합니다. $extend_file = array(); $tmp = dir(G5_EXTEND_PATH); diff --git a/install/gnuboard5.sql b/install/gnuboard5.sql index 160d07850..5e7eef002 100644 --- a/install/gnuboard5.sql +++ b/install/gnuboard5.sql @@ -251,6 +251,7 @@ CREATE TABLE IF NOT EXISTS `g5_config` ( `cf_memo_del` int(11) NOT NULL DEFAULT '0', `cf_visit_del` int(11) NOT NULL DEFAULT '0', `cf_popular_del` int(11) NOT NULL DEFAULT '0', + `cf_optimize_date` date NOT NULL default '0000-00-00', `cf_use_member_icon` tinyint(4) NOT NULL DEFAULT '0', `cf_member_icon_size` int(11) NOT NULL DEFAULT '0', `cf_member_icon_width` int(11) NOT NULL DEFAULT '0', diff --git a/lib/common.lib.php b/lib/common.lib.php index 02860e0a5..5d2edd776 100644 --- a/lib/common.lib.php +++ b/lib/common.lib.php @@ -2690,4 +2690,23 @@ function conv_unescape_nl($str) return str_replace($search, $replace, $str); } + +// 회원 삭제 +function member_delete($mb_id) +{ + global $config; + global $g5; + + $sql = " select mb_name, mb_nick, mb_ip, mb_recommend, mb_memo, mb_level from {$g5['member_table']} where mb_id= '".$mb_id."' "; + $mb = sql_fetch($sql); + if ($mb['mb_recommend']) { + $row = sql_fetch(" select count(*) as cnt from {$g5['member_table']} where mb_id = '".addslashes($mb['mb_recommend'])."' "); + if ($row['cnt']) + insert_point($mb['mb_recommend'], $config['cf_recommend_point'] * (-1), $mb_id.'님의 회원자료 삭제로 인한 추천인 포인트 반환', "@member", $mb['mb_recommend'], $mb_id.' 추천인 삭제'); + } + + // 회원자료는 정보만 없앤 후 아이디는 보관하여 다른 사람이 사용하지 못하도록 함 : 061025 + $sql = " update {$g5['member_table']} set mb_password = '', mb_level = 1, mb_email = '', mb_homepage = '', mb_tel = '', mb_hp = '', mb_zip1 = '', mb_zip2 = '', mb_addr1 = '', mb_addr2 = '', mb_birth = '', mb_sex = '', mb_signature = '', mb_memo = '".date('Ymd', G5_SERVER_TIME)." 삭제함\n{$mb['mb_memo']}', mb_leave_date = '".date('Ymd', G5_SERVER_TIME)."' where mb_id = '{$mb_id}' "; + sql_query($sql); +} ?> \ No newline at end of file From 43cfe7358259fafd4272dad71473308264a641e5 Mon Sep 17 00:00:00 2001 From: chicpro Date: Thu, 5 Jun 2014 09:33:49 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=EC=9D=BC=EC=A0=95=EA=B8=B0=EA=B0=84=20?= =?UTF-8?q?=EC=A7=80=EB=82=9C=20=EB=A9=94=EB=AA=A8=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bbs/memo.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/bbs/memo.php b/bbs/memo.php index f5e4f032a..4d9c0129a 100644 --- a/bbs/memo.php +++ b/bbs/memo.php @@ -1,18 +1,12 @@ Date: Thu, 5 Jun 2014 14:06:48 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=EA=B3=B5=EC=A7=80=EC=97=AC=EB=B6=80=20?= =?UTF-8?q?=EA=B2=B0=EC=A0=95=20=EC=BD=94=EB=93=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/common.lib.php b/lib/common.lib.php index 5d2edd776..d0077577f 100644 --- a/lib/common.lib.php +++ b/lib/common.lib.php @@ -364,7 +364,8 @@ function get_list($write_row, $board, $skin_url, $subject_len=40) $list = $write_row; unset($write_row); - $list['is_notice'] = preg_match("/[^0-9]{0,1}{$list['wr_id']}[\r]{0,1}/",$board['bo_notice']); + $board_notice = array_map('trim', explode(',', $board['bo_notice'])); + $list['is_notice'] = in_array($list['wr_id'], $board_notice); if ($subject_len) $list['subject'] = conv_subject($list['wr_subject'], $subject_len, '…');