복사시 로그,,
본문
복사할때 내용에 로그가 기록되는데요,..
저는 내용에 로그가 아니고
a->b게시판에 복사할때
b게시판의 댓글에 복사한 사람의 아이디로 댓글이 달리게 하고 싶습니다.
move_update.php에 이렇게 되어 있는데...
이걸 어떻게 고치면 될까요?
고수님들의 한수를 부탁드려봅니다..
$sql2 = " select * from $write_table where wr_num = '$wr_num' order by wr_parent, wr_is_comment, wr_comment desc, wr_id ";
$result2 = sql_query($sql2);
while ($row2 = sql_fetch_array($result2))
{
$nick = cut_str($member['mb_nick'], $config['cf_cut_name']);
if (!$row2['wr_is_comment'] && $config['cf_use_copy_log']) {
if(strstr($row2['wr_option'], 'html')) {
$log_tag1 = '<div class="content_'.$sw.'">';
$log_tag2 = '</div>';
} else {
$log_tag1 = "\n";
$log_tag2 = '';
}
$row2['wr_content'] .= "\n".$log_tag1.'[이 게시물은 '.$nick.'님에 의해 '.G5_TIME_YMDHIS.' '.$board['bo_subject'].'에서 '.($sw == 'copy' ? '복사' : '이동').' 됨]'.$log_tag2;
}
답변 3
$sql2 = " select * from $write_table where wr_num = '$wr_num' order by wr_parent, wr_is_comment, wr_comment desc, wr_id ";
$result2 = sql_query($sql2);
while ($row2 = sql_fetch_array($result2))
{
// 게시글 추천, 비추천수
$wr_good = $wr_nogood = 0;
if ($sw == 'move' && $i == 0) {
$wr_good = $row2['wr_good'];
$wr_nogood = $row2['wr_nogood'];
}
$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_hit = '{$row2['wr_hit']}',
wr_good = '{$wr_good}',
wr_nogood = '{$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_file = '{$row2['wr_file']}',
wr_last = '{$row2['wr_last']}',
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();
$nick = cut_str($member['mb_nick'], $config['cf_cut_name']);
if (!$row2['wr_is_comment'] && $config['cf_use_copy_log']) {
$wr_content = '[이 게시물은 '.$nick.'님에 의해 '.G5_TIME_YMDHIS.' '.($sw == 'copy' ? '복사' : '이동').' 됨]';
$sub_sql = " select max(wr_comment) as max_comment from $move_write_table where wr_parent = '{$insert_id}' and wr_is_comment = 1 ";
$sub_row = sql_fetch($sub_sql);
$sub_row['max_comment'] += 1;
$tmp_comment = $sub_row['max_comment'];
$tmp_comment_reply = '';
$wr_subject = get_text(stripslashes($row2['wr_subject']));
$sql = " insert into $move_write_table
set ca_name = '{$row2['ca_name']}',
wr_option = '$wr_secret',
wr_num = '{$next_wr_num}',
wr_reply = '',
wr_parent = '{$insert_id}',
wr_is_comment = 1,
wr_comment = '$tmp_comment',
wr_comment_reply = '$tmp_comment_reply',
wr_subject = '',
wr_content = '$wr_content',
mb_id = '{$member['mb_id']}',
wr_password = '{$row2['wr_password']}',
wr_name = '$nick',
wr_email = '{$row2['wr_email']}',
wr_homepage = '{$row2['wr_homepage']}',
wr_datetime = '".G5_TIME_YMDHIS."',
wr_last = '',
wr_ip = '{$_SERVER['REMOTE_ADDR']}',
wr_1 = '$wr_1',
wr_2 = '$wr_2',
wr_3 = '$wr_3',
wr_4 = '$wr_4',
wr_5 = '$wr_5',
wr_6 = '$wr_6',
wr_7 = '$wr_7',
wr_8 = '$wr_8',
wr_9 = '$wr_9',
wr_10 = '$wr_10' ";
sql_query($sql);
$comment_id = mysql_insert_id();
// 원글에 댓글수 증가 & 마지막 시간 반영
sql_query(" update $move_write_table set wr_comment = wr_comment + 1, wr_last = '".G5_TIME_YMDHIS."' where wr_id = '{$insert_id}' ");
// 새글 INSERT
sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '$move_bo_table', '$comment_id', '{$insert_id}', '".G5_TIME_YMDHIS."', '{$row2['mb_id']}' ) ");
// 댓글 1 증가
sql_query(" update {$g5['board_table']} set bo_count_comment = bo_count_comment + 1 where bo_table = '$move_bo_table' ");
}
// 코멘트가 아니라면
if (!$row2['wr_is_comment'])
{
이렇게 수정해 주시면 됩니다~ 답변 채택 부탁 드릴께요~!
!-->/bbs/write_comment_update.php
해당 파일의 로직을 참고 / 복사 하여 활용이 가능합니다. write_comment_update.php 는 그누보드의 코멘트를 등록 / 수정하는 기능을 하는 파일로, 이 부분의 코드를 활용 한다면 그누보드 시스템에 따라 코멘트를 등록 할 수 있습니다.
$sql = " select max(wr_comment) as max_comment from $write_table
where wr_parent = '$wr_id' and wr_is_comment = 1 ";
$row = sql_fetch($sql);
//$row[max_comment] -= 1;
$row['max_comment'] += 1;
$tmp_comment = $row['max_comment'];
$tmp_comment_reply = '';
$wr_subject = get_text(stripslashes($wr['wr_subject']));
$sql = " insert into $write_table
set ca_name = '{$wr['ca_name']}',
wr_option = '$wr_secret',
wr_num = '{$wr['wr_num']}',
wr_reply = '',
wr_parent = '$wr_id',
wr_is_comment = 1,
wr_comment = '$tmp_comment',
wr_comment_reply = '$tmp_comment_reply',
wr_subject = '',
wr_content = '$wr_content',
mb_id = '$mb_id',
wr_password = '$wr_password',
wr_name = '$wr_name',
wr_email = '$wr_email',
wr_homepage = '$wr_homepage',
wr_datetime = '".G5_TIME_YMDHIS."',
wr_last = '',
wr_ip = '{$_SERVER['REMOTE_ADDR']}',
wr_1 = '$wr_1',
wr_2 = '$wr_2',
wr_3 = '$wr_3',
wr_4 = '$wr_4',
wr_5 = '$wr_5',
wr_6 = '$wr_6',
wr_7 = '$wr_7',
wr_8 = '$wr_8',
wr_9 = '$wr_9',
wr_10 = '$wr_10' ";
sql_query($sql);
$comment_id = mysql_insert_id();
// 원글에 댓글수 증가 & 마지막 시간 반영
sql_query(" update $write_table set wr_comment = wr_comment + 1, wr_last = '".G5_TIME_YMDHIS."' where wr_id = '$wr_id' ");
// 새글 INSERT
sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '$bo_table', '$comment_id', '$wr_id', '".G5_TIME_YMDHIS."', '{$member['mb_id']}' ) ");
// 댓글 1 증가
sql_query(" update {$g5['board_table']} set bo_count_comment = bo_count_comment + 1 where bo_table = '$bo_table' ");
이 부분의 소스 코드가 실제 신규 코멘트를 등록 하는 부분이라 볼 수 있는데요, 여기서 필요한 변수가 무엇인지 확인 할 수 있습니다.
1. 게시물 제목
2. 원본 게시물 id
3. 원본 게시물 정보
4. 등록할 코멘트 내용
5. 등록하는 멤버 아이디
4. 등록하는 사람의 이름 등...
올려주신 소스 코드를 보면, 원본 게시물의 정보를 받아 오는 곳은 $row2 로 확인 할 수 있습니다.
이를 응용하여 코드를 수정해 본다면
$sql2 = " select * from $write_table where wr_num = '$wr_num' order by wr_parent, wr_is_comment, wr_comment desc, wr_id ";
$result2 = sql_query($sql2);
while ($row2 = sql_fetch_array($result2))
{
$nick = cut_str($member['mb_nick'], $config['cf_cut_name']);
if (!$row2['wr_is_comment'] && $config['cf_use_copy_log']) {
$wr_content = '[이 게시물은 '.$nick.'님에 의해 '.G5_TIME_YMDHIS.' '.$board['bo_subject'].'에서 '.($sw == 'copy' ? '복사' : '이동').' 됨]';
$sub_sql = " select max(wr_comment) as max_comment from $write_table
where wr_parent = '{$row2['wr_id']}' and wr_is_comment = 1 ";
$sub_row = sql_fetch($sub_sql);
$sub_row['max_comment'] += 1;
$tmp_comment = $sub_row['max_comment'];
$tmp_comment_reply = '';
$wr_subject = get_text(stripslashes($row2['wr_subject']));
$sql = " insert into $write_table
set ca_name = '{$row2['ca_name']}',
wr_option = '$wr_secret',
wr_num = '{$row2['wr_num']}',
wr_reply = '',
wr_parent = '{$row2['wr_id']}',
wr_is_comment = 1,
wr_comment = '$tmp_comment',
wr_comment_reply = '$tmp_comment_reply',
wr_subject = '',
wr_content = '$wr_content',
mb_id = '{$row2['mb_id']}',
wr_password = '{$row2['wr_password']}',
wr_name = '{$row2['wr_name']}',
wr_email = '{$row2['wr_email']}',
wr_homepage = '{$row2['wr_homepage']}',
wr_datetime = '".G5_TIME_YMDHIS."',
wr_last = '',
wr_ip = '{$_SERVER['REMOTE_ADDR']}',
wr_1 = '$wr_1',
wr_2 = '$wr_2',
wr_3 = '$wr_3',
wr_4 = '$wr_4',
wr_5 = '$wr_5',
wr_6 = '$wr_6',
wr_7 = '$wr_7',
wr_8 = '$wr_8',
wr_9 = '$wr_9',
wr_10 = '$wr_10' ";
sql_query($sql);
$comment_id = mysql_insert_id();
// 원글에 댓글수 증가 & 마지막 시간 반영
sql_query(" update $write_table set wr_comment = wr_comment + 1, wr_last = '".G5_TIME_YMDHIS."' where wr_id = '{$row2['wr_id']}' ");
// 새글 INSERT
sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '$bo_table', '$comment_id', '{$row2['wr_id']}', '".G5_TIME_YMDHIS."', '{$row2['mb_id']}' ) ");
// 댓글 1 증가
sql_query(" update {$g5['board_table']} set bo_count_comment = bo_count_comment + 1 where bo_table = '$bo_table' ");
}
.
.
.
.
.
이렇게 될거 같네요~!
!-->!-->
옮겨간 게시물에 덧글이 달리길 원할때는
while ($row2 = sql_fetch_array($result2))
{
$nick = cut_str($member['mb_nick'], $config['cf_cut_name']);
if (!$row2['wr_is_comment'] && $config['cf_use_copy_log']) {
if(strstr($row2['wr_option'], 'html')) {
$log_tag1 = '<div class="content_'.$sw.'">';
$log_tag2 = '</div>';
} else {
$log_tag1 = "\n";
$log_tag2 = '';
}
$row2['wr_content'] .= "\n".$log_tag1.'[이 게시물은 '.$nick.'님에 의해 '.G5_TIME_YMDHIS.' '.$board['bo_subject'].'에서 '.($sw == 'copy' ? '복사' : '이동').' 됨]'.$log_tag2;
}
// 게시글 추천, 비추천수
$wr_good = $wr_nogood = 0;
if ($sw == 'move' && $i == 0) {
$wr_good = $row2['wr_good'];
$wr_nogood = $row2['wr_nogood'];
}
$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_hit = '{$row2['wr_hit']}',
wr_good = '{$wr_good}',
wr_nogood = '{$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_file = '{$row2['wr_file']}',
wr_last = '{$row2['wr_last']}',
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();
여기 아래 부분에 위에서 알려 드린 코드를 입력 하시면 됩니다.
※ 순정 그누보드 기준 103번 라인 아래에 추가
$sub_sql = " select max(wr_comment) as max_comment from $move_write_table
where wr_parent = '{$insert_id}' and wr_is_comment = 1 ";
$sub_row = sql_fetch($sub_sql);
$sub_row['max_comment'] += 1;
$tmp_comment = $sub_row['max_comment'];
$tmp_comment_reply = '';
$wr_subject = get_text(stripslashes($row2['wr_subject']));
$sql = " insert into $move_write_table
set ca_name = '{$row2['ca_name']}',
wr_option = '$wr_secret',
wr_num = '{$next_wr_num}',
wr_reply = '',
wr_parent = '{$insert_id}',
wr_is_comment = 1,
wr_comment = '$tmp_comment',
wr_comment_reply = '$tmp_comment_reply',
wr_subject = '',
wr_content = '$wr_content',
mb_id = '{$row2['mb_id']}',
wr_password = '{$row2['wr_password']}',
wr_name = '{$row2['wr_name']}',
wr_email = '{$row2['wr_email']}',
wr_homepage = '{$row2['wr_homepage']}',
wr_datetime = '".G5_TIME_YMDHIS."',
wr_last = '',
wr_ip = '{$_SERVER['REMOTE_ADDR']}',
wr_1 = '$wr_1',
wr_2 = '$wr_2',
wr_3 = '$wr_3',
wr_4 = '$wr_4',
wr_5 = '$wr_5',
wr_6 = '$wr_6',
wr_7 = '$wr_7',
wr_8 = '$wr_8',
wr_9 = '$wr_9',
wr_10 = '$wr_10' ";
sql_query($sql);
$comment_id = mysql_insert_id();
// 원글에 댓글수 증가 & 마지막 시간 반영
sql_query(" update $move_write_table set wr_comment = wr_comment + 1, wr_last = '".G5_TIME_YMDHIS."' where wr_id = '{$insert_id}' ");
// 새글 INSERT
sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '$move_bo_table', '$comment_id', '{$insert_id}', '".G5_TIME_YMDHIS."', '{$row2['mb_id']}' ) ");
// 댓글 1 증가
sql_query(" update {$g5['board_table']} set bo_count_comment = bo_count_comment + 1 where bo_table = '$move_bo_table' ");
}
.
.
.
.
.
오류가 생기거나 하면 알려 주세요~!
!-->!-->