(함수버전)코멘트가 특정시간 이내에 작성된것 체크해보자 > 그누3 팁자료실

그누3 팁자료실

(함수버전)코멘트가 특정시간 이내에 작성된것 체크해보자 정보

그누호환 (함수버전)코멘트가 특정시간 이내에 작성된것 체크해보자

본문

최신글과 리스트에서 코멘트가 특정시간 이전에 작성된것일 경우 다르게 표시하기.
이버젼은 그누보드가 패치될때마다 수정하셔야 되는것입니다.

1. lib/developer.lib.php에 함수를 만들어 놓고 사용하고자 할경우
  다음 내용을 lib/developer.lib.php에 추가한다.
 
    // 코멘트일경우 이것이 지정된 시간내인지 체크하는 루틴
function get_comment_time($hours,$bo_table,$wrid, $wrcommentcnt)

    global $cfg;

    $sql2 = " select (unix_timestamp(now()) - unix_timestamp(wr_datetime))/(60*60*$hours)
                from {$cfg[write_table_prefix]}{$bo_table}
                where wr_parent_id = $wrid
                  and wr_comment = $wrcommentcnt
                  and wr_commentcnt = 0 ";
    $result2 = sql_fetch($sql2);
   
    if($result2[0] < 1) {  // $hours 시간전에 올라온글
        return true;
    } else {
        return false;
    }         
}

2. 최신글에서 적용하기..(그누보드가 패치되면 수정해야함)
    수정파일 : lib/latest.lib.php
    수정전 :
        // 코멘트 카운트
        $list[$i][commentcnt] = "";
        if ($row[wr_commentcnt] > 0) {
            $list[$i][commentcnt] = "($row[wr_commentcnt])";
        }
    수정후 :
        // 코멘트 카운트
        $list[$i][commentcnt] = "";
        if ($row[wr_commentcnt] > 0) {
    $tcheck = get_comment_time(24,$bo_table,$row[wr_id],$row[wr_commentcnt]);
            if($tcheck) {
                $list[$i][commentcnt] = "<font color=blue>($row[wr_commentcnt])</font>";
            } else {
                $list[$i][commentcnt] = "($row[wr_commentcnt])";
            }

            //$list[$i][commentcnt] = "($row[wr_commentcnt])"; // 원본 주석처리
        }

3. 게시판에 적용하기..(그누보드가 패치되면 수정해야함)
    수정파일 : bbs/gblist.php
    수정전 :
$list[$i][commentcnt] = "";
if ($row[wr_commentcnt]) {
    $list[$i][commentcnt] = "($row[wr_commentcnt])";
}     
수정후 :
$list[$i][commentcnt] = "";
if ($row[wr_commentcnt]) {
    $tcheck = get_comment_time(24,$bo_table,$row[wr_id],$row[wr_commentcnt]);
                    if($tcheck) {
                        $list[$i][commentcnt] = "<font color=blue>($row[wr_commentcnt])</font>";
                    } else {
                        $list[$i][commentcnt] = "($row[wr_commentcnt])";
                    }

    //$list[$i][commentcnt] = "($row[wr_commentcnt])"; // 원본 주석처리
}

ps. 2,3에서 get_comment_time(24,$bo_table,$row[wr_id],$row[wr_commentcnt]) 호출시 24라는것이 있는데
    이것이 시간설정임, 만약 12시간으로 하고싶으면 12로 수정하면됨.
추천
0

댓글 전체

전체 80
그누3 팁자료실 내용 검색

회원로그인

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