트랙백이랑 코멘트 따로 받게하기 (2. view_trackback.php 추가) 정보
트랙백이랑 코멘트 따로 받게하기 (2. view_trackback.php 추가)
관련링크
본문
좀 전에
switch ($op) {
case 1:
include_once("./view_comment.php");
break;
case 2:
include_once("./view_trackback.php");
break;
default:
include_once("./view_trackback.php");
include_once("./view_comment.php");
}
로 수정하였지만 view_trackback.php 파일이 없으니까 만듭니다.
만들어서 올리려다 스킨화 시켜놓는게 좋을것 같아서 스킨화 합니다
볼짱 없어도 그냥 해봅니다
아래와 같이 파일을 만들어서 bbs/ 폴더에 view_trackback.php 이란 이름으로 파일을 생성해 주세요
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
// 자동등록방지
include_once ("./norobot.inc.php");
echo "";
$list = array();
$is_comment_write = false;
if ($member[mb_level] >= $board[bo_comment_level])
$is_comment_write = true;
// 코멘트 출력
//$sql = " select * from $write_table where wr_parent = '$wr_id' and wr_is_comment = 1 order by wr_comment desc, wr_comment_reply ";
$sql = " select * from $write_table where wr_parent = '$wr_id' and wr_is_comment = 1 order by wr_comment, wr_comment_reply ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$list[$i] = $row;
//$list[$i][name] = get_sideview($row[mb_id], cut_str($row[wr_name], 20, ''), $row[wr_email], $row[wr_homepage]);
$tmp_name = get_text(cut_str($row[wr_name], $config[cf_cut_name])); // 설정된 자리수 만큼만 이름 출력
if ($board[bo_use_sideview])
$list[$i][name] = get_sideview($row[mb_id], $tmp_name, $row[wr_email], $row[wr_homepage]);
else
$list[$i][name] = "$tmp_name";
// 공백없이 연속 입력한 문자 자르기 (way 보드 참고. way.co.kr)
//$list[$i][content] = eregi_replace("[^ \n<>]{130}", "\\0\n", $row[wr_content]);
$list[$i][content] = conv_content($row[wr_content], 2, 'wr_content');
$list[$i][content] = search_font($stx, $list[$i][content]);
$list[$i][trackback] = url_auto_link($row[wr_trackback]);
$list[$i][datetime] = substr($row[wr_datetime],2,14);
// 관리자가 아니라면 중간 IP 주소를 감춘후 보여줍니다.
$list[$i][ip] = $row[wr_ip];
if (!$is_admin)
$list[$i][ip] = preg_replace("/([0-9]+).([0-9]+).([0-9]+).([0-9]+)/", "\\1.□.\\3.\\4", $row[wr_ip]);
$list[$i][is_reply] = false;
$list[$i][is_edit] = false;
$list[$i][is_del] = false;
if ($is_comment_write || $is_admin)
{
if ($member[mb_id])
{
if ($row[mb_id] == $member[mb_id] || $is_admin)
{
$list[$i][del_link] = "./delete_comment.php?bo_table=$bo_table&comment_id=$row[wr_id]&cwin=$cwin&page=$page".$qstr;
$list[$i][is_edit] = true;
$list[$i][is_del] = true;
}
}
else
{
if (!$row[mb_id]) {
$list[$i][del_link] = "./password.php?w=x&bo_table=$bo_table&comment_id=$row[wr_id]&page=$page".$qstr;
$list[$i][is_del] = true;
}
}
if (strlen($row[wr_comment_reply]) < 10)
$list[$i][is_reply] = true;
}
// 05.05.22
// 답변있는 코멘트는 수정, 삭제 불가
if ($i > 0 && !$is_admin)
{
if ($row[wr_comment_reply])
{
$tmp_comment_reply = substr($row[wr_comment_reply], 0, strlen($row[wr_comment_reply]) - 1);
if ($tmp_comment_reply == $list[$i-1][wr_comment_reply])
{
$list[$i-1][is_edit] = false;
$list[$i-1][is_del] = false;
}
}
}
}
// 코멘트수 제한 설정값
if ($is_admin)
{
$comment_min = $comment_max = 0;
}
else
{
$comment_min = (int)$board[bo_comment_min];
$comment_max = (int)$board[bo_comment_max];
}
include_once("$board_skin_path/view_comment.skin.php");
// 필터
echo "\n";
echo "\n";
if (!$member[mb_id]) // 비회원일 경우에만
echo "\n";
?>
그리고 또 날로 먹는것 같아서 덤으로
<?
//
// 트랙백 핑 받는 페이지
//
define("_GNUBOARD_", TRUE);
include_once("./_common.php");
// 오류는 write_log() 로 잡는다.
include_once("$g4[path]/lib/etc.lib.php");
//write_log("$g4[path]/lib/log/aaa", 1);
//phpinfo(); exit;
//preg_match("/tb\.php\/([^\/]+)\/([^\/]+)$/", $_SERVER[PHP_SELF], $matches);
//$bo_table = $matches[1];
//$wr_id = $matches[2];
$arr = explode("/", $_SERVER[PATH_INFO]);
$bo_table = $arr[1];
$wr_id = $arr[2];
$write_table = $g4[write_prefix] . $bo_table; // 게시판 테이블 전체이름
$sql = " select wr_id,
ca_name,
wr_email
from $write_table where wr_id = '$wr_id' ";
$wr = sql_fetch($sql, FALSE);
// wr_id가 없거나 트랙백으로 넘어온게 아니라면
if (!$wr[wr_id] || !($_POST[title] && $_POST[excerpt] && $_POST[url] && $_POST[blog_name])) {
$tmp_dir = str_replace("/tb.php", "", $_SERVER[SCRIPT_NAME]);
header("location:$tmp_dir/board.php?bo_table=$bo_table&wr_id=$wr_id");
exit;
}
$title = $_POST[title];
$excerpt = $_POST[excerpt];
if (strlen($title) > 100) $title = cut_str($title, 100);
if (strlen($excerpt) > 255) $excerpt = cut_str(str_replace("\n","",$excerpt), 255);
$excerpt = preg_replace("/
/i", " ", $excerpt);
$excerpt = preg_replace("/\n/i", " ", $excerpt);
$excerpt = strip_tags($excerpt);
$excerpt = stripslashes($excerpt);
echo cut_str($excerpt, 255);
$msg = "";
// 두번씩 INSERT 되는것을 막기 위해
if ($_POST[title]) {
$board = sql_fetch(" select bo_subject, bo_use_trackback from $g4[board_table] where bo_table = '$bo_table' ");
if (!$board[bo_use_trackback])
$msg = "트랙백 사용이 금지된 게시판입니다.";
if (!$msg) {
$next_num = get_next_num($write_table);
$sql = " select max(wr_comment) as max_comment from $write_table
where wr_parent = '$wr_id' and wr_is_comment = 1 ";
$row = sql_fetch($sql);
$row[max_comment] += 1;
$sql = " insert into $g4[write_prefix]$bo_table
set wr_num = '$next_num',
wr_parent = '$wr_id',
wr_is_comment = '2',
mb_id = 'Trackback',
wr_subject = '$_POST[title]',
wr_1='$_POST[blog_name]',
wr_2='$_POST[url]',
wr_comment = '$row[max_comment]',
wr_content = '$excerpt',
wr_name = '$_POST[blog_name]',
wr_password = '".sql_password($g4[server_time])."',
wr_datetime = '$g4[time_ymdhis]',
wr_ip = '$_SERVER[REMOTE_ADDR]' ";
$result = sql_query($sql, FALSE);
if ($result) {
$comment_id = mysql_insert_id();
sql_query(" update $write_table set wr_trackback_num = wr_trackback_num + 1 where wr_id = '$wr_id' ", FALSE);
sql_query(" insert into $g4[board_new_table] ( bo_table, wr_id, wr_parent, bn_datetime ) values ( '$bo_table', '$comment_id', '$wr_id', '$g4[time_ymdhis]' ) ");
sql_query(" update $g4[board_table] set bo_count_comment = bo_count_comment + 1 where bo_table = '$bo_table' ", FALSE);
} else
$msg = "$write_table TABLE INSERT 오류";
}
//write_log("$g4[path]/data/log/aaa", $msg);
if ($msg) // 비정상(오류)
{
echo "<?xml version=\"1.0\" encoding=\"$g4[charset]\"?>\n";
echo "\n";
echo "1\n";
echo "$msg\n";
echo "\n";
}
else // 정상
{
// 메일발송 사용
if ($config[cf_email_use] && $board[bo_use_email])
{
include_once("$g4[path]/lib/mailer.lib.php");
// 관리자의 정보를 얻고
$super_admin = get_admin("super");
$group_admin = get_admin("group");
$board_admin = get_admin("board");
$wr_name = $blog_name = get_text(stripslashes($_POST[blog_name]));
$wr_subject = $title = get_text(stripslashes($title));
$wr_content = $excerpt = nl2br(get_text(stripslashes($excerpt)));
$link_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$subject = "'{$board[bo_subject]}' 게시판에 트랙백에 의한 글이 올라왔습니다.";
define("_GNUBOARD_", TRUE);
ob_start();
include_once ("./write_update_mail.php");
$content = ob_get_contents();
ob_end_clean();
// 게시판 관리자에게 보내는 메일
if ($config[cf_email_wr_board_admin])
mailer($blog_name, "", $board_admin[mb_email], $subject, $content, 1);
// 그룹 관리자에게 보내는 메일
if ($group_admin[mb_email] != $board_admin[mb_email])
{
if ($config[cf_email_wr_group_admin])
mailer($blog_name, "", $group_admin[mb_email], $subject, $content, 1);
}
// 최고관리자에게 보내는 메일
if ($super_admin[mb_email] != $board_admin[mb_email])
{
if ($config[cf_email_wr_super_admin])
mailer($blog_name, "", $super_admin[mb_email], $subject, $content, 1);
}
// 답변 메일받기 (원게시자에게 보내는 메일)
if ($wr[wr_recv_email] && $wr[wr_email] && $wr[wr_email] != $admin[mb_email])
{
if ($config[cf_email_wr_write])
mailer($blog_name, "", $wr[wr_email], $subject, $content, 1);
// 코멘트 쓴 모든이에게 메일 발송
if ($config[cf_email_wr_comment_all])
{
$sql = " select wr_email from $write_table
where wr_email not in ( '$admin[mb_email]' , '$wr[wr_email]', '' )
and wr_parent = '$wr_id'
group by wr_email ";
$result = sql_query($sql);
while ($row=sql_fetch_array($result))
mailer($blog_name, "", $row[wr_email], $subject, $content, 1);
}
}
}
}
}
echo "<?xml version=\"1.0\" encoding=\"$g4[charset]\"?>\n";
echo "\n";
echo "0\n";
echo "\n";
?>
그냥 제가 쓰는 tb.php 입니다 =ㅅ=
저는 index.php 로 임의로 수정해서 사용하고 있습니다.
그냥 제 취향대로
이나 \n 부분을 잘라서 한줄로 만들어 버렸습니다 =ㅅ=//
switch ($op) {
case 1:
include_once("./view_comment.php");
break;
case 2:
include_once("./view_trackback.php");
break;
default:
include_once("./view_trackback.php");
include_once("./view_comment.php");
}
로 수정하였지만 view_trackback.php 파일이 없으니까 만듭니다.
만들어서 올리려다 스킨화 시켜놓는게 좋을것 같아서 스킨화 합니다
볼짱 없어도 그냥 해봅니다
아래와 같이 파일을 만들어서 bbs/ 폴더에 view_trackback.php 이란 이름으로 파일을 생성해 주세요
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
// 자동등록방지
include_once ("./norobot.inc.php");
echo "";
$list = array();
$is_comment_write = false;
if ($member[mb_level] >= $board[bo_comment_level])
$is_comment_write = true;
// 코멘트 출력
//$sql = " select * from $write_table where wr_parent = '$wr_id' and wr_is_comment = 1 order by wr_comment desc, wr_comment_reply ";
$sql = " select * from $write_table where wr_parent = '$wr_id' and wr_is_comment = 1 order by wr_comment, wr_comment_reply ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$list[$i] = $row;
//$list[$i][name] = get_sideview($row[mb_id], cut_str($row[wr_name], 20, ''), $row[wr_email], $row[wr_homepage]);
$tmp_name = get_text(cut_str($row[wr_name], $config[cf_cut_name])); // 설정된 자리수 만큼만 이름 출력
if ($board[bo_use_sideview])
$list[$i][name] = get_sideview($row[mb_id], $tmp_name, $row[wr_email], $row[wr_homepage]);
else
$list[$i][name] = "$tmp_name";
// 공백없이 연속 입력한 문자 자르기 (way 보드 참고. way.co.kr)
//$list[$i][content] = eregi_replace("[^ \n<>]{130}", "\\0\n", $row[wr_content]);
$list[$i][content] = conv_content($row[wr_content], 2, 'wr_content');
$list[$i][content] = search_font($stx, $list[$i][content]);
$list[$i][trackback] = url_auto_link($row[wr_trackback]);
$list[$i][datetime] = substr($row[wr_datetime],2,14);
// 관리자가 아니라면 중간 IP 주소를 감춘후 보여줍니다.
$list[$i][ip] = $row[wr_ip];
if (!$is_admin)
$list[$i][ip] = preg_replace("/([0-9]+).([0-9]+).([0-9]+).([0-9]+)/", "\\1.□.\\3.\\4", $row[wr_ip]);
$list[$i][is_reply] = false;
$list[$i][is_edit] = false;
$list[$i][is_del] = false;
if ($is_comment_write || $is_admin)
{
if ($member[mb_id])
{
if ($row[mb_id] == $member[mb_id] || $is_admin)
{
$list[$i][del_link] = "./delete_comment.php?bo_table=$bo_table&comment_id=$row[wr_id]&cwin=$cwin&page=$page".$qstr;
$list[$i][is_edit] = true;
$list[$i][is_del] = true;
}
}
else
{
if (!$row[mb_id]) {
$list[$i][del_link] = "./password.php?w=x&bo_table=$bo_table&comment_id=$row[wr_id]&page=$page".$qstr;
$list[$i][is_del] = true;
}
}
if (strlen($row[wr_comment_reply]) < 10)
$list[$i][is_reply] = true;
}
// 05.05.22
// 답변있는 코멘트는 수정, 삭제 불가
if ($i > 0 && !$is_admin)
{
if ($row[wr_comment_reply])
{
$tmp_comment_reply = substr($row[wr_comment_reply], 0, strlen($row[wr_comment_reply]) - 1);
if ($tmp_comment_reply == $list[$i-1][wr_comment_reply])
{
$list[$i-1][is_edit] = false;
$list[$i-1][is_del] = false;
}
}
}
}
// 코멘트수 제한 설정값
if ($is_admin)
{
$comment_min = $comment_max = 0;
}
else
{
$comment_min = (int)$board[bo_comment_min];
$comment_max = (int)$board[bo_comment_max];
}
include_once("$board_skin_path/view_comment.skin.php");
// 필터
echo "\n";
echo "\n";
if (!$member[mb_id]) // 비회원일 경우에만
echo "\n";
?>
그리고 또 날로 먹는것 같아서 덤으로
<?
//
// 트랙백 핑 받는 페이지
//
define("_GNUBOARD_", TRUE);
include_once("./_common.php");
// 오류는 write_log() 로 잡는다.
include_once("$g4[path]/lib/etc.lib.php");
//write_log("$g4[path]/lib/log/aaa", 1);
//phpinfo(); exit;
//preg_match("/tb\.php\/([^\/]+)\/([^\/]+)$/", $_SERVER[PHP_SELF], $matches);
//$bo_table = $matches[1];
//$wr_id = $matches[2];
$arr = explode("/", $_SERVER[PATH_INFO]);
$bo_table = $arr[1];
$wr_id = $arr[2];
$write_table = $g4[write_prefix] . $bo_table; // 게시판 테이블 전체이름
$sql = " select wr_id,
ca_name,
wr_email
from $write_table where wr_id = '$wr_id' ";
$wr = sql_fetch($sql, FALSE);
// wr_id가 없거나 트랙백으로 넘어온게 아니라면
if (!$wr[wr_id] || !($_POST[title] && $_POST[excerpt] && $_POST[url] && $_POST[blog_name])) {
$tmp_dir = str_replace("/tb.php", "", $_SERVER[SCRIPT_NAME]);
header("location:$tmp_dir/board.php?bo_table=$bo_table&wr_id=$wr_id");
exit;
}
$title = $_POST[title];
$excerpt = $_POST[excerpt];
if (strlen($title) > 100) $title = cut_str($title, 100);
if (strlen($excerpt) > 255) $excerpt = cut_str(str_replace("\n","",$excerpt), 255);
$excerpt = preg_replace("/
/i", " ", $excerpt);
$excerpt = preg_replace("/\n/i", " ", $excerpt);
$excerpt = strip_tags($excerpt);
$excerpt = stripslashes($excerpt);
echo cut_str($excerpt, 255);
$msg = "";
// 두번씩 INSERT 되는것을 막기 위해
if ($_POST[title]) {
$board = sql_fetch(" select bo_subject, bo_use_trackback from $g4[board_table] where bo_table = '$bo_table' ");
if (!$board[bo_use_trackback])
$msg = "트랙백 사용이 금지된 게시판입니다.";
if (!$msg) {
$next_num = get_next_num($write_table);
$sql = " select max(wr_comment) as max_comment from $write_table
where wr_parent = '$wr_id' and wr_is_comment = 1 ";
$row = sql_fetch($sql);
$row[max_comment] += 1;
$sql = " insert into $g4[write_prefix]$bo_table
set wr_num = '$next_num',
wr_parent = '$wr_id',
wr_is_comment = '2',
mb_id = 'Trackback',
wr_subject = '$_POST[title]',
wr_1='$_POST[blog_name]',
wr_2='$_POST[url]',
wr_comment = '$row[max_comment]',
wr_content = '$excerpt',
wr_name = '$_POST[blog_name]',
wr_password = '".sql_password($g4[server_time])."',
wr_datetime = '$g4[time_ymdhis]',
wr_ip = '$_SERVER[REMOTE_ADDR]' ";
$result = sql_query($sql, FALSE);
if ($result) {
$comment_id = mysql_insert_id();
sql_query(" update $write_table set wr_trackback_num = wr_trackback_num + 1 where wr_id = '$wr_id' ", FALSE);
sql_query(" insert into $g4[board_new_table] ( bo_table, wr_id, wr_parent, bn_datetime ) values ( '$bo_table', '$comment_id', '$wr_id', '$g4[time_ymdhis]' ) ");
sql_query(" update $g4[board_table] set bo_count_comment = bo_count_comment + 1 where bo_table = '$bo_table' ", FALSE);
} else
$msg = "$write_table TABLE INSERT 오류";
}
//write_log("$g4[path]/data/log/aaa", $msg);
if ($msg) // 비정상(오류)
{
echo "<?xml version=\"1.0\" encoding=\"$g4[charset]\"?>\n";
echo "\n";
echo "1\n";
echo "$msg\n";
echo "\n";
}
else // 정상
{
// 메일발송 사용
if ($config[cf_email_use] && $board[bo_use_email])
{
include_once("$g4[path]/lib/mailer.lib.php");
// 관리자의 정보를 얻고
$super_admin = get_admin("super");
$group_admin = get_admin("group");
$board_admin = get_admin("board");
$wr_name = $blog_name = get_text(stripslashes($_POST[blog_name]));
$wr_subject = $title = get_text(stripslashes($title));
$wr_content = $excerpt = nl2br(get_text(stripslashes($excerpt)));
$link_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$subject = "'{$board[bo_subject]}' 게시판에 트랙백에 의한 글이 올라왔습니다.";
define("_GNUBOARD_", TRUE);
ob_start();
include_once ("./write_update_mail.php");
$content = ob_get_contents();
ob_end_clean();
// 게시판 관리자에게 보내는 메일
if ($config[cf_email_wr_board_admin])
mailer($blog_name, "", $board_admin[mb_email], $subject, $content, 1);
// 그룹 관리자에게 보내는 메일
if ($group_admin[mb_email] != $board_admin[mb_email])
{
if ($config[cf_email_wr_group_admin])
mailer($blog_name, "", $group_admin[mb_email], $subject, $content, 1);
}
// 최고관리자에게 보내는 메일
if ($super_admin[mb_email] != $board_admin[mb_email])
{
if ($config[cf_email_wr_super_admin])
mailer($blog_name, "", $super_admin[mb_email], $subject, $content, 1);
}
// 답변 메일받기 (원게시자에게 보내는 메일)
if ($wr[wr_recv_email] && $wr[wr_email] && $wr[wr_email] != $admin[mb_email])
{
if ($config[cf_email_wr_write])
mailer($blog_name, "", $wr[wr_email], $subject, $content, 1);
// 코멘트 쓴 모든이에게 메일 발송
if ($config[cf_email_wr_comment_all])
{
$sql = " select wr_email from $write_table
where wr_email not in ( '$admin[mb_email]' , '$wr[wr_email]', '' )
and wr_parent = '$wr_id'
group by wr_email ";
$result = sql_query($sql);
while ($row=sql_fetch_array($result))
mailer($blog_name, "", $row[wr_email], $subject, $content, 1);
}
}
}
}
}
echo "<?xml version=\"1.0\" encoding=\"$g4[charset]\"?>\n";
echo "\n";
echo "0\n";
echo "\n";
?>
그냥 제가 쓰는 tb.php 입니다 =ㅅ=
저는 index.php 로 임의로 수정해서 사용하고 있습니다.
그냥 제 취향대로
이나 \n 부분을 잘라서 한줄로 만들어 버렸습니다 =ㅅ=//
추천
1
1
댓글 1개
감사합니다.