태터툴즈 답글 삭제부분 수정
태터툴즈 0.96 정식버전에만 해당하는 내용임
어쩌다보니 최근엔 계속 태터툴즈 관련 포스팅이다. 아무튼;; 0.96 정식버전에 추가된 기능중의 하이라이트라고 할 수 있는 답글에 답글달기 기능 중에 의도한 것과 살짝 다르게 동작해서 당황하게 되는 부분이 하나 있는데, 하위 답글이 달린 상위 답글을 삭제했을때의 경우다. 상위 답글이 삭제되면서 하위 답글들은 최근 답글 목록 외에서는 영영 볼 수 없는 미아가 돼버리고 마는데 이걸 방지하려면 약간의 수정이 필요하다.
칼을 대야할 부분은 del_exe.php 파일의 34 ~ 43번째 줄이다. (아래 표시된 부분)
put_query("delete from t3_".$dbid."_reply where no = '$num'");
set_rp_cnt($pnum);
?>
<script type="text/javascript">
alert('지정하신 글이 삭제되었습니다t');
opener.exe_frame.location.href='add_exe.php?md=rp&num=<?=$pnum?>&d_target=post_<?=$pnum?>';
window.close();
</script>
<?
exit;
set_rp_cnt($pnum);
?>
<script type="text/javascript">
alert('지정하신 글이 삭제되었습니다t');
opener.exe_frame.location.href='add_exe.php?md=rp&num=<?=$pnum?>&d_target=post_<?=$pnum?>';
window.close();
</script>
<?
exit;
위의 부분을 일단 아래와 같이 고쳐놓은 뒤에,
list ($is_parent) = mysql_fetch_array(mysql_query("select count(*) from t3_${dbid}_reply where rno = '$num'"));
if($is_parent)
{
/* 뭔가 삽입될 곳 */
}
else
{
put_query("delete from t3_".$dbid."_reply where no = '$num'");
set_rp_cnt($pnum);
?>
<script type="text/javascript">
alert('지정하신 글이 삭제되었습니다t');
opener.exe_frame.location.href='add_exe.php?md=rp&num=<?=$pnum?>&d_target=post_<?=$pnum?>';
window.close();
</script>
<?
exit;
}
if($is_parent)
{
/* 뭔가 삽입될 곳 */
}
else
{
put_query("delete from t3_".$dbid."_reply where no = '$num'");
set_rp_cnt($pnum);
?>
<script type="text/javascript">
alert('지정하신 글이 삭제되었습니다t');
opener.exe_frame.location.href='add_exe.php?md=rp&num=<?=$pnum?>&d_target=post_<?=$pnum?>';
window.close();
</script>
<?
exit;
}
/* 뭔가 삽입될 곳 */ 이라고 표시된 곳에 어떻게 처리할건지에 따르는 코드를 넣어주면 된다. 답글 삭제시에 하위 답글을 어떻게 처리할 것인가는 기호에따라 몇가지 방법이 있을 수 있는데 대략 3가지 정도 추려보면,
-
상위 답글을 아예 못지우게 하는 방법. 방문자의 삭제 권리를 무시하는 방법이므로 사전에 낙장불입 시스템임을 알려둘 필요가 있다.
?>
<script type="text/javascript">
alert('하위 답글이 달려있어서 지울 수 없습니다t');
window.close();
</script>
<?
exit; -
상위 답글의 이름, 홈페이지, IP, 본문만 날려버리는 방법. 일단 리플 개수가 줄어들지 않아 좋다 -_-
put_query("update t3_${dbid}_reply set name='Anonymous', homepage='', body='(삭제된 답글입니다)', password='', ip='0.0.0.0' where no = '$num'");
?>
<script type="text/javascript">
alert('하위 답글이 달려있어서 내용만 삭제했습니다t');
opener.exe_frame.location.href='add_exe.php?md=rp&num=<?=$pnum?>&d_target=post_<?=$pnum?>';
window.close();
</script>
<?
exit; -
하위 답글까지 몽땅 삭제하는 방법. 화끈한 만큼 운영에 주의가 필요하다.
put_query("delete from t3_${dbid}_reply where no = '$num' or rno = '$num'");
set_rp_cnt($pnum);
?>
<script type="text/javascript">
alert('지정하신 답글과 관련 답글이 모두 삭제되었습니다t');
opener.exe_frame.location.href='add_exe.php?md=rp&num=<?=$pnum?>&d_target=post_<?=$pnum?>';
window.close();
</script>
<?
exit;
이렇게 3개의 방법중 원하는 방법에 해당하는 코드를 /* 뭔가 삽입될 곳 */ 부분에 넣어주면 된다.
이 블로그는 두번째 방법을 쓰고있다. 어떤 방법이든 이렇게 수정해두지 않으면 쓰레기 데이터가 쌓여서 DB의 일관성에도 문제가 있고 Staticker 같은 통계프로그램에서도 잘못된 결과가 나올 수 있으니 가급적 수정해주는쪽을 추천.
'컴퓨터 얘기 > 프로그래밍' 카테고리의 다른 글
| 태터툴즈 답글 + 기타등등을 RSS로 (21) | 2005/09/13 |
|---|---|
| Konfabulator Widget 만들기 (26) | 2005/08/16 |
| 태터툴즈 답글 삭제부분 수정 (8) | 2005/08/16 |
| 태터툴즈 0.96 위치로그 업데이터 (9) | 2005/08/15 |
| 태터툴즈 0.96용 노가다 유틸 (5) | 2005/08/13 |
| 태터툴즈용 간단한 통계 그래프 (9) | 2005/08/12 |
태그 : 태터툴즈