답변 3개
참고를 한번 해보시는게 어떠실지요..
view_comment.skin.php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
?>
function fviewcomment_submit(f)
{
var pattern = /(^\s*)|(\s*$)/g; // 공백 체크
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; // 공백 체크
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("댓글은 "+char_min+"글자 이상 쓰셔야 합니다.");
return false;
} else if (char_max > 0 && char_max < cnt)
{
alert("댓글은 "+char_max+"글자 이하로 쓰셔야 합니다.");
return false;
}
}
else if (!document.getElementById('wr_content').value)
{
alert("댓글을 입력하여 주십시오.");
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;
}
}
// 파일 용량 체크
if (f.bf_file) {
var file = f.bf_file.files[0];
if (file && file.size > 2097152) { // 2MB = 2097152 bytes
alert('첨부파일 용량이 2MB를 초과했습니다.');
return false;
}
}
return true;
}
// 댓글 삭제
function comment_delete()
{
return confirm("이 댓글을 삭제하시겠습니까?");
}
.view-comment-form {
margin: 20px 0;
padding: 20px;
background: #f8f9fa;
border-radius: 5px;
}
.comment-write-input {
margin-bottom: 15px;
}
.comment-write-input label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
.comment-write-input input {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
}
.comment-write-content textarea {
width: 100%;
min-height: 100px;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
resize: vertical;
}
.comment-file-upload {
margin: 15px 0;
padding: 10px;
background: #fff;
border: 1px solid #ddd;
border-radius: 4px;
}
.file-upload-group {
margin-bottom: 10px;
}
.file-upload-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
.file-desc {
font-size: 12px;
color: #666;
}
.btn_submit {
padding: 10px 20px;
background: #007bff;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
.btn_submit:hover {
background: #0056b3;
}
write_comment_update.php
include_once('./_common.php');
include_once(G5_LIB_PATH.'/mailer.lib.php');
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
// 댓글 권한 체크
check_comment_token();
$w = isset($_POST['w']) ? clean_xss_tags($_POST['w']) : '';
$bo_table = isset($_POST['bo_table']) ? clean_xss_tags($_POST['bo_table']) : '';
$wr_id = isset($_POST['wr_id']) ? (int)$_POST['wr_id'] : 0;
$comment_id = isset($_POST['comment_id']) ? (int)$_POST['comment_id'] : 0;
// 파일 업로드 설정
$upload_max_filesize = ini_get('upload_max_filesize');
if (empty($upload_max_filesize)) {
$upload_max_filesize = '2M';
}
$upload_max_filesize = return_bytes($upload_max_filesize);
$upload_max_filesize = min($upload_max_filesize, 2097152); // 2MB로 제한
// 디렉토리가 없다면 생성
$upload_dir = G5_DATA_PATH.'/file/'.$bo_table;
if (!is_dir($upload_dir)) {
@mkdir($upload_dir, G5_DIR_PERMISSION);
@chmod($upload_dir, G5_DIR_PERMISSION);
}
$chars_array = array_merge(range(0,9), range('a','z'), range('A','Z'));
// 파일 업로드 처리
$file_upload_msg = '';
$bf_file = array();
$comment_file = array();
if (isset($_FILES['bf_file']['name']) && is_array($_FILES['bf_file']['name'])) {
for ($i=0; $i $upload = array(); $upload['file'] = ''; $upload['source'] = ''; $upload['filesize'] = 0; $upload['image'] = array(); $upload['image'][0] = 0; $upload['image'][1] = 0; $upload['image'][2] = 0; $upload['fileurl'] = ''; $upload['thumburl'] = ''; $upload['storage'] = ''; $tmp_file = $_FILES['bf_file']['tmp_name'][$i]; $filesize = $_FILES['bf_file']['size'][$i]; $filename = $_FILES['bf_file']['name'][$i]; $filename = get_safe_filename($filename); if (!is_uploaded_file($tmp_file)) { continue; } if ($filesize > $upload_max_filesize) { $file_upload_msg .= '\"'.$filename.'\" 파일의 용량이 서버에 설정된 값을 초과하여 업로드 할 수 없습니다.\\n'; continue; } $timg = @getimagesize($tmp_file); if (preg_match("/\.({$config['cf_image_extension']})$/i", $filename) || !empty($timg)) { if ($timg[2] < 1 || $timg[2] > 16) { continue; } } $upload['image'] = $timg; // 프로그램 원래 파일명 $upload['source'] = $filename; $upload['filesize'] = $filesize; // 아래의 문자열이 들어간 파일은 -x 를 붙여서 웹경로를 알더라도 실행을 하지 못하도록 함 $filename = preg_replace("/\.(php|pht|phtm|htm|cgi|pl|exe|jsp|asp|inc|phar)/i", "$0-x", $filename); // 접미사를 붙인 파일명 $upload['file'] = abs(ip2long($_SERVER['REMOTE_ADDR'])).'_'.substr(md5(uniqid($filename)), 0, 8).'_'.replace_filename($filename); $dest_file = $upload_dir.'/'.$upload['file']; // 업로드가 안된다면 에러메세지 출력하고 죽어버립니다. $error_code = move_uploaded_file($tmp_file, $dest_file) or die($_FILES['bf_file']['error'][$i]); // 올라간 파일의 퍼미션을 변경합니다. chmod($dest_file, G5_FILE_PERMISSION); $upload['fileurl'] = G5_DATA_URL.'/file/'.$bo_table.'/'.$upload['file']; $comment_file[] = $upload; } } if($w == 'c') { $wr = get_write($write_table, $wr_id); if (!$wr['wr_id']) { alert("글이 존재하지 않습니다.\\n글이 삭제되었거나 이동하였을 수 있습니다."); } $tmp_comment = $comment_id; if ($is_admin == 'super') // 최고관리자 통과 ; else if ($is_admin == 'group') { // 그룹관리자 $mb = get_member($write['mb_id']); if ($member['mb_id'] != $group['gr_admin']) // 자신이 관리하는 그룹인가? alert('자신이 관리하는 그룹의 게시판이 아니므로 댓글을 달 수 없습니다.'); } else if ($is_admin == 'board') { // 게시판관리자이면 $mb = get_member($write['mb_id']); if ($member['mb_id'] != $board['bo_admin']) // 자신이 관리하는 게시판인가? alert('자신이 관리하는 게시판이 아니므로 댓글을 달 수 없습니다.'); } if (!$is_admin && !$board['bo_use_comment']) alert('이 게시판은 댓글을 사용하지 않습니다.'); // 댓글 답변 if ($comment_id) { $reply_array = get_write($write_table, $comment_id); if (!$reply_array['wr_id']) alert('답변할 댓글이 없습니다.\\n\\n답변하는 동안 댓글이 삭제되었을 수 있습니다.'); if($wr['wr_parent'] != $reply_array['wr_parent']) alert('댓글을 등록할 수 없습니다.'); $tmp_comment = $reply_array['wr_id']; } $sql = " select max(wr_comment_reply) as reply from {$write_table} where wr_parent = '$wr_id' and wr_comment = '$tmp_comment' and wr_is_comment = 1 "; $row = sql_fetch($sql); if ($row['reply']) { $reply = $row['reply'] + 1; if ($reply > 99) alert('더 이상 답변하실 수 없습니다.\\n\\n답변은 99번까지만 가능합니다.'); $wr_comment_reply = $reply; } else { $wr_comment_reply = ''; } // 댓글 입력 $sql = " insert into $write_table set wr_parent = '$wr_id', wr_is_comment = 1, wr_comment = '$tmp_comment', wr_comment_reply = '$wr_comment_reply', wr_subject = '', wr_content = '$wr_content', mb_id = '$member[mb_id]', wr_password = '$wr_password', wr_name = '$wr_name', wr_email = '$wr_email', wr_homepage = '$wr_homepage', wr_datetime = '".G5_TIME_YMDHIS."', wr_last = '', wr_ip = '{$_SERVER['REMOTE_ADDR']}', wr_1 = '$wr_1', wr_2 = '$wr_2', wr_3 = '$wr_3', wr_4 = '$wr_4', wr_5 = '$wr_5', wr_6 = '$wr_6', wr_7 = '$wr_7', wr_8 = '$wr_8', wr_9 = '$wr_9', wr_10 = '$wr_10' "; sql_query($sql); $comment_id = sql_insert_id(); // 파일 정보 DB에 입력 if($comment_file) { foreach($comment_file as $cf) { $sql = " insert into {$g5['board_file_table']} set bo_table = '$bo_table', wr_id = '$comment_id', bf_no = '0', bf_source = '{$cf['source']}', bf_file = '{$cf['file']}', bf_content = '', bf_fileurl = '{$cf['fileurl']}', bf_thumburl = '{$cf['thumburl']}', bf_storage = '{$cf['storage']}', bf_download = 0, bf_filesize = '{$cf['filesize']}', bf_width = '{$cf['image'][0]}', bf_height = '{$cf['image'][1]}', bf_type = '{$cf['image'][2]}', bf_datetime = '".G5_TIME_YMDHIS."' "; sql_query($sql); } } // 원글에 댓글수 증가 sql_query(" update $write_table set wr_comment = wr_comment + 1 where wr_id = '$wr_id' "); // 새글 INSERT sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '$bo_table', '$comment_id', '$wr_id', '".G5_TIME_YMDHIS."', '{$member['mb_id']}' ) "); // 댓글 1 증가 sql_query(" update {$g5['board_table']} set bo_count_comment = bo_count_comment + 1 where bo_table = '$bo_table' "); // 메일발송 사용 if ($config['cf_email_use'] && $board['bo_use_email']) { // 관리자의 정보를 얻고 $super_admin = get_admin('super'); $group_admin = get_admin('group'); $board_admin = get_admin('board'); $wr_subject = get_text(stripslashes($wr['wr_subject'])); $wr_content = nl2br(get_text(stripslashes("원글\n{$wr['wr_subject']}\n\n\n댓글\n$wr_content"))); $warr = array( ''=>'입력', 'u'=>'수정', 'r'=>'답변', 'c'=>'댓글 ', 'cu'=>'댓글 수정' ); $str = $warr[$w]; $subject = '['.$config['cf_title'].'] '.$board['bo_subject'].' 게시판에 '.$str.'글이 올라왔습니다.'; $link_url = get_pretty_url($bo_table, $wr_id, $qstr."#c_".$comment_id); include_once(G5_LIB_PATH.'/mailer.lib.php'); ob_start(); include_once ('./write_update_mail.php'); $content = ob_get_contents(); ob_end_clean(); $array_email = array(); // 게시판관리자에게 보내는 메일 if ($config['cf_email_wr_board_admin']) $array_email[] = $board_admin['mb_email']; // 게시판그룹관리자에게 보내는 메일 if ($config['cf_email_wr_group_admin']) $array_email[] = $group_admin['mb_email']; // 최고관리자에게 보내는 메일 if ($config['cf_email_wr_super_admin']) $array_email[] = $super_admin['mb_email']; // 원글게시자에게 보내는 메일 if ($config['cf_email_wr_write']) $array_email[] = $wr['wr_email']; // 중복된 메일 주소는 제거 $unique_email = array_unique($array_email); $unique_email = array_values($unique_email); for ($i=0; $i mailer($wr_name, $wr_email, $unique_email[$i], $subject, $content, 1); } } } // 사용자 코드 실행 @include_once($board_skin_path.'/write_comment_update.skin.php'); @include_once($board_skin_path.'/write_comment_update.tail.skin.php'); delete_cache_latest($bo_table); if ($file_upload_msg) { alert($file_upload_msg, get_pretty_url($bo_table, $wr_id, $qstr.'#c_'.$comment_id)); } else { goto_url(get_pretty_url($bo_table, $wr_id, $qstr.'#c_'.$comment_id)); } ?>
답변에 대한 댓글 1개
write_comment_update.php 이 파일이 bbs 안에 있나요?
감사합니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인