테스트 사이트 - 개발 중인 베타 버전입니다

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

janedoe 7년 전 조회 2,160

</p>

<p><?php

if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가</p>

<p>// 특정게시판에 적용하고 싶을때

$ttable = array('wholesale');

foreach($ttable as $t) {

    $tbo_table = $t;

// 특정게시판에 적용하고 싶을때</p>

<p>/*

// 전체게시판에 적용하고 싶을때

$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'];    </p>

<p>    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개

해피정
7년 전

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

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

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

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

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

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

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

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

j
janedoe
7년 전
사용자가 요구하신 기능이 아니라 그냥 제가 개인적 호기심으로 구현해보고싶은 기능이라 계속 질문을 올리고 있습니다. 조언주셔서 감사합니다.

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인