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

자동삭제 소스 삽질해서 만들었는데 뭐가 잘못된건지 확인부탁드립니다. 채택완료

재형johnpark 5년 전 조회 1,993

이것저것 삽질해서 만들었는데 도무지 알수가 없네요....

그누버전 Version 5.4.2.5 이구요.

글등록하면 500에러뜨구요....글목록에서 클릭하면 500에러가 뜨네요.

시간지나도 삭제도 안되고....고수님들 도와주세요...

 

</p>

<p><?php

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

<p>$count_write = 0;

$count_comment = 0;

$wr_time = "wr_datetime < date_add(now(), interval -2 minute) and ca_name = '삭제대기'";</p>

<p>$tmp_array = array();

if ($wr_id) // 건별삭제

 $sql = " select wr_id from {$g5['write_prefix']}{$bo_table} where wr_is_comment = 0 and $wr_time";

    $tmp_array[0] = sql_query($sql);</p>

<p>$chk_count = count($tmp_array);</p>

<p>// 거꾸로 읽는 이유는 답변글부터 삭제가 되어야 하기 때문임

for ($i=$chk_count-1; $i>=0; $i--)

{

    $write = sql_fetch(" select * from $write_table where wr_id = '$tmp_array[$i]' ");</p>

<p>    $len = strlen($write['wr_reply']);

    if ($len < 0) $len = 0;

    $reply = substr($write['wr_reply'], 0, $len);</p>

<p>    // 원글만 구한다.

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

<p>    $sql = " select wr_id, mb_id, wr_is_comment, wr_content 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'])

        {

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

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

            $result2 = sql_query($sql2);

            while ($row2 = sql_fetch_array($result2)) {

                // 파일삭제

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

                if( file_exists($delete_file) ){

                    @unlink($delete_file);

                }</p>

<p>                // 썸네일삭제

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

                    delete_board_thumbnail($bo_table, $row2['bf_file']);

                }

            }</p>

<p>            // 에디터 썸네일 삭제

            delete_editor_thumbnail($row['wr_content']);</p>

<p>            // 파일테이블 행 삭제

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

<p>            $count_write++;

        }

    }</p>

<p>    // 게시글 삭제

    sql_query(" delete from $write_table where wr_parent = '{$write['wr_id']}' ");</p>

<p>    // 최근게시물 삭제

    sql_query(" delete from {$g5['board_new_table']} where bo_table = '$bo_table' and wr_parent = '{$write['wr_id']}' ");</p>

<p>    // 스크랩 삭제

    sql_query(" delete from {$g5['scrap_table']} where bo_table = '$bo_table' and wr_id = '{$write['wr_id']}' ");</p>

<p>    $bo_notice = board_notice($board['bo_notice'], $write['wr_id']);

    sql_query(" update {$g5['board_table']} set bo_notice = '$bo_notice' where bo_table = '$bo_table' ");

    $board['bo_notice'] = $bo_notice;

}</p>

<p>// 글숫자 감소

if ($count_write > 0 || $count_comment > 0)

    sql_query(" update {$g5['board_table']} set bo_count_write = bo_count_write - '$count_write', bo_count_comment = bo_count_comment - '$count_comment' where bo_table = '$bo_table' ");</p>

<p>//delete_cache_latest($bo_table);</p>

<p>//run_event('bbs_delete_all', $tmp_array, $board);</p>

<p>?></p>

<p>

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

답변 1개

채택된 답변
+20 포인트
e
5년 전

8~9줄을 아래와 같이 수정해보세요..

$sql = " select wr_id from {$g5['write_prefix']}{$bo_table} where wr_is_comment = 0 and $wr_time"; $result = sql_query($sql);

while($row = sql_fetch_array($result)) {

  $tmp_array[] = $row['wr_id'];

}

 

 

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

답변에 대한 댓글 1개

재형johnpark
5년 전
감사합니다. 덕분에 며칠간 잠못자고 삽질하던게 해결됐네요. 자동글삭제하실분들은 위에 소스 응용하면 되겠네요.파일까지 깔끔하게 삭제됩니다.

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

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

로그인