테스트 사이트 - 개발 중인 베타 버전입니다

댓글 확률 답글 질문..드립니다. 채택완료

익명닉네임 10년 전 조회 6,469

 

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

 

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

 

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

 

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

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

답변 2개

채택된 답변
+20 포인트
p
10년 전

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

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

로그인 후 평가할 수 있습니다

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

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

로그인 후 평가할 수 있습니다

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

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

로그인