diff --git a/adm/config_form.php b/adm/config_form.php index c0e5f9510..fc061c043 100644 --- a/adm/config_form.php +++ b/adm/config_form.php @@ -108,7 +108,8 @@ if(!sql_query(" select cf_point_term from {$g4['config_table']} ", false)) { sql_query(" ALTER TABLE `{$g4['point_table']}` ADD `po_use_point` int(11) NOT NULL DEFAULT '0' AFTER `po_point`, ADD `po_expired` tinyint(4) NOT NULL DEFAULT '0' AFTER `po_use_point`, - ADD `po_expire_date` date NOT NULL DEFAULT '0000-00-00' AFTER `po_expired` ", false); + ADD `po_expire_date` date NOT NULL DEFAULT '0000-00-00' AFTER `po_expired` + ADD `po_mb_point` int(11) NOT NULL DEFAULT '0' AFTER `po_expire_date` ", false); } $g4['title'] = '환경설정'; diff --git a/adm/point_list.php b/adm/point_list.php index 5f93b2bd4..2c51cb399 100644 --- a/adm/point_list.php +++ b/adm/point_list.php @@ -113,28 +113,16 @@ function point_clear()
  • 포인트 순 정렬
  • -
    - - - - - - - - - - + + @@ -156,20 +144,14 @@ function point_clear() ?> - - - - + + +
    - - - 회원아이디 이름 별명일시 포인트 내용 포인트만료일시만료일 포인트합
    - - - - -
    - -
    - -
    - -
    @@ -236,24 +212,6 @@ function point_clear() - - diff --git a/adm/point_list_delete.php b/adm/point_list_delete.php deleted file mode 100644 index bf672a333..000000000 --- a/adm/point_list_delete.php +++ /dev/null @@ -1,52 +0,0 @@ -= G4_TIME_YMD) { - $mb_id = $row['mb_id']; - $po_point = abs($row['po_point']); - - delete_use_point($mb_id, $po_point); - } - } else { - if($row['po_expired'] != 1 && $row['po_use_point'] > 0) { - insert_use_point($row['mb_id'], $row['po_use_point'], $row['po_id']); - } - } - - // 포인트 내역삭제 - $sql = " delete from {$g4['point_table']} where po_id = '{$_POST['po_id'][$k]}' "; - sql_query($sql); - - $sum_point = get_point_sum($_POST['mb_id'][$k]); - - $sql= " update {$g4['member_table']} set mb_point = '{$sum_point}' where mb_id = '{$_POST['mb_id'][$k]}' "; - sql_query($sql); -} - -goto_url('./point_list.php?'.$qstr); -?> diff --git a/bbs/delete.php b/bbs/delete.php index 21ec46c15..973813b5f 100644 --- a/bbs/delete.php +++ b/bbs/delete.php @@ -73,8 +73,7 @@ while ($row = sql_fetch_array($result)) if (!$row['wr_is_comment']) { // 원글 포인트 삭제 - if (!delete_point($row['mb_id'], $bo_table, $row['wr_id'], '쓰기')) - insert_point($row['mb_id'], $board['bo_write_point'] * (-1), "{$board['bo_subject']} {$row['wr_id']} 글삭제"); + insert_point($row['mb_id'], $board['bo_write_point'] * (-1), "{$board['bo_subject']} {$row['wr_id']} 글삭제"); // 업로드된 파일이 있다면 파일삭제 $sql2 = " select * from {$g4['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$row['wr_id']}' "; @@ -101,8 +100,7 @@ while ($row = sql_fetch_array($result)) else { // 코멘트 포인트 삭제 - if (!delete_point($row['mb_id'], $bo_table, $row['wr_id'], '코멘트')) - insert_point($row['mb_id'], $board['bo_comment_point'] * (-1), "{$board['bo_subject']} {$write['wr_id']}-{$row['wr_id']} 코멘트삭제"); + insert_point($row['mb_id'], $board['bo_comment_point'] * (-1), "{$board['bo_subject']} {$write['wr_id']}-{$row['wr_id']} 코멘트삭제"); $count_comment++; } diff --git a/bbs/delete_all.php b/bbs/delete_all.php index 330ad4c17..1c6bfbbf0 100644 --- a/bbs/delete_all.php +++ b/bbs/delete_all.php @@ -84,8 +84,7 @@ for ($i=count($tmp_array)-1; $i>=0; $i--) if (!$row['wr_is_comment']) { // 원글 포인트 삭제 - if (!delete_point($row['mb_id'], $bo_table, $row['wr_id'], '쓰기')) - insert_point($row['mb_id'], $board['bo_write_point'] * (-1), "{$board['bo_subject']} {$row['wr_id']} 글 삭제"); + insert_point($row['mb_id'], $board['bo_write_point'] * (-1), "{$board['bo_subject']} {$row['wr_id']} 글 삭제"); // 업로드된 파일이 있다면 $sql2 = " select * from {$g4['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$row['wr_id']}' "; @@ -114,8 +113,7 @@ for ($i=count($tmp_array)-1; $i>=0; $i--) else { // 코멘트 포인트 삭제 - if (!delete_point($row['mb_id'], $bo_table, $row['wr_id'], '코멘트')) - insert_point($row['mb_id'], $board['bo_comment_point'] * (-1), "{$board['bo_subject']} {$write['wr_id']}-{$row['wr_id']} 코멘트삭제"); + insert_point($row['mb_id'], $board['bo_comment_point'] * (-1), "{$board['bo_subject']} {$write['wr_id']}-{$row['wr_id']} 코멘트삭제"); $count_comment++; } diff --git a/bbs/delete_comment.php b/bbs/delete_comment.php index 89d5fe84d..ca4c99421 100644 --- a/bbs/delete_comment.php +++ b/bbs/delete_comment.php @@ -59,8 +59,7 @@ if ($row['cnt'] && !$is_admin) alert('이 코멘트와 관련된 답변코멘트가 존재하므로 삭제 할 수 없습니다.'); // 코멘트 삭제 -if (!delete_point($write['mb_id'], $bo_table, $comment_id, '댓글')) - insert_point($write['mb_id'], $board['bo_comment_point'] * (-1), "{$board['bo_subject']} {$write['wr_parent']}-{$comment_id} 코멘트삭제"); +insert_point($write['mb_id'], $board['bo_comment_point'] * (-1), "{$board['bo_subject']} {$write['wr_parent']}-{$comment_id} 코멘트삭제"); // 코멘트 삭제 sql_query(" delete from {$write_table} where wr_id = '{$comment_id}' "); diff --git a/install/gnuboard4s.sql b/install/gnuboard4s.sql index 78f661892..48af2f8d5 100644 --- a/install/gnuboard4s.sql +++ b/install/gnuboard4s.sql @@ -495,7 +495,8 @@ CREATE TABLE IF NOT EXISTS `g4s_point` ( `po_point` int(11) NOT NULL default '0', `po_use_point` int(11) NOT NULL default '0', `po_expired` tinyint(4) NOT NULL default '0', - `po_expire_date` date NOT NULL default '0000-00-00', + `po_expire_date` date NOT NULL default '0000-00-00', + `po_mb_point` int(11) NOT NULL default '0', `po_rel_table` varchar(20) NOT NULL default '', `po_rel_id` varchar(20) NOT NULL default '', `po_rel_action` varchar(255) NOT NULL default '', diff --git a/lib/common.lib.php b/lib/common.lib.php index eae0e8afd..46c1582eb 100644 --- a/lib/common.lib.php +++ b/lib/common.lib.php @@ -881,11 +881,6 @@ function insert_point($mb_id, $point, $content='', $rel_table='', $rel_id='', $r return -1; } - // 포인트를 사용한 경우 포인트 내역에 사용금액 기록 - if($point < 0) { - insert_use_point($mb_id, $point); - } - // 포인트 건별 생성 $po_expire_date = '0000-00-00'; if($config['cf_point_term'] > 0) { @@ -896,8 +891,10 @@ function insert_point($mb_id, $point, $content='', $rel_table='', $rel_id='', $r } $po_expired = 0; - if($point < 0) + if($point < 0) { $po_expired = 1; + $po_expire_date = G4_TIME_YMD; + } $sql = " insert into {$g4['point_table']} set mb_id = '$mb_id', @@ -911,11 +908,23 @@ function insert_point($mb_id, $point, $content='', $rel_table='', $rel_id='', $r po_rel_id = '$rel_id', po_rel_action = '$rel_action' "; sql_query($sql); + $po_id = mysql_insert_id(); - $sum_point = get_point_sum($mb_id); + // 포인트를 사용한 경우 포인트 내역에 사용금액 기록 + if($point < 0) { + insert_use_point($mb_id, $point); + } + + // 회원포인트 + $sum_mb_point = get_point_sum($mb_id); // 포인트 UPDATE - $sql = " update {$g4['member_table']} set mb_point = '$sum_point' where mb_id = '$mb_id' "; + $sql = " update {$g4['member_table']} set mb_point = '$sum_mb_point' where mb_id = '$mb_id' "; + sql_query($sql); + + $sql = " update {$g4['point_table']} + set po_mb_point = '$sum_mb_point' + where po_id = '$po_id' "; sql_query($sql); return 1; @@ -957,53 +966,23 @@ function insert_use_point($mb_id, $point, $po_id='') } } -function delete_use_point($mb_id, $point) -{ - global $g4; - - $point1 = abs($point); - $sql = " select po_id, po_use_point, po_expired, po_expire_date - from {$g4['point_table']} - where mb_id = '$mb_id' - and po_use_point > 0 - order by po_id desc "; - $result = sql_query($sql); - for($i=0; $row=sql_fetch_array($result); $i++) { - $point2 = $row['po_use_point']; - - $po_expired = $row['po_expired']; - if($row['po_expired'] == 100 && ($row['po_expire_date'] == '0000-00-00' || $row['po_expire_date'] >= G4_TIME_YMD)) - $po_expired = 0; - - if($point2 >= $point1) { - $sql = " update {$g4['point_table']} - set po_use_point = po_use_point - '$point1', - po_expired = '$po_expired' - where po_id = '{$row['po_id']}' "; - sql_query($sql); - break; - } else { - $sql = " update {$g4['point_table']} - set po_use_point = '0', - po_expired = '$po_expired' - where po_id = '{$row['po_id']}' "; - sql_query($sql); - - $point1 -= $point2; - } - } -} - // 포인트 내역 합계 function get_point_sum($mb_id) { global $g4, $config; - // 유효기간이 있을 때 기간이 지난 포인트 expired 체크 if($config['cf_point_term'] > 0) { + // 소멸포인트가 있으면 내역 추가 + $expire_point = get_expire_point($mb_id); + if($expire_point > 0) { + insert_point($mb_id, -1*$expire_point, '포인트 소멸', '@expire', $mb_id, 'expire'.'-'.uniqid('')); + } + + // 유효기간이 있을 때 기간이 지난 포인트 expired 체크 $sql = " update {$g4['point_table']} set po_expired = '1' where mb_id = '$mb_id' + and po_expired <> '1' and po_expire_date <> '0000-00-00' and po_expire_date < '".G4_TIME_YMD."' "; sql_query($sql); @@ -1016,46 +995,29 @@ function get_point_sum($mb_id) and po_expired = '0' "; $row = sql_fetch($sql); - return $row['sum_po_point']; + if($row['sum_po_point'] < 0) + return 0; + else + return $row['sum_po_point']; } -// 포인트 삭제 -function delete_point($mb_id, $rel_table, $rel_id, $rel_action) +// 소멸 포인트 +function get_expire_point($mb_id) { - global $g4; + global $g4, $config; - $result = false; - if ($rel_table || $rel_id || $rel_action) - { - // 포인트정보 - $sql = " select po_id, mb_id, po_use_point, po_expired - from {$g4['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($config['cf_point_term'] == 0) + return 0; - $result = sql_query(" delete from {$g4['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' ", false); + $sql = " select sum(po_point - po_use_point) as sum_point + from {$g4['point_table']} + where mb_id = '$mb_id' + and po_expired = '0' + and po_expire_date <> '0000-00-00' + and po_expire_date < '".G4_TIME_YMD."' "; + $row = sql_fetch($sql); - // 포인트 사용 값이 있으면 다른 포인트 내역으로 이동시킴 - if($result && $row['po_expired'] != 1 && $row['po_use_point'] > 0) { - insert_use_point($row['mb_id'], $row['po_use_point'], $row['po_id']); - } - - // 포인트 내역의 합을 구하고 - $sum_point = get_point_sum($mb_id); - - // 포인트 UPDATE - $sql = " update {$g4['member_table']} set mb_point = '$sum_point' where mb_id = '$mb_id' "; - $result = sql_query($sql, false); - } - - return $result; + return $row['sum_point']; } // 회원 레이어