댓글이 달린 후 5일 후 글이 자동삭제 되게 하려고 합니다

댓글이 달린 후 5일 후 글이 자동삭제 되게 하려고 합니다

QA

댓글이 달린 후 5일 후 글이 자동삭제 되게 하려고 합니다

본문


<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
// 특정게시판에 적용하고 싶을때
$ttable = array('wholesale');
foreach($ttable as $t) {
    $tbo_table = $t;
// 특정게시판에 적용하고 싶을때
/*
// 전체게시판에 적용하고 싶을때
$sql = "select * from ".$g5['board_table']." order by bo_table asc ";
$result = sql_query($sql);
while($data = sql_fetch_array($result)) {
    $tbo_table = $data["bo_table"];
// 전체게시판에 적용하고 싶을때
*/
    
    sql_query(" delete from ".$g5['write_prefix'].$tbo_table." where wr_datetime < date_add(now(), interval -5 day) and wr_is_comment = 1 ");
    sql_query(" delete from ".$g5['new_win_table']." where wr_datetime < date_add(now(), interval -5 day) and bo_table = '".$tbo_table."' ");
    
    // 게시판의 글 수
    $sql = " select count(*) as cnt from ".$g5['write_prefix'].$tbo_table." where wr_is_comment = 0 ";
    $row = sql_fetch($sql);
    $bo_count_write = $row['cnt'];
    
    // 게시판의 코멘트 수
    $sql = " select count(*) as cnt from ".$g5['write_prefix'].$tbo_table." where wr_is_comment = 1 ";
    $row = sql_fetch($sql);
    $bo_count_comment = $row['cnt'];    
    if (isset($_POST['proc_count'])) {
        // 원글을 얻습니다.
        //$sql = " select wr_id from {$g5['write_prefix']}{$tbo_table} where wr_is_comment = 0 ";
        $sql = " select a.wr_id, (count(b.wr_parent) - 1) as cnt from ".$g5['write_prefix'].$tbo_table." a, ".$g5['write_prefix'].$tbo_table." b where a.wr_id=b.wr_parent and a.wr_is_comment=0 group by a.wr_id ";
        $result = sql_query($sql);
        for ($i=0; $row=sql_fetch_array($result); $i++) {
            /*
            // 코멘트수를 얻습니다.
            $sql2 = " select count(*) as cnt from {$g5['write_prefix']}$tbo_table where wr_parent = '{$row['wr_id']}' and wr_is_comment = 1 ";
            $row2 = sql_fetch($sql2);
            */
            
            sql_query(" update ".$g5['write_prefix'].$tbo_table." set wr_comment = '".$row['cnt']."' where wr_id = '".$row['wr_id']."' ");
        }
    }
    
    // 공지사항에는 등록되어 있지만 실제 존재하지 않는 글 아이디는 삭제합니다.
    $bo_notice = "";
    $lf = "";
    if ($board['bo_notice']) {
        $tmp_array = explode(",", $board['bo_notice']);
        for ($i=0; $i<count($tmp_array); $i++) {
            $tmp_wr_id = trim($tmp_array[$i]);
            $row = sql_fetch(" select count(*) as cnt from ".$g5['write_prefix'].$tbo_table." where wr_id = '".$tmp_wr_id."' ");
            if ($row['cnt']) {
                $bo_notice .= $lf . $tmp_wr_id;
                $lf = ",";
            }
        }
    }
    
    $sql = " update ".$g5['board_table']."
    set bo_notice = '".$bo_notice."',
    bo_count_write = '".$bo_count_write."',
    bo_count_comment = '".$bo_count_comment."'
    where bo_table = '".$tbo_table."' ";
    sql_query($sql);
}
?>

 

해피정님이 올려두신 팁을 보고 이렇게 작성해봤는데 제대로 된것인지 모르겠어요 

php능력자님들 도와주세요.

디자이너는 웁니다. 

이 질문에 댓글 쓰기 :

답변 1

댓글이 달린후 5일후 삭제라....  저 팁과 다른 성격의 문제이네요

저건 코멘트가 5일후 삭제하겠다는 형태의 쿼리가 될듯 싶네요

댓글 올라온후 5일후 댓글을 삭제한다는건지,

댓글 올라온후 5일이 되면 원글까지 삭제한다는건지,

그것에 따라서 다른 쿼리문을 사용해야 싶습니다.

저의 생각은 여기까지 ~~~

그후 작업은 다른 능력자님께 패스,  혹은 작업요청으로 슝~~~

답변을 작성하시기 전에 로그인 해주세요.
전체 59,613
QA 내용 검색

회원로그인

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