2022-09-17 20:50:50 +09:00
|
|
|
<?php
|
|
|
|
|
// 코멘트 삭제
|
2024-09-23 11:07:19 +09:00
|
|
|
include_once "./_common.php";
|
2022-09-17 20:50:50 +09:00
|
|
|
|
2024-09-19 20:57:39 +09:00
|
|
|
$delete_comment_token = get_session('ss_delete_comment_' . $comment_id . '_token');
|
|
|
|
|
set_session('ss_delete_comment_' . $comment_id . '_token', '');
|
2022-09-17 20:50:50 +09:00
|
|
|
|
|
|
|
|
if (!($token && $delete_comment_token == $token))
|
2024-09-19 20:57:39 +09:00
|
|
|
alert('토큰 에러로 삭제 불가합니다.');
|
2022-09-17 20:50:50 +09:00
|
|
|
|
|
|
|
|
// 4.1
|
2024-09-28 13:03:15 +09:00
|
|
|
@include_once $board_skin_path . '/delete_comment.head.skin.php';
|
2022-09-17 20:50:50 +09:00
|
|
|
|
2024-09-30 01:58:32 +09:00
|
|
|
$write = sql_fetch("SELECT * FROM {$write_table} WHERE wr_id = '{$comment_id}' ");
|
2022-09-17 20:50:50 +09:00
|
|
|
|
|
|
|
|
if (!$write['wr_id'] || !$write['wr_is_comment'])
|
2024-09-19 20:57:39 +09:00
|
|
|
alert('등록된 코멘트가 없거나 코멘트 글이 아닙니다.');
|
2022-09-17 20:50:50 +09:00
|
|
|
|
|
|
|
|
if ($is_admin == 'super') // 최고관리자 통과
|
2024-09-19 20:57:39 +09:00
|
|
|
;
|
2022-09-17 20:50:50 +09:00
|
|
|
else if ($is_admin == 'group') { // 그룹관리자
|
2024-09-19 20:57:39 +09:00
|
|
|
$mb = get_member($write['mb_id']);
|
|
|
|
|
if ($member['mb_id'] == $group['gr_admin']) { // 자신이 관리하는 그룹인가?
|
|
|
|
|
if ($member['mb_level'] >= $mb['mb_level']) // 자신의 레벨이 크거나 같다면 통과
|
|
|
|
|
;
|
|
|
|
|
else
|
|
|
|
|
alert('그룹관리자의 권한보다 높은 회원의 코멘트이므로 삭제할 수 없습니다.');
|
|
|
|
|
} else
|
|
|
|
|
alert('자신이 관리하는 그룹의 게시판이 아니므로 코멘트를 삭제할 수 없습니다.');
|
2022-09-17 20:50:50 +09:00
|
|
|
} else if ($is_admin == 'board') { // 게시판관리자이면
|
2024-09-19 20:57:39 +09:00
|
|
|
$mb = get_member($write['mb_id']);
|
|
|
|
|
if ($member['mb_id'] == $board['bo_admin']) { // 자신이 관리하는 게시판인가?
|
|
|
|
|
if ($member['mb_level'] >= $mb['mb_level']) // 자신의 레벨이 크거나 같다면 통과
|
|
|
|
|
;
|
|
|
|
|
else
|
|
|
|
|
alert('게시판관리자의 권한보다 높은 회원의 코멘트이므로 삭제할 수 없습니다.');
|
|
|
|
|
} else
|
|
|
|
|
alert('자신이 관리하는 게시판이 아니므로 코멘트를 삭제할 수 없습니다.');
|
2022-09-17 20:50:50 +09:00
|
|
|
} else if ($member['mb_id']) {
|
2024-09-19 20:57:39 +09:00
|
|
|
if ($member['mb_id'] != $write['mb_id'])
|
|
|
|
|
alert('자신의 글이 아니므로 삭제할 수 없습니다.');
|
2022-09-17 20:50:50 +09:00
|
|
|
} else {
|
2024-09-19 20:57:39 +09:00
|
|
|
if (!check_password($wr_password, $write['wr_password']))
|
|
|
|
|
alert('비밀번호가 틀립니다.');
|
2022-09-17 20:50:50 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$len = strlen($write['wr_comment_reply']);
|
2024-09-19 20:57:39 +09:00
|
|
|
if ($len < 0)
|
|
|
|
|
$len = 0;
|
2022-09-17 20:50:50 +09:00
|
|
|
$comment_reply = substr($write['wr_comment_reply'], 0, $len);
|
|
|
|
|
|
2024-09-30 01:58:32 +09:00
|
|
|
$sql = "SELECT count(*) as cnt FROM {$write_table}
|
2022-09-17 20:50:50 +09:00
|
|
|
where wr_comment_reply like '{$comment_reply}%'
|
|
|
|
|
and wr_id <> '{$comment_id}'
|
|
|
|
|
and wr_parent = '{$write['wr_parent']}'
|
|
|
|
|
and wr_comment = '{$write['wr_comment']}'
|
|
|
|
|
and wr_is_comment = 1 ";
|
|
|
|
|
$row = sql_fetch($sql);
|
|
|
|
|
if ($row['cnt'] && !$is_admin)
|
2024-09-19 20:57:39 +09:00
|
|
|
alert('이 코멘트와 관련된 답변코멘트가 존재하므로 삭제 할 수 없습니다.');
|
2022-09-17 20:50:50 +09:00
|
|
|
|
|
|
|
|
// 코멘트 포인트 삭제
|
|
|
|
|
if (!delete_point($write['mb_id'], $bo_table, $comment_id, '댓글'))
|
2024-09-19 20:57:39 +09:00
|
|
|
insert_point($write['mb_id'], $board['bo_comment_point'] * (-1), "{$board['bo_subject']} {$write['wr_parent']}-{$comment_id} 댓글삭제");
|
2022-09-17 20:50:50 +09:00
|
|
|
|
|
|
|
|
// 코멘트 삭제
|
|
|
|
|
sql_query(" delete from {$write_table} where wr_id = '{$comment_id}' ");
|
|
|
|
|
|
|
|
|
|
// 코멘트가 삭제되므로 해당 게시물에 대한 최근 시간을 다시 얻는다.
|
2024-09-30 01:58:32 +09:00
|
|
|
$sql = "SELECT max(wr_datetime) as wr_last FROM {$write_table} where wr_parent = '{$write['wr_parent']}' ";
|
2022-09-17 20:50:50 +09:00
|
|
|
$row = sql_fetch($sql);
|
|
|
|
|
|
|
|
|
|
// 원글의 코멘트 숫자를 감소
|
2024-09-30 01:58:32 +09:00
|
|
|
sql_query("UPDATE {$write_table} SET wr_comment = wr_comment - 1, wr_last = '{$row['wr_last']}' where wr_id = '{$write['wr_parent']}' ");
|
2022-09-17 20:50:50 +09:00
|
|
|
|
|
|
|
|
// 코멘트 숫자 감소
|
2024-09-30 01:58:32 +09:00
|
|
|
sql_query("UPDATE {$g5['board_table']} SET bo_count_comment = bo_count_comment - 1 where bo_table = '{$bo_table}' ");
|
2022-09-17 20:50:50 +09:00
|
|
|
|
|
|
|
|
// 새글 삭제
|
|
|
|
|
sql_query(" delete from {$g5['board_new_table']} where bo_table = '{$bo_table}' and wr_id = '{$comment_id}' ");
|
|
|
|
|
|
|
|
|
|
// 사용자 코드 실행
|
2024-09-28 13:03:15 +09:00
|
|
|
@include_once $board_skin_path . '/delete_comment.skin.php';
|
|
|
|
|
@include_once $board_skin_path . '/delete_comment.tail.skin.php';
|
2022-09-17 20:50:50 +09:00
|
|
|
|
|
|
|
|
delete_cache_latest($bo_table);
|
|
|
|
|
|
2024-09-28 13:03:15 +09:00
|
|
|
EventHandler::triggerEvent("gnuboard.bbs.delete_comment", $comment_id, $board);
|
|
|
|
|
|
2024-09-19 20:57:39 +09:00
|
|
|
goto_url('./board.php?bo_table=' . $bo_table . '&wr_id=' . $write['wr_parent'] . '&page=' . $page . $qstr);
|