제로보드 관련된 유용한 정보를 공유하는 곳입니다.
  • 웹미니 한줄 전광판 영역 입니다.
글 수 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/bf5/trackback
소중한 댓글 부탁드립니다.
추천수 10단위당 메달이 1개씩 노출되고, 추천수에 따라 배경색이 변하며, 일정수의 추천수를 받을시 BEST 아이콘이 붙게됩니다.
추천수에 따른 배경색 보기 본문으로 바로가기
  • 추천수 50개이상
  • 추천수 30개이상
  • 추천수 20개이상
  • 추천수 10개이상
  • 추천수 3개이상
닫기

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

List of Articles
번호 제목 글쓴이 날짜sort 추천 수 조회 수
38 쪽지에 파일을 첨부하자!!! [1] title: [ani]깜빡이는 표정빽짱구 2004-10-24 19 5259
37 best of best 생일자 로그인시 축하메세지 및 축하곡 띄우기 title: [ani]깜빡이는 표정빽짱구 2004-10-24 32 3593
36 best of best 일정조회수 되면 Cool 마크 달기. [1] title: [ani]깜빡이는 표정빽짱구 2004-10-24 21 2858
35 새로운 코멘트 달리면 코멘트숫자 색갈바꿔주기 [1] 맑은숲 2004-10-28 18 2493
34 회원 탈퇴할 때 비밀번호와 주민등록번호 확인후 탈퇴시키기 title: [ani]깜빡이는 표정빽짱구 2005-01-02 16 5120
33 best of best "where" 검색시 오류 뜨는것 해결 [1] title: [ani]깜빡이는 표정빽짱구 2005-01-02 22 2761
32 방문객이 레이어 메뉴의 회원정보 보기를 금지시키자!!! title: [ani]깜빡이는 표정빽짱구 2005-01-20 18 3335
31 실시간 쪽지함띄우기 title: [ani]깜빡이는 표정빽짱구 2005-03-09 15 3273
30 일반문서에 레벨별 권한을 주는 방법 title: [ani]깜빡이는 표정빽짱구 2005-03-13 11 3013
29 자동로그인 풀림현상 100%해결법 [2] title: [ani]깜빡이는 표정빽짱구 2005-03-16 12 4552
28 업로드시 그림 파일명이 한글일경우 이름 자동 변경하기 [1] title: [ani]깜빡이는 표정빽짱구 2005-03-16 11 3742
27 다운로드시 포인트 차감 + 강제 다운로드 창 뜨기. title: [ani]깜빡이는 표정빽짱구 2005-04-04 16 3891
26 best of best 로그인창에 아이디 비밀번호란 이미지넣기 title: [ani]깜빡이는 표정빽짱구 2005-04-05 28 3766
25 제로보드 비밀글관련 보안패치 4.1 pl7 title: [ani]깜빡이는 표정빽짱구 2005-04-06 17 5435
24 각종 검색버그 다 잡았습니다. [1] title: [ani]깜빡이는 표정빽짱구 2005-11-11 16 3233
23 제로보드에 글쓴이 국가 아이콘 달기 file title: [ani]깜빡이는 표정빽짱구 2005-11-17 10 4458
22 글읽기 권한 없을때 제목 클릭하면 경고창 띄우기 title: [ani]깜빡이는 표정빽짱구 2005-11-17 4 2584
21 게시판별로 권한 출력하기 title: [ani]깜빡이는 표정빽짱구 2005-11-20 4 2608
20 로그인 풀림과 로그아웃 잘안되는 문제 title: [ani]깜빡이는 표정빽짱구 2005-12-04 14 5011
19 hit best of best 제로보드 pl8 보안 취약점 패치하세요 [2] title: [ani]깜빡이는 표정빽짱구 2006-06-17 63 10263