<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
if (count($list)) $RollButton = "ON";
echo "<link rel='stylesheet' href='{$board_skin_url}/style.css'>";
?>
<script>
// 글자수 제한
var char_min = parseInt(<?php echo $comment_min ?>); // 최소
var char_max = parseInt(<?php echo $comment_max ?>); // 최대
</script>
<?php
$Cname = "추가 내용"; //기본 : 댓글
echo "<article id='COMMENT'>";
echo "<section class='C-ButtonTitle'>";
if (count($list)) echo "<button class='cmt_btn Button-BO' title='{$Cname} 열기/닫기'>{$Cname} 목록 (".count($list)."개)</i></button>";
echo "</section>";
## PRINT START
ob_start();
echo "<section id='bo_vc'>";
$cmt_amt = count($list);
for ($i=$cmt_amt-1; $i>=0; $i--) {
$comment_id = $list[$i]['wr_id'];
$cmt_depth = strlen($list[$i]['wr_comment_reply']) * 50;
$comment = $list[$i]['content'];
$comment = preg_replace("/\[\<a\s.*href\=\"(http|https|ftp|mms)\:\/\/([^[:space:]]+)\.(mp3|wma|wmv|asf|asx|mpg|mpeg)\".*\<\/a\>\]/i", "<script>doc_write(obj_movie('$1://$2.$3'));</script>", $comment);
$cmt_sv = $cmt_amt - $i + 1; // 댓글 헤더 z-index 재설정 ie8 이하 사이드뷰 겹침 문제 해결
## LIST
echo "<article id='c_{$comment_id}'>";
echo "<section class='C-List' style='z-index:{$cmt_sv}'>";
echo "<div><span></span>NO. ".sprintf('%02d',$i+1)." - {$list[$i]['wr_1']}</div>";
echo "<div><span></span>".date('Y년 m월 d일', strtotime($list[$i]['datetime']))."<label>".date(' / A h:i:s', strtotime($list[$i]['datetime']))."</label></div>";
echo "</section>";
// 댓글 출력
echo "<div style='margin-left:{$cmt_depth}px;'>";
if (strstr($list[$i]['wr_option'], "secret")) echo "<span>비밀글</span>";
echo "</div>";
echo "<div class='C-Comment' style='margin-left:{$cmt_depth}px;'>{$comment}</div>";
// 링크 출력
if ($list[$i]['wr_2']) {
$list[$i]['wr_2'] = str_replace('127.0.0.1',$_SERVER['HTTP_HOST'],$list[$i]['wr_2']); // 관리자 도메인을 사용자 도메인으로 치환
echo "<div class='C-Link' style='margin-left:{$cmt_depth}>px;'>";
echo "<span><label><i class='material-icons'>push_pin</i></label>{$list[$i]['wr_3']}</span>";
echo "<span>{$list[$i]['wr_2']}</span>";
echo "<button type='button' class='Button-BO' onclick=\"window.open('{$list[$i]['wr_2']}')\">링크 / 이동</button>";
echo "</div>";
}
if($list[$i]['is_reply'] || $list[$i]['is_edit'] || $list[$i]['is_del']) {
$query_string = clean_query_string($_SERVER['QUERY_STRING']);
if($w == 'cu') {
$sql = " select wr_id, wr_content, mb_id from $write_table where wr_id = '$c_id' and wr_is_comment = '1' ";
$cmt = sql_fetch($sql);
if (!($is_admin || ($member['mb_id'] == $cmt['mb_id'] && $cmt['mb_id'])))
$cmt['wr_content'] = '';
$c_wr_content = $cmt['wr_content'];
}
$c_reply_href = './board.php?'.$query_string.'&c_id='.$comment_id.'&w=c#bo_vc_w';
$c_edit_href = './board.php?'.$query_string.'&c_id='.$comment_id.'&w=cu#bo_vc_w';
echo "<div class='C-Edit' style='margin-left:{$cmt_depth}>px;'>";
if ($list[$i]['is_edit']) echo "<a href='{$c_edit_href}' onclick=\"comment_box('{$comment_id}', 'cu'); return false;\"><button class='Button-BO B1'>수정</button></a>";
if ($list[$i]['is_reply']) echo "<a href='{$c_reply_href}' onclick=\"comment_box('{$comment_id}', 'c'); return false;\"><button class='Button-SO'>답변</button></a>";
if ($list[$i]['is_del']) echo "<a href='{$list[$i]['del_link']}' onclick=\"return comment_delete();\"><button class='Button-SO B3'>삭제</button></a>";
echo "</div>";
}
echo "<span id='edit_{$comment_id}' class='bo_vc_w'></span>"; //수정
echo "<span id='reply_{$comment_id}' class='bo_vc_w'></span>"; //답변
echo "<input type='hidden' value='".strstr($list[$i]['wr_option'],"secret")."' id='secret_comment_{$comment_id}'>";
echo "<textarea id='save_comment_{$comment_id}' style='display:none'>".get_text($list[$i]['content1'], 0)."</textarea>";
// 여분필드 추가 시작
echo "<input type='hidden' id='save_wr1_{$comment_id}' value='{$list[$i]['wr_1']}' />";
echo "<input type='hidden' id='save_wr2_{$comment_id}' value='{$list[$i]['wr_2']}' />";
echo "<input type='hidden' id='save_wr3_{$comment_id}' value='{$list[$i]['wr_3']}' />";
// 여분필드 추가 끝
echo "</article>";
}
if ($i == 0) echo "<div id='bo_vc_empty'>등록된 {$Cname}이 없습니다.</div>";
echo "</section>";
$link_comment = ob_get_contents();
ob_end_clean();
## PRINT END
if (!$is_admin) { echo $link_comment; } //관리자가 아닐경우 : 출력 ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
if ($is_comment_write) {
if($w == '')
$w = 'c';
## WRITE
echo "<aside id='bo_vc_w' class='C-Wirte'>";
echo "<div class='C-Title'><span>쓰기</span><span>{$Cname}</span></div>";
echo "<form name='fviewcomment' id='fviewcomment' action='{$comment_action_url}' onsubmit='return fviewcomment_submit(this);' method='post' autocomplete='off'>";
echo "<input type='hidden' name='w' value='{$w}' id='w'>";
echo "<input type='hidden' name='bo_table' value='{$bo_table}'>";
echo "<input type='hidden' name='wr_id' value='{$wr_id}'>";
echo "<input type='hidden' name='comment_id' value='{$c_id}' id='comment_id'>";
echo "<input type='hidden' name='sca' value='{$sca}'>";
echo "<input type='hidden' name='sfl' value='{$sfl}'>";
echo "<input type='hidden' name='stx' value='{$stx}'>";
echo "<input type='hidden' name='spt' value='{$spt}'>";
echo "<input type='hidden' name='page' value='{$page}'>";
echo "<input type='hidden' name='is_good' value=''>";
echo "<div class='C-line'>";
echo "<div class='C-Name'>제목</div>";
echo "<div class='C-Value'><input type='text' name='wr_1' id='wr_1' value='' size='95' placeholder='제목입력' required></div>";
echo "<div class='C-Name'>링크명칭</div>";
echo "<div class='C-Value'><input type='text' name='wr_3' id='wr_3' size='60' maxLength='200' placeholder='관련링크명칭'></div>";
echo "<div class='C-Name'>링크URL</div>";
echo "<div class='C-Value'><input type='text' name='wr_2' id='wr_2' size='60' maxLength='200' placeholder='관련링크주소'></div>";
echo "</div>";
if ($comment_min || $comment_max) echo "<strong id='char_cnt'><span id='char_count'></span>글자</strong>";
echo "<div class='C-Size'>";
echo "<button type='button' class='Button-BO' onclick=\"textarea_increase('wr_content', 6);\">확대</button><button type='button' class='Button-BO' onclick=\"textarea_original('wr_content', 3);\">기본</button><button type='button' class='Button-BO' onclick=\"textarea_decrease('wr_content', 6);\">축소</button>";
echo "<span><input type='checkbox' name='wr_secret' value='secret' id='wr_secret'> <label class='secret'>비밀글</label></span>";
echo "</div>";
if ($is_guest) {
echo "<div class='GU-1'>";
echo "<div class='L-1' for='wr_name'>이름</div>";
echo "<div class='R-1'><input type='text' name='wr_name' value='".get_cookie('ck_sns_name')."' id='wr_name' required size='20' placeholder='이름'></div>";
echo "<div class='L-1' for='wr_password'>비밀번호</div>";
echo "<div class='R-1'><input type='password' name='wr_password' id='wr_password' required size='20' placeholder='비밀번호'></div>";
echo $captcha_html;
echo "</div>";
}
echo "<div class='C-Content'>";
echo "<textarea id='wr_content' name='wr_content' maxlength='10000' required rows='3' title='{$Cname}' placeholder='{$Cname} 내용 작성'";
if ($comment_min || $comment_max) echo "onkeyup=\"check_byte('wr_content', 'char_count');\"";
echo ">{$c_wr_content}</textarea>";
if ($comment_min || $comment_max) echo "<script> check_byte('wr_content', 'char_count'); </script>";
echo "<input type='submit' id='btn_submit' value='입 력' class='Button-BO' style='writing-mode: vertical-rl;'>";
echo "</div>";
// 스크립트
echo "<script src='{$board_skin_url}/script_comment.js'></script>";
echo "</form>";
echo "</aside>";
if ($is_admin) { echo $link_comment; } // 관리자 댓글쓰기 : 출력 ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
}
echo "</article>";
?>
<script>
var save_before = '';
var save_html = document.getElementById('bo_vc_w').innerHTML;
function good_and_write()
{
var f = document.fviewcomment;
if (fviewcomment_submit(f)) {
f.is_good.value = 1;
f.submit();
} else {
f.is_good.value = 0;
}
}
function fviewcomment_submit(f)
{
var pattern = /(^\s*)|(\s*$)/g; // \s 공백 문자
f.is_good.value = 0;
var subject = "";
var content = "";
$.ajax({
url: g5_bbs_url+"/ajax.filter.php",
type: "POST",
data: {
"subject": "",
"content": f.wr_content.value
},
dataType: "json",
async: false,
cache: false,
success: function(data, textStatus) {
subject = data.subject;
content = data.content;
}
});
if (content) {
alert("내용에 금지단어('"+content+"')가 포함되어있습니다");
f.wr_content.focus();
return false;
}
// 양쪽 공백 없애기
var pattern = /(^\s*)|(\s*$)/g; // \s 공백 문자
document.getElementById('wr_content').value = document.getElementById('wr_content').value.replace(pattern, "");
if (char_min > 0 || char_max > 0)
{
check_byte('wr_content', 'char_count');
var cnt = parseInt(document.getElementById('char_count').innerHTML);
if (char_min > 0 && char_min > cnt)
{
alert("<?php echo $Cname; ?>은 "+char_min+"글자 이상 쓰셔야 합니다.");
return false;
} else if (char_max > 0 && char_max < cnt)
{
alert("<?php echo $Cname; ?>은 "+char_max+"글자 이하로 쓰셔야 합니다.");
return false;
}
}
else if (!document.getElementById('wr_content').value)
{
alert("<?php echo $Cname; ?>을 입력하여 주십시오.");
return false;
}
if (typeof(f.wr_name) != 'undefined')
{
f.wr_name.value = f.wr_name.value.replace(pattern, "");
if (f.wr_name.value == '')
{
alert('이름이 입력되지 않았습니다.');
f.wr_name.focus();
return false;
}
}
if (typeof(f.wr_password) != 'undefined')
{
f.wr_password.value = f.wr_password.value.replace(pattern, "");
if (f.wr_password.value == '')
{
alert('비밀번호가 입력되지 않았습니다.');
f.wr_password.focus();
return false;
}
}
<?php if($is_guest) echo chk_captcha_js(); ?>
set_comment_token(f);
document.getElementById("btn_submit").disabled = "disabled";
return true;
}
function comment_box(comment_id, work)
{
var el_id,
form_el = 'fviewcomment',
respond = document.getElementById(form_el);
// 댓글 아이디가 넘어오면 답변, 수정
if (comment_id)
{
if (work == 'c')
el_id = 'reply_' + comment_id;
else
el_id = 'edit_' + comment_id;
}
else
el_id = 'bo_vc_w';
if (save_before != el_id)
{
if (save_before)
{
document.getElementById(save_before).style.display = 'none';
}
document.getElementById(el_id).style.display = '';
document.getElementById(el_id).appendChild(respond);
//입력값 초기화
document.getElementById('wr_content').value = '';
// 댓글 수정
if (work == 'cu')
{
document.getElementById('wr_content').value = document.getElementById('save_comment_' + comment_id).value;
document.getElementById("wr_1").value = document.getElementById("save_wr1_" + comment_id).value; // 여분필드 추가
document.getElementById("wr_2").value = document.getElementById("save_wr2_" + comment_id).value;
document.getElementById("wr_3").value = document.getElementById("save_wr3_" + comment_id).value;
if (typeof char_count != 'undefined')
check_byte('wr_content', 'char_count');
if (document.getElementById('secret_comment_'+comment_id).value)
document.getElementById('wr_secret').checked = true;
else
document.getElementById('wr_secret').checked = false;
}
document.getElementById('comment_id').value = comment_id;
document.getElementById('w').value = work;
if(save_before)
$("#captcha_reload").trigger("click");
save_before = el_id;
}
}
function comment_delete() { return confirm("이 <?php echo $Cname; ?>을 삭제하시겠습니까?"); }
comment_box('', 'c'); // 댓글 입력폼이 보이도록 처리하기위해서 추가 (root님)
<?php if($board['bo_use_sns'] && ($config['cf_facebook_appid'] || $config['cf_twitter_key'])) { ?>
$(function() {
// sns 등록
$("#bo_vc_send_sns").load(
"<?php echo G5_SNS_URL; ?>/view_comment_write.sns.skin.php?bo_table=<?php echo $bo_table; ?>",
function() {
save_html = document.getElementById('bo_vc_w').innerHTML;
}
);
});
<?php } ?>
</script>
<script>
$(function() {
//댓글열기
$(".cmt_btn").click(function(){
$(this).toggleClass("cmt_btn_op");
$("#bo_vc").toggle();
});
});
</script>