n회 이상 글 썼을 경우 포인트 지급 하지 않기 매개 게시판마다 다드르게 하려면 어떻게 수정해야 하나요?

n회 이상 글 썼을 경우 포인트 지급 하지 않기 매개 게시판마다 다드르게 하려면 어떻게 수정해야 하나요?

QA

n회 이상 글 썼을 경우 포인트 지급 하지 않기 매개 게시판마다 다드르게 하려면 어떻게 수정해야 하나요?

본문

n회 이상 글 썼을 경우 포인트 지급 하지 않기 매개 게시판마다 다드르게 하려면 어떻게 수정해야 하나요?

게시판 관리에서 bo_1 사용해서 매개 게시판마다 다르게 하려합니다.

lib/common.lib.php 에서 아래처럼 하니 작동 되지 않습니다ㅏ.

 

// 포인트 부여
function insert_point($mb_id, $point, $content='', $rel_table='', $rel_id='', $rel_action='', $expire=0, $repeat=0)
{
    global $config;
    global $g5;
    global $is_admin;
    
    // 하루 게시글 지전한개수이상 넘게 쓸 경우는 더이상 포인트 지급 안함
    if ($rel_action=='쓰기'){
        $sql = " select count(*) as cnt from {$g5['point_table']} where mb_id = '$mb_id' and left(po_datetime,10) = '".G5_TIME_YMD."' and po_rel_action = '쓰기' ";
        $row = sql_fetch($sql);
        if ($row['cnt'] > $board['bo_1'])
        return + 1;
    }

    // 포인트 사용을 하지 않는다면 return
    if (!$config['cf_use_point']) { return 0; }

    // 포인트가 없다면 업데이트 할 필요 없음
    if ($point == 0) { return 0; }

    // 회원아이디가 없다면 업데이트 할 필요 없음
    if ($mb_id == '') { return 0; }
    $mb = sql_fetch(" select mb_id from {$g5['member_table']} where mb_id = '$mb_id' ");
    if (!$mb['mb_id']) { return 0; }

    // 회원포인트
    $mb_point = get_point_sum($mb_id);

    // 이미 등록된 내역이라면 건너뜀 - 반복기능 추가
    if (!$repeat && ($rel_table || $rel_id || $rel_action))
    {
        $sql = " select count(*) as cnt from {$g5['point_table']}
                  where mb_id = '$mb_id'
                    and po_rel_table = '$rel_table'
                    and po_rel_id = '$rel_id'
                    and po_rel_action = '$rel_action' ";
        $row = sql_fetch($sql);
        if ($row['cnt'])
            return -1;
    }

    // 포인트 건별 생성
    $po_expire_date = '9999-12-31';
    if($config['cf_point_term'] > 0) {
        if($expire > 0)
            $po_expire_date = date('Y-m-d', strtotime('+'.($expire - 1).' days', G5_SERVER_TIME));
        else
            $po_expire_date = date('Y-m-d', strtotime('+'.($config['cf_point_term'] - 1).' days', G5_SERVER_TIME));
    }

    $po_expired = 0;
    if($point < 0) {
        $po_expired = 1;
        $po_expire_date = G5_TIME_YMD;
    }
    $po_mb_point = $mb_point + $point;

    $sql = " insert into {$g5['point_table']}
                set mb_id = '$mb_id',
                    po_datetime = '".G5_TIME_YMDHIS."',
                    po_content = '".addslashes($content)."',
                    po_point = '$point',
                    po_use_point = '0',
                    po_mb_point = '$po_mb_point',
                    po_expired = '$po_expired',
                    po_expire_date = '$po_expire_date',
                    po_rel_table = '$rel_table',
                    po_rel_id = '$rel_id',
                    po_rel_action = '$rel_action' ";
    sql_query($sql);

    // 포인트를 사용한 경우 포인트 내역에 사용금액 기록
    if($point < 0) {
        insert_use_point($mb_id, $point);
    }

    // 포인트 UPDATE
    $sql = " update {$g5['member_table']} set mb_point = '$po_mb_point' where mb_id = '$mb_id' ";
    sql_query($sql);
    
    // XP UPDATE
    update_xp($mb_id, $point, $content, $rel_table, $rel_action);

    return 1;
}

이 질문에 댓글 쓰기 :

답변 3

글이 작성되는 순간에 적용하시는게 좋을듯 합니다.

 

bbs/write_update.php 파일 약 297번재줄

 


    // 쓰기 포인트 부여
    if ($w == '') {
        if ($notice) {
            $bo_notice = $wr_id.($board['bo_notice'] ? ",".$board['bo_notice'] : '');
            sql_query(" update {$g5['board_table']} set bo_notice = '{$bo_notice}' where bo_table = '{$bo_table}' ");
        }
        insert_point($member['mb_id'], $board['bo_write_point'], "{$board['bo_subject']} {$wr_id} 글쓰기", $bo_table, $wr_id, '쓰기');
    } else {
        // 답변은 코멘트 포인트를 부여함
        // 답변 포인트가 많은 경우 코멘트 대신 답변을 하는 경우가 많음
        insert_point($member['mb_id'], $board['bo_comment_point'], "{$board['bo_subject']} {$wr_id} 글답변", $bo_table, $wr_id, '쓰기');
    }
}  else if ($w == 'u') {
    if (get_session('ss_bo_table') != $_POST['bo_table'] || get_session('ss_wr_id') != $_POST['wr_id']) {
        alert('올바른 방법으로 수정하여 주십시오.', get_pretty_url($bo_table));
    }

 

위 코드에서 insert_point 부분에 적용

 


// xxx 라는 테이블의 게시판일경우
if($bo_table == "xxx") {
$count = sql_fetch(" select count(*) as cnt from {$write_table} where bo_table = '{$bo_table}' and mb_id= '{$mb_id}'");
if($count['cnt'] >= $board['bo_1']) { 게시글이 bo_1 에 설정한 개수보다 작거나 같을때만 포인트 지급
insert_point($member['mb_id'], $board['bo_write_point'], "{$board['bo_subject']} {$wr_id} 글쓰기", $bo_table, $wr_id, '쓰기');
}
} else {
insert_point($member['mb_id'], $board['bo_write_point'], "{$board['bo_subject']} {$wr_id} 글쓰기", $bo_table, $wr_id, '쓰기');
}

 

직접 해보진 않았습니다.

 

 

 

포인트 부여하지 않는다는게 무슨뜻인지 이해가 가질 않네요

잘 된다는뜻인가요..?

안되신다니 아쉽네요 고생하세요~

답변을 작성하시기 전에 로그인 해주세요.
전체 16,737
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT