일정 기간 지나면 게시글 자동삭제 질문입니다.
본문
https://sir.kr/g4_tiptech/12417
위 팁을 그누보드5에 적용시켜서 아래와 같이 테스트를 해봤습니다..
그런데 설정한 시간이 지나도 자폭이 안됩니다..
어떻게 해야 설정한 시간이 지나면 삭제를 할 수 있을지 고수님들의 고견 부탁드립니다..
// list.skin.php
//자폭 시작
for ($i=0; $i<count($list); $i++) {
$count_write = 0;
$count_comment = 0;
if($list[$i][wr_10]) {
$g5[time_ymd] = date("Y-m-d H:i", $g5[server_time]);
$stoday = $g5[time_ymd];
$bombdate = $list[$i][wr_10];
$By = substr($bombdate,0,4);
$Bm = substr($bombdate,5,2);
$Bd = substr($bombdate,8,2) + 7;
$Bh = substr($bombdate,11,2);
$Bi = substr($bombdate,14,2);
$bombdate7 = date("Y-m-d H:i",mktime($Bh,$Bi,0,$Bm,$Bd,$By) );
$bombc = $list[$i][wr_id];
if ($stoday > $bombdate7) {
$sql = " select wr_id, mb_id, wr_is_comment from $write_table where wr_parent = '$bombc' order by wr_id ";
$result = sql_query($sql);
while ($row = sql_fetch_array($result))
{
// 원글이라면
if (!$row[wr_is_comment])
{
// 원글 포인트 삭제
if (!delete_point($row[mb_id], $bo_table, $row[wr_id], '쓰기'))
insert_point($row[mb_id], $board[bo_write_point] * (-1), "$board[bo_subject] $row[wr_id] 글삭제");
// 업로드된 파일이 있다면 파일삭제
$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)){
@unlink("$g5[path]/data/file/$bo_table/$row2[bf_file]");
@unlink("$g5[path]/data/file/$bo_table/thumb/$write[wr_id]"); //썸네일 삭제
@unlink("$g5[path]/data/file/$bo_table/latest_thumb/$write[wr_id]"); //최근게시물 썸네일 삭제
}
//추천기록 삭제
sql_query(" delete from g5_board_good where wr_id = '$row[wr_id]' AND bo_table = '$bo_table' "); //수정
// 파일테이블 행 삭제
sql_query(" delete from $g5[board_file_table] where bo_table = '$bo_table' and wr_id = '$row[wr_id]' ");
$count_write++;
}
else
{
// 코멘트 포인트 삭제
if (!delete_point($row[mb_id], $bo_table, $row[wr_id], '코멘트'))
insert_point($row[mb_id], $board[bo_comment_point] * (-1), "$board[bo_subject] {$view[wr_id]}-{$row[wr_id]} 코멘트삭제");
$count_comment++;
}
}
// 게시글 삭제
sql_query(" delete from $write_table where wr_parent = '$bombc' ");
// 최근게시물 삭제
sql_query(" delete from $g5[board_new_table] where bo_table = '$bo_table' and wr_parent = '$bombc' ");
// 스크랩 삭제
sql_query(" delete from $g5[scrap_table] where bo_table = '$bo_table' and wr_id = '$bombc' ");
// 공지사항 삭제
$notice_array = explode("\n", trim($board[bo_notice]));
$bo_notice = "";
for ($k=0; $k<count($notice_array); $k++)
if ((int)$bombc != (int)$notice_array[$k])
$bo_notice .= $notice_array[$k] . "\n";
$bo_notice = trim($bo_notice);
sql_query(" update $g5[board_table] set bo_notice = '$bo_notice' where bo_table = '$bo_table' ");
// 글숫자 감소
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' ");
$bend = 1;
}
}
if(count($list) == $i+1 && $bend == 1){
goto_url("./board.php?bo_table=$bo_table&page=$page");}
}
//자폭 끝
// view.skin.php
//자폭시작
if ($view['wr_10']) {
$g5['time_ymd'] = date("Y-m-d H:i", $g5['server_time']);
$stoday = $g5['time_ymd'];
$bombdate = $view['wr_10'];
if ($stoday > $bombdate) {
$sql = " select wr_id, mb_id, wr_is_comment from $write_table where wr_parent = '$view[wr_id]' order by wr_id ";
$result = sql_query($sql);
while ($row = sql_fetch_array($result))
{
// 원글이라면
if (!$row['wr_is_comment'])
{
// 원글 포인트 삭제
if (!delete_point($row['mb_id'], $bo_table, $row['wr_id'], '쓰기'))
insert_point($row['mb_id'], $board['bo_write_point'] * (-1), "$board[bo_subject] $row[wr_id] 글삭제");
// 업로드된 파일이 있다면 파일삭제
$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)){
@unlink("$g5[path]/data/file/$bo_table/$row2[bf_file]");
@unlink("$g5[path]/data/file/$bo_table/thumb/$write[wr_id]"); //썸네일 삭제
@unlink("$g5[path]/data/file/$bo_table/latest_thumb/$write[wr_id]"); //최근게시물 썸네일 삭제
}
//추천기록 삭제
sql_query(" delete from g5_board_good where wr_id = '$row[wr_id]' AND bo_table = '$bo_table' "); //수정
// 파일테이블 행 삭제
sql_query(" delete from $g5[board_file_table] where bo_table = '$bo_table' and wr_id = '$row[wr_id]' ");
$count_write++;
}
else
{
// 코멘트 포인트 삭제
if (!delete_point($row['mb_id'], $bo_table, $row['wr_id'], '코멘트'))
insert_point($row['mb_id'], $board['bo_comment_point'] * (-1), "$board[bo_subject] {$view[wr_id]}-{$row[wr_id]} 코멘트삭제");
$count_comment++;
}
}
// 게시글 삭제
sql_query(" delete from $write_table where wr_parent = '$view[wr_id]' ");
// 최근게시물 삭제
sql_query(" delete from $g5[board_new_table] where bo_table = '$bo_table' and wr_parent = '$view[wr_id]' ");
// 스크랩 삭제
sql_query(" delete from $g5[scrap_table] where bo_table = '$bo_table' and wr_id = '$view[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 $g5[board_table] set bo_notice = '$bo_notice' where bo_table = '$bo_table' ");
// 글숫자 감소
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' ");
if($view['mb_id'] != $member['mb_id']){
$smsg = "글을 폭파 시켰습니다.";
}
alert($smsg, "./board.php?bo_table=$bo_table");
}
$BombDay = "<a href=\"javascript:alert('자폭 설정이 되어 있습니다.\\n자폭일 : ".$view['wr_10']."')\"><font color=red class=small>(자폭 설정이 작동 중입니다. 지정일: $bombdate)</font></a><br>";
}
//자폭 끝
// write.skin.php
<select name="wr_10" id="wr_10" class="frm_input full_input required">
<option value="" selected>자폭안함</option>
<option value="<?php echo date("Y-m-d H:i", time() + (int)(60*60*24-86380))?>">20초</option>
</select>
!-->!-->!-->
답변 1
일반 php로는 해당 조건이 되었을 때 누군가 그 페이지에 접속해 새로고침해줘야 작동할 겁니다.
님이 의도한 것처럼 정해진 시간에 작동하도록 하려면, 크론탭 이용해야 한다고 하더라구요.
답변을 작성하시기 전에 로그인 해주세요.