답변 2개 / 댓글 3개
채택된 답변
+20 포인트
eyekiss 님 말씀대로 해 보세요. 아마 맞을 겁니다.
그래도 안된다면 아래 방법으로 해보세요.
Hook 파일 생성
/extend/comment_filter.extend.php
필요한 기능만 comment_filter.extend.php (변경가능) 로 저장해서
extend 폴더에 업로드 하세요.
그래도 안된다면 아래 방법으로 해보세요.
Hook 파일 생성
/extend/comment_filter.extend.php
Copy
<?php
if (!defined('_GNUBOARD_')) exit;
add_event('write_comment_update_before', function($board, $wr_id, $w){
if ($w !== 'c') return;
global $wr_content, $is_admin, $write_table;
$min_len = 3; // 최소글자수
$max_len = 300; // 최대 글자수
$flood_time = 10; // 도배 제한 초
$content = trim($wr_content);
$content_check = preg_replace('/\s+/', '', strip_tags($content));
$len = mb_strlen($content_check);
/* 최소 글자수 */
if(!$is_admin && $len < $min_len){
alert("댓글은 최소 {$min_len}자 이상 입력해야 합니다.");
}
/* 최대 글자수 */
if($len > $max_len){
alert("댓글은 {$max_len}자 이하만 가능합니다.");
}
/* 동일 댓글 방지 */
$sql = " select wr_id from {$write_table}
where wr_parent = '{$wr_id}'
and wr_content = '".sql_real_escape_string($content)."'
limit 1 ";
$row = sql_fetch($sql);
if($row['wr_id']){
alert("같은 댓글을 반복 등록할 수 없습니다.");
}
/* 도배 방지 */
if(!$is_admin && isset($_SESSION['ss_comment_time'])){
if(time() - $_SESSION['ss_comment_time'] < $flood_time){
alert("댓글은 {$flood_time}초 후에 작성 가능합니다.");
}
}
$_SESSION['ss_comment_time'] = time();
});
필요한 기능만 comment_filter.extend.php (변경가능) 로 저장해서
extend 폴더에 업로드 하세요.
답변에 대한 댓글 2개
/bbs/write_comment_update.php
if ($w == 'c') // 댓글 입력
{
이 부분 바로 아래
아래소스를 적용해보세요
/* 댓글 필터 */
$min_len = 3; // 최소 글자수
$max_len = 300; // 최대 글자수
$flood_time = 10; // 도배 제한 초
$content = trim($wr_content);
$content_check = preg_replace('/\s+/', '', strip_tags($content));
$len = mb_strlen($content_check);
/* 최소 글자수 */
if(!$is_admin && $len < $min_len){
alert("댓글은 최소 {$min_len}자 이상 입력해야 합니다.");
}
/* 최대 글자수 */
if($len > $max_len){
alert("댓글은 {$max_len}자 이하만 가능합니다.");
}
/* 동일 댓글 방지 */
$sql = " select wr_id from $write_table
where wr_parent = '$wr_id'
and wr_content = '".sql_real_escape_string($content)."'
limit 1 ";
$row = sql_fetch($sql);
if($row['wr_id']){
alert("같은 댓글을 반복 등록할 수 없습니다.");
}
/* 도배 방지 */
if(!$is_admin && isset($_SESSION['ss_comment_time'])){
if(time() - $_SESSION['ss_comment_time'] < $flood_time){
alert("댓글은 {$flood_time}초 후에 작성 가능합니다.");
}
}
$_SESSION['ss_comment_time'] = time();
if ($w == 'c') // 댓글 입력
{
이 부분 바로 아래
아래소스를 적용해보세요
/* 댓글 필터 */
$min_len = 3; // 최소 글자수
$max_len = 300; // 최대 글자수
$flood_time = 10; // 도배 제한 초
$content = trim($wr_content);
$content_check = preg_replace('/\s+/', '', strip_tags($content));
$len = mb_strlen($content_check);
/* 최소 글자수 */
if(!$is_admin && $len < $min_len){
alert("댓글은 최소 {$min_len}자 이상 입력해야 합니다.");
}
/* 최대 글자수 */
if($len > $max_len){
alert("댓글은 {$max_len}자 이하만 가능합니다.");
}
/* 동일 댓글 방지 */
$sql = " select wr_id from $write_table
where wr_parent = '$wr_id'
and wr_content = '".sql_real_escape_string($content)."'
limit 1 ";
$row = sql_fetch($sql);
if($row['wr_id']){
alert("같은 댓글을 반복 등록할 수 없습니다.");
}
/* 도배 방지 */
if(!$is_admin && isset($_SESSION['ss_comment_time'])){
if(time() - $_SESSION['ss_comment_time'] < $flood_time){
alert("댓글은 {$flood_time}초 후에 작성 가능합니다.");
}
}
$_SESSION['ss_comment_time'] = time();
답변을 작성하려면 로그인이 필요합니다.