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

도배방지 (연속글 차단) (코드수정)

· 13년 전 · 9370 · 13
Untitled-1.gif
질문게시판에 질문이 있길래 적어봅니다.
write_update.head.skin.php에 아래코드 추가 (스킨에 write_update.head.skin.php가 없으면 파일 추가)

if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
//시간계산
function oekaki_paint_time($paint_time){
$ptime=sprintf("%d시간 %d분 %d초",$paint_time/3600,($paint_time/60)%60,$paint_time%60);
if($paint_time<3600)$ptime=sprintf("%d분 %d초",($paint_time/60)%60,$paint_time%60);
if($paint_time<60)$ptime=sprintf("%d초",$paint_time%60);
$array=array(' 0분',' 0초');
$ptime=str_replace($array,'',$ptime);
return $ptime;
}

//관리자나 글 수정시에는 체크하지 않는다
if(!$is_admin&&($w!='u')){
//연속된 글을 작성 하였더라도 해당 시간이 지나면 글쓰기 가능. 사용하지 않으려면 값을 0으로 설정
$write_time=24; //단위 시간
//$write_time옵션 사용시 해당 옵션을 활성화 하면 도배 게시물에서 제일 마지막 게시물의 시간을 체크한다.
//0은 도배 게시물중 제일 오래된(시간상) 게시물, 1은 도배 게시물중 가장 최근 게시물.
$last_list=0;
//연속글 카운트 원하는 숫자로 수정
$write_count=5;
//회원이면 아이디 비회원이면 아이피를 가져온다
$fild=$is_member?'mb_id':'wr_ip';
//$write_count를 참고하여 마지막 작성된 글의 아이디 혹은 아이피를 가져온다
$test=sql_query(" select $fild, wr_datetime from $write_table where wr_is_comment = '0' order by wr_id desc limit $write_count ");
$list_count=0;
//회원이면 아이디 비회원이면 아이피 할당
$name_ip=$is_member?$member['mb_id']:$_SERVER['REMOTE_ADDR'];
while($test_list=mysql_fetch_array($test)) {
if($name_ip==$test_list[$fild]){
if($write_time){
if($last_list&&!$list_count)$lists=true; else if(!$last_list)$lists=true; else $lists=false;
if($lists){
$stime=strtotime($test_list['wr_datetime']);
$write_time2=$g4['server_time']-$stime;
$write_time3=($write_time*3600)+$stime;
if($write_time2>=($write_time3-$stime)) break;
}
}
$list_count++;
}
}
//차단
if($list_count>=$write_count) {
if($write_time){
$write_time4=oekaki_paint_time($write_time3-$g4['server_time']);
$error_text='\n다른사람이 글을 작성하지 않는다면 다음글은\n'.$write_time4.' 후에 작성 가능합니다.\n('.date('Y.m.d A.g:i:s',$write_time3).')';
}
alert('글을 '.$write_count.'개이상 연속으로 작성할 수 없습니다.'.$error_text);
}
}


----------------------------
oekaki_paint_time()은 제 스킨에서 쓰던 함수인데 여러곳에서 유용하게 쓰입니다.

댓글 작성

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

로그인하기

댓글 13개

13년 전
감사합니다 ㅋ
감사합니다.~
13년 전
굿굿

게시글 목록

번호 제목
34706
34693
34563
34536
34521
34480
34479
34466
34437
34436
34435
34406
34398
34387
34382
34375
34364
34336
34294
34293