일정기간후 게시물이 삭제되엇음 하는데 도와주세요... > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

일정기간후 게시물이 삭제되엇음 하는데 도와주세요... 정보

일정기간후 게시물이 삭제되엇음 하는데 도와주세요...

본문

그누보드는 정말 왕초보입니다.

홈페이지 만들려하니 쉽지 않군요.. 휴~~~



일정기간후에 올려진게시물이 자동삭제 되었으면하는데 정말 쉽지않군요.

코드는 어떻게 도움받아 찾았지만 어떻게 적용해야하는지...

어디다 어떻게 적용해야하는지 아시는분 넓으신 아량으로 도움주시면 감사하겠습니다.









어느분의 일부 게시물에서...



 

게시물을 설정된 시간이내의 글은 삭재하려는데..
스킨파일에서...
// 자동 삭제 시간
 $write_table = $cfg[write_table_prefix] . $bo_table; // 게시판 테이블 전체이름
 $deltime = 5;
 $delDBTime = date("Y-m-d H:i:s", time() - $deltime * 3600);// 이 시간 이전 기록은 삭제한다.
 $sql = "select count(*) from $write_table where wr_datetime < '$delDBTime' and wr_id";
 $sql = "delete from $write_table where wr_datetime < '$delDBTime' and wr_id";
 sql_query($sql);
이렇게 위와같이하면 자동삭재는 되는데..
첨부된 화일이 같이 지워지지가 않네요...
그간 그누의 게시물에 조회를 해보니..아직 없더군요...
고민중입니다....어떻게해야...설정된시간내의 게시물이 첨부파일과같이 지워지느냐가 관건입니다.





또 다른 게시물에서....






<?

// 몇일지난 게시물을 삭제?
$days = 7;

/***********************************************

$days 일 지난 광고물을 자동 삭제시키는 프로그램

***********************************************/
include_once ("dbconfig.php");
include_once ("./config.php");
include_once ("./_common.php");
include_once ("./lib/connect.lib.php");


function delete_by_wr_id($wr_id,$write_table,$bo_table){


// 나라오름님 수정 : 원글과 코멘트수가 정상적으로 업데이트 되지 않는 오류를 잡아 주셨습니다.
$sql = " select wr_id, mb_id, wr_is_comment from $write_table where wr_parent = '$wr_id' order by wr_id ";
$result = sql_query($sql);
$count_write = 0; // by Ted (set number of list to count)
$count_comment = 0; // by Ted (sometimes total count of bulletin becomes less than zero)
while ($row = sql_fetch_array($result))
{

// 업로드된 파일이 있다면 파일삭제
$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]");
    @unlink("$g4[path]/data/file/$bo_table/$row2[bf_file].thum"); // by Ted (it locates here rather than within skin file to be sure working perfectly)
}

// 파일테이블 행 삭제
sql_query(" delete from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$row[wr_id]' ");

$count_write++;
}

echo $wr_id.",".$write_table;
// 게시글 삭제
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' ");

// 글숫자 감소
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' ");
}



function delete_run($bo_table){
$write_table = $g4[write_prefix].$bo_table; // 게시판 테이블 전체이름

$connect = @mysql_connect($mysql_host, $mysql_user, $mysql_pass);
$select_db = @mysql_select_db($connect, $connect);
if (!$select_db) {
    echo "DB 접속 오류";
    exit;
}
echo "1";
$today = $g4[time_ymd];
$now = $g4[time_his];

$gap = date("Y-m-d", time() - 86400 * $days);

$sql = "select wr_id from $write_table where wr_datetime < '$gap'";
$result = sql_query($sql);

while ($row = mysql_fetch_array($result)) {
delete_by_wr_id($row[wr_id],$write_table,$bo_table);
}
}
delete_run('tip');
delete_run('notice');
delete_run('gallery');
delete_run('test');
?>
  • 복사

댓글 전체

자동으로 삭제될려고하면 서버쪽에서 어쩌구 저쩌구 하니 그건 힘들죠

그래서 index.php 파일에 삭제할수 있게 하는쪽으로 생각해보세요
© SIRSOFT
현재 페이지 제일 처음으로