제로보드 관련된 유용한 정보를 공유하는 곳입니다.
  • 웹미니 한줄 전광판 영역 입니다.
글 수 98
출처 :  
http://www.nzeo.com/bbs/zboard.php?id=cgi_tip&page=1&sn1=&divpage=1&sn=off&ss=on&sc=off&keyword=코멘트&select_arrange=headnum&desc=asc&no=6006자신이 올린 글에 달린 댓글(코멘트)만 모아보자......

        강좌나 커뮤니티 또는 NZEO의 '유용한 팁 공유 게시판'과 같은 성격의 게시판을 운영하는 경우
        자기가 올린 글에 달린 댓글에 답변을 빈번하게 달아야 하는 경우가 발생하거나,
        오래전에 올렸던 글에 대한 댓글이 올라 왔을때 너무 오래전에 올려서 미처 확인이 않되는 경우가 발생하게 되는데,
        이때 자신이 올린 글에 최근에 달린 댓글만 모아놓은 페이지가 있거나,
        댓글이 달리면 알려주는 기능이 필요하다고 생각했습니다.


1. 먼저, schema.sql 을 수정해야합니다.

        277번 라인 이하에 있는 다음 내용 중에,
        
/////////////////////////////////////////////////////////////////////////////////
// 간단한 답글 테이블
/////////////////////////////////////////////////////////////////////////////////

$board_comment_schema ="

  create table zetyx_board_comment_$table_name (
    no int(11) default '0' not null auto_increment primary key ,
    parent int(11) not null,
    ismember int(20) default '0' not null,
    name char(20),
    password char(20),
    memo text,
    ip char(15),
    reg_date int(13),

    KEY parent (parent)
  )

";


위 내용 중에 있는
        

         reg_date int(13),

    KEY parent (parent)


사이(292번째 줄)에

    p_member int(20) default '0' not null,

를 삽입합니다.

----------------------------------------------------------------------------------

2. 다음으로 기존에 사용하던 게시판이 있다면,
        (처음 install한다면 2번내용은 건너뛰어도 됩니다.)

2-1.        먼저,  DB를 약간 손봐야 합니다.
        아래와 같은 내용으로 add_field.php 라는 파일을 만들고  bbs/  디렉토리에 ftp를 이용해 올립니다.
        그리고, 최고관리자로 로그인한 후 add_field.php를 실행합니다.
        물론 그전에 DB를 Backup하는것은 기본이겠죠....

<?
include "lib.php";

$connect=dbConn();
$member=member_info();

if(!$member[no]) Error("먼저 최고관리자로 로그인하시기 바랍니다.");
if($member[is_admin]!=1) error("최고관리자만이 설치할 수 있습니다.");

echo "<center><font style=font-size:9pt>";

$result = @mysql_query("SELECT name FROM $admin_table");
while(@extract(mysql_fetch_array($result))) {
        @mysql_query("ALTER TABLE zetyx_board_comment"."_$name ADD `p_member` INT(20) DEFAULT '0' NOT NULL",$connect);
        echo "mysql/$t_board_comment"."_$name 테이블이 정상적으로 변환되었습니다.<br>";
        @flush();
}

echo "</center>";
@flush();
?>

        
2-2.다음으로 위에서 추가된 'p_member' field에 코멘트가 누구의 글에 달린것인지를 확인할 수 있는 원본글쓴이의 회원번호를 update해줘야 합니다.
        위에서와 마찬가지로 아래에 있는 내용으로 update_p_member.php 라는 파일을 만들고   bbs/  디렉토리에 ftp를 이용해 올립니다.
        그리고, 최고관리자로 로그인한 후 update_p_member.php를 실행합니다.

<?
include "lib.php";

$connect=dbConn();
$member=member_info();

if(!$member[no]) Error("먼저 최고관리자로 로그인하시기 바랍니다.");
if($member[is_admin]!=1) error("최고관리자만이 설치할 수 있습니다.");

echo "<center><font style=font-size:9pt>";
$result = @mysql_query("SELECT name FROM $admin_table");
while(@extract(mysql_fetch_array($result))) {
        $result_com = @mysql_query("select no,parent from zetyx_board_comment_".$name." where p_member='0' ",$connect);
        while(@extract(mysql_fetch_array($result_com))) {
                $result_board = @mysql_query("select ismember from zetyx_board_"."$name where no=$parent",$connect);
                @extract(mysql_fetch_array($result_board));
                @mysql_query("update zetyx_board_comment_"."$name set p_member=$ismember where no='$no'",$connect) or error(mysql_error());
                echo "name:".$name."-no:".$no."-parent:".$parent."-ismember:".$ismember."<br>";
        @flush();
        }
        echo "mysql/$t_board_comment"."_$name 테이블이 정상적으로 변환되었습니다.<br>";
        @flush();
}
echo "</center>";
@flush();
?>

------------------------------------------------------------------------------


3.         comment_ok.php 파일의 92번째줄에 있는 아래 내용을 수정합니다..

        [수정 전]

// 해당글이 있는 지를 검사
        $check = mysql_fetch_array(mysql_query("select count(*) from $t_board"."_$id where no = '$no'", $connect));
        if(!$check[0]) Error("원본 글이 존재하지 않습니다.");

