자동댓글 닉네임 질문 드립니다.

자동댓글 닉네임 질문 드립니다.

QA

자동댓글 닉네임 질문 드립니다.

본문

자동댓글 소스가 있어서 랜덤으로 적용하는것까지 수정을 했는데요

 

<?php

if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

 

$reply = array('가을비','꾸루','지노님','단이','오로시남','짱꽁이네','순리진리','먼지가','누리빼꼼','소모리','이꼬장이','애드피지','부산꾸미','멋진아빠','소미닝','클라쓰','브지되지','부엉','한실장','godloves231','초자연인','현이오르다','monykingkong');

$randint = mt_rand(0, count($reply)-1);


 

$array = array('ㅋㅋㅋㅋ','ㅎㅎㅎ','잼있네요^^','오늘도 좋은하루되세요~','헐...','이거 진짠가요?','대박','^^','음..','ㅋ','ㅎㅎ'); 

$max_reply = rand(1,10);//1에서 10사이의 랜덤수를 저장해서 아래 루프에서 돌리게됩니다.

 

for($m=1;$m<=$max_reply;$m++){

 

    $randNum = rand(0,count($array)-1); 


 

if($w == ''){

    $wr_write = get_write($write_table, $wr_id);//원글정보

    $wr_write_content = $array[$randNum]; //댓글내용

    $wr_write_cname = $reply[$randint];//등록자명

    $wr_write_mb_id = $config[cf_admin];//등록아이디

    $wr_write_password = sql_password(G5_SERVER_TIME);//패스워드

  

    $sql = " insert into $write_table

                set ca_name = '$wr_write[ca_name]',

                    wr_num = '$wr_write[wr_num]',

                    wr_parent = '$wr_id',

                    wr_is_comment = '1',

                    wr_comment = '1',

                    wr_content = '$wr_write_content',

                    mb_id = '$wr_write_mb_id',

                    wr_password = '$wr_write_password',

                    wr_name = '$wr_write_cname',

                    wr_datetime = '".G5_TIME_YMDHIS."',

                    wr_ip = '000.000.000.000' ";

    sql_query($sql);

  

  

    // 원글에 코멘트수 증가

    sql_query(" update $write_table set wr_comment = wr_comment + 1, wr_last = '".G5_TIME_YMDHIS."' where wr_id = '$wr_id' ");

    sql_query(" update {$g5['board_new_table']} set as_comment = as_comment + 1 where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ", false);

    // 코멘트 1 증가

    sql_query(" update {$g5['board_table']} set bo_count_comment = bo_count_comment + 1 where bo_table = '$bo_table' ");

  

}

 

}


 

@include_once($write_skin_path.'/write_update.tail.skin.php');

// 목록으로 이동하기

if($w == '' && isset($is_direct) && $is_direct) {

    if ($file_upload_msg)

        alert($file_upload_msg, G5_HTTP_BBS_URL.'/board.php?bo_table='.$bo_table);

    else

        goto_url(G5_HTTP_BBS_URL.'/board.php?bo_table='.$bo_table);

}

 

?>

 

 

문제는 댓글 내용이 랜덤으로 작성은 잘되는데 닉네임이 1개로만 통일이 되더라구요

 

만약 8개의 댓글이 랜덤으로 작성된다면 닉네임은 무조건 저중에서 한가지만 입력됩니다

 

겹치는게 있을수도 있지만 너무 딱 고정이 되버려서요 해결방법이 있을까요?

 

2041951127_1592984232.904.png

이 질문에 댓글 쓰기 :

답변 1

$randint = mt_rand(0, count($reply)-1);

 

이부분이 for문 안으로 들어가셔야 합니다.

 

 

<?php

if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

 

$reply = array('가을비','꾸루','지노님','단이','오로시남','짱꽁이네','순리진리','먼지가','누리빼꼼','소모리','이꼬장이','애드피지','부산꾸미','멋진아빠','소미닝','클라쓰','브지되지','부엉','한실장','godloves231','초자연인','현이오르다','monykingkong');

 


 

$array = array('ㅋㅋㅋㅋ','ㅎㅎㅎ','잼있네요^^','오늘도 좋은하루되세요~','헐...','이거 진짠가요?','대박','^^','음..','ㅋ','ㅎㅎ'); 

$max_reply = rand(1,10);//1에서 10사이의 랜덤수를 저장해서 아래 루프에서 돌리게됩니다.

 

for($m=1;$m<=$max_reply;$m++){

 

    $randNum = rand(0,count($array)-1); 

    $randint = mt_rand(0, count($reply)-1);

 

if($w == ''){

    $wr_write = get_write($write_table, $wr_id);//원글정보

    $wr_write_content = $array[$randNum]; //댓글내용

    $wr_write_cname = $reply[$randint];//등록자명

    $wr_write_mb_id = $config[cf_admin];//등록아이디

    $wr_write_password = sql_password(G5_SERVER_TIME);//패스워드

  

    $sql = " insert into $write_table

                set ca_name = '$wr_write[ca_name]',

                    wr_num = '$wr_write[wr_num]',

                    wr_parent = '$wr_id',

                    wr_is_comment = '1',

                    wr_comment = '1',

                    wr_content = '$wr_write_content',

                    mb_id = '$wr_write_mb_id',

                    wr_password = '$wr_write_password',

                    wr_name = '$wr_write_cname',

                    wr_datetime = '".G5_TIME_YMDHIS."',

                    wr_ip = '000.000.000.000' ";

    sql_query($sql);

  

  

    // 원글에 코멘트수 증가

    sql_query(" update $write_table set wr_comment = wr_comment + 1, wr_last = '".G5_TIME_YMDHIS."' where wr_id = '$wr_id' ");

    sql_query(" update {$g5['board_new_table']} set as_comment = as_comment + 1 where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ", false);

    // 코멘트 1 증가

    sql_query(" update {$g5['board_table']} set bo_count_comment = bo_count_comment + 1 where bo_table = '$bo_table' ");

  

}

 

}


 

@include_once($write_skin_path.'/write_update.tail.skin.php');

// 목록으로 이동하기

if($w == '' && isset($is_direct) && $is_direct) {

    if ($file_upload_msg)

        alert($file_upload_msg, G5_HTTP_BBS_URL.'/board.php?bo_table='.$bo_table);

    else

        goto_url(G5_HTTP_BBS_URL.'/board.php?bo_table='.$bo_table);

}

 

?>

답변을 작성하시기 전에 로그인 해주세요.
전체 35
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT