채택완료

댓글 확률 답글 질문..드립니다.

2015-02-26 (목) 13:40:53 6,668

밑 코드 확인해서 좀 뭐가 문제인지 봐주세요..

Copy
//이벤트 댓글 테스트용if ($w == "c" && rand(1, 100) >= "10") // 코멘트 입력{    /*    if ($member[mb_point] + $board[bo_comment_point] < 0 && !$is_admin)        alert("보유하신 포인트(".number_format($member[mb_point]).")가 없거나 모자라서 코멘트쓰기(".number_format($board[bo_comment_point]).")가 불가합니다.\\n\\n포인트를 적립하신 후 다시 코멘트를 써 주십시오.");    */    // 코멘트쓰기 포인트설정시 회원의 포인트가 음수인 경우 코멘트를 쓰지 못하던 버그를 수정 (곱슬최씨님)    $tmp_point = ($member[mb_point] > 0) ? $member[mb_point] : 0;    if ($tmp_point + $board[bo_comment_point] < 0 && !$is_admin)        alert("보유하신 포인트(".number_format($member[mb_point]).")가 없거나 모자라서 코멘트쓰기(".number_format($board[bo_comment_point]).")가 불가합니다.\\n\\n포인트를 적립하신 후 다시 코멘트를 써 주십시오.");     // 코멘트 답변    if ($comment_id)     {        $sql = " select wr_id, wr_comment, wr_comment_reply from $write_table                   where wr_id = '$comment_id' ";        $reply_array = sql_fetch($sql);        if (!$reply_array[wr_id])            alert("답변할 코멘트가 없습니다.\\n\\n답변하는 동안 코멘트가 삭제되었을 수 있습니다.");         $tmp_comment = $reply_array[wr_comment];         if (strlen($reply_array[wr_comment_reply]) == 5)            alert("더 이상 답변하실 수 없습니다.\\n\\n답변은 5단계 까지만 가능합니다.");         $reply_len = strlen($reply_array[wr_comment_reply]) + 1;        if ($board[bo_reply_order]) {            $begin_reply_char = "A";            $end_reply_char = "Z";            $reply_number = +1;            $sql = " select MAX(SUBSTRING(wr_comment_reply, $reply_len, 1)) as reply                        from $write_table                       where wr_parent = '$wr_id'                         and wr_comment = '$tmp_comment'                        and SUBSTRING(wr_comment_reply, $reply_len, 1) <> '' ";        }         else         {            $begin_reply_char = "Z";            $end_reply_char = "A";            $reply_number = -1;            $sql = " select MIN(SUBSTRING(wr_comment_reply, $reply_len, 1)) as reply                        from $write_table                       where wr_parent = '$wr_id'                         and wr_comment = '$tmp_comment'                       and SUBSTRING(wr_comment_reply, $reply_len, 1) <> '' ";        }        if ($reply_array[wr_comment_reply])             $sql .= " and wr_comment_reply like '$reply_array[wr_comment_reply]%' ";        $row = sql_fetch($sql);         if (!$row[reply])            $reply_char = $begin_reply_char;        else if ($row[reply] == $end_reply_char) // A~Z은 26 입니다.            alert("더 이상 답변하실 수 없습니다.\\n\\n답변은 26개 까지만 가능합니다.");        else            $reply_char = chr(ord($row[reply]) + $reply_number);         $tmp_comment_reply = $reply_array[wr_comment_reply] . $reply_char;    }    else     {        $sql = " select max(wr_comment) as max_comment from $write_table                   where wr_parent = '$wr_id' and wr_is_comment = 1 ";        $row = sql_fetch($sql);        //$row[max_comment] -= 1;        $row[max_comment] += 1;        $tmp_comment = $row[max_comment];        $tmp_comment_reply = "";    }     $sql = " insert into $write_table                set ca_name = '$wr[ca_name]',                    wr_option = '$wr_secret',                    wr_num = '$wr[wr_num]',                    wr_reply = '',                    wr_parent = '$wr_id',                    wr_is_comment = '1',                    wr_comment = '$tmp_comment',                    wr_comment_reply = 'A',                    wr_subject = '$wr_subject',                    wr_content = '경) {$wr_name}님 럭키 이벤트에 당첨 되셨습니다. Point {$point_rand}점 (축',                    mb_id = 'Luck★Event',                    wr_password = '$wr_password',                    wr_name = 'Luck★Event',                    wr_email = '$wr_email',                    wr_homepage = '$wr_homepage',                    wr_datetime = '$g4[time_ymdhis]',                    wr_last = '',                    wr_ip = '$_SERVER[REMOTE_ADDR]',                    wr_1 = '$wr_1',                    wr_2 = '$wr_2',                    wr_3 = '$wr_3',                    wr_4 = '$wr_4',                    wr_5 = '$wr_5',                    wr_6 = '$wr_6',                    wr_7 = '$wr_7',                    wr_8 = '$wr_8',                    wr_9 = '$wr_9',                    wr_10 = '$wr_10' ";    sql_query($sql);     $comment_id = mysql_insert_id();     // 원글에 코멘트수 증가 & 마지막 시간 반영    sql_query(" update $write_table set wr_comment = wr_comment + 1, wr_last = '$g4[time_ymdhis]' where wr_id = '$wr_id' ");     // 새글 INSERT    //sql_query(" insert into $g4[board_new_table] ( bo_table, wr_id, wr_parent, bn_datetime ) values ( '$bo_table', '$comment_id', '$wr_id', '$g4[time_ymdhis]' ) ");    sql_query(" insert into $g4[board_new_table] ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '$bo_table', '$comment_id', '$wr_id', '$g4[time_ymdhis]', '$member[mb_id]' ) ");     // 코멘트 1 증가    sql_query(" update $g4[board_table] set bo_count_comment = bo_count_comment + 1 where bo_table = '$bo_table' ");     // 포인트 부여    insert_point($member[mb_id], $point_rand, "$board[bo_subject] {$wr_id}-{$comment_id} 코멘트쓰기 당첨", $bo_table, $comment_id, '코멘트');     // 메일발송 사용    if ($config[cf_email_use] && $board[bo_use_email])    {        // 관리자의 정보를 얻고        $super_admin = get_admin("super");        $group_admin = get_admin("group");        $board_admin = get_admin("board");         $wr_subject = get_text(stripslashes($wr[wr_subject]));        $wr_content = nl2br(get_text(stripslashes("----- 원글 -----\n\n$wr[wr_subject]\n\n\n----- 코멘트 -----\n\n$wr_content")));         $warr = array( ""=>"입력", "u"=>"수정", "r"=>"답변", "c"=>"코멘트", "cu"=>"코멘트 수정" );        $str = $warr[$w];         $subject = "'{$board[bo_subject]}' 게시판에 {$str}글이 올라왔습니다.";        // 4.00.15 - 메일로 보내는 코멘트의 바로가기 링크 수정        $link_url = "$g4[url]/$g4[bbs]/board.php?bo_table=$bo_table&wr_id=$wr_id&$qstr#c_{$comment_id}";         include_once("$g4[path]/lib/mailer.lib.php");         ob_start();        include_once ("./write_update_mail.php");        $content = ob_get_contents();        ob_end_clean();         $array_email = array();        // 게시판관리자에게 보내는 메일        if ($config[cf_email_wr_board_admin]) $array_email[] = $board_admin[mb_email];        // 게시판그룹관리자에게 보내는 메일        if ($config[cf_email_wr_group_admin]) $array_email[] = $group_admin[mb_email];        // 최고관리자에게 보내는 메일        if ($config[cf_email_wr_super_admin]) $array_email[] = $super_admin[mb_email];         // 옵션에 메일받기가 체크되어 있고, 게시자의 메일이 있다면        if (strstr($wr[wr_option], "mail") && $wr[wr_email]) {            // 원글 메일발송에 체크가 되어 있다면            if ($config[cf_email_wr_write]) $array_email[] = $wr[wr_email];             // 코멘트 쓴 모든이에게 메일 발송이 되어 있다면 (자신에게는 발송하지 않는다)            if ($config[cf_email_wr_comment_all]) {                $sql = " select distinct wr_email from $write_table                          where wr_email not in ( '$wr[wr_email]', '$member[mb_email]', '' )                            and wr_parent = '$wr_id' ";                $result = sql_query($sql);                while ($row=sql_fetch_array($result))                    $array_email[] = $row[wr_email];            }        }         // 중복된 메일 주소는 제거        $unique_email = array_unique($array_email);        $unique_email = array_values($unique_email);        for ($i=0; $i<count($unique_email); $i++) {            mailer($wr_name, $wr_email, $unique_email[$i], $subject, $content, 1);        }    }}

rand(1, 100) 의 랜덤을 잡고 10 으로했습니다. 그러면 10% 확률로 답글이 달리게 한번 짜봣는데 자꾸 답글 달리네요..

제가 무슨 실수를했는지 고수분들 좀 알려주세요 ㅠ_ㅠ.

|

답변 2개

채택된 답변
+20 포인트

조건문이 rand(1,100) >= 10 이라서

10보다 크면 무조건이겠네요 ;;;;;

2015-02-26 (목) 13:45:44

제가 스스로 해결했습니다.. 죄송합니닷..^^_

답변을 작성하려면 로그인이 필요합니다.