썸네일 갤러리 추천수에 따라 게시물 자동 이동
갤러리 게시판인 경우, 일정 추천수가 되면 일명 베스트 갤러리 혹은, 쿨 갤러리로의 이동이 구현되어 있으면 좋은 경우가 있습니다
사진 커뮤니티에서 많이 필요로 하는데요
제로보드 dq 갤러리의 경우는 상용으로 그런 기능을 사용할 수 있습니다
그래서 저도, 썸네일 갤러리 게시판 추천수에 따른 게시물 자동 이동을 구현해 봤습니다
다행히 gnu 보드는 move.php 와 move_update.php 가 있어서
관리자가 게시물을 이동/복사 할 수 있는 기능이 구현되어 있어서
(복사 - 붙여넣기) 로 만들었습니다 ㅡ _-
[[ 사용된 버전 ]]
gnu보드 4.08.00
http://www.sir.co.kr/bbs/tb.php/g4_pds/1977
썸네일갤러리 - forever
http://www.sir.co.kr/bbs/tb.php/g4_skin_board/5975
[[ 게시판 환경 설정 ]]
- 여분필드3 에 이동할 게시판 이름
- 여분필드4 에 이동할 추천수
[[ good.php ]]
/bbs/good.php
<?
include_once("./_common.php");
echo "<meta http-equiv='content-type' content='text/html; charset=$g4[charset]'>";
if (!$is_member)
{
$href = "./login.php?$qstr&url=".urlencode("./board.php?bo_table=$bo_table&wr_id=$wr_id");
echo "<script language='JavaScript'>alert('회원만 가능합니다.'); top.location.href = '$href';</script>";
exit;
}
if (!($bo_table && $wr_id))
alert_close("값이 제대로 넘어오지 않았습니다.");
$ss_name = "ss_view_{$bo_table}_{$wr_id}";
if (!get_session($ss_name))
alert_close("해당 게시물에서만 추천 또는 비추천 하실 수 있습니다.");
$row = sql_fetch(" select count(*) as cnt from {$g4[write_prefix]}{$bo_table} ", FALSE);
if (!$row[cnt])
alert_close("존재하는 게시판이 아닙니다.");
if ($good == "good" || $good == "nogood")
{
if($write[mb_id] == $member[mb_id])
alert_close("자신의 글에는 추천 또는 비추천 하실 수 없습니다.");
if (!$board[bo_use_good] && $good == "good")
alert_close("이 게시판은 추천 기능을 사용하지 않습니다.");
if (!$board[bo_use_nogood] && $good == "nogood")
alert_close("이 게시판은 비추천 기능을 사용하지 않습니다.");
$sql = " select bg_flag from $g4[board_good_table]
where bo_table = '$bo_table'
and wr_id = '$wr_id'
and mb_id = '$member[mb_id]'
and bg_flag in ('good', 'nogood') ";
$row = sql_fetch($sql);
if ($row[bg_flag])
{
if ($row[bg_flag] == "good")
$status = "추천";
else
$status = "비추천";
echo "<script language='JavaScript'>alert('이미 \'$status\' 하신 글 입니다.');</script>";
}
else
{
// 추천(찬성), 비추천(반대) 카운트 증가
sql_query(" update {$g4[write_prefix]}{$bo_table} set wr_{$good} = wr_{$good} + 1 where wr_id = '$wr_id' ");
//////////////////////////////////////////////////////////////////////////////////////////////
///////////// 추천수에 따른 best 갤러리로 이동 060610 pearl짓거리 전문 추가 /////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
// 추천시 이동할 게시판 설정과 추천수 확인용 쿼리
$sql5 = "select * from $g4[board_table] where bo_table = '$bo_table'";
$result5 = sql_query($sql5);
while($row5 = sql_fetch_array($result5))
{
if($row5[bo_3] && $row5[bo_4])
{
// 여분필드3 에 설정된 이동할 게시판 이름 설정
$move_bo_table = $row5[bo_3]; // 테이블 이름 저장
$move_write_table = $g4['write_prefix'] . $move_bo_table; // DB 테이블명 저장
// 여분필드4 에 설정된 추천수 설정
$goodCnt = $row5[bo_4];
}
else
{
$goodCnt = '0.3'; // 추천수가 없으면 0.3 세팅(의미 없음)
}
}
// 해당 게시물 현재 추천수 조회 쿼리
$row = sql_fetch("select wr_good from {$g4[write_prefix]}{$bo_table} where wr_id = '$wr_id'",FALSE);
// 추천수가 이동할 값인지 비교, good(추천) 인지 비교 - 추천수가 안됐거나 good(추천)이 아니면 실행 안됨
if ($row[wr_good] == $goodCnt && $good == "good")
{
// board_good 테이블, 추천 내역 생성
sql_query(" insert $g4[board_good_table] set bo_table = '$bo_table', wr_id = '$wr_id', mb_id = '$member[mb_id]', bg_flag = '$good', bg_datetime = '$g4[time_ymdhis]' ");
$sw = "move"; // 이동이 아니라 복사일 경우는 copy
$act = "이동"; // 이동이 아니라 복사일 경우는 복사
$wr_id_list = $wr_id;
$save = array();
$save_count_write = 0;
$save_count_comment = 0;9
$cnt = 0;
$src_dir = "$g4[path]/data/file/$bo_table"; // 원본 디렉토리
$dst_dir = "$g4[path]/data/file/$move_bo_table"; // 복사본 디렉토리
$count_write = 0;
$count_comment = 0;
// 해당 게시물 번호 조회
$sql4 = "select wr_num from $write_table where wr_id = '$wr_id'";
$result4 = sql_fetch($sql4);
$wr_num = $result4[wr_num];
// 해당 게시물 조회 - 본문, 코멘트, 답글까지
$sql2 = " select * from $write_table where wr_num = $wr_num order by wr_parent, wr_comment desc, wr_id ";
$result2 = sql_query($sql2);
// 이동할 게시판에 게시물 순번 설정
$next_wr_num = get_next_num($move_write_table);
// 게시물 본문과 코멘트, 답글이 다 이동할때까지
while ($row2 = sql_fetch_array($result2))
{
// 본문 글에 이동 되었다는 메세지 추가
if (!$row2[wr_is_comment] && $config[cf_use_copy_log])
$row2[wr_content] .= " \n[이 게시물은 추천수 $goodCnt 이상으로, {$board[bo_subject]} 게시판에서 $move_bo_table 게시판으로 " . ($sw == 'copy' ? '복사' : '이동') ." 되었습니다]";
// 이동되는 게시판에 추가
$sql = " insert into $move_write_table
set wr_num = '$next_wr_num',
wr_reply = '$row2[wr_reply]',
wr_is_comment = '$row2[wr_is_comment]',
wr_comment = '$row2[wr_comment]',
wr_comment_reply = '$row2[wr_comment_reply]',
ca_name = '".addslashes($row2[ca_name])."',
wr_option = '$row2[wr_option]',
wr_subject = '".addslashes($row2[wr_subject])."',
wr_content = '".addslashes($row2[wr_content])."',
wr_link1 = '".addslashes($row2[wr_link1])."',
wr_link2 = '".addslashes($row2[wr_link2])."',
wr_link1_hit = '$row2[wr_link1_hit]',
wr_link2_hit = '$row2[wr_link2_hit]',
wr_trackback = '".addslashes($row2[wr_trackback])."',
wr_hit = '$row2[wr_hit]',
wr_good = '$row2[wr_good]',
wr_nogood = '$row2[wr_nogood]',
mb_id = '$row2[mb_id]',
wr_password = '$row2[wr_password]',
wr_name = '".addslashes($row2[wr_name])."',
wr_email = '".addslashes($row2[wr_email])."',
wr_homepage = '".addslashes($row2[wr_homepage])."',
wr_datetime = '$row2[wr_datetime]',
wr_ip = '$row2[wr_ip]',
wr_1 = '".addslashes($row2[wr_1])."',
wr_2 = '".addslashes($row2[wr_2])."',
wr_3 = '".addslashes($row2[wr_3])."',
wr_4 = '".addslashes($row2[wr_4])."',
wr_5 = '".addslashes($row2[wr_5])."',
wr_6 = '".addslashes($row2[wr_6])."',
wr_7 = '".addslashes($row2[wr_7])."',
wr_8 = '".addslashes($row2[wr_8])."',
wr_9 = '".addslashes($row2[wr_9])."',
wr_10 = '".addslashes($row2[wr_10])."' ";
sql_query($sql);
$insert_id = mysql_insert_id();
// 코멘트가 아니라면
if (!$row2[wr_is_comment])
{
$save_parent = $insert_id;
$sql3 = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$row2[wr_id]' order by bf_no ";
$result3 = sql_query($sql3);
for ($k=0; $row3 = sql_fetch_array($result3); $k++)
{
if ($row3[bf_file])
{
// 원본파일을 복사하고 퍼미션을 변경
@copy("$src_dir/$row3[bf_file]", "$dst_dir/$row3[bf_file]");
@chmod("$dst_dir/$row3[bf_file]", 0606);
// 원본섬네일 파일을 복사하고 퍼미션을 변경
@copy("$src_dir/$row3[bf_file].Thum", "$dst_dir/$row3[bf_file].Thum");
@chmod("$dst_dir/$row3[bf_file].Thum", 0606);
}
// board_file 테이블 추가
$sql = " insert into $g4[board_file_table]
set bo_table = '$move_bo_table',
wr_id = '$insert_id',
bf_no = '$row3[bf_no]',
bf_source = '$row3[bf_source]',
bf_file = '$row3[bf_file]',
bf_download = '$row3[bf_download]',
bf_content = '$row3[bf_content]',
bf_filesize = '$row3[bf_filesize]',
bf_width = '$row3[bf_width]',
bf_height = '$row3[bf_height]',
bf_type = '$row3[bf_type]',
bf_datetime = '$row3[bf_datetime]' ";
sql_query($sql);
if ($sw == "move" && $row3[bf_file])
$save[$cnt][bf_file][$k] = "$src_dir/$row3[bf_file]";
}
$count_write++;
if ($sw == "move" && $i == 0)
{
// 스크랩 이동
sql_query(" update $g4[scrap_table] set bo_table = '$move_bo_table', wr_id = '$save_parent' where bo_table = '$bo_table' and wr_id = '$row2[wr_id]' ");
// 최신글 이동
sql_query(" update $g4[board_new_table] set bo_table = '$move_bo_table', wr_id = '$save_parent', wr_parent = '$save_parent' where bo_table = '$bo_table' and wr_id = '$row2[wr_id]' ");
}
}
else
{
$count_comment++;
if ($sw == "move")
{
// 최신글 이동
sql_query(" update $g4[board_new_table] set bo_table = '$move_bo_table', wr_id = '$insert_id', wr_parent = '$save_parent' where bo_table = '$bo_table' and wr_id = '$row2[wr_id]' ");
}
}
sql_query(" update $move_write_table set wr_parent = '$save_parent' where wr_id = '$insert_id' ");
if ($sw == "move")
$save[$cnt][wr_id] = $row2[wr_parent];
$cnt++;
}
sql_query(" update $g4[board_table] set bo_count_write = bo_count_write + '$count_write' where bo_table = '$move_bo_table' ");
sql_query(" update $g4[board_table] set bo_count_comment = bo_count_comment + '$count_comment' where bo_table = '$move_bo_table' ");
// '이동' 인경우 원본 게시판의 게시물 삭제
if ($sw == "move")
{
for ($i=0; $i<count($save); $i++)
{
for ($k=0; $k<count($save[$i][bf_file]); $k++)
@unlink($save[$i][bf_file][$k]);
sql_query(" delete from $write_table where wr_parent = '{$save[$i][wr_id]}' ");
sql_query(" delete from $g4[board_new_table] where bo_table = '$bo_table' and wr_id = '{$save[$i][wr_id]}' ");
sql_query(" delete from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '{$save[$i][wr_id]}' ");
}
sql_query(" update $g4[board_table] set bo_count_write = bo_count_write - 1, bo_count_comment = bo_count_comment - 1 where bo_table = '$bo_table' ");
// 이동할 추천수가 됐으면 '이 글을 추천 하셨습니다' 대신 이동 됐다는 메세지
echo "<script language='JavaScript'>alert('\'$goodCnt\' 번째 추천입니다. \'$move_bo_table\' 게시판으로 이동 됩니다');</script>";
$href_c = "./board.php?bo_table=$bo_table"; // 이동인 경우 해당 게시물이 게시판에서 삭제 되므로 게시판 보기로 리플래쉬
echo "<script language='JavaScript'>top.location.href = '$href_c';</script>";
}
} // 여기까지 자동이동 if 문 이동 로직
//////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// 여기까지 추천수에 의한 자동 이동 로직 /////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
// 내역 생성 - 이동하지 않는 보통때 내역 생성 쿼리
sql_query(" insert $g4[board_good_table] set bo_table = '$bo_table', wr_id = '$wr_id', mb_id = '$member[mb_id]', bg_flag = '$good', bg_datetime = '$g4[time_ymdhis]' ");
if ($good == "good")
$status = "추천";
else
$status = "비추천";
echo "<script language='JavaScript'> alert('이 글을 \'$status\' 하셨습니다.');</script>";
// 기본 good.php 에 없는 건데, 추천 후 해당 게시물 리플래쉬 해줌(추천 카운트 올라간거 확인됨)
$href_r = "./board.php?bo_table=$bo_table&wr_id=$wr_id&page=$page";
echo "<script language='JavaScript'>top.location.href = '$href_r';</script>";
}
}
?>
[[ 테스트 및 문제점 ]]
- 이동할 게시판을 다른형식(갤러리가 아닌) 게시판은 안해봤습니다
될지 장담할 수 없습니다
- good.php 파일을 반드시 backup 하고 해보시기 바랍니다
잘못된 수정으로 인한 피해는 제가 지지 않습니다
- 파일 중간에 //(주석) 줄 부터 //(주석) 줄 까지가 제가 추가한 내용으로
원래 good.php 의 54 55 라인 사이에 넣은 겁니다
- 추가한 부분에 될 수 있는한 주석을 많이 달아서 설명해 놨습니다
- 여분필드3 에 넣는 이동할 게시판 이름의 게시판 테이블이 g4_write_test 인 경우
여분필드3 에 test 를 넣으셔야 합니다
사진 커뮤니티에서 많이 필요로 하는데요
제로보드 dq 갤러리의 경우는 상용으로 그런 기능을 사용할 수 있습니다
그래서 저도, 썸네일 갤러리 게시판 추천수에 따른 게시물 자동 이동을 구현해 봤습니다
다행히 gnu 보드는 move.php 와 move_update.php 가 있어서
관리자가 게시물을 이동/복사 할 수 있는 기능이 구현되어 있어서
(복사 - 붙여넣기) 로 만들었습니다 ㅡ _-
[[ 사용된 버전 ]]
gnu보드 4.08.00
http://www.sir.co.kr/bbs/tb.php/g4_pds/1977
썸네일갤러리 - forever
http://www.sir.co.kr/bbs/tb.php/g4_skin_board/5975
[[ 게시판 환경 설정 ]]
- 여분필드3 에 이동할 게시판 이름
- 여분필드4 에 이동할 추천수
[[ good.php ]]
/bbs/good.php
<?
include_once("./_common.php");
echo "<meta http-equiv='content-type' content='text/html; charset=$g4[charset]'>";
if (!$is_member)
{
$href = "./login.php?$qstr&url=".urlencode("./board.php?bo_table=$bo_table&wr_id=$wr_id");
echo "<script language='JavaScript'>alert('회원만 가능합니다.'); top.location.href = '$href';</script>";
exit;
}
if (!($bo_table && $wr_id))
alert_close("값이 제대로 넘어오지 않았습니다.");
$ss_name = "ss_view_{$bo_table}_{$wr_id}";
if (!get_session($ss_name))
alert_close("해당 게시물에서만 추천 또는 비추천 하실 수 있습니다.");
$row = sql_fetch(" select count(*) as cnt from {$g4[write_prefix]}{$bo_table} ", FALSE);
if (!$row[cnt])
alert_close("존재하는 게시판이 아닙니다.");
if ($good == "good" || $good == "nogood")
{
if($write[mb_id] == $member[mb_id])
alert_close("자신의 글에는 추천 또는 비추천 하실 수 없습니다.");
if (!$board[bo_use_good] && $good == "good")
alert_close("이 게시판은 추천 기능을 사용하지 않습니다.");
if (!$board[bo_use_nogood] && $good == "nogood")
alert_close("이 게시판은 비추천 기능을 사용하지 않습니다.");
$sql = " select bg_flag from $g4[board_good_table]
where bo_table = '$bo_table'
and wr_id = '$wr_id'
and mb_id = '$member[mb_id]'
and bg_flag in ('good', 'nogood') ";
$row = sql_fetch($sql);
if ($row[bg_flag])
{
if ($row[bg_flag] == "good")
$status = "추천";
else
$status = "비추천";
echo "<script language='JavaScript'>alert('이미 \'$status\' 하신 글 입니다.');</script>";
}
else
{
// 추천(찬성), 비추천(반대) 카운트 증가
sql_query(" update {$g4[write_prefix]}{$bo_table} set wr_{$good} = wr_{$good} + 1 where wr_id = '$wr_id' ");
//////////////////////////////////////////////////////////////////////////////////////////////
///////////// 추천수에 따른 best 갤러리로 이동 060610 pearl짓거리 전문 추가 /////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
// 추천시 이동할 게시판 설정과 추천수 확인용 쿼리
$sql5 = "select * from $g4[board_table] where bo_table = '$bo_table'";
$result5 = sql_query($sql5);
while($row5 = sql_fetch_array($result5))
{
if($row5[bo_3] && $row5[bo_4])
{
// 여분필드3 에 설정된 이동할 게시판 이름 설정
$move_bo_table = $row5[bo_3]; // 테이블 이름 저장
$move_write_table = $g4['write_prefix'] . $move_bo_table; // DB 테이블명 저장
// 여분필드4 에 설정된 추천수 설정
$goodCnt = $row5[bo_4];
}
else
{
$goodCnt = '0.3'; // 추천수가 없으면 0.3 세팅(의미 없음)
}
}
// 해당 게시물 현재 추천수 조회 쿼리
$row = sql_fetch("select wr_good from {$g4[write_prefix]}{$bo_table} where wr_id = '$wr_id'",FALSE);
// 추천수가 이동할 값인지 비교, good(추천) 인지 비교 - 추천수가 안됐거나 good(추천)이 아니면 실행 안됨
if ($row[wr_good] == $goodCnt && $good == "good")
{
// board_good 테이블, 추천 내역 생성
sql_query(" insert $g4[board_good_table] set bo_table = '$bo_table', wr_id = '$wr_id', mb_id = '$member[mb_id]', bg_flag = '$good', bg_datetime = '$g4[time_ymdhis]' ");
$sw = "move"; // 이동이 아니라 복사일 경우는 copy
$act = "이동"; // 이동이 아니라 복사일 경우는 복사
$wr_id_list = $wr_id;
$save = array();
$save_count_write = 0;
$save_count_comment = 0;9
$cnt = 0;
$src_dir = "$g4[path]/data/file/$bo_table"; // 원본 디렉토리
$dst_dir = "$g4[path]/data/file/$move_bo_table"; // 복사본 디렉토리
$count_write = 0;
$count_comment = 0;
// 해당 게시물 번호 조회
$sql4 = "select wr_num from $write_table where wr_id = '$wr_id'";
$result4 = sql_fetch($sql4);
$wr_num = $result4[wr_num];
// 해당 게시물 조회 - 본문, 코멘트, 답글까지
$sql2 = " select * from $write_table where wr_num = $wr_num order by wr_parent, wr_comment desc, wr_id ";
$result2 = sql_query($sql2);
// 이동할 게시판에 게시물 순번 설정
$next_wr_num = get_next_num($move_write_table);
// 게시물 본문과 코멘트, 답글이 다 이동할때까지
while ($row2 = sql_fetch_array($result2))
{
// 본문 글에 이동 되었다는 메세지 추가
if (!$row2[wr_is_comment] && $config[cf_use_copy_log])
$row2[wr_content] .= " \n[이 게시물은 추천수 $goodCnt 이상으로, {$board[bo_subject]} 게시판에서 $move_bo_table 게시판으로 " . ($sw == 'copy' ? '복사' : '이동') ." 되었습니다]";
// 이동되는 게시판에 추가
$sql = " insert into $move_write_table
set wr_num = '$next_wr_num',
wr_reply = '$row2[wr_reply]',
wr_is_comment = '$row2[wr_is_comment]',
wr_comment = '$row2[wr_comment]',
wr_comment_reply = '$row2[wr_comment_reply]',
ca_name = '".addslashes($row2[ca_name])."',
wr_option = '$row2[wr_option]',
wr_subject = '".addslashes($row2[wr_subject])."',
wr_content = '".addslashes($row2[wr_content])."',
wr_link1 = '".addslashes($row2[wr_link1])."',
wr_link2 = '".addslashes($row2[wr_link2])."',
wr_link1_hit = '$row2[wr_link1_hit]',
wr_link2_hit = '$row2[wr_link2_hit]',
wr_trackback = '".addslashes($row2[wr_trackback])."',
wr_hit = '$row2[wr_hit]',
wr_good = '$row2[wr_good]',
wr_nogood = '$row2[wr_nogood]',
mb_id = '$row2[mb_id]',
wr_password = '$row2[wr_password]',
wr_name = '".addslashes($row2[wr_name])."',
wr_email = '".addslashes($row2[wr_email])."',
wr_homepage = '".addslashes($row2[wr_homepage])."',
wr_datetime = '$row2[wr_datetime]',
wr_ip = '$row2[wr_ip]',
wr_1 = '".addslashes($row2[wr_1])."',
wr_2 = '".addslashes($row2[wr_2])."',
wr_3 = '".addslashes($row2[wr_3])."',
wr_4 = '".addslashes($row2[wr_4])."',
wr_5 = '".addslashes($row2[wr_5])."',
wr_6 = '".addslashes($row2[wr_6])."',
wr_7 = '".addslashes($row2[wr_7])."',
wr_8 = '".addslashes($row2[wr_8])."',
wr_9 = '".addslashes($row2[wr_9])."',
wr_10 = '".addslashes($row2[wr_10])."' ";
sql_query($sql);
$insert_id = mysql_insert_id();
// 코멘트가 아니라면
if (!$row2[wr_is_comment])
{
$save_parent = $insert_id;
$sql3 = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$row2[wr_id]' order by bf_no ";
$result3 = sql_query($sql3);
for ($k=0; $row3 = sql_fetch_array($result3); $k++)
{
if ($row3[bf_file])
{
// 원본파일을 복사하고 퍼미션을 변경
@copy("$src_dir/$row3[bf_file]", "$dst_dir/$row3[bf_file]");
@chmod("$dst_dir/$row3[bf_file]", 0606);
// 원본섬네일 파일을 복사하고 퍼미션을 변경
@copy("$src_dir/$row3[bf_file].Thum", "$dst_dir/$row3[bf_file].Thum");
@chmod("$dst_dir/$row3[bf_file].Thum", 0606);
}
// board_file 테이블 추가
$sql = " insert into $g4[board_file_table]
set bo_table = '$move_bo_table',
wr_id = '$insert_id',
bf_no = '$row3[bf_no]',
bf_source = '$row3[bf_source]',
bf_file = '$row3[bf_file]',
bf_download = '$row3[bf_download]',
bf_content = '$row3[bf_content]',
bf_filesize = '$row3[bf_filesize]',
bf_width = '$row3[bf_width]',
bf_height = '$row3[bf_height]',
bf_type = '$row3[bf_type]',
bf_datetime = '$row3[bf_datetime]' ";
sql_query($sql);
if ($sw == "move" && $row3[bf_file])
$save[$cnt][bf_file][$k] = "$src_dir/$row3[bf_file]";
}
$count_write++;
if ($sw == "move" && $i == 0)
{
// 스크랩 이동
sql_query(" update $g4[scrap_table] set bo_table = '$move_bo_table', wr_id = '$save_parent' where bo_table = '$bo_table' and wr_id = '$row2[wr_id]' ");
// 최신글 이동
sql_query(" update $g4[board_new_table] set bo_table = '$move_bo_table', wr_id = '$save_parent', wr_parent = '$save_parent' where bo_table = '$bo_table' and wr_id = '$row2[wr_id]' ");
}
}
else
{
$count_comment++;
if ($sw == "move")
{
// 최신글 이동
sql_query(" update $g4[board_new_table] set bo_table = '$move_bo_table', wr_id = '$insert_id', wr_parent = '$save_parent' where bo_table = '$bo_table' and wr_id = '$row2[wr_id]' ");
}
}
sql_query(" update $move_write_table set wr_parent = '$save_parent' where wr_id = '$insert_id' ");
if ($sw == "move")
$save[$cnt][wr_id] = $row2[wr_parent];
$cnt++;
}
sql_query(" update $g4[board_table] set bo_count_write = bo_count_write + '$count_write' where bo_table = '$move_bo_table' ");
sql_query(" update $g4[board_table] set bo_count_comment = bo_count_comment + '$count_comment' where bo_table = '$move_bo_table' ");
// '이동' 인경우 원본 게시판의 게시물 삭제
if ($sw == "move")
{
for ($i=0; $i<count($save); $i++)
{
for ($k=0; $k<count($save[$i][bf_file]); $k++)
@unlink($save[$i][bf_file][$k]);
sql_query(" delete from $write_table where wr_parent = '{$save[$i][wr_id]}' ");
sql_query(" delete from $g4[board_new_table] where bo_table = '$bo_table' and wr_id = '{$save[$i][wr_id]}' ");
sql_query(" delete from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '{$save[$i][wr_id]}' ");
}
sql_query(" update $g4[board_table] set bo_count_write = bo_count_write - 1, bo_count_comment = bo_count_comment - 1 where bo_table = '$bo_table' ");
// 이동할 추천수가 됐으면 '이 글을 추천 하셨습니다' 대신 이동 됐다는 메세지
echo "<script language='JavaScript'>alert('\'$goodCnt\' 번째 추천입니다. \'$move_bo_table\' 게시판으로 이동 됩니다');</script>";
$href_c = "./board.php?bo_table=$bo_table"; // 이동인 경우 해당 게시물이 게시판에서 삭제 되므로 게시판 보기로 리플래쉬
echo "<script language='JavaScript'>top.location.href = '$href_c';</script>";
}
} // 여기까지 자동이동 if 문 이동 로직
//////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// 여기까지 추천수에 의한 자동 이동 로직 /////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
// 내역 생성 - 이동하지 않는 보통때 내역 생성 쿼리
sql_query(" insert $g4[board_good_table] set bo_table = '$bo_table', wr_id = '$wr_id', mb_id = '$member[mb_id]', bg_flag = '$good', bg_datetime = '$g4[time_ymdhis]' ");
if ($good == "good")
$status = "추천";
else
$status = "비추천";
echo "<script language='JavaScript'> alert('이 글을 \'$status\' 하셨습니다.');</script>";
// 기본 good.php 에 없는 건데, 추천 후 해당 게시물 리플래쉬 해줌(추천 카운트 올라간거 확인됨)
$href_r = "./board.php?bo_table=$bo_table&wr_id=$wr_id&page=$page";
echo "<script language='JavaScript'>top.location.href = '$href_r';</script>";
}
}
?>
[[ 테스트 및 문제점 ]]
- 이동할 게시판을 다른형식(갤러리가 아닌) 게시판은 안해봤습니다
될지 장담할 수 없습니다
- good.php 파일을 반드시 backup 하고 해보시기 바랍니다
잘못된 수정으로 인한 피해는 제가 지지 않습니다
- 파일 중간에 //(주석) 줄 부터 //(주석) 줄 까지가 제가 추가한 내용으로
원래 good.php 의 54 55 라인 사이에 넣은 겁니다
- 추가한 부분에 될 수 있는한 주석을 많이 달아서 설명해 놨습니다
- 여분필드3 에 넣는 이동할 게시판 이름의 게시판 테이블이 g4_write_test 인 경우
여분필드3 에 test 를 넣으셔야 합니다
첨부파일
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기
댓글 24개
아뒤가 심히... 뭔가 걸리는듯 하지만. ^^;;
단순한 게시물만의 이동이 아니라,
파일자료까지 제어가 가능하다면,
여러모로 활용이 가능할 듯 합니다.
스크랩.............즉시...했습니다
^^
위 내용중 다음 부분을 찾으세요.
$sw = "move"; // 이동이 아니라 복사일 경우는 copy
$act = "이동"; // 이동이 아니라 복사일 경우는 복사
$wr_id_list = $wr_id;
$save = array();
$save_count_write = 0;
$save_count_comment = 0;9
$cnt = 0;
여기서
$save_count_comment = 0; //9
로 수정하셔야 작동이 됩니다.
나머지는 09버전 이상에서 바뀐 부분만 수정하시면 잘 됩니다.
암것도 안나오네요. ㅠㅠ
이글을 왜 이제서야 봤을까?
적용해 봐야겠네요 ^^
정말 좋은 기능인데요...
function mw_good_load() {
$.get("<?=$board_skin_path?>/mw.proc/mw.good.php?bo_table=<?=$bo_table?>&wr_id=<?=$wr_id?>", function (data) {
$("#mw_good").html(data);
});
}
function mw_good_act(good) {
alert(data);
이런식으로 되어 있으며 실제로 처리하는 php는
mw.good.act.php 에서 echo "<javacript>이런식으로 쓰게 되면 alert창으로 해당 메시지를 뛰우게 되어 본의 아니게 script코드를 먹이지 못하여 다음과 코드를 작성할때 애매해집니다.
echo "<script language='JavaScript'>alert('\'$goodCnt\' 번째 추천입니다. \'$move_bo_table\' 게시판으로 이동 됩니다');</script>";
$href_c = "./board.php?bo_table=$bo_table"; // 이동인 경우 해당 게시물이 게시판에서 삭제 되므로 게시판 보기로 리플래쉬
echo "<script language='JavaScript'>top.location.href = '$href_c';</script>";
그래서 어쩔수 없이 하드 코딩으로 넘겨주는 값을 임의로 줬습니다.
275 // 구조가 거지 같애서 이안에 javascript선언하기가 애매함 대신 리턴값을 표시 해줌으로써 바같에서(view_skin.php) 처리
276 die("'$goodCnt'"); 277 }
*view_skin.php
//alert(data);
if(data>0) <--추천수 몇번째 이상부터
{
var msg = data + "번째 추천입니다. 베스트 게시판으로 이동됩니다.";
alert(msg);
top.location.href = './board.php?bo_table=B01';
}
else
{
alert(data);
}
일단 작동은 잘되는데..하드 코딩인만큼 이렇게 하면 db값과 여기 추천수 값을 둘다 변경해야됩니다.
혹시 다른 방법이 생각나시는분 댓글 ㄱㄱ^^
제가 단 댓글은 리플레쉬 없이 추천수가 카운팅 되는건데..
혹시 어떤부분이 안되신건지 남겨주시면 제가 아는범위내에서 답글달게요~
답변 무지 많이 기다렸는데 답장이 없어 원망하고 있었다는...ㅋ
이렇게 답글 남겨 주셔서 감사 드립니다. ^^
간단하게 질문 드리겠습니다.
현재 그누보드 및 배추스킨 (mw.basic) 최신 버전을 사용하고 있습니다.
1. 원문 내용처럼 good.php 파일 수정 후 해당 게시판 여분필드 3번과 4번항목 기재하였으나 전혀 동작이 되질 않습니다.
( 추천 클릭하면 수정전처럼 계속 추천 수만 올라가고 해당 게시물이 이동이 되질 않습니다. ㅠㅠ )
2. 그래서 good.php 외에 어떤 파일을 수정하면 배추스킨에서도 정상 작동할 수 있는지 여쭈어 본겁니다.
며칠째 헤메고 있으니 부디 광명을 주시길...부탁 드리겠습니다. 그리고 감사 합니다. ^__^
DB여분 필드값에 혹시 추천 카운터도 설정하셨나요
그런데 이동수가 되었을시 추천반영은 되는데 댓글이 남지 않네요
function mw_good_act(good) {
$.get("<?=$board_skin_path?>/good.act.php?bo_table=<?=$bo_table?>&wr_id=<?=$wr_id?>&good="+good, function (data) {
die ("'$goodCnt'");
//alert(data);
if(data>2)
{
var msg = data + "번째 추천입니다. 베스트 게시판으로 이동됩니다.";
alert(msg);
top.location.href = './board.php?bo_table=best';
}
else
{
alert(data);
}
mw_good_load();
});
}
mw_good_load();
어느 부분이 잘못된건지 모르겠네요.
추천수 알림창을 good.act 쪽에 넣어도 마찬가지네요