안녕하세요 추천횟수 제한

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
안녕하세요 추천횟수 제한

QA

안녕하세요 추천횟수 제한

본문

안녕하세요 하단 코드와 같이 추천을 사용하고 있습니다

 

근데 여기서 추천에 따른 포인트를 지급하니 너무 추천을 남발해서 

 

회원 당 하루 10개 만 추천 가능하게 하고 싶습니다.

 

10개 이상 시 하루에 추천 개수를 제한하는 알람이 나오게끔 하고싶은데

 

어떻게 하면 좋을까요?
 


<?php
include_once('./_common.php');
 
$opt = isset($opt) ? $opt : '';
 
if($opt) {
    //댓글일 때 설정값 변경
    $board['bo_use_good'] = isset($boset['na_cgood']) ? $boset['na_cgood'] : $board['bo_use_good'];
    $board['bo_use_nogood'] = isset($boset['na_cnogood']) ? $boset['na_cnogood'] : $board['bo_use_nogood'];
 
    run_event('comment_good_before', $bo_table, $wr_id, $good);
} else {
    run_event('bbs_good_before', $bo_table, $wr_id, $good);
 
    @include_once($board_skin_path.'/good.head.skin.php');
}
 
$error = $success = $count = "";
 
function print_result($error, $success, $count) {
    echo '{ "error": "' . $error . '", "success": "' . $success . '", "count": "' . $count . '" }';
    exit;
}
 
if (!$is_member) {
    $error = '회원만 가능합니다.';
    print_result($error, $success, $count);
}
 
if (!($bo_table && $wr_id)) {
    $error = '값이 제대로 넘어오지 않았습니다.';
    print_result($error, $success, $count);
}
 
if (!$board['bo_table']) {
    $error = '존재하는 게시판이 아닙니다.';
    print_result($error, $success, $count);
}
 
$ss_name = ($write['wr_is_comment']) ? 'ss_view_'.$bo_table.'_'.$write['wr_parent'] : 'ss_view_'.$bo_table.'_'.$wr_id;
if (!get_session($ss_name)) {
    $error = '해당 게시물에서만 추천 또는 비추천 하실 수 있습니다.';
    print_result($error, $success, $count);
}
 
$is_success = false;
$ss_times = isset($boset['na_gtimes']) ? (int)$boset['na_gtimes'] : 0; // 횟수
$ss_name = 'ss_good_'.$bo_table.'_'.$wr_id; // 세션
 
if ($good == 'good' || $good == 'nogood') {
 
    if($write['mb_id'] == $member['mb_id']) {
        $error = '자신의 글에는 추천 또는 비추천 하실 수 없습니다.';
        print_result($error, $success, $count);
    }
 
    if (!$board['bo_use_good'] && $good == 'good') {
        $error = '이 게시판은 추천 기능을 사용하지 않습니다.';
        print_result($error, $success, $count);
    }
 
    if (!$board['bo_use_nogood'] && $good == 'nogood') {
        $error = '이 게시판은 비추천 기능을 사용하지 않습니다.';
        print_result($error, $success, $count);
    }
 
    $sql = " select bg_id, bg_flag, bg_datetime from {$g5['board_good_table']}
                where bo_table = '{$bo_table}'
                and wr_id = '{$wr_id}'
                and mb_id = '{$member['mb_id']}'
                and bg_flag in ('good', 'nogood') ";
    $row = sql_fetch($sql);
    if (isset($row['bg_flag']) && $row['bg_flag']) {
 
        $good = $row['bg_flag'];
 
        if ($good == 'good')
            $status = '추천';
        else
            $status = '비추천';
 
        // 취소체크
        $cancel_sec = isset($boset['na_gcancel']) ? (int)$boset['na_gcancel'] : 0;
        if($cancel_sec > 0 && G5_SERVER_TIME < (strtotime($row['bg_datetime']) + $cancel_sec)) {
            if($ss_times > 0) {
                $times = get_session($ss_name);
                if($times) {
                    if($ss_times > $times) {
                        set_session($ss_name, $times + 1);
                    } else {
                        $error = "더이상 취소할 수 없습니다.";
                        print_result($error, $success, $count);
                    }
                } else {
                    set_session($ss_name, 1);
                }
            }
           
            // 내역 삭제
            sql_query(" delete from {$g5['board_good_table']} where bg_id = '{$row['bg_id']}' ", false);
 
            // 추천(찬성), 비추천(반대) 카운트 감소
            sql_query(" update $write_table set wr_{$good} = wr_{$good} - 1 where wr_id = '{$wr_id}' ");
 
            $count = $write['wr_'.$good] - 1;
            $success = "$status 취소를 하셨습니다.";
 
        } else {
            $error = "이미 $status 하셨습니다.";
        }
 
        print_result($error, $success, $count);
 
    } else{
 
        // 추천(찬성), 비추천(반대) 카운트 증가
        sql_query(" update $write_table set wr_{$good} = wr_{$good} + 1 where wr_id = '{$wr_id}' ");
 
        // 내역 생성
        sql_query(" insert {$g5['board_good_table']} set bo_table = '{$bo_table}', wr_id = '{$wr_id}', mb_id = '{$member['mb_id']}', bg_flag = '{$good}', bg_datetime = '".G5_TIME_YMDHIS."' ");
 
        if ($good == 'good') {
            $status = '추천';
            insert_point($write['mb_id'], '1', "{$board['bo_subject']} {$wr_id} {$member['mb_nick']}님이 추천", $bo_table, $wr_id, $member['mb_id'].'추천');
        } else {
            $status = '비추천';
        }
 
        $count = $write['wr_'.$good] + 1;
 
        $is_success = true;
 
        if($opt) {
            run_event('comment_increase_good_json', $bo_table, $wr_id, $good);
        } else {
            run_event('bbs_increase_good_json', $bo_table, $wr_id, $good);
        }
 
    }
}
 
//댓글은 실행안함
if($opt) {
    run_event('comment_good_after', $bo_table, $wr_id, $good);
} else {
    run_event('bbs_good_after', $bo_table, $wr_id, $good);
 
    @include_once($board_skin_path.'/good.tail.skin.php');
}
 
if($is_success) {
    $success = "$status 하셨습니다.";
    print_result($error, $success, $count);
}

이 질문에 댓글 쓰기 :

답변 2

 insert_point($write['mb_id'], ...

봐서는 게시물 쓴 회원이 포인트를 받는 거 같은데

주는 사람이 아닌 받는 사람이 10회 초과하지 못하도록 한다는 것인가요?

답변을 작성하시기 전에 로그인 해주세요.
전체 0
QA 내용 검색
  • 개별 목록 구성 제목 답변작성자조회작성일
  • 질문이 없습니다.

회원로그인

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