// 코멘트 입력
        mysql_query("insert into $t_comment"."_$id (parent,ismember,name,password,memo,reg_date,ip) values ('$parent','$member[no]','$name','$password','$memo','$reg_date','$REMOTE_ADDR')") or error(mysql_error());


        [수정 후]

// 해당글이 있는 지를 검사
        $check = mysql_fetch_array(mysql_query("select ismember from $t_board"."_$id where no = '$no'", $connect));
        if(!$check[0])        {
                Error("원본 글이 존재하지 않습니다.");
        } else {
                $p_member = $check[0];         //원본글 쓴사람 회원번호를 불러온다.
        }

// 코멘트 입력
        mysql_query("insert into $t_comment"."_$id (parent,ismember,name,password,memo,reg_date,ip,p_member) values ('$parent','$member[no]','$name','$password','$memo','$reg_date','$REMOTE_ADDR','$p_member')") or error(mysql_error());


------------------------------------------------------------------------------



4. 마지막으로 이제는 자기글에 달린 댓글을 모으는 일만 남았습니다.



<?
        $_zb_url = "제로보드가 설치된 url/";
        $_zb_path = "제로보드가 설치된 절대경로/";
        include $_zb_path."outlogin.php";

        // 회원레벨에 맞추어 조회권한을 준다         (10등급은 조회불가)
        if ($member[level] > 9)         echo"<script>alert('죄송합니다!\n\n로그인 후 사용이 가능합니다.');history.back();</script>";

        $memo_on_sound;

        $p_member = $member[no];

// Function Recent Comment        
function recent_cmt($num, $textlen, $datetype="Y-m-d H:i") {
        global $_zb_url, $connect, $t_board, $t_comment, $mb_id, $mb_conf, $p_member;

//         수정할 부분         #########################################################
//         예,         $list = array("id1"=>"게시판 제목1", "id2"=>"게시판 제목2", "id3"=>"게시판 제목3", --------);                        
//         여기서 id1,id2,id3,---은 아래에 지정한 게시판id와 같게 해야함.
//         ##################################################################

        $list=array("        "=>"        ","        "=>"        ");                //         빈곳에 직접입력

//         ###################################################################


  // get and set variable
        $id = $mb_id; // get IDs
        $cutTimeMode = $mb_conf[timemode]; // get time mode
        $tc = 0; //Total Counts

  // timeMode (1: in 24 hours; 2: today; 3: week;)
        if($cutTimeMode == 1){
                $cut_time = time() - 3600 * 24;   // 24hours
        }else if($cutTimeMode == 2){
                $cut_time = mktime(0,0,0,date("m"),date("d"),date("Y")); // today
        }else if($cutTimeMode == 3){
                $cut_time = time() - 3600 * 24*7;   // 7days
        }else{
                $cut_time = 0; // normal
        }  

        // get values from database
        for( $i = 0; $i < sizeof($id); $i++){
          // get memo data
                $query = "select * from ".$t_comment."_".$id[$i]." where p_member=".$p_member." and reg_date > $cut_time order by no desc limit $num";
                $result = mysql_query($query, $connect) or die(mysql_error());

                while($data=mysql_fetch_array($result)){
                  // memo data
                        $cmt[$tc][no]      = $data[no];
                        $cmt[$tc][name]    = stripslashes($data[name]);
                        $cmt[$tc][parent]  = $data[parent];
                        $cmt[$tc][date]    = date($datetype, $data[reg_date]);
                        $cmt[$tc][reg_date] = $data[reg_date];
                        $cmt[$tc][memo]     = cut_str(stripslashes($data[memo]), $textlen);

                  // get parent data
                        $p_data = mysql_fetch_array(mysql_query("select * from $t_board"."_$id[$i] where no='$data[parent]'"));
                        $cmt[$tc][p_clinic] = $list[$id[$i]];
                        $cmt[$tc][p_subject] = cut_str(stripslashes($p_data[subject]), 100);
                        $cmt[$tc][p_name]    = stripslashes($p_data[name]);
                        $cmt[$tc][p_date]    = date($datetype, $p_data[reg_date]);
                        $cmt[$tc][p_target]  = $_zb_url."view.php?id=".$id[$i]."&no=".$p_data[no];

                  // ready for sorting
                        $tm[$tc] = $data[reg_date]."_$tc";
                        $map[$data[reg_date]."_$tc"] = $tc;

                        $tc++;
                }
        }

        // sort by time
        if($tc)  sort($tm);

        // output
        $tmp1 = time() - 3600 * 24;
        $tmp2 = time() - 3600 * 24 * 3;

        for($i = sizeof($tm)-1; $i >= sizeof($tm)-$num && $i >= 0; $i--){
                $n = $map[$tm[$i]];
                if($cmt[$n][reg_date] > $tmp1){
                        $tmpcolor = "#CC0033";
                }else if($cmt[$n][reg_date] > $tmp2){
                        $tmpcolor = "blue";
                }else{
                        $tmpcolor = "green";
                }

                print "<table width=700>n";
                print "<tr>n";
                print "        <td colspan=2>[".$cmt[$n][p_clinic]."] <a href=".$cmt[$n][p_target]." title='본문으로 바로 이동'><font color=#6699CC><b>".$cmt[$n][p_subject]."</b></font></a><font color=#6699CC> ...".$cmt[$n][p_date]."</font></td>n";
                print "</tr>n";
                print        "<tr>n";
                print        "        <td width=20> </td>n";
                print        "        <td width=680 align=left><font color=$tmpcolor>(<b>".$cmt[$n][name]."</b>)</font> ".$cmt[$n][memo]." <font color=$tmpcolor>(".$cmt[$n][date].")</font></td>n";
                print        "</tr>n";
                print        "</table>nn";        
                
                if($tc) echo"<table width=95% border=0 cellspcing=0 cellpadding=0 align=center><tr height=1><td bgcolor=#E0E0E0></td></tr></table>";
        }
}

