고수님들 제발 가르쳐주세요..2틀째입니다..ㅠㅠ있는포인트 다겁니다. > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

고수님들 제발 가르쳐주세요..2틀째입니다..ㅠㅠ있는포인트 다겁니다. 정보

고수님들 제발 가르쳐주세요..2틀째입니다..ㅠㅠ있는포인트 다겁니다.

본문

http://www.sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=19357

이 팁을 참고로 해서 코멘트 작성시 원글 작성자에게 포인트 주는것을 만들었습니다.

그런데 코멘트 삭제시 원글 작성자에게 회수해야하는데 안되는겁니다..

그래서 겨우 어떻게 만들었는데..



write_comment_update.head.skin.php 에다가

밑의 소스를 넣었습니다.

<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 
 
$arr =mysql_fetch_array(mysql_query("select mb_id from $write_table where wr_id='$write[wr_parent]'")); 

$source_mb_id = $arr[0]; 

if ($member['mb_id'] != $source_mb_id) 
{
if (!delete_point($source_mb_id, $bo_table, $source_mb_id, '코멘트평가포인트')) 
	insert_point($source_mb_id, ($board[bo_1])* (-1), "$bo_table $wr_id-{$member['mb_id']}코멘트평가삭제", $bo_table, $wr_id, $member['mb_id']); 

}

?>

그런데 전형 작동이 안됩니다..

delete_point함수를 제가 잘못 인식하고 있는걸까요..타겟이 안맞는걸가요..

도와주십시요..
  • 복사

댓글 전체

command.lib.php
에 이와같은게 있습니다...

// 포인트 삭제
function delete_point($mb_id, $rel_table, $rel_id, $rel_action)
{
    global $g4;

    $result = false;
    if ($rel_table || $rel_id || $rel_action)
    {
        $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) as sum_po_point from $g4[point_table] where mb_id = '$mb_id' ";
        $row = sql_fetch($sql);
        $sum_point = $row[sum_po_point];

        // 포인트 UPDATE
        $sql = " update $g4[member_table] set mb_point = '$sum_point' where mb_id = '$mb_id' ";
        $result = sql_query($sql);
    }

    return $result;
}
치에님 어쩔수 없이 그렇게 했습니다..그런데 치명적인 단점이 나오지요..

그게 뭐냐면...

같은 회원이 코멘트를 작성하고 지운후 다시 쓰면 그때는 원글작성자에게 포인트가 더해지지 않습니다.
제가 보기에는 delete_point로 넘겨주시는 인자가 잘못된거 같은데요,,

insert_point($write['mb_id'], 100, "{$bo_table} - {$wr_id} 코멘트추가 포인트", $bo_table, $wr_id, $member['mb_id']);

위 소스가 참고로 하셔서 만드시 소스 중 포인트를 주는 부분입니다.

delete_point($source_mb_id, $bo_table, $source_mb_id, '코멘트평가포인트')) 
이 소스가 pray님이 사용하신 delete_point 소스구요

function insert_point  ($mb_id, $point, $content='', $rel_table='', $rel_id='', $rel_action='')
function delete_point ($mb_id, $rel_table, $rel_id, $rel_action)

위가 insert_point와 delete_point 함수 선언인데 공통으로 들어가는 부분 $mb_id랑 $rel_table, $rel_id, $rel_action이 동일해야 검색이 제대로 이뤄져 해당하는 포인트 레코드가 지워지겠죠?

제가 보기에 몇몇군데가 이상해서 좀 고쳐봤습니다.

$write = sql_fetch(" select * from $write_table where wr_id = '$comment_id' ");
$arr =mysql_fetch_array(mysql_query("select wr_id, mb_id from $write_table where wr_id='$write[wr_parent]'"));

$source_wr_id = $arr[0];
$source_mb_id = $arr[1];

if ($member['mb_id'] != $source_mb_id)
{
if (!delete_point($source_mb_id, $bo_table, $source_wr_id, $write[mb_id])
insert_point($source_mb_id, ($board[bo_1])* (-1), "$bo_table $wr_id-{$member['mb_id']}코멘트평가삭제", $bo_table, $wr_id, $member['mb_id']);
}

1. 제가 보기엔 이소스 위치 자체가 좀 이상한거 같습니다. write_comment_update.head.skin.php 가 아니라 코멘트 삭제시라면 delete_comment.head.skin.php에 들어가야 될듯 합니다.
2. $delete_comment.php를 보시면 $write함수는 delete_comment.head.skin.php 를 include 해오는 아래부분에서 선언이 됩니다. 따라서 위에서 쓰신
$arr =mysql_fetch_array(mysql_query("select mb_id from $write_table where wr_id='$write[wr_parent]'")); 여기에 $write[wr_parent]는 아마 빈값일겁니다.
3. 위에 설명해 놓은거처럼 delete_point에 넣어놓은 인자를 잘 비교해 보시기 바랍니다. 참고로 delete_point 젤 마지막 $rel_action에는 코멘트 작성자 아이디가 들어가야할듯 싶습니다.

뭐 일단 눈에 보이는것만 대충 적어봤는데 제가 테스트를 해보진 않아서 잘돌아갈진 모르겠네요,,
아프군하님 여러가지 지적 감사합니다..
일단 delete_comment.head.skin.php는 들어가있습니다 그리고 설명 감사드립니다!!
덕분에 무언가 진전이 있습니다

결과는 포인트 삭제가 안되고있습니다..아마도
if (!delete_point($source_mb_id, $bo_table, $source_wr_id, $write[mb_id])
가 맞질 않는것 같습니다..아이고.
코멘트 등록시
insert_point($write['mb_id'], 100, "{$bo_table} - {$wr_id} 코멘트추가 포인트", $bo_table, $wr_id, $member['mb_id']);
여기에 들어가는 인자들을 한번다 찍어보고
코멘트 삭제시
delete_point($source_mb_id, $bo_table, $source_wr_id, $write[mb_id])
여기에 들어가는 인자들을 다 찍어보세요.
직접 출력되는 값으로 비교해보면 어디서 틀린지 쉽게 확인하실수 있을실 거에요,,!!
역시 잘 안됩니다. 셀렉이 잘안되는건지 도저히 모르겠네요.되면 공개도 할려고 햇었는데...우와ㅠㅠ
아무튼 아프군하님 그리고 도와주신분님들 감사합니다!
성공했습니다!!!!말씀 하신대로 인자들 다 하나씩 찍어보고 그리고 가장 중요한게
업데이트한 데이터랑 지울 데이터 내용이 같게끔 해야하는군요.

뭔가 소스가 엄청 지저분해졌습니다.공부를 많이 하지 않으면 안될거 같네요..

그리고 head파일 보다는 tail에 넣는게 중요한것 같습니다. 다 한번 다시 써야하니까요.
그것도 파일 뒤져보다가 알았네요;
아아....저도 이것때문에 고생한적 있어서....제가봤으면 말씀드릴수 있었는데..
죄송합니다 늦게 봐서 ㅠ.ㅠ

delete_point와 insert_point가 왜 두개나 붙어있음녀 무슨역할을 하는지;;

차이는 간단히..글쓰기,등과 같이 일정한 내용일때는 내역 자체를 삭제 하기 위해 delete_point가 있는 거구요(DB부하 감소를 위한거 일거 같습니다.)

그런데 내역이 약간이라도 다르다면 (또는 포인트 정리로, 기록이 없는 경우등등) 결국 -값으로 insert_point한는 거죠
© SIRSOFT
현재 페이지 제일 처음으로