게시판문의드립니다.

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
게시판문의드립니다.

QA

게시판문의드립니다.

본문

이움빌더껀데 여기에 문의해도 될지모르겠네요...ㅠㅠ

게시글 보기에서 좋아요클릭하는 기능이있는데요 로그인해서 눌러지는데 비회원도 좋아요 누르기가능하게 하고싶은데 소스를 봐도 모르겠고 문의해봐도 답없어서 고수님들 도와주세욤~

 


        <?php /* 추천 비추천 시작 */?>
        <?php if ($good_href || $nogood_href) { ?>
        <div class="board-view-good-btn">
            <div class="m-b-10">
                <?php if ($good_href) { ?>
                <span class="board-view-act-gng">
                    <a href="<?php echo $good_href.'&'.$qstr ?>" id="good_button" class="act-gng-btn" type="button"><i class="far fa-thumbs-up display-block"></i><strong class="text-teal"><?php echo number_format($view['wr_good']); ?></strong><div class="mask"><h5>추천</h5></div></a>
                    <b id="bo_v_act_good"></b>
                </span>
                <?php } ?>
                <?php if ($nogood_href) { ?>
                <span class="board-view-act-gng">
                    <a href="<?php echo $nogood_href.'&'.$qstr ?>" id="nogood_button" class="act-gng-btn" type="button"><i class="far fa-thumbs-down display-block"></i><strong class="text-pink"><?php echo number_format($view['wr_nogood']); ?></strong><div class="mask"><h5>비추천</h5></div></a>
                    <b id="bo_v_act_nogood"></b>
                </span>
                <?php } ?>
            </div>
        </div>
        <?php } else {
            if($board['bo_use_good'] || $board['bo_use_nogood']) {
        ?>
        <div class="board-view-good-btn">
            <div class="m-b-10">
                <?php if ($board['bo_use_good']) { ?>
                <span class="board-view-act-gng">
                    <span class="act-gng-btn disabled"><i class="far fa-thumbs-up display-block"></i><strong class="text-teal"><?php echo number_format($view['wr_good']); ?></strong></span>
                </span>
                <?php } ?>
                <?php if ($board['bo_use_nogood']) { ?>
                <span class="board-view-act-gng">
                    <span class="act-gng-btn disabled"><i class="far fa-thumbs-down display-block"></i><strong class="text-pink"><?php echo number_format($view['wr_nogood']); ?></strong></span>
                </span>
                <?php } ?>
            </div>
        </div>
        <?php
            }
        }
        ?>
        <?php /* 추천 비추천 끝 */?>

    </div>

<!--  -->
            <div class="info-box-bottom" style="float:right;">
                <span><?php echo date("y-m-d H:i", strtotime($view['wr_datetime'])) ?></span>
                <span><i class="far fa-eye"></i><?php echo number_format($view['wr_hit']); ?></span>
                <span><i class="far fa-comment-dots"></i><strong class="text-deep-orange"><?php echo number_format($view['wr_comment']); ?></strong></span>
                <?php if ($is_good) { ?>
                <span><i class="far fa-thumbs-up"></i><strong class="text-teal"><?php echo number_format($view['wr_good']); ?></strong></span>
                <?php } ?>
                <?php if ($is_nogood ) { ?>
                <span><i class="far fa-thumbs-down"></i><strong class="text-pink"><?php echo number_format($view['wr_nogood']); ?></strong></span>
                <?php } ?>
            </div>
        </div>
    </div>
        <?php /* 본문 내용 끝 */?>

    <?php /* 댓글 시작 */?>
    <?php include_once(G5_BBS_PATH . '/view_comment.php'); ?>
    <?php /* 댓글 끝 */?>
</article>

<script>
<?php if ($board['bo_download_point'] < 0) { ?>
$(function() {
    $("a.view_file_download").click(function() {
        if(!g5_is_member) {
            alert("다운로드 권한이 없습니다.\n회원이시라면 로그인 후 이용해 보십시오.");
            return false;
        }

        var msg = "파일을 다운로드 하시면 포인트가 차감(<?php echo number_format($board['bo_download_point']) ?>점)됩니다.\n\n포인트는 게시물당 한번만 차감되며 다음에 다시 다운로드 하셔도 중복하여 차감하지 않습니다.\n\n그래도 다운로드 하시겠습니까?";

        if(confirm(msg)) {
            var href = $(this).attr("href")+"&js=on";
            $(this).attr("href", href);

            return true;
        } else {
            return false;
        }
    });
});
<?php } ?>

function board_move(href)
{
    window.open(href, "boardmove", "left=50, top=50, width=500, height=550, scrollbars=1");
}
</script>

<script>
$(function() {
    $("a.view_image").click(function() {
        window.open(this.href, "large_image", "location=yes,links=no,toolbar=no,top=10,left=10,width=10,height=10,resizable=yes,scrollbars=no,status=no");
        return false;
    });

    // 추천, 비추천
    $("#good_button, #nogood_button").click(function() {
        var $tx;
        if(this.id == "good_button")
            $tx = $("#bo_v_act_good");
        else
            $tx = $("#bo_v_act_nogood");

        excute_good(this.href, $(this), $tx);
        return false;
    });

    // 이미지 리사이즈
    $("#bo_v_atc").viewimageresize();
});

function excute_good(href, $el, $tx)
{
    $.post(
        href,
        { js: "on" },
        function(data) {
            if(data.error) {
                alert(data.error);
                return false;
            }

            if(data.count) {
                $el.find("strong").text(number_format(String(data.count)));
                if($tx.attr("id").search("nogood") > -1) {
                    $tx.text("이 글을 비추천하셨습니다.");
                    $tx.fadeIn(200).delay(2500).fadeOut(200);
                } else {
                    $tx.text("이 글을 추천하셨습니다.");
                    $tx.fadeIn(200).delay(2500).fadeOut(200);
                }
            }
        }, "json"
    );
}
</script>

이 질문에 댓글 쓰기 :

답변 4

위 코드에서 수정하는 것이 아니라 view.php에서 

 $good_href / $nogood_href 링크를 회원만 가능하게 되어있는 것을 수정해야 합니다

이것을 수정해도 good.php에서 비회원은 처리 안되게한 부분을 수정해야 하고

아이디 대신 비회원은 아이피를 등록하든지 무언가 구분자를 넣어야 계속해서 누르는 것을

막을 수 있습니다

 

스크립트 부분을 다음과 같이 수정하시면 되지 않을까 합니다.


$(function() {
    $("a.view_image").click(function() {
        window.open(this.href, "large_image", "location=yes,links=no,toolbar=no,top=10,left=10,width=10,height=10,resizable=yes,scrollbars=no,status=no");
        return false;
    });
    // 추천, 비추천
    $("#good_button, #nogood_button").click(function() {
        var $tx;
        if(this.id == "good_button")
            $tx = $("#bo_v_act_good");
        else
            $tx = $("#bo_v_act_nogood");
        excute_good(this.href, $(this), $tx);
        return false;
    });
    // 비회원도 좋아요 버튼을 클릭할 수 있도록 함
    $(".act-gng-btn").click(function() {
        var href = $(this).attr("href") + '&js=on';
        $(this).attr("href", href);
        // 좋아요 버튼 클릭을 처리하는 기존 함수 호출
        var $tx;
        if(this.id == "good_button")
            $tx = $("#bo_v_act_good");
        else
            $tx = $("#bo_v_act_nogood");
        excute_good(href, $(this), $tx);
        return false;
    });
    // 이미지 리사이즈
    $("#bo_v_atc").viewimageresize();
});
function excute_good(href, $el, $tx) {
    $.post(
        href,
        { js: "on" },
        function(data) {
            if(data.error) {
                alert(data.error);
                return false;
            }
            if(data.count) {
                $el.find("strong").text(number_format(String(data.count)));
                if($tx.attr("id").search("nogood") > -1) {
                    $tx.text("이 글을 비추천하셨습니다.");
                    $tx.fadeIn(200).delay(2500).fadeOut(200);
                } else {
                    $tx.text("이 글을 추천하셨습니다.");
                    $tx.fadeIn(200).delay(2500).fadeOut(200);
                }
            }
        }, "json"
    );
}

다음과 같이 해보시겠어요


$(function() {
    $("a.view_image").click(function() {
        window.open(this.href, "large_image", "location=yes,links=no,toolbar=no,top=10,left=10,width=10,height=10,resizable=yes,scrollbars=no,status=no");
        return false;
    });

    // 추천, 비추천
    $("#good_button, #nogood_button").click(function() {
        var $tx;
        if (this.id == "good_button")
            $tx = $("#bo_v_act_good");
        else
            $tx = $("#bo_v_act_nogood");

        excute_good(this.href, $(this), $tx);
        return false;
    });

    // 비회원도 좋아요 버튼을 클릭할 수 있도록 함
    $(".act-gng-btn").click(function() {
        var href = $(this).attr("href") + '&js=on';
        $(this).attr("href", href);

        // 좋아요 버튼 클릭을 처리하는 기존 함수 호출
        var $tx;
        if (this.id == "good_button")
            $tx = $("#bo_v_act_good");
        else
            $tx = $("#bo_v_act_nogood");

        excute_good(href, $(this), $tx);
        return false;
    });

    // 이미지 리사이즈
    $("#bo_v_atc").viewimageresize();
});

function excute_good(href, $el, $tx) {
    $.post(
        href,
        { js: "on" },
        function(data) {
            if (data.error) {
                alert(data.error);
                return false;
            }

            if (data.count !== undefined) {
                $el.find("strong").text(number_format(String(data.count)));
                if ($tx.attr("id").search("nogood") > -1) {
                    $tx.text("이 글을 비추천하셨습니다.");
                    $tx.fadeIn(200).delay(2500).fadeOut(200);
                } else {
                    $tx.text("이 글을 추천하셨습니다.");
                    $tx.fadeIn(200).delay(2500).fadeOut(200);
                }
            }
        }, "json"
    );
}

이것두 안됩니다.... 감사합니다

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

회원로그인

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