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

일정기간 지나면 자동삭제에 대한 질문입니다.

재형johnpark 5년 전 조회 3,598

더운날씨에 다들 고생이 많으십니다.

삽질하디 안되서 결국 질문글 올립니다.

해피정님이 올려주신 팁(https://sir.kr/g5_tip/6900)에다가 파일 삭제하는 소스를 추가했는데...

뭐가 잘못된건지 안되네요.. 혹 아시는 분 수정부탁드립니다.

</strong></p>

<p><?php

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

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

$ttable = array('order_ys');

foreach($ttable as $t) {

    $tbo_table = $t;

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

<p>/*

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

$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"];

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

*/

    

    sql_query(" delete from {$g5['write_prefix']}{$tbo_table} where wr_datetime < date_add(now(), interval -30 day) ");

    sql_query(" delete from {$g5['board_new_table']} where wr_datetime < date_add(now(), interval -30 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 ";

    if ($board['bo_notice']) $sql .= " bo_notice = '{$bo_notice}', ";

    $sql .= " bo_count_write = '{$bo_count_write}', ";

    $sql .= " bo_count_comment = '{$bo_count_comment}' ";

    $sql .= " where bo_table = '{$tbo_table}' ";

    sql_query($sql);

    

    // 업로드된 파일이 있다면

                $sql = " select * from {$g5['board_file_table']} where bo_table = '$tbo_table' and wr_id = '{$row['wr_id']}' ";

                $result = sql_query($sql);

                $row = sql_fetch_array($result);

                    // 파일삭제

                    $delete_file = run_replace('delete_file_path', G5_DATA_PATH.'/file/'.$tbo_table.'/'.str_replace('../', '',$row['bf_file']), $row);

                    if( file_exists($delete_file) ){

                        @unlink($delete_file);

                    }

    

      // 썸네일삭제

      if(preg_match("/\.({$config['cf_image_extension']})$/i", $row['bf_file'])) {

                        delete_board_thumbnail($tbo_table, $row['bf_file']);

                    }

      // 파일테이블 행 삭제

      sql_query(" delete from {$g5['board_file_table']} where bo_table = '$tbo_table' and wr_id = '{$row['wr_id']}' ");

                    

}

?></p>

<p><strong>

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

답변 1개

s
sinbi Expert
5년 전

30일 자닜는지?

사용하는 그누가 그누54 이상인지 체크해 보세요.

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

답변에 대한 댓글 3개

재형johnpark
5년 전
한시간으로하고 테스트하면 글목록에서는 삭제가 되는데 첨부된 파일들이 안지워지네요.
s
sinbi
5년 전
사용하는 그누 버전이?
재형johnpark
5년 전
Version 5.4.2.5 입니다.

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

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

로그인