쿠폰시스템 게시판글쓰기후 일정확률로 쿠폰 생성하기
http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=85498&sca=&sfl=wr_subject&stx=%C4%ED%C6%F9&sop=and
위 스킨 응용해서 글쓰기후 일정 확률로 쿠폰생성하고 그 쿠폰정보를 그 글쓴이에게만
쪽지로 알려주고싶은데요 가능할까요?
위 스킨 응용해서 글쓰기후 일정 확률로 쿠폰생성하고 그 쿠폰정보를 그 글쓴이에게만
쪽지로 알려주고싶은데요 가능할까요?
|
댓글을 작성하시려면 로그인이 필요합니다.
댓글 10개
아래는 함수를 간략히 설명드리겠습니다. 급조해서 만들거라 오류 있을수 있을것 같구요.
오늘 맨유대 서울 축구 하길래 기분 좋아서 한번 만들어 보았습니다
오류 잇으면 메세지 바로 주세요..
사용은
bbs/write_update.php 파일에서
@include_once ("$board_skin_path/write_update.skin.php");
위 코드가 있을거구요 이 코드 바로 아래에
coupon_give( "쿠폰줄 회원 아이디", "쿠폰제목, 지급할포인트", "사용일수", "쿠폰줄 확률(사용않할시 비워 두세요" );
// 회원아이디, 쿠폰제목, 지급할 포인트, 유효기간(일), 발급될확률 ( 1% ~ 100% )
function coupon_give( $mb_id, $coupon_subject, $coupon_point, $use_day, $persent="" )
{
global $g4;
global $board;
global $wr_id;
global $config;
$mb_id = (string)preg_replace( "/[^a-zA-Z]/", "", $mb_id );
$use_day = (int)preg_replace( "/[^0-9]/", "", $use_day );
$coupon_point = (int)preg_replace( "/[^0-9]/", "", $coupon_point );
if ( ! $mb_id ) return; // 회원아이디 없으면 종료
if ( ! $use_day ) return; // 유효기간 없으면 종료
if ( ! $coupon_point ) return; // 쿠폰 포인트가 없으면 종료
if ( ! $coupon_subject ) return; // 쿠폰 제목이 없으면 종료
// 확률로 쿠폰을 지급한다면
if ( $persent )
{
$rand = rand( 0, 100 );
// 확률 범위를 넘었다면 종료
if ( $rand < (int)$persent )
return;
}
// 쿠폰 유효기간
$use_time = date( "Y-m-d H:i:s", time() + ( 86400 * $use_day ) );
// 쿠폰 번호를 생성
$coupon_number = coupon_number();
$coupon_kind = "포인트관련";
$coupon_category = "포인트적립";
$cu_opt1 = $coupon_point;
// 쿠폰 저장
$result = sql_query(" insert into $g4[coupon_table]
set
cu_no = '',
cu_kind = '$coupon_kind',
cu_category = '$coupon_category',
cu_subject = '$coupon_subject',
cu_number = '$coupon_number',
cu_status = '1',
cu_memo = '“$board[bo_subject]” 게시판 “$_POST[wr_subject]” 글쓰기로 획득하였습니다',
cu_use_time = '$use_time',
cu_opt1 = '$cu_opt1',
cu_opt2 = '$cu_opt2',
cu_opt3 = '$cu_opt3',
cu_opt4 = '$cu_opt4',
cu_opt5 = '$cu_opt5',
cu_explan = '$cu_explan',
cu_datetime = '$g4[time_ymdhis]' ");
// 저장된 쿠폰이 있을때
if ( $result )
{
$row = sql_fetch(" select max(me_id) as max_me_id from $g4[memo_table] ");
$me_id = $row[max_me_id] + 1;
$me_memo = "안녕하세요. 사이트 관리자입니다\n\n“$board[bo_subject]” 게시판 “$_POST[wr_subject]” 글 작성으로 쿠폰을 획득하셨습니다\n\n쿠폰번호 : $coupon_number\n사용기간 : $use_time\n\n언제나 최선을 다하는 관리자 되겠습니다\n\n감사함니다";
// 쪽지 INSERT
sql_query(" insert into $g4[memo_table]
set
me_id = '$me_id',
me_recv_mb_id = '$mb_id',
me_send_mb_id = '$config[cf_admin]',
me_send_datetime = '$g4[time_ymdhis]',
me_memo = '$me_memo' ");
// 실시간 쪽지 알림 기능
sql_query(" update $g4[member_table]
set
mb_memo_call = '$config[cf_admin]'
where
mb_id = '$mb_id' ");
}
return;
}
// 사용자 코드 실행
@include_once ("$board_skin_path/write_update.skin.php"); 아래에
coupon_give( "", "이벤트, 300", "30", "100" );
// 회원아이디, 쿠폰제목, 지급할 포인트, 유효기간(일), 발급될확률 ( 1% ~ 100% )
.
.
이런식으로 넣엇는데 글쓰기 확인누룬후에 상태에서 공백유지가되네요..write_update.php 못넘어가는거같은데..
쪽지도않오구요.
앞쪽 "" 아이디지정이 특정아이디가아닌 모두로 하고싶은데 저렇게 하는게맞는지^^..;;
쿠폰목록은 잘생성되는거같은데 쪽지가 오질않네요
이런식으로 하시구요... 위에
아래 함수를 extend/coupon.extend.php 에 맨 마지막에 넣어 주세요
php 는 <? 이 안에 넣는거 아시죠? ^^; ?>
포인트좀 많이 주세효~ ㅠ.ㅠ
// 회원아이디, 쿠폰제목, 지급할 포인트, 유효기간(일), 발급될확률 ( 1% ~ 100% )
function coupon_give( $mb_id, $coupon_subject, $coupon_point, $use_day, $persent="" )
{
global $g4;
global $board;
global $wr_id;
global $config;
$mb_id = (string)preg_replace( "/[^a-zA-Z]/", "", $mb_id );
$use_day = (int)preg_replace( "/[^0-9]/", "", $use_day );
$coupon_point = (int)preg_replace( "/[^0-9]/", "", $coupon_point );
if ( ! $mb_id ) return; // 회원아이디 없으면 종료
if ( ! $use_day ) return; // 유효기간 없으면 종료
if ( ! $coupon_point ) return; // 쿠폰 포인트가 없으면 종료
if ( ! $coupon_subject ) return; // 쿠폰 제목이 없으면 종료
// 확률로 쿠폰을 지급한다면
if ( $persent )
{
$rand = rand( 0, 100 );
// 확률 범위를 넘었다면 종료
if ( $rand < (int)$persent )
return;
}
// 쿠폰 유효기간
$use_time = date( "Y-m-d H:i:s", time() + ( 86400 * $use_day ) );
// 쿠폰 번호를 생성
$coupon_number = coupon_number();
$coupon_kind = "포인트관련";
$coupon_category = "포인트적립";
$cu_opt1 = $coupon_point;
// 쿠폰 저장
$result = sql_query(" insert into $g4[coupon_table]
set
cu_no = '',
cu_kind = '$coupon_kind',
cu_category = '$coupon_category',
cu_subject = '$coupon_subject',
cu_number = '$coupon_number',
cu_status = '1',
cu_memo = '“$board[bo_subject]” 게시판 “$_POST[wr_subject]” 글쓰기로 획득하였습니다',
cu_use_time = '$use_time',
cu_opt1 = '$cu_opt1',
cu_opt2 = '$cu_opt2',
cu_opt3 = '$cu_opt3',
cu_opt4 = '$cu_opt4',
cu_opt5 = '$cu_opt5',
cu_explan = '$cu_explan',
cu_datetime = '$g4[time_ymdhis]' ");
// 저장된 쿠폰이 있을때
if ( $result )
{
$row = sql_fetch(" select max(me_id) as max_me_id from $g4[memo_table] ");
$me_id = $row[max_me_id] + 1;
$me_memo = "안녕하세요. 사이트 관리자입니다\n\n“$board[bo_subject]” 게시판 “$_POST[wr_subject]” 글 작성으로 쿠폰을 획득하셨습니다\n\n쿠폰번호 : $coupon_number\n사용기간 : $use_time\n\n언제나 최선을 다하는 관리자 되겠습니다\n\n감사함니다";
// 쪽지 INSERT
sql_query(" insert into $g4[memo_table]
set
me_id = '$me_id',
me_recv_mb_id = '$mb_id',
me_send_mb_id = '$config[cf_admin]',
me_send_datetime = '$g4[time_ymdhis]',
me_memo = '$me_memo' ");
// 실시간 쪽지 알림 기능
sql_query(" update $g4[member_table]
set
mb_memo_call = '$config[cf_admin]'
where
mb_id = '$mb_id' ");
}
return;
}
coupon_give( "", "1,000 p 충전쿠폰", 30, 100, 30 ); 이게맞는지...
coupon.extend.php 아래쪽에 저장하고 올려봣는데 이번엔
글쓰기 확인후...
www/extend/coupon_extend.php on line 165
165라인 : function coupon_give( $mb_id, $coupon_subject, $coupon_point, $use_day, $persent="" )
사용할때 형식에 맞게 사용하시면 될것 같은데...
위에껀 테스트구요 실제 사용하시려면
회원아이디 쿠폰제목 포인트, 사용일수, 확률(1~100)
coupon_give( $member[mb_id], "1,000 p 충전쿠폰", 1000, 10, 30 );
이렇게 사용하시면 되요
$rand = rand( 1, 100 );
// 확률 범위를 넘었다면 종료
if ( $rand > (int)$persent )
return;
이렇게 변경해야 겠네요