하나의 게시판에서 특정 회원의 글 모두 삭제하기 > 그누4 팁자료실

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.

하나의 게시판에서 특정 회원의 글 모두 삭제하기 정보

하나의 게시판에서 특정 회원의 글 모두 삭제하기

첨부파일

delete_all_mem.php (4.9K) 40회 다운로드 2007-07-08 10:53:02

본문

참고> 코멘트는 삭제 되지 않습니다.
참고> 기존에 올라온 팁인지 중복인지는 체크하지 않았습니다.
참고> 그냥 간단하게 delete_all.php를 수정했습니다.
 
아래의 소스를 bbs 안에 delete_all_mem.php 로 저장하여 넣습니다.
 
<?
include_once("./_common.php");
// 4.11
@include_once("$board_skin_path/delete_all_mem.head.skin.php");

// 사용자 코드 실행
@include_once("$board_skin_path/delete_all_mem.skin.php");

if (empty($mb_id) || empty($bo_table)) alert('정상적인 사용이 아닙니다.');
$sql = " select wr_id from $write_table where wr_is_comment = 0 and mb_id='$mb_id' order by wr_num, wr_reply ";
$result = sql_query($sql);
$tmp_array = Array();
while($data = @mysql_fetch_assoc($result)){
  $tmp_array[] = $data['wr_id'];
}
// 거꾸로 읽는 이유는 답변글부터 삭제가 되어야 하기 때문임
for ($i=count($tmp_array)-1; $i>=0; $i--)
{
    $write = sql_fetch(" select * from $write_table where wr_id = '{$tmp_array[$i]}' ");
    if ($is_admin == "super") // 최고관리자 통과
        ;
    else if ($is_admin == "group") // 그룹관리자
    {
        $mb = get_member($write[mb_id]);
        if ($member[mb_id] == $group[gr_admin]) // 자신이 관리하는 그룹인가?
        {
            if ($member[mb_level] >= $mb[mb_level]) // 자신의 레벨이 크거나 같다면 통과
                ;
            else
                continue;
        }
        else
            continue;
    }
    else if ($is_admin == "board") // 게시판관리자이면
    {
        $mb = get_member($write[mb_id]);
        if ($member[mb_id] == $board[bo_admin]) // 자신이 관리하는 게시판인가?
            if ($member[mb_level] >= $mb[mb_level]) // 자신의 레벨이 크거나 같다면 통과
                ;
            else
                continue;
        else
            continue;
    }
    else if ($member[mb_id] && $member[mb_id] == $write[mb_id]) // 자신의 글이라면
    {
        ;
    }
    else if ($wr_password && !$write[mb_id] && sql_password($wr_password) == $write[wr_password]) // 패스워드가 같다면
    {
        ;
    }
    else
        continue;   // 나머지는 삭제 불가
    $len = strlen($write[wr_reply]);
    if ($len < 0) $len = 0;
    $reply = substr($write[wr_reply], 0, $len);
    // 원글만 구한다.
    $sql = " select count(*) as cnt from $write_table
              where wr_reply like '$reply%'
                and wr_id <> '$write[wr_id]'
                and wr_num = '$write[wr_num]'
                and wr_is_comment = 0 ";
    $row = sql_fetch($sql);
    if ($row[cnt])
            continue;
    // 나라오름님 수정 : 원글과 코멘트수가 정상적으로 업데이트 되지 않는 오류를 잡아 주셨습니다.
    //$sql = " select wr_id, mb_id, wr_comment from $write_table where wr_parent = '$write[wr_id]' order by wr_id ";
    $sql = " select wr_id, mb_id, wr_is_comment from $write_table where wr_parent = '$write[wr_id]' order by wr_id ";
    $result = sql_query($sql);
    while ($row = sql_fetch_array($result))
    {
        // 원글이라면
        if (!$row[wr_is_comment])
        {
            // 원글 포인트 삭제
            if (!delete_point($row[mb_id], $bo_table, $row[wr_id], '쓰기'))
                insert_point($row[mb_id], $board[bo_write_point] * (-1), "$board[bo_subject] $row[wr_id] 글삭제");
            // 업로드된 파일이 있다면
            $sql2 = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$row[wr_id]' ";
            $result2 = sql_query($sql2);
            while ($row2 = sql_fetch_array($result2))
                // 파일삭제
                @unlink("$g4[path]/data/file/$bo_table/$row2[bf_file]");
               
            // 파일테이블 행 삭제
            sql_query(" delete from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$row[wr_id]' ");
            $count_write++;
        }
        else
        {
            // 코멘트 포인트 삭제
            if (!delete_point($row[mb_id], $bo_table, $row[wr_id], '코멘트'))
                insert_point($row[mb_id], $board[bo_comment_point] * (-1), "$board[bo_subject] {$write[wr_id]}-{$row[wr_id]} 코멘트삭제");
            $count_comment++;
        }
    }
    // 게시글 삭제
    sql_query(" delete from $write_table where wr_parent = '$write[wr_id]' ");
    // 최근게시물 삭제
    sql_query(" delete from $g4[board_new_table] where bo_table = '$bo_table' and wr_parent = '$write[wr_id]' ");
    // 스크랩 삭제
    sql_query(" delete from $g4[scrap_table] where bo_table = '$bo_table' and wr_id = '$write[wr_id]' ");
    // 공지사항 삭제
    $notice_array = explode("\n", trim($board[bo_notice]));
    $bo_notice = "";
    for ($k=0; $k<count($notice_array); $k++)
        if ((int)$write[wr_id] != (int)$notice_array[$k])
            $bo_notice .= $notice_array[$k] . "\n";
    $bo_notice = trim($bo_notice);
    sql_query(" update $g4[board_table] set bo_notice = '$bo_notice' where bo_table = '$bo_table' ");
    $board[bo_notice] = $bo_notice;
}
// 글숫자 감소
if ($count_write > 0 || $count_comment > 0)
    sql_query(" update $g4[board_table] set bo_count_write = bo_count_write - '$count_write', bo_count_comment = bo_count_comment - '$count_comment' where bo_table = '$bo_table' ");
