r

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

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

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로 수정하면됨.
|
댓글을 작성하시려면 로그인이 필요합니다.

그누3 팁자료실

+
제목 글쓴이 날짜 조회
22년 전 조회 1,735
22년 전 조회 1,716
22년 전 조회 6,078
MMando
22년 전 조회 2,959
22년 전 조회 1,759
22년 전 조회 1,661
22년 전 조회 1,463
22년 전 조회 3,000
22년 전 조회 1,933
22년 전 조회 1,591
22년 전 조회 1,808
22년 전 조회 1,639
22년 전 조회 1,539
22년 전 조회 2,384
22년 전 조회 1,987
22년 전 조회 5,304
&&nbsp;&nbsp;
22년 전 조회 1,964
&&nbsp;&nbsp;
22년 전 조회 1,991
&&nbsp;&nbsp;
22년 전 조회 1,739
22년 전 조회 3,194