g5 merge 충돌 수정
This commit is contained in:
68
bbs/qadelete.php
Normal file
68
bbs/qadelete.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
|
||||
if($is_guest)
|
||||
alert('회원이시라면 로그인 후 이용해 주십시오.', G5_URL);
|
||||
|
||||
$tmp_array = array();
|
||||
if ($qa_id) // 건별삭제
|
||||
$tmp_array[0] = $qa_id;
|
||||
else // 일괄삭제
|
||||
$tmp_array = $_POST['chk_qa_id'];
|
||||
|
||||
$count = count($tmp_array);
|
||||
if(!$count)
|
||||
alert('삭제할 게시글을 하나이상 선택해 주십시오.');
|
||||
|
||||
for($i=0; $i<$count; $i++) {
|
||||
$qa_id = $tmp_array[$i];
|
||||
|
||||
$sql = " select qa_id, qa_type, qa_status, qa_parent, qa_content, qa_file1, qa_file2
|
||||
from {$g5['qa_content_table']}
|
||||
where qa_id = '$qa_id' ";
|
||||
$row = sql_fetch($sql);
|
||||
|
||||
if(!$row['qa_id'])
|
||||
continue;
|
||||
|
||||
// 첨부파일 삭제
|
||||
for($k=1; $k<=2; $k++) {
|
||||
@unlink(G5_DATA_PATH.'/qa/'.$row['qa_file'.$k]);
|
||||
// 썸네일삭제
|
||||
if(preg_match("/\.({$config['cf_image_extension']})$/i", $row['qa_file'.$k])) {
|
||||
delete_qa_thumbnail($row['qa_file'.$k]);
|
||||
}
|
||||
}
|
||||
|
||||
// 에디터 썸네일 삭제
|
||||
delete_editor_thumbnail($row['qa_content']);
|
||||
|
||||
// 답변이 있는 질문글이라면 답변글 삭제
|
||||
if(!$row['qa_type'] && $row['qa_status']) {
|
||||
$row2 = sql_fetch(" select qa_content, qa_file1, qa_file2 from {$g5['qa_content_table']} where qa_parent = '$qa_id' ");
|
||||
// 첨부파일 삭제
|
||||
for($k=1; $k<=2; $k++) {
|
||||
@unlink(G5_DATA_PATH.'/qa/'.$row2['qa_file'.$k]);
|
||||
// 썸네일삭제
|
||||
if(preg_match("/\.({$config['cf_image_extension']})$/i", $row2['qa_file'.$k])) {
|
||||
delete_qa_thumbnail($row2['qa_file'.$k]);
|
||||
}
|
||||
}
|
||||
|
||||
// 에디터 썸네일 삭제
|
||||
delete_editor_thumbnail($row2['qa_content']);
|
||||
|
||||
sql_query(" delete from {$g5['qa_content_table']} where qa_type = '1' and qa_parent = '$qa_id' ");
|
||||
}
|
||||
|
||||
// 답변글 삭제시 질문글의 상태변경
|
||||
if($row['qa_type']) {
|
||||
sql_query(" update {$g5['qa_content_table']} set qa_status = '0' where qa_id = '{$row['qa_parent']}' ");
|
||||
}
|
||||
|
||||
// 글삭제
|
||||
sql_query(" delete from {$g5['qa_content_table']} where qa_id = '$qa_id' ");
|
||||
}
|
||||
|
||||
goto_url(G5_BBS_URL.'/qalist.php'.preg_replace('/^&/', '?', $qstr));
|
||||
?>
|
||||
67
bbs/qadownload.php
Normal file
67
bbs/qadownload.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
|
||||
$no = (int)$no;
|
||||
|
||||
// 쿠키에 저장된 ID값과 넘어온 ID값을 비교하여 같지 않을 경우 오류 발생
|
||||
// 다른곳에서 링크 거는것을 방지하기 위한 코드
|
||||
if (!get_session('ss_qa_view_'.$qa_id))
|
||||
alert('잘못된 접근입니다.');
|
||||
|
||||
$sql = " select qa_subject, qa_file{$no}, qa_source{$no} from {$g5['qa_content_table']} where qa_id = '$qa_id' ";
|
||||
$file = sql_fetch($sql);
|
||||
if (!$file['qa_file'.$no])
|
||||
alert_close('파일 정보가 존재하지 않습니다.');
|
||||
|
||||
if($is_guest) {
|
||||
alert('다운로드 권한이 없습니다.\\n회원이시라면 로그인 후 이용해 보십시오.', G5_BBS_URL.'/login.php?url='.urlencode(G5_BBS_URL.'/qaview.php?qa_id='.$qa_id));
|
||||
}
|
||||
|
||||
$filepath = G5_DATA_PATH.'/qa/'.$file['qa_file'.$no];
|
||||
$filepath = addslashes($filepath);
|
||||
if (!is_file($filepath) || !file_exists($filepath))
|
||||
alert('파일이 존재하지 않습니다.');
|
||||
|
||||
$g5['title'] = '다운로드 > '.conv_subject($file['qa_subject'], 255);
|
||||
|
||||
$original = urlencode($file['qa_source'.$no]);
|
||||
|
||||
if(preg_match("/msie/i", $_SERVER['HTTP_USER_AGENT']) && preg_match("/5\.5/", $_SERVER['HTTP_USER_AGENT'])) {
|
||||
header("content-type: doesn/matter");
|
||||
header("content-length: ".filesize("$filepath"));
|
||||
header("content-disposition: attachment; filename=\"$original\"");
|
||||
header("content-transfer-encoding: binary");
|
||||
} else {
|
||||
header("content-type: file/unknown");
|
||||
header("content-length: ".filesize("$filepath"));
|
||||
header("content-disposition: attachment; filename=\"$original\"");
|
||||
header("content-description: php generated data");
|
||||
}
|
||||
header("pragma: no-cache");
|
||||
header("expires: 0");
|
||||
flush();
|
||||
|
||||
$fp = fopen($filepath, 'rb');
|
||||
|
||||
// 4.00 대체
|
||||
// 서버부하를 줄이려면 print 나 echo 또는 while 문을 이용한 방법보다는 이방법이...
|
||||
//if (!fpassthru($fp)) {
|
||||
// fclose($fp);
|
||||
//}
|
||||
|
||||
$download_rate = 10;
|
||||
|
||||
while(!feof($fp)) {
|
||||
//echo fread($fp, 100*1024);
|
||||
/*
|
||||
echo fread($fp, 100*1024);
|
||||
flush();
|
||||
*/
|
||||
|
||||
print fread($fp, round($download_rate * 1024));
|
||||
flush();
|
||||
usleep(1000);
|
||||
}
|
||||
fclose ($fp);
|
||||
flush();
|
||||
?>
|
||||
124
bbs/qalist.php
Normal file
124
bbs/qalist.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
|
||||
if($is_guest)
|
||||
alert('회원이시라면 로그인 후 이용해 보십시오.', './login.php?url='.urlencode(G5_BBS_URL.'/qalist.php'));
|
||||
|
||||
$qaconfig = get_qa_config();
|
||||
|
||||
$g5['title'] = $qaconfig['qa_title'];
|
||||
include_once('./_head.php');
|
||||
|
||||
$qa_skin_path = (G5_IS_MOBILE ? G5_MOBILE_PATH : G5_PATH).'/'.G5_SKIN_DIR.'/qa/'.$qaconfig['qa_skin'];
|
||||
$qa_skin_url = (G5_IS_MOBILE ? G5_MOBILE_URL : G5_URL).'/'.G5_SKIN_DIR.'/qa/'.$qaconfig['qa_skin'];
|
||||
$skin_file = $qa_skin_path.'/list.skin.php';
|
||||
|
||||
$category_option = '';
|
||||
if ($qaconfig['qa_category']) {
|
||||
$category_href = G5_BBS_URL.'/qalist.php';
|
||||
|
||||
$category_option .= '<li><a href="'.$category_href.'"';
|
||||
if ($sca=='')
|
||||
$category_option .= ' id="bo_cate_on"';
|
||||
$category_option .= '>전체</a></li>';
|
||||
|
||||
$categories = explode('|', $qaconfig['qa_category']); // 구분자가 | 로 되어 있음
|
||||
for ($i=0; $i<count($categories); $i++) {
|
||||
$category = trim($categories[$i]);
|
||||
if ($category=='') continue;
|
||||
$category_msg = '';
|
||||
$category_option .= '<li><a href="'.($category_href."?sca=".urlencode($category)).'"';
|
||||
if ($category==$sca) { // 현재 선택된 카테고리라면
|
||||
$category_option .= ' id="bo_cate_on"';
|
||||
$category_msg = '<span class="sound_only">열린 분류 </span>';
|
||||
}
|
||||
$category_option .= '>'.$category_msg.$category.'</a></li>';
|
||||
}
|
||||
}
|
||||
|
||||
if(is_file($skin_file)) {
|
||||
$sql_common = " from {$g5['qa_content_table']} ";
|
||||
$sql_search = " where qa_type = '0' ";
|
||||
|
||||
if(!$is_admin)
|
||||
$sql_search .= " and mb_id = '{$member['mb_id']}' ";
|
||||
|
||||
if($sca) {
|
||||
if (preg_match("/[a-zA-Z]/", $sca))
|
||||
$sql_search .= " and INSTR(LOWER(qa_category), LOWER('$sca')) > 0 ";
|
||||
else
|
||||
$sql_search .= " and INSTR(qa_category, '$sca') > 0 ";
|
||||
}
|
||||
|
||||
$stx = trim($stx);
|
||||
if($stx) {
|
||||
if (preg_match("/[a-zA-Z]/", $stx))
|
||||
$sql_search .= " and ( INSTR(LOWER(qa_subject), LOWER('$sca')) > 0 or INSTR(LOWER(qa_content), LOWER('$stx')) > 0 )";
|
||||
else
|
||||
$sql_search .= " and ( INSTR(qa_subject, '$stx') > 0 or INSTR(qa_content, '$stx') > 0 ) ";
|
||||
}
|
||||
|
||||
$sql_order = " order by qa_num ";
|
||||
|
||||
$sql = " select count(*) as cnt
|
||||
$sql_common
|
||||
$sql_search ";
|
||||
$row = sql_fetch($sql);
|
||||
$total_count = $row['cnt'];
|
||||
|
||||
$page_rows = G5_IS_MOBILE ? $qaconfig['qa_mobile_page_rows'] : $qaconfig['qa_page_rows'];
|
||||
$total_page = ceil($total_count / $page_rows); // 전체 페이지 계산
|
||||
if (!$page) { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
|
||||
$from_record = ($page - 1) * $page_rows; // 시작 열을 구함
|
||||
|
||||
$sql = " select *
|
||||
$sql_common
|
||||
$sql_search
|
||||
$sql_order
|
||||
limit $from_record, $page_rows ";
|
||||
$result = sql_query($sql);
|
||||
|
||||
$list = array();
|
||||
$num = $total_count - ($page - 1) * $page_rows;
|
||||
$subject_len = G5_IS_MOBILE ? $qaconfig['qa_mobile_subject_len'] : $qaconfig['qa_subject_len'];
|
||||
for($i=0; $row=sql_fetch_array($result); $i++) {
|
||||
$list[$i] = $row;
|
||||
|
||||
$list[$i]['category'] = get_text($row['qa_category']);
|
||||
$list[$i]['subject'] = conv_subject($row['qa_subject'], $subject_len, '…');
|
||||
if ($stx) {
|
||||
$list[$i]['subject'] = search_font($stx, $list[$i]['subject']);
|
||||
}
|
||||
|
||||
$list[$i]['view_href'] = G5_BBS_URL.'/qaview.php?qa_id='.$row['qa_id'].$qstr;
|
||||
|
||||
$list[$i]['icon_file'] = '';
|
||||
if(trim($row['qa_file1']) || trim($row['qa_file2']))
|
||||
$list[$i]['icon_file'] = '<img src="'.$qa_skin_url.'/img/icon_file.gif">';
|
||||
|
||||
$list[$i]['name'] = get_text($row['qa_name']);
|
||||
$list[$i]['date'] = substr($row['qa_datetime'], 2, 8);
|
||||
|
||||
$list[$i]['num'] = $num - $i;
|
||||
}
|
||||
|
||||
$is_checkbox = false;
|
||||
$admin_href = '';
|
||||
if($is_admin) {
|
||||
$is_checkbox = true;
|
||||
$admin_href = G5_ADMIN_URL.'/qa_config.php';
|
||||
}
|
||||
|
||||
$list_href = G5_BBS_URL.'/qalist.php';
|
||||
$write_href = G5_BBS_URL.'/qawrite.php';
|
||||
|
||||
$list_pages = preg_replace('/(\.php)(&|&)/i', '$1?', get_paging(G5_IS_MOBILE ? $qaconfig['qa_mobile_page_rows'] : $qaconfig['qa_page_rows'], $page, $total_page, './qalist.php'.$qstr.'&page='));
|
||||
|
||||
$stx = get_text(stripslashes($stx));
|
||||
include_once($skin_file);
|
||||
} else {
|
||||
echo '<div>'.str_replace(G5_PATH.'/', '', $skin_file).'이 존재하지 않습니다.</div>';
|
||||
}
|
||||
|
||||
include_once('./_tail.php');
|
||||
?>
|
||||
175
bbs/qaview.php
Normal file
175
bbs/qaview.php
Normal file
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
include_once(G5_EDITOR_LIB);
|
||||
|
||||
if($is_guest)
|
||||
alert('회원이시라면 로그인 후 이용해 보십시오.', './login.php?url='.urlencode(G5_BBS_URL.'/qalist.php'));
|
||||
|
||||
$qaconfig = get_qa_config();
|
||||
|
||||
$g5['title'] = $qaconfig['qa_title'];
|
||||
include_once('./_head.php');
|
||||
|
||||
$qa_skin_path = (G5_IS_MOBILE ? G5_MOBILE_PATH : G5_PATH).'/'.G5_SKIN_DIR.'/qa/'.$qaconfig['qa_skin'];
|
||||
$qa_skin_url = (G5_IS_MOBILE ? G5_MOBILE_URL : G5_URL).'/'.G5_SKIN_DIR.'/qa/'.$qaconfig['qa_skin'];
|
||||
$skin_file = $qa_skin_path.'/view.skin.php';
|
||||
|
||||
if(is_file($skin_file)) {
|
||||
$sql = " select * from {$g5['qa_content_table']} where qa_id = '$qa_id' ";
|
||||
if(!$is_admin) {
|
||||
$sql .= " and mb_id = '{$member['mb_id']}' ";
|
||||
}
|
||||
|
||||
$view = sql_fetch($sql);
|
||||
|
||||
if(!$view['qa_id'])
|
||||
alert('게시글이 존재하지 않습니다.\\n삭제되었거나 자신의 글이 아닌 경우입니다.');
|
||||
|
||||
$subject_len = G5_IS_MOBILE ? $qaconfig['qa_mobile_subject_len'] : $qaconfig['qa_subject_len'];
|
||||
|
||||
$view['category'] = get_text($view['qa_category']);
|
||||
$view['subject'] = conv_subject($view['qa_subject'], $subject_len, '…');
|
||||
$view['content'] = conv_content($view['qa_content'], $view['qa_html']);
|
||||
$view['name'] = get_text($view['qa_name']);
|
||||
$view['datetime'] = $view['qa_datetime'];
|
||||
|
||||
if (trim($stx))
|
||||
$view['subject'] = search_font($stx, $view['subject']);
|
||||
|
||||
if (trim($stx))
|
||||
$view['content'] = search_font($stx, $view['content']);
|
||||
|
||||
// 이전글, 다음글
|
||||
$sql = " select qa_id, qa_subject
|
||||
from {$g5['qa_content_table']}
|
||||
where qa_type = '0' ";
|
||||
if(!$is_admin) {
|
||||
$sql .= " and mb_id = '{$member['mb_id']}' ";
|
||||
}
|
||||
|
||||
// 이전글
|
||||
$prev_search = " and qa_num < '{$view['qa_num']}' order by qa_num desc limit 1 ";
|
||||
$prev = sql_fetch($sql.$prev_search);
|
||||
|
||||
$prev_href = '';
|
||||
if (isset($prev['qa_id']) && $prev['qa_id']) {
|
||||
$prev_qa_subject = get_text(cut_str($prev['qa_subject'], 255));
|
||||
$prev_href = G5_BBS_URL.'/qaview.php?qa_id='.$prev['qa_id'].$qstr;
|
||||
}
|
||||
|
||||
// 다음글
|
||||
$next_search = " and qa_num > '{$view['qa_num']}' order by qa_num asc limit 1 ";
|
||||
$next = sql_fetch($sql.$next_search);
|
||||
|
||||
$next_href = '';
|
||||
if (isset($next['qa_id']) && $next['qa_id']) {
|
||||
$next_qa_subject = get_text(cut_str($next['qa_subject'], 255));
|
||||
$next_href = G5_BBS_URL.'/qaview.php?qa_id='.$next['qa_id'].$qstr;
|
||||
}
|
||||
|
||||
|
||||
// 관련질문
|
||||
$rows = 10;
|
||||
$sql = " select *
|
||||
from {$g5['qa_content_table']}
|
||||
where qa_id <> '$qa_id'
|
||||
and qa_related = '{$view['qa_related']}'
|
||||
and qa_type = '0'
|
||||
order by qa_num, qa_type
|
||||
limit 0, $rows ";
|
||||
$result = sql_query($sql);
|
||||
|
||||
$rel_list = array();
|
||||
$rel_count = 0;
|
||||
for($i=0; $row=sql_fetch_array($result); $i++) {
|
||||
$rel_list[$i] = $row;
|
||||
$rel_list[$i]['category'] = get_text($row['qa_category']);
|
||||
$rel_list[$i]['subject'] = conv_subject($row['qa_subject'], $subject_len, '…');
|
||||
$rel_list[$i]['name'] = get_text($row['qa_name']);
|
||||
$rel_list[$i]['date'] = substr($row['qa_datetime'], 2, 8);
|
||||
$rel_list[$i]['view_href'] = G5_BBS_URL.'/qaview.php?qa_id='.$row['qa_id'].$qstr;
|
||||
$rel_count++;
|
||||
}
|
||||
$view['rel_count'] = $rel_count;
|
||||
|
||||
$update_href = '';
|
||||
$delete_href = '';
|
||||
$write_href = G5_BBS_URL.'/qawrite.php';
|
||||
$rewrite_href = G5_BBS_URL.'/qawrite.php?w=r&qa_id='.$view['qa_id'];
|
||||
$list_href = G5_BBS_URL.'/qalist.php'.preg_replace('/^&/', '?', $qstr);
|
||||
|
||||
/*
|
||||
if($view['qa_type']) {
|
||||
if($is_admin)
|
||||
$update_href = G5_BBS_URL.'/qawrite.php?w=u&qa_id='.$view['qa_id'].$qstr;
|
||||
} else {
|
||||
if($view['qa_status'] == 0)
|
||||
$update_href = G5_BBS_URL.'/qawrite.php?w=u&qa_id='.$view['qa_id'].$qstr;
|
||||
}
|
||||
*/
|
||||
if(($view['qa_type'] && $is_admin) || (!$view['qa_type'] && $view['qa_status'] == 0)) {
|
||||
$update_href = G5_BBS_URL.'/qawrite.php?w=u&qa_id='.$view['qa_id'].$qstr;
|
||||
$delete_href = G5_BBS_URL.'/qadelete.php?qa_id='.$view['qa_id'].$qstr;
|
||||
}
|
||||
|
||||
// 질문글이고 등록된 답변이 있다면
|
||||
$answer = array();
|
||||
$answer_update_href = '';
|
||||
$answer_delete_href = '';
|
||||
if(!$view['qa_type'] && $view['qa_status']) {
|
||||
$sql = " select *
|
||||
from {$g5['qa_content_table']}
|
||||
where qa_type = '1'
|
||||
and qa_parent = '{$view['qa_id']}' ";
|
||||
$answer = sql_fetch($sql);
|
||||
|
||||
if($is_admin) {
|
||||
$answer_update_href = G5_BBS_URL.'/qawrite.php?w=u&qa_id='.$answer['qa_id'].$qstr;
|
||||
$answer_delete_href = G5_BBS_URL.'/qadelete.php?qa_id='.$answer['qa_id'].$qstr;
|
||||
}
|
||||
}
|
||||
|
||||
$stx = get_text(stripslashes($stx));
|
||||
|
||||
$is_dhtml_editor = false;
|
||||
// 모바일에서는 DHTML 에디터 사용불가
|
||||
if ($config['cf_editor'] && $qaconfig['qa_use_editor'] && !G5_IS_MOBILE) {
|
||||
$is_dhtml_editor = true;
|
||||
}
|
||||
$editor_html = editor_html('qa_content', $content, $is_dhtml_editor);
|
||||
$editor_js = '';
|
||||
$editor_js .= get_editor_js('qa_content', $is_dhtml_editor);
|
||||
$editor_js .= chk_editor_js('qa_content', $is_dhtml_editor);
|
||||
|
||||
$ss_name = 'ss_qa_view_'.$qa_id;
|
||||
if(!get_session($ss_name))
|
||||
set_session($ss_name, TRUE);
|
||||
|
||||
// 첨부파일
|
||||
$view['img_file'] = array();
|
||||
$view['download_href'] = array();
|
||||
$view['download_source'] = array();
|
||||
$view['img_count'] = 0;
|
||||
$view['download_count'] = 0;
|
||||
|
||||
for ($i=1; $i<=2; $i++) {
|
||||
if(preg_match("/\.({$config['cf_image_extension']})$/i", $view['qa_file'.$i])) {
|
||||
$view['img_file'][] = '<a href="'.G5_BBS_URL.'/view_image.php?fn='.urlencode('/data/qa/'.$view['qa_file'.$i]).'" target="_blank" class="view_image"><img src="'.G5_DATA_URL.'/qa/'.$view['qa_file'.$i].'"></a>';
|
||||
$view['img_count']++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($view['qa_file'.$i]) {
|
||||
$view['download_href'][] = G5_BBS_URL.'/qadownload.php?qa_id='.$view['qa_id'].'&no='.$i;
|
||||
$view['download_source'][] = $view['qa_source'.$i];
|
||||
$view['download_count']++;
|
||||
}
|
||||
}
|
||||
|
||||
include_once($skin_file);
|
||||
} else {
|
||||
echo '<div>'.str_replace(G5_PATH.'/', '', $skin_file).'이 존재하지 않습니다.</div>';
|
||||
}
|
||||
|
||||
include_once('./_tail.php');
|
||||
?>
|
||||
141
bbs/qawrite.php
Normal file
141
bbs/qawrite.php
Normal file
@ -0,0 +1,141 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
include_once(G5_EDITOR_LIB);
|
||||
|
||||
if($w != '' && $w != 'u' && $w != 'r') {
|
||||
alert('올바른 방법으로 이용해 주십시오.');
|
||||
}
|
||||
|
||||
if($is_guest)
|
||||
alert('회원이시라면 로그인 후 이용해 보십시오.', './login.php?url='.urlencode(G5_BBS_URL.'/qalist.php'));
|
||||
|
||||
$qaconfig = get_qa_config();
|
||||
|
||||
$g5['title'] = $qaconfig['qa_title'];
|
||||
include_once('./_head.php');
|
||||
|
||||
$qa_skin_path = (G5_IS_MOBILE ? G5_MOBILE_PATH : G5_PATH).'/'.G5_SKIN_DIR.'/qa/'.$qaconfig['qa_skin'];
|
||||
$qa_skin_url = (G5_IS_MOBILE ? G5_MOBILE_URL : G5_URL).'/'.G5_SKIN_DIR.'/qa/'.$qaconfig['qa_skin'];
|
||||
$skin_file = $qa_skin_path.'/write.skin.php';
|
||||
|
||||
if(is_file($skin_file)) {
|
||||
/*==========================
|
||||
$w == a : 답변
|
||||
$w == r : 추가질문
|
||||
$w == u : 수정
|
||||
==========================*/
|
||||
|
||||
if($w == 'u' || $w == 'r') {
|
||||
$sql = " select * from {$g5['qa_content_table']} where qa_id = '$qa_id' ";
|
||||
if(!$is_admin) {
|
||||
$sql .= " and mb_id = '{$member['mb_id']}' ";
|
||||
}
|
||||
|
||||
$write = sql_fetch($sql);
|
||||
|
||||
if($w == 'u') {
|
||||
if(!$write['qa_id'])
|
||||
alert('게시글이 존재하지 않습니다.\\n삭제되었거나 자신의 글이 아닌 경우입니다.');
|
||||
|
||||
if(!$is_admin) {
|
||||
if($write['qa_type'] == 0 && $write['qa_status'] == 1)
|
||||
alert('답변이 등록된 문의글은 수정할 수 없습니다.');
|
||||
|
||||
if($write['mb_id'] != $member['mb_id'])
|
||||
alert('게시글을 수정할 권한이 없습니다.\\n\\n올바른 방법으로 이용해 주십시오.', G5_URL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 분류
|
||||
$category_option = '';
|
||||
if(trim($qaconfig['qa_category'])) {
|
||||
$category = explode('|', $qaconfig['qa_category']);
|
||||
for($i=0; $i<count($category); $i++) {
|
||||
$category_option .= option_selected($category[$i], $write['qa_category']);
|
||||
}
|
||||
} else {
|
||||
alert('1:1문의 설정에서 분류를 설정해 주십시오');
|
||||
}
|
||||
|
||||
$is_dhtml_editor = false;
|
||||
// 모바일에서는 DHTML 에디터 사용불가
|
||||
if ($config['cf_editor'] && $qaconfig['qa_use_editor'] && !G5_IS_MOBILE) {
|
||||
$is_dhtml_editor = true;
|
||||
}
|
||||
|
||||
// 추가질문에서는 제목을 공백으로
|
||||
if($w == 'r')
|
||||
$write['qa_subject'] = '';
|
||||
|
||||
$content = '';
|
||||
if ($w == '') {
|
||||
$content = $qaconfig['qa_insert_content'];
|
||||
} else if($w == 'r') {
|
||||
if($is_dhtml_editor)
|
||||
$content = '<div><br><br><br>====== 이전 답변내용 =======<br></div>';
|
||||
else
|
||||
$content = "\n\n\n\n====== 이전 답변내용 =======\n";
|
||||
|
||||
$content .= get_text($write['qa_content'], 0);
|
||||
} else {
|
||||
$content = get_text($write['qa_content'], 0);
|
||||
}
|
||||
|
||||
$editor_html = editor_html('qa_content', $content, $is_dhtml_editor);
|
||||
$editor_js = '';
|
||||
$editor_js .= get_editor_js('qa_content', $is_dhtml_editor);
|
||||
$editor_js .= chk_editor_js('qa_content', $is_dhtml_editor);
|
||||
|
||||
$upload_max_filesize = number_format($qaconfig['qa_upload_size']) . ' 바이트';
|
||||
|
||||
$html_value = '';
|
||||
if ($write['qa_html']) {
|
||||
$html_checked = 'checked';
|
||||
$html_value = $write['qa_html'];
|
||||
|
||||
if($w == 'r' && $write['qa_html'] == 1 && !$is_dhtml_editor)
|
||||
$html_value = 2;
|
||||
}
|
||||
|
||||
$is_email = false;
|
||||
$req_email = '';
|
||||
if($qaconfig['qa_use_email']) {
|
||||
$is_email = true;
|
||||
|
||||
if($qaconfig['qa_req_email'])
|
||||
$req_email = 'required';
|
||||
|
||||
if($w == '' || $w == 'r')
|
||||
$write['qa_email'] = $member['mb_email'];
|
||||
|
||||
if($w == 'u' && $is_admin && $write['qa_type'])
|
||||
$is_email = false;
|
||||
}
|
||||
|
||||
$is_hp = false;
|
||||
$req_hp = '';
|
||||
if($qaconfig['qa_use_hp']) {
|
||||
$is_hp = true;
|
||||
|
||||
if($qaconfig['qa_req_hp'])
|
||||
$req_hp = 'required';
|
||||
|
||||
if($w == '' || $w == 'r')
|
||||
$write['qa_hp'] = $member['mb_hp'];
|
||||
|
||||
if($w == 'u' && $is_admin && $write['qa_type'])
|
||||
$is_hp = false;
|
||||
}
|
||||
|
||||
$list_href = G5_BBS_URL.'/qalist.php'.preg_replace('/^&/', '?', $qstr);
|
||||
|
||||
$action_url = https_url(G5_BBS_DIR).'/qawrite_update.php';
|
||||
|
||||
include_once($skin_file);
|
||||
} else {
|
||||
echo '<div>'.str_replace(G5_PATH.'/', '', $skin_file).'이 존재하지 않습니다.</div>';
|
||||
}
|
||||
|
||||
include_once('./_tail.php');
|
||||
?>
|
||||
339
bbs/qawrite_update.php
Normal file
339
bbs/qawrite_update.php
Normal file
@ -0,0 +1,339 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
|
||||
/*==========================
|
||||
$w == a : 답변
|
||||
$w == r : 추가질문
|
||||
$w == u : 수정
|
||||
==========================*/
|
||||
|
||||
if($is_guest)
|
||||
alert('회원이시라면 로그인 후 이용해 보십시오.', './login.php?url='.urlencode(G5_BBS_URL.'/qalist.php'));
|
||||
|
||||
$msg = array();
|
||||
|
||||
$qa_subject = '';
|
||||
if (isset($_POST['qa_subject'])) {
|
||||
$qa_subject = substr(trim($_POST['qa_subject']),0,255);
|
||||
}
|
||||
if ($qa_subject == '') {
|
||||
$msg[] = '<strong>제목</strong>을 입력하세요.';
|
||||
}
|
||||
|
||||
$qa_content = '';
|
||||
if (isset($_POST['qa_content'])) {
|
||||
$qa_content = substr(trim($_POST['qa_content']),0,65536);
|
||||
}
|
||||
if ($qa_content == '') {
|
||||
$msg[] = '<strong>내용</strong>을 입력하세요.';
|
||||
}
|
||||
|
||||
if (!empty($msg)) {
|
||||
$msg = implode('<br>', $msg);
|
||||
alert($msg);
|
||||
}
|
||||
|
||||
// 090710
|
||||
if (substr_count($qa_content, '&#') > 50) {
|
||||
alert('내용에 올바르지 않은 코드가 다수 포함되어 있습니다.');
|
||||
exit;
|
||||
}
|
||||
|
||||
$upload_max_filesize = ini_get('upload_max_filesize');
|
||||
|
||||
if (empty($_POST)) {
|
||||
alert("파일 또는 글내용의 크기가 서버에서 설정한 값을 넘어 오류가 발생하였습니다.\\npost_max_size=".ini_get('post_max_size')." , upload_max_filesize=".$upload_max_filesize."\\n게시판관리자 또는 서버관리자에게 문의 바랍니다.");
|
||||
}
|
||||
|
||||
for ($i=1; $i<=5; $i++) {
|
||||
$var = "qa_$i";
|
||||
$$var = "";
|
||||
if (isset($_POST['qa_'.$i]) && $_POST['qa_'.$i]) {
|
||||
$$var = escape_trim($_POST['qa_'.$i]);
|
||||
}
|
||||
}
|
||||
|
||||
// 1:1문의 설정값
|
||||
$qaconfig = get_qa_config();
|
||||
|
||||
if($w == 'u' || $w == 'a' || $w == 'r') {
|
||||
if($w == 'a' && !$is_admin)
|
||||
alert('답변은 관리자만 등록할 수 있습니다.');
|
||||
|
||||
$sql = " select * from {$g5['qa_content_table']} where qa_id = '$qa_id' ";
|
||||
if(!$is_admin) {
|
||||
$sql .= " and mb_id = '{$member['mb_id']}' ";
|
||||
}
|
||||
|
||||
$write = sql_fetch($sql);
|
||||
|
||||
if($w == 'u') {
|
||||
if(!$write['qa_id'])
|
||||
alert('게시글이 존재하지 않습니다.\\n삭제되었거나 자신의 글이 아닌 경우입니다.');
|
||||
|
||||
if(!$is_admin) {
|
||||
if($write['qa_type'] == 0 && $write['qa_status'] == 1)
|
||||
alert('답변이 등록된 문의글은 수정할 수 없습니다.');
|
||||
|
||||
if($write['mb_id'] != $member['mb_id'])
|
||||
alert('게시글을 수정할 권한이 없습니다.\\n\\n올바른 방법으로 이용해 주십시오.', G5_URL);
|
||||
}
|
||||
}
|
||||
|
||||
if($w == 'a') {
|
||||
if(!$write['qa_id'])
|
||||
alert('문의글이 존재하지 않아 답변글을 등록할 수 없습니다.');
|
||||
|
||||
if($write['qa_type'] == 1)
|
||||
alert('답변글에는 다시 답변을 등록할 수 없습니다.');
|
||||
}
|
||||
}
|
||||
|
||||
// 디렉토리가 없다면 생성합니다. (퍼미션도 변경하구요.)
|
||||
@mkdir(G5_DATA_PATH.'/qa', G5_DIR_PERMISSION);
|
||||
@chmod(G5_DATA_PATH.'/qa', G5_DIR_PERMISSION);
|
||||
|
||||
$chars_array = array_merge(range(0,9), range('a','z'), range('A','Z'));
|
||||
|
||||
// 가변 파일 업로드
|
||||
$file_upload_msg = '';
|
||||
$upload = array();
|
||||
for ($i=1; $i<=count($_FILES['bf_file']['name']); $i++) {
|
||||
$upload[$i]['file'] = '';
|
||||
$upload[$i]['source'] = '';
|
||||
$upload[$i]['del_check'] = false;
|
||||
|
||||
// 삭제에 체크가 되어있다면 파일을 삭제합니다.
|
||||
if (isset($_POST['bf_file_del'][$i]) && $_POST['bf_file_del'][$i]) {
|
||||
$upload[$i]['del_check'] = true;
|
||||
@unlink(G5_DATA_PATH.'/qa/'.$write['qa_file'.$i]);
|
||||
// 썸네일삭제
|
||||
if(preg_match("/\.({$config['cf_image_extension']})$/i", $write['qa_file'.$i])) {
|
||||
delete_qa_thumbnail($write['qa_file'.$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$tmp_file = $_FILES['bf_file']['tmp_name'][$i];
|
||||
$filesize = $_FILES['bf_file']['size'][$i];
|
||||
$filename = $_FILES['bf_file']['name'][$i];
|
||||
$filename = preg_replace('/(<|>|=)/', '', $filename);
|
||||
|
||||
// 서버에 설정된 값보다 큰파일을 업로드 한다면
|
||||
if ($filename) {
|
||||
if ($_FILES['bf_file']['error'][$i] == 1) {
|
||||
$file_upload_msg .= '\"'.$filename.'\" 파일의 용량이 서버에 설정('.$upload_max_filesize.')된 값보다 크므로 업로드 할 수 없습니다.\\n';
|
||||
continue;
|
||||
}
|
||||
else if ($_FILES['bf_file']['error'][$i] != 0) {
|
||||
$file_upload_msg .= '\"'.$filename.'\" 파일이 정상적으로 업로드 되지 않았습니다.\\n';
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_uploaded_file($tmp_file)) {
|
||||
// 관리자가 아니면서 설정한 업로드 사이즈보다 크다면 건너뜀
|
||||
if (!$is_admin && $filesize > $qaconfig['qa_upload_size']) {
|
||||
$file_upload_msg .= '\"'.$filename.'\" 파일의 용량('.number_format($filesize).' 바이트)이 게시판에 설정('.number_format($qaconfig['qa_upload_size']).' 바이트)된 값보다 크므로 업로드 하지 않습니다.\\n';
|
||||
continue;
|
||||
}
|
||||
|
||||
//=================================================================\
|
||||
// 090714
|
||||
// 이미지나 플래시 파일에 악성코드를 심어 업로드 하는 경우를 방지
|
||||
// 에러메세지는 출력하지 않는다.
|
||||
//-----------------------------------------------------------------
|
||||
$timg = @getimagesize($tmp_file);
|
||||
// image type
|
||||
if ( preg_match("/\.({$config['cf_image_extension']})$/i", $filename) ||
|
||||
preg_match("/\.({$config['cf_flash_extension']})$/i", $filename) ) {
|
||||
if ($timg['2'] < 1 || $timg['2'] > 16)
|
||||
continue;
|
||||
}
|
||||
//=================================================================
|
||||
|
||||
if ($w == 'u') {
|
||||
// 존재하는 파일이 있다면 삭제합니다.
|
||||
@unlink(G5_DATA_PATH.'/qa/'.$write['qa_file'.$i]);
|
||||
// 이미지파일이면 썸네일삭제
|
||||
if(preg_match("/\.({$config['cf_image_extension']})$/i", $write['qa_file'.$i])) {
|
||||
delete_qa_thumbnail($row['qa_file'.$i]);
|
||||
}
|
||||
}
|
||||
|
||||
// 프로그램 원래 파일명
|
||||
$upload[$i]['source'] = $filename;
|
||||
$upload[$i]['filesize'] = $filesize;
|
||||
|
||||
// 아래의 문자열이 들어간 파일은 -x 를 붙여서 웹경로를 알더라도 실행을 하지 못하도록 함
|
||||
$filename = preg_replace("/\.(php|phtm|htm|cgi|pl|exe|jsp|asp|inc)/i", "$0-x", $filename);
|
||||
|
||||
shuffle($chars_array);
|
||||
$shuffle = implode('', $chars_array);
|
||||
|
||||
// 첨부파일 첨부시 첨부파일명에 공백이 포함되어 있으면 일부 PC에서 보이지 않거나 다운로드 되지 않는 현상이 있습니다. (길상여의 님 090925)
|
||||
$upload[$i]['file'] = abs(ip2long($_SERVER['REMOTE_ADDR'])).'_'.substr($shuffle,0,8).'_'.str_replace('%', '', urlencode(str_replace(' ', '_', $filename)));
|
||||
|
||||
$dest_file = G5_DATA_PATH.'/qa/'.$upload[$i]['file'];
|
||||
|
||||
// 업로드가 안된다면 에러메세지 출력하고 죽어버립니다.
|
||||
$error_code = move_uploaded_file($tmp_file, $dest_file) or die($_FILES['bf_file']['error'][$i]);
|
||||
|
||||
// 올라간 파일의 퍼미션을 변경합니다.
|
||||
chmod($dest_file, G5_FILE_PERMISSION);
|
||||
}
|
||||
}
|
||||
|
||||
if($w == '' || $w == 'a' || $w == 'r') {
|
||||
if($w == '' || $w == 'r') {
|
||||
$row = sql_fetch(" select MIN(qa_num) as min_qa_num from {$g5['qa_content_table']} ");
|
||||
$qa_num = $row['min_qa_num'] - 1;
|
||||
}
|
||||
|
||||
if($w == 'a') {
|
||||
$qa_num = $write['qa_num'];
|
||||
$qa_parent = $write['qa_id'];
|
||||
$qa_related = $write['qa_related'];
|
||||
$qa_category = $write['qa_category'];
|
||||
$qa_type = 1;
|
||||
$qa_status = 1;
|
||||
}
|
||||
|
||||
$sql = " insert into {$g5['qa_content_table']}
|
||||
set qa_num = '$qa_num',
|
||||
mb_id = '{$member['mb_id']}',
|
||||
qa_name = '{$member['mb_nick']}',
|
||||
qa_email = '$qa_email',
|
||||
qa_hp = '$qa_hp',
|
||||
qa_type = '$qa_type',
|
||||
qa_parent = '$qa_parent',
|
||||
qa_related = '$qa_related',
|
||||
qa_category = '$qa_category',
|
||||
qa_email_recv = '$qa_email_recv',
|
||||
qa_sms_recv = '$qa_sms_recv',
|
||||
qa_html = '$qa_html',
|
||||
qa_subject = '$qa_subject',
|
||||
qa_content = '$qa_content',
|
||||
qa_status = '$qa_status',
|
||||
qa_file1 = '{$upload[1]['file']}',
|
||||
qa_source1 = '{$upload[1]['source']}',
|
||||
qa_file2 = '{$upload[2]['file']}',
|
||||
qa_source2 = '{$upload[2]['source']}',
|
||||
qa_ip = '{$_SERVER['REMOTE_ADDR']}',
|
||||
qa_datetime = '".G5_TIME_YMDHIS."',
|
||||
qa_1 = '$qa_1',
|
||||
qa_2 = '$qa_2',
|
||||
qa_3 = '$qa_3',
|
||||
qa_4 = '$qa_4',
|
||||
qa_5 = '$qa_5' ";
|
||||
sql_query($sql);
|
||||
|
||||
if($w == '' || $w == 'r') {
|
||||
$qa_id = mysql_insert_id();
|
||||
|
||||
if($w == 'r' && $write['qa_related']) {
|
||||
$qa_related = $write['qa_related'];
|
||||
} else {
|
||||
$qa_related = $qa_id;
|
||||
}
|
||||
|
||||
$sql = " update {$g5['qa_content_table']}
|
||||
set qa_parent = '$qa_id',
|
||||
qa_related = '$qa_related'
|
||||
where qa_id = '$qa_id' ";
|
||||
sql_query($sql);
|
||||
}
|
||||
|
||||
if($w == 'a') {
|
||||
$sql = " update {$g5['qa_content_table']}
|
||||
set qa_status = '1'
|
||||
where qa_id = '{$write['qa_parent']}' ";
|
||||
sql_query($sql);
|
||||
}
|
||||
} else if($w == 'u') {
|
||||
if(!$upload[1]['file'] && !$upload[1]['del_check']) {
|
||||
$upload[1]['file'] = $write['qa_file1'];
|
||||
$upload[1]['source'] = $write['qa_source1'];
|
||||
}
|
||||
|
||||
if(!$upload[2]['file'] && !$upload[2]['del_check']) {
|
||||
$upload[2]['file'] = $write['qa_file2'];
|
||||
$upload[2]['source'] = $write['qa_source2'];
|
||||
}
|
||||
|
||||
$sql = " update {$g5['qa_content_table']}
|
||||
set qa_email = '$qa_email',
|
||||
qa_hp = '$qa_hp',
|
||||
qa_category = '$qa_category',
|
||||
qa_html = '$qa_html',
|
||||
qa_subject = '$qa_subject',
|
||||
qa_content = '$qa_content',
|
||||
qa_file1 = '{$upload[1]['file']}',
|
||||
qa_source1 = '{$upload[1]['source']}',
|
||||
qa_file2 = '{$upload[2]['file']}',
|
||||
qa_source2 = '{$upload[2]['source']}',
|
||||
qa_1 = '$qa_1',
|
||||
qa_2 = '$qa_2',
|
||||
qa_3 = '$qa_3',
|
||||
qa_4 = '$qa_4',
|
||||
qa_5 = '$qa_5' ";
|
||||
if($qa_sms_recv)
|
||||
$sql .= ", qa_sms_recv = '$qa_sms_recv' ";
|
||||
$sql .= " where qa_id = '$qa_id' ";
|
||||
sql_query($sql);
|
||||
}
|
||||
|
||||
// SMS 알림
|
||||
if($config['cf_sms_use'] == 'icode' && $qaconfig['qa_use_sms']) {
|
||||
include_once(G5_LIB_PATH.'/icode.sms.lib.php');
|
||||
|
||||
// 답변글은 질문 등록자에게 전송
|
||||
if($w == 'a' && $write['qa_sms_recv'] && trim($write['qa_hp'])) {
|
||||
$sms_content = $config['cf_title'].' '.$qaconfig['qa_title'].'에 답변이 등록되었습니다.';
|
||||
$send_number = preg_replace('/[^0-9]/', '', $qaconfig['qa_send_number']);
|
||||
$recv_number = preg_replace('/[^0-9]/', '', $write['qa_hp']);
|
||||
|
||||
if($recv_number) {
|
||||
$SMS = new SMS; // SMS 연결
|
||||
$SMS->SMS_con($config['cf_icode_server_ip'], $config['cf_icode_id'], $config['cf_icode_pw'], $config['cf_icode_server_port']);
|
||||
$SMS->Add($recv_number, $send_number, $config['cf_icode_id'], iconv("utf-8", "euc-kr", stripslashes($sms_content)), "");
|
||||
$SMS->Send();
|
||||
}
|
||||
}
|
||||
|
||||
// 문의글 등록시 관리자에게 전송
|
||||
if(($w == '' || $w == 'r') && trim($qaconfig['qa_admin_hp'])) {
|
||||
$sms_content = $config['cf_title'].' '.$qaconfig['qa_title'].'에 문의글이 등록되었습니다.';
|
||||
$send_number = preg_replace('/[^0-9]/', '', $qa_hp);
|
||||
$recv_number = preg_replace('/[^0-9]/', '', $qaconfig['qa_admin_hp']);
|
||||
|
||||
if($recv_number) {
|
||||
$SMS = new SMS; // SMS 연결
|
||||
$SMS->SMS_con($config['cf_icode_server_ip'], $config['cf_icode_id'], $config['cf_icode_pw'], $config['cf_icode_server_port']);
|
||||
$SMS->Add($recv_number, $send_number, $config['cf_icode_id'], iconv("utf-8", "euc-kr", stripslashes($sms_content)), "");
|
||||
$SMS->Send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 답변 이메일전송
|
||||
if($w == 'a' && $write['qa_email_recv'] && trim($write['qa_email'])) {
|
||||
include_once(G5_LIB_PATH.'/mailer.lib.php');
|
||||
|
||||
$subject = $config['cf_title'].' '.$qaconfig['qa_title'].' 답변 알림 메일';
|
||||
$content = conv_content($qa_content, $qa_html);
|
||||
|
||||
mailer($config['cf_title'], $admin['mb_email'], $write['qa_email'], $subject, $content, 1);
|
||||
}
|
||||
|
||||
if($w == 'a')
|
||||
$result_url = G5_BBS_URL.'/qaview.php?qa_id='.$qa_id.$qstr;
|
||||
else if($w == 'u' && $write['qa_type'])
|
||||
$result_url = G5_BBS_URL.'/qaview.php?qa_id='.$write['qa_parent'].$qstr;
|
||||
else
|
||||
$result_url = G5_BBS_URL.'/qalist.php'.preg_replace('/^&/', '?', $qstr);
|
||||
|
||||
if ($file_upload_msg)
|
||||
alert($file_upload_msg, $result_url);
|
||||
else
|
||||
goto_url($result_url);
|
||||
?>
|
||||
@ -10,6 +10,9 @@ $bo_table = $_GET['bo_table'];
|
||||
if(strpos($filename, 'data/editor')) {
|
||||
$editor_file = strstr($filename, 'editor');
|
||||
$filepath = G5_DATA_PATH.'/'.$editor_file;
|
||||
} else if(strpos($filename, 'data/qa')) {
|
||||
$editor_file = strstr($filename, 'qa');
|
||||
$filepath = G5_DATA_PATH.'/'.$editor_file;
|
||||
} else {
|
||||
$editor_file = '';
|
||||
$filepath = G5_DATA_PATH.'/file/'.$bo_table.'/'.$filename;
|
||||
|
||||
Reference in New Issue
Block a user