// 4.11
@include_once("$board_skin_path/delete_all_mem.tail.skin.php");
alert("$mb_id 님의 글을 전체 삭제 하였습니다.", "./board.php?bo_table=$bo_table&page=$page" . $qstr);
?>
 
그런다음
js/sideview.js 를 아래와 같이 추가 수정해줍니다.
 
 
 
        // 최고관리자일 경우
        if (g4_is_admin == "super") {
            // 회원정보변경
            if (mb_id)
                this.insertTail("modify", "<a href='"+g4_path+"/" + g4_admin + "/member_form.php?w=u&mb_id="+mb_id+"' target='_blank'>회원정보변경</a>");
            // 포인트내역
            if (mb_id)
                this.insertTail("point", "<a href='"+g4_path+"/" + g4_admin + "/point_list.php?sfl=mb_id&stx="+mb_id+"' target='_blank'>포인트내역</a>");
            // 코멘트 제외한 원글 삭제
            if (mb_id)
                this.insertTail("del_write", "<a href='"+g4_path+"/" + g4_bbs + "/delete_all_mem.php?bo_table="+g4_bo_table+"&mb_id="+mb_id+"'>게시물삭제</a>");
 
 
 
 
그렇게 되면 전체 관리자일 경우
특정게시판 리스트나 보기페이지의 해당 회원의 닉을 클릭하면
뜨는 레이어에서 게시물 삭제라는 링크가 나오고
그것을 클릭하면
해당 게시판에서 해당 회원의 코멘트를 제외한 글은 모두 지워집니다.
 
 
 
스팸글등록하는 사람들 글 지울때 유용하리라고 봅니다.
추천
1

댓글 7개

오 +_+

전 블랙이라는 게시판을 따로 만들어 불량 게시물을 이동시켜 혼자 봅니다. 흐흐

마치 이런 것 처럼?!

http://www.sir.co.kr/bbs/board.php?bo_table=zzz
전 비추천 N회일경우 지정된 게시판으로 복사하고 원글은(코멘트도 개별적용) 잠가 버립니다.그후엔 저혼자서만 봅니다.ㅎㅎ
http://www.sir.co.kr/bbs/tb.php/g4_tiptech/10767/6b8820280065ae6596d3babdc28da278
창화님이 올리신 팁과 이팁이랑 연동 부분도 고려해봐야 겠군요.^^
경로가 https://sir.kr/g4_tiptech/10767 로 변경되었네요.
혹시나 링크 눌러서 연결안되 당황하는 분이 있을까 싶어서...
전체 78 |RSS
그누4 팁자료실 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT