고수님들 질문드립니다 게시판 링크걸고 걸린링크 클릭시 이동하게 할수잇나요

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
고수님들 질문드립니다 게시판 링크걸고 걸린링크 클릭시 이동하게 할수잇나요

QA

고수님들 질문드립니다 게시판 링크걸고 걸린링크 클릭시 이동하게 할수잇나요

본문

특정 게시판  글작성시  제목에 예를들어 네이버-https://naver.com 작성하고 네이버 클릭하면 바로 네이버로 넘어갈수 잇는 링크 게시판 만들수 잇을가요 ? 만약 가능하다면 아래 게시판 코드에서 어디부분 수정하면 될가요

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

// 선택옵션으로 인해 셀합치기가 가변적으로 변함
$colspan = 5;

if ($is_checkbox) $colspan++;
if ($is_good) $colspan++;
if ($is_nogood) $colspan++;

// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.css">', 0);
?>

<? //방지
if($re){
    $re_row = sql_fetch(" select * from g5_write_{$bo_table} where wr_id = '{$re}' ");

    $re1 = strtotime(date('Y-m-d H:i:s')); //현재 시간
    $re2 = strtotime('+3 hours',strtotime($re_row['wr_datetime'])); //등록된 시간 + 3 hours
    
    if($re_row['wr_datetime']){
        if($re1 > $re2){
            sql_query(" update g5_write_{$bo_table} set wr_datetime = '".G5_TIME_YMDHIS."', wr_hit = '0' where wr_id = '{$re}' ");
            sql_query(" update g5_board_new set bn_datetime = '".G5_TIME_YMDHIS."' where wr_id = '{$re}' and bo_table = '{$bo_table}' ");
            alert($lang['list_re_text']); 
        }else{
            alert('Eroor'); 
        }
    }
}
?>
        
<!-- 게시판 목록 시작 { -->
<div id="bo_list" style="width:<?php echo $width; ?>">

    <form name="fboardlist" id="fboardlist" action="./board_list_update.php" onsubmit="return fboardlist_submit(this);" method="post">
    <input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
    <input type="hidden" name="sfl" value="<?php echo $sfl ?>">
    <input type="hidden" name="stx" value="<?php echo $stx ?>">
    <input type="hidden" name="spt" value="<?php echo $spt ?>">
    <input type="hidden" name="sca" value="<?php echo $sca ?>">
    <input type="hidden" name="sst" value="<?php echo $sst ?>">
    <input type="hidden" name="sod" value="<?php echo $sod ?>">
    <input type="hidden" name="page" value="<?php echo $page ?>">
    <input type="hidden" name="sw" value="">

    <div class="tbl_head01 tbl_wrap">
        <table>
        <caption><?php echo $board['bo_subject'] ?> 목록</caption>

        <thead>
        <tr>
            <?php if ($is_checkbox) { ?>
            <th scope="col">
                <label for="chkall" class="sound_only">현재 페이지 게시물 전체</label>
                <input type="checkbox" id="chkall" onclick="if (this.checked) all_checked(true); else all_checked(false);">
            </th>
            <?php } ?>
            <th scope="col"><?=$lang['bd_th1']?></th>
            <th scope="col"><?=$lang['bd_th2']?></th>
            <th scope="col"><?=$lang['bd_th3']?></th>
            <?php if ($is_good) { ?><th scope="col"><?php echo subject_sort_link('wr_good', $qstr2, 1) ?>추천 <i class="fa fa-sort" aria-hidden="true"></i></a></th><?php } ?>
            <?php if ($is_nogood) { ?><th scope="col"><?php echo subject_sort_link('wr_nogood', $qstr2, 1) ?>비추천 <i class="fa fa-sort" aria-hidden="true"></i></a></th><?php } ?>
            <th scope="col"><?=$lang['bd_th4']?></th>
        </tr>
        </thead>

        <tbody>
        <?php
        for ($i=0; $i<count($list); $i++) {
        ?>
        <tr class="<?php if ($list[$i]['is_notice']) echo "bo_notice"; ?>">
            <?php if ($is_checkbox) { ?>
            <td class="td_chk">
                <label for="chk_wr_id_<?php echo $i ?>" class="sound_only"><?php echo $list[$i]['subject'] ?></label>
                <input type="checkbox" name="chk_wr_id[]" value="<?php echo $list[$i]['wr_id'] ?>" id="chk_wr_id_<?php echo $i ?>">
            </td>
            <?php } ?>
            <td class="td_datetime">
                <? //지역
                $code1 = explode("|",$lang['rgn_code']); //대응된 코드
                $ctxt1 = explode("|",$lang['rgn_list']); //선택된 언어로 대체
                
                for($y=0;$y<count($code1);$y++){
                    
                    if($list[$i]['wr_1'] == $code1[$y]){
                        echo $ctxt1[$y];
                    }
                    
                }
                ?>
            </td>
            <td class="td_subject" style="padding-left:<?php echo $list[$i]['reply'] ? (strlen($list[$i]['wr_reply'])*10) : '0'; ?>px">
                <div class="bo_tit">
                    <? if ($wr_id == $list[$i]['wr_id']) echo "<span class=\"bo_current\">".$lang['list_read']."</span>"; ?>
                    <? if ($list[$i]['is_notice']){ ?>
                        <? echo '<strong class="notice_icon">['.$lang['write_notice'].']</strong>'; ?>
                    <? }else{ ?>
                        <? if ($list[$i]['mb_id'] == $member['mb_id']){ ?>
                            <? 
                            $ty1 = strtotime(date('Y-m-d H:i:s')); //현재 시간
                            $ty2 = strtotime('+3 hours',strtotime($list[$i]['wr_datetime'])); //등록된 시간 + 3 hours
                            
                            $ty = $ty2 - $ty1; //시간차
                            //echo $ty;
                            
                            $th_hourse = intval(abs($ty)/3600); //나머지 시간
                            $th_minute = intval(abs($ty)%3600/60); //나머지 분

                            if($ty1 > $ty2){ 
                            ?>
                            <a href="<?=$_SERVER['REQUEST_URI']?>&re=<?=$list[$i]['wr_id']?>" class="re_load">[<?=$lang['list_re']?>]</a>
                            <? }else{ ?>
                            <a href="javascript:;" onclick="alert('<?=$lang['list_re_alt'].$th_hourse.$lang['list_re_alt_text1'].$th_minute.$lang['list_re_alt_text2']?> ')" class="re_load">[<?=$lang['list_re']?>]</a>
                            <? } ?>
                        <? } ?>
                    <? } ?>
                    <a href="<?php echo $list[$i]['href'] ?>">
                        <?php echo $list[$i]['icon_reply'] ?>
                        <?php
                            if (isset($list[$i]['icon_secret'])) echo rtrim($list[$i]['icon_secret']);
                         ?>
                        <?php echo $list[$i]['subject'].$list[$i]['is_notice']; ?>
                       
                    </a>
                    <?php
                    // if ($list[$i]['file']['count']) { echo '<'.$list[$i]['file']['count'].'>'; }
                    if (isset($list[$i]['icon_new'])) echo rtrim($list[$i]['icon_new']);
                    if (isset($list[$i]['icon_hot'])) echo rtrim($list[$i]['icon_hot']);
                    ?>
                </div>
            </td>
            <td class="td_datetime">
                <? //분류
                $code2 = explode("|",$lang['cate_code']); //대응된 코드
                $ctxt2 = explode("|",$lang['cate_list']); //선택된 언어로 대체
                
                for($y=0;$y<count($code2);$y++){
                    
                    if($list[$i]['ca_name'] == $code2[$y]){
                        echo $ctxt2[$y];
                    }
                    
                }
                ?>
            </td>
            <?php if ($is_good) { ?><td class="td_num"><?php echo $list[$i]['wr_good'] ?></td><?php } ?>
            <?php if ($is_nogood) { ?><td class="td_num"><?php echo $list[$i]['wr_nogood'] ?></td><?php } ?>
            <td class="td_datetime"><?php echo substr($list[$i]['wr_datetime'],0,10) ?></td>
        </tr>
        <?php } ?>
        <?php if (count($list) == 0) { echo '<tr><td colspan="'.$colspan.'" class="empty_table">'.$lang['list_search'].'</td></tr>'; } ?>
        </tbody>
        </table>
    </div>

    <?php if ($list_href || $is_checkbox || $write_href) { ?>
    <div class="bo_fx">
        <?php if ($list_href || $write_href) { ?>
        <ul class="btn_bo_user">
            <?php if ($is_checkbox) { ?>
            <li><button type="submit" name="btn_submit" value="선택삭제" onclick="document.pressed=this.value" class="btn btn_admin"><i class="fa fa-trash-o" aria-hidden="true"></i> <?=$lang['list_choice_del']?></button></li>
            <?php } ?>
            <?php if ($list_href) { ?><li><a href="<?php echo $list_href ?>" class="btn_b01 btn"><i class="fa fa-list" aria-hidden="true"></i> <?=$lang['list_home']?></a></li><?php } ?>
        </ul>
        <?php } ?>
    </div>
    <?php } ?>

    </form>
</div>

<?php if($is_checkbox) { ?>
<noscript>
<p>자바스크립트를 사용하지 않는 경우<br>별도의 확인 절차 없이 바로 선택삭제 처리하므로 주의하시기 바랍니다.</p>
</noscript>
<?php } ?>

<!-- 페이지 -->
<?php echo $write_pages;  ?>


<?php if ($is_checkbox) { ?>
<script>
function all_checked(sw) {
    var f = document.fboardlist;

    for (var i=0; i<f.length; i++) {
        if (f.elements[i].name == "chk_wr_id[]")
            f.elements[i].checked = sw;
    }
}

function fboardlist_submit(f) {
    var chk_count = 0;

    for (var i=0; i<f.length; i++) {
        if (f.elements[i].name == "chk_wr_id[]" && f.elements[i].checked)
            chk_count++;
    }

    if (!chk_count) {
        alert("<?=$lang['list_choice_text']?>");
        return false;
    }

    if(document.pressed == "선택삭제") {
        if (!confirm("<?=$lang['list_choice_del_text']?>"))
            return false;

        f.removeAttribute("target");
        f.action = "./board_list_update.php";
    }

    return true;
}
</script>
<?php } ?>
<!-- } 게시판 목록 끝 -->

이 질문에 댓글 쓰기 :

답변 3

제목에 홈페이지 주소가 있다고 가정하고 아래의 코드를 참고해서 보세요..
본문 내용이든 뭐든 정규식으로 하면 모두 적용 가능 합니다.
http와 https모두 작동 되게 했습니다.

클래스 명을 넣어서 다양하게 css 를 조정 하고 효과를 줄 수 있습니다.


$view['wr_subject'] = "네이버와 다음에 방문해 보세요 https://www.naver.com http://www.daum.net";
$view['wr_subject'] = preg_replace("/(https?:\/\/[^\s]+)/", '<a href="$1" class="클래스명" target="_blank">$1</a>', $view['wr_subject']);
echo $view['wr_subject'];

등록시
if(strpos($_REQUEST['subject'], "http://") !== false){

    $chk_subject = explode("http://", $_REQUEST['subject']);

    $subject_link = "//".$chk_subject[1];

}

if(strpos($_REQUEST['subject'], "https://") !== false){

    $chk_subject = explode("https://", $_REQUEST['subject']);

    $subject_link = "//".$chk_subject[1];

}

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

회원로그인

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