?>







<?
        //         이부분을 수정한다.
        //         댓글을 불러올 게시판 id를 넣어준다
    $mb_id = array("id1", "id2", "id3", ------ );
    $mb_conf[timemode] = 0; // 1: 24시간이내,    2: 오늘 0시부터 올라온 코멘트,  3: 7일 이내,    0: 노말

        recent_cmt(10,200);                //         불러올 함수(댓글수,글자수)

?>



위의 내용을 적당히 편집하여 불러오면 되겠죠.

profile 글쓴이 빽짱구

단점이 없는 사람은 장점도 거의 없다 - 에이브러햄 링컨

엮인글 :
https://web.webmini.net/zb4/17393/e70/trackback
소중한 댓글 부탁드립니다.
추천수 10단위당 메달이 1개씩 노출되고, 추천수에 따라 배경색이 변하며, 일정수의 추천수를 받을시 BEST 아이콘이 붙게됩니다.
추천수에 따른 배경색 보기 본문으로 바로가기
  • 추천수 50개이상
  • 추천수 30개이상
  • 추천수 20개이상
  • 추천수 10개이상
  • 추천수 3개이상
닫기

첫번째 댓글을 남겨주세요!

List of Articles
번호 제목 글쓴이 날짜 추천 수sort 조회 수
38 최근게시물 추출시 비밀글 보이게 하기 , 답글 안보이게 하기 title: [ani]깜빡이는 표정빽짱구 2004-04-10 16 3443
37 가입약관 넣기 [2] title: [ani]깜빡이는 표정빽짱구 2004-02-23 16 2294
36 게시판타이틀메뉴 자동 생성 + 카테고리--->이미지로 바꿀수 있음. title: [ani]깜빡이는 표정빽짱구 2006-06-22 15 7088
35 실시간 쪽지함띄우기 title: [ani]깜빡이는 표정빽짱구 2005-03-09 15 3273
34 오늘 올라온 게시물 갯수 등... title: [ani]깜빡이는 표정빽짱구 2004-10-24 15 2210
33 코멘트 달린글 삭제 못하게 하기 title: [ani]깜빡이는 표정빽짱구 2004-07-12 15 2793
32 자료 다운받을시 그자료 올린사람에게 포인트 주기 title: [ani]깜빡이는 표정빽짱구 2004-04-20 15 2275
31 개인정보수정시 이미지 네임 추가하기 title: [ani]깜빡이는 표정빽짱구 2004-02-23 15 2606
30 가입약관 넣기 다른방법 (가입약관 먼저 보여주기) [1] title: [ani]깜빡이는 표정빽짱구 2004-02-23 15 2632
29 로그인 풀림과 로그아웃 잘안되는 문제 title: [ani]깜빡이는 표정빽짱구 2005-12-04 14 5011
28 게시판 생성시 오류메세지 title: [ani]깜빡이는 표정빽짱구 2004-07-08 14 3936
27 서브 레이어에서 홈페이지 링크에 %2f 가 붙는 문제 title: [ani]깜빡이는 표정빽짱구 2004-05-28 14 2404
26 유료회원만 글 볼수있게 하자. title: [ani]깜빡이는 표정빽짱구 2004-05-05 14 2355
25 로그인이나 최근게시물 맨위에 5줄 다른팁 title: [ani]깜빡이는 표정빽짱구 2004-04-20 14 2287
24 제로보드, 쪽지오면 자동쪽지함 띄우기 title: [ani]깜빡이는 표정빽짱구 2004-03-07 14 5089
23 게시물 읽은 사람들 리스트 보여주기 [1] title: [ani]깜빡이는 표정빽짱구 2004-10-24 13 3292
22 쪽지보낼때 경고메세지 띄우기 title: [ani]깜빡이는 표정빽짱구 2004-05-29 13 2233
21 방명록 최근게시물 추출하기 [2] title: [ani]깜빡이는 표정빽짱구 2004-05-26 13 3253
20 게시물 읽은회원 리스트 출력하기 title: [ani]깜빡이는 표정빽짱구 2004-04-12 13 3428
19 코맨트에 링크주소시 target=_blank> 해결하기 title: [ani]깜빡이는 표정빽짱구 2004-04-11 13 3113