########################################################################
/*
Template_ 를 이용한 게시판
Gboy Board Template_
제작자 : 강병호
제작일 : 2004.12.04 ~ 2004.12.10
연락처 : gboy0713@yahoo.co.kr
Version : 1.0.0
템플릿언더바
Program : Template_
Version : 2.2.3
Date : 2004-05-27
Author : Hyeong-Gil Park
Email : xtac@xtac.net
Homepage : http://www.xtac.net
Licence : LGPL (Freeware)
본 게시판은 템플릿언더바(Template Underscore)를 이용한 게시판입니다.
유동적인 스킨 적용과 HTML과 PHP의 분리를 목적으로 하였으며
디자인작업을 보다 쉽고 빠르게 그리고 유지보수가 용이하게
할 목적으로 제작 하게 되었습니다.
*/
#########################################################################
########################################################################
/*
추가 기능 및 수정 요구 사항
1. 수정
게시판 전체 경로의 환경설정을 수동으로 한다.
2. 추가
관리자 바로 삭제
공지글 입력
비밀글 추가
겔러리 기능 추가
연속 보기 추가
연속 삭제 추가
웹편집기 추가
*/
#########################################################################
################################ 초기설정 ###############################
//자바스크립트 클래스
include_once ("class/javascript.class.php");
//기타 클래스
include_once ("class/function.class.php");
//환경설정
include_once ("inc/config.htm");
//DB 기본 클래스
include_once ("class/db.class.php");
//DB 사용 클래스
include_once ("class/db.class.use.php");
//Template_ 클래스
include_once ("class/Template_.class.php");
//파일 업로드 클래스
include_once ("class/file.class.php");
//Template_ 객체 호출
if(!$tpl) $tpl = new Template_;
##########################################################################
################################ 환경설정 ################################
$bbs_setup = $fun->setup_init(BBS_SETUP, $code);
$sql = "select * from ".MEMBER_SETUP;
$rs = $db -> query($sql);
$member_setup = $db -> fetch_array($rs);
$sql = "select * from ".BBS_CONFIG;
$rs = $db -> query($sql);
$row = $db -> fetch_array($rs);
//게시판 웹 절대 경로 (이미지 출력용)
$bbs_setup[bbs_path] = $row[bbs_path]."_template/";
$bbs_setup[_bbs_path_] = $row[bbs_path];
//게시판 서버 절대 경로
$bbs_setup[bbs_file_path] = $DOCUMENT_ROOT.$row[bbs_path];
if(!$_COOKIE['_user_level']) $_COOKIE['_user_level'] = 5;
###########################################################################
//레벨설정
$fun -> bbs_level($_COOKIE[_user_level], $type, "/sub07_01.html");
//게시판 사용중유무
if($bbs_setup[bbs_use] == false) $fun->error_msg($bbs_setup[bbs_name]." 게시판은 사용이 중지 되었습니다.");
//코드가 없으면 에로메세지
if(!$code) $fun->error_msg("게시판 구분 코드가 없습니다.");
//저작권
if($bbs_setup[lin_use] == 1 && ($type != "download" && $get_type != "secret")){
$tpl->define(array("body" => $bbs_setup[_file_]."bbs/".$bbs_setup[skin]."/lin.htm"));
//기본값 지정
$tpl->assign(
array(
"site_company" => $site_company,
"site_tel" => $site_tel,
"site_email" => $site_emali
)
);
//출력
$tpl->print_("body");
}
$tpl->assign(
array(
"domain" => $domain
)
);
//검색
$search = "&part=$part&word=$word&domain=$domain";
//기본링크 값설정
$write_link = "$PHP_SELF?type=write&code=$code&id=$id&page=$page$search";
$modify_link = "$PHP_SELF?type=modify&code=$code&id=$id&page=$page$search";
$delete_link = "$PHP_SELF?type=delete_form&code=$code&id=$id&page=$page$search";
$reply_link = "$PHP_SELF?type=reply&code=$code&id=$id&page=$page$search";
$list_link = "$PHP_SELF?type=list&code=$code&page=$page$search";
$refresh_link = "$PHP_SELF?type=list&code=$code";
//초기값
if(!$page) $page = 1;
if(!$type) $type = "list";
$_POST["ip"] = $REMOTE_ADDR;
//검색 조건
if($word){
//전체검색일 경우
if($part == "all"){
$sql_ = " and (subject LIKE '%$word%' ";
$sql_ .= " or content LIKE '%$word%' ";
$sql_ .= " or email LIKE '%$word%' ";
$sql_ .= " or name LIKE '%$word%' ) ";
//개별검색인 경우
}else $sql_ = " and $part LIKE '%$word%' ";
}
###########################################################################
//조건에 따른 출력
switch($type){
######################################################################
/*
게시물 저장
1. 넘어온 값과 필요한 값을 넣은 후 db class를 이용하여 저장합니다.
2. 저장후 저장 고유번호를 그룹값으로 다시 업데이트 합니다.
3. 페이지 이동
*/
######################################################################
case "insert":
//필터링
if($bbs_setup[filter_use] == 2){
if(!$fun -> filter($bbs_setup[filter], $_POST[content])){
$javascript->error_mesg("등록 금지 단어가 입력되었습니다.");
}
if(!$fun -> filter($bbs_setup[filter], $_POST[subject])){
$javascript->error_mesg("등록 금지 단어가 입력되었습니다.");
}
}
if(is_array($_FILES)){
if(!is_dir($bbs_setup[bbs_file_path]."data/$code/")){
mkdir($bbs_setup[bbs_file_path]."data/$code/", 0777);
}
$_FILE_ = $file -> multi_upload($_FILES, "upfile");
for($i = 0 ; $i < sizeof($_FILE_) ; $i++){
$_P["filename"][$i] = $file -> file_upload($_FILE_[$i],$bbs_setup[bbs_file_path]."data/$code/");
}
$_POST["filename"] = @implode(",", $_P["filename"]);
}
//업로드가 없으면 공백처리
if(str_repeat(",", ($bbs_setup[filenum]-1)) == $_POST["filename"]) unset($_POST["filename"]);
//저장
$insert_id = $db -> insert(BBS, $_POST);
//그룹값넣기
$sql = "update ".BBS." set grp = '$insert_id' where id = '$insert_id' ";
$rs = $db -> query($sql);
if(trim($_POST[wdate])){
$sql = "update ".BBS." set wdate = '$_POST[wdate]' where id = '$insert_id'";
$rs = $db -> query($sql);
}
//이동
$javascript->mesg_link("", "http://www.nowonkfcc.kr".$PHP_SELF."?type=list&code=$code&page=$page$search");
break;
######################################################################
/*
메모 저장
1. 게시물을 메모로 설정후 메모의 그룹 설정 후 저장한다.
2. 페이지 이동
*/
######################################################################
case "memo_insert":
//필터링
if($bbs_setup[filter_use] == 2){
if(!$fun -> filter($bbs_setup[filter], $_POST[content])){
$javascript->error_mesg("등록 금지 단어가 입력되었습니다.");
}
}
//메모설정
$_POST["memo"] = 1;
//부모값지정
$_POST["grp"] = $_POST["id"];
//저장
$insert_id = $db -> insert(BBS, $_POST);
//이동
$javascript->mesg_link("", $PHP_SELF."?type=read&code=$code&id=$id&page=$page$search");
break;
######################################################################
/*
답변쓰기
1. 답변저장/이미지등록
2. 페이지 이동
*/
######################################################################
case "reinsert":
//필터링
if($bbs_setup[filter_use] == 2){
if(!$fun -> filter($bbs_setup[filter], $_POST[content])){
$javascript->error_mesg("등록 금지 단어가 입력되었습니다.");
}
if(!$fun -> filter($bbs_setup[filter], $_POST[subject])){
$javascript->error_mesg("등록 금지 단어가 입력되었습니다.");
}
}
if(is_array($_FILES)){
if(!is_dir($bbs_setup[bbs_file_path]."data/$code/")){
mkdir($bbs_setup[bbs_file_path]."data/$code/", 0777);
}
$_FILE_ = $file -> multi_upload($_FILES, "upfile");
for($i = 0 ; $i < sizeof($_FILE_) ; $i++){
$_P["filename"][$i] = $file -> file_upload($_FILE_[$i],$bbs_setup[bbs_file_path]."data/$code/");
}
$_POST["filename"] = @implode(",", $_P["filename"]);
}
$sql = "select grp,loc,stp from ".BBS." where code = '$code' and id = '$id'";
$rs = $db -> query($sql);
$row = $db -> fetch_array($rs);
$grp = $row[0];
$loc = $row[1];
$stp = $row[2];
$sql1 = "select grp,loc,stp from ".BBS." where code = '$code' and grp = $grp and stp > $stp and ";
$sql1 .= "loc <= $loc order by stp";
$rs1 = $db -> query($sql1);
$row1 = $db -> fetch_row($rs1);
if($row1[0]){
$br_str = $row1[2];
$sql2 = "select grp,loc,stp from ".BBS." where code = '$code' and grp = $grp ";
$sql2 .= "and stp > $stp and stp < $br_str and loc > $loc order by stp desc";
}else{
$sql2 = "select grp,loc,stp from ".BBS." where code = '$code' ";
$sql2 .= "and grp = $grp and stp > $stp and loc > $loc order by stp desc";
}
$rs2 = $db -> query($sql2);
$row2 = $db -> fetch_row($rs2);
if($row2[0]) $stp = $row2[2];
$sql3 ="update ".BBS." set stp = stp + 1 where code = '$code' and grp = $grp and stp > $stp";
$rs3 = $db -> query($sql3);
$_POST["stp"] = $stp + 1;
$_POST["loc"] = $loc + 1;
$_POST["grp"] = $grp;
$_POST["subject"] = str_replace("Re:", "", $subject); if(is_array($_FILES)){
if(!is_dir($bbs_setup[bbs_file_path]."data/$code/"))
mkdir($bbs_setup[bbs_file_path]."data/$code/", 0777);
$_FILE_ = $file -> multi_upload($_FILES, "upfile");
for($i = 0 ; $i < sizeof($_FILE_) ; $i++){
$_P["filename"][$i] = $file -> file_upload($_FILE_[$i],$bbs_setup[bbs_file_path]."data/$code/");
}
$_POST["filename"] = @implode(",", $_P["filename"]);
}
$insert_id = $db -> insert(BBS, $_POST);
if(trim($_POST[wdate])){
$sql = "update ".BBS." set wdate = '$_POST[wdate]' where id = '$insert_id'";
$rs = $db -> query($sql);
}
$javascript->mesg_link("","http://www.nowonkfcc.kr".$PHP_SELF."?code=$code&page=$page$search");
break;
######################################################################
/*
정보수정
1. 정보수정/이미지등록/이미지업데이트
2. 페이지 이동
*/
######################################################################
case "update":
//필터링
if($bbs_setup[filter_use] == 2){
if(!$fun -> filter($bbs_setup[filter], $_POST[content])){
$javascript->error_mesg("등록 금지 단어가 입력되었습니다.");
}
if(!$fun -> filter($bbs_setup[filter], $_POST[subject])){
$javascript->error_mesg("등록 금지 단어가 입력되었습니다.");
}
}
//정보읽어오기
$sql = "select * from ".BBS." where id = '$id' and code = '$code' ";
$row = $db -> fetch_array($db -> query($sql));
if(!$_POST[header]) $_POST[header] = '2';
if(!$_COOKIE[_user_id]) $_COOKIE[_user_id] = "guest";
//비밀번호 검사 후 저장
if($row[pass]==$_POST["pass"] || $_COOKIE[_user_level]==1 || $bbs_setup[bbs_admin]==$_COOKIE[_user_id]){
//파일 다시업로드
if(is_array($_FILES)){
if(!is_dir($bbs_setup[bbs_file_path]."data/$code/")){
mkdir($bbs_setup[bbs_file_path]."data/$code/", 0777);
}
$sql = "select * from ".BBS." where code = '$code' and id = '$id'";
$rs = $db -> query($sql);
$row = $db -> fetch_array($rs);
$filename = explode(",", $row[filename]);
$_FILE_ = $file -> multi_upload($_FILES, "upfile");
for($i = 0 ; $i < sizeof($_FILE_) ; $i++){
if($_FILE_[$i]["name"] != ""){
if($_POST[del_file][$i]){
@unlink($bbs_setup[bbs_file_path]."data/$code/".$filename[$i]);
}
$_P["filename"][$i] = $file -> file_upload(
$_FILE_[$i],
$bbs_setup[bbs_file_path]."data/$code/"
);
}else{
if($_POST[del_file][$i]){
@unlink($bbs_setup[bbs_file_path]."data/$code/".$_POST[del_file][$i]);
$_P["filename"][$i] = "";
}else $_P["filename"][$i] = $filename[$i];
}
}
$_POST["filename"] = @implode(",", $_P["filename"]);
}
while(list($k, $v) = each($_POST)) if(!$v) $_POST[$k] = " ";
$_POST["html"] = ($_POST["html"] == "2") ? "2" : "1";
$_POST["secret"] = ($_POST["secret"] == "2") ? "2" : "1";
$db -> update(BBS, $_POST, "id", array($id));
if(trim($_POST[wdate])){
$sql = "update ".BBS." set wdate = '$_POST[wdate]' where id = '$id'";
$rs = $db -> query($sql);
}
}else $javascript->error_mesg("비밀번호가 서로 다릅니다.");
//이동
$javascript->mesg_link("", "http://www.nowonkfcc.kr".$PHP_SELF."?type=read&code=$code&id=$id&page=$page$search");
break;
######################################################################
/*
게시물이동
1. 게시물 이동
2. 페이지 이동
*/
######################################################################
case "move":
//선택한 게시물이 같은 그룹이면 그대로 적용하고 같은 그룹이 아닌 답글이면 원글로 등록
//원글이면 원글로 등록 한다.
while(list($k, $v) = each($chk)){
//정보를 읽어온다.
$sql = "select * from ".BBS." where code = '$code' and id = '$v'";
$rs = $db -> query($sql);
while($row = $db -> fetch_assoc($rs)) $grp[$row[grp]][] = $row[id];
}
while(list($k, $v) = each($grp)){
while(list($a, $b) = each($v)){
$sql = "select * from ".BBS." where code = '$code' and id = '$b'";
$rsg = $db -> query($sql);
while($rog = $db -> fetch_assoc($rsg)){
$rog[id] = "";
$rog[wdate] = "";
$rog[hit] = "0";
$rog[code] = $_POST[move];
$rog[name] = "운영자";
$rog[email] = "";
$rog[pass] = rand(1000, 9999);
$insert_id = $db -> insert(BBS, $rog);
//원글일경우
if($a == 0){
$sql = "update ".BBS." set grp = '$insert_id', stp = '0', loc = '0' ";
$sql .= "where code = '$move' and id = '$insert_id'";
$rs = $db -> query($sql);
$new_grp = $insert_id;
//답글인 경우
}else{
$sql = "update ".BBS." set grp = '$new_grp' where code = '$move' and id = '$insert_id'";
$rs = $db -> query($sql);
}
}
}
}
//이동
$javascript->mesg_link("", $PHP_SELF."?type=list&code=$code&page=$page$search");
break;
######################################################################
/*
게시물 삭제
1. 게시물 삭제
2. 페이지 이동
*/
######################################################################
case "delete":
//정보읽어오기
$sql = "select * from ".BBS." where id = '$id' and code = '$code' ";
$row = $db -> fetch_array($db -> query($sql));
if(!$_COOKIE[_user_id]) $_COOKIE[_user_id] = "guest";
//비밀글인경우
if($get_type == "secret"){
if($row[pass]==$_POST["pass"]||$_COOKIE[_user_level]==1||$bbs_setup[bbs_admin]==$_COOKIE[_user_id]){
setcookie("_secret_cookie_".$id, md5($id), 0);
exit($javascript->mesg_link("", $_POST[url]));
}else{
$sql = "select * from ".BBS." where id = '$row[grp]'";
$rsx = $db -> query($sql);
$rox = $db -> fetch_array($rsx);
//원글의 비번비교
if($rox[pass] == $_POST[pass]){
setcookie("_secret_cookie_".$rox[id], md5($rox[id]), 0);
exit($javascript->mesg_link("", $_POST[url]));
}else exit($javascript->error_mesg("비밀번호가 서로 다릅니다."));
}
}
//비밀번호 검사 후 삭제
if($row[pass]==$_POST["pass"] || $_COOKIE[_user_level] == 1 || $bbs_setup[bbs_admin]==$_COOKIE[_user_id]){
$sql = "delete from ".BBS." where id = '$id' and code = '$code' ";
$db -> query($sql);
//본글일 경우 메모 모두 삭제
if($row[memo] != "1"){
$sql = "delete from ".BBS." where code = '$code' and memo = 1 and grp = '$id'";
$rs = $db -> query($sql);
}else $row[id] = $row[grp];
//파일삭제
if($row[filename]){
$file = explode(",", $row[filename]);
while(list($k, $v) = each($file)){
if($v) @unlink($bbs_setup[bbs_file_path]."data/".$row[code]."/".$v);
}
}
}else $javascript->error_mesg("비밀번호가 서로 다릅니다.");
$type = ($row[memo] == "1") ? "read" : "list";
//이동
$javascript->mesg_link("", $PHP_SELF."?type=$type&code=$code&id=$row[id]&page=$page$search");
break;
######################################################################
/*
선택 삭제
1. 선택 삭제
2. 페이지 이동
*/
######################################################################
case "all_del":
if($bbs_setup["admin_bbs"] == $_COOKIE[_user_id] || $_COOKIE[_user_level] == 1){
while(list($k, $id) = each($chk)){
//정보읽어오기
$sql = "select * from ".BBS." where id = '$id' and code = '$code' ";
$row = $db -> fetch_array($db -> query($sql));
$sql = "delete from ".BBS." where id = '$id' and code = '$code' ";
$db -> query($sql);
//본글일 경우 메모 모두 삭제
if($row[memo] != "1"){
$sql = "delete from ".BBS." where code = '$code' and memo = 1 and grp = '$id'";
$rs = $db -> query($sql);
}
//파일삭제
if($row[filename]){
$file = explode(",", $row[filename]);
while(list($k, $v) = each($file)){
if($v) @unlink($bbs_setup[bbs_file_path]."data/".$row[code]."/".$v);
}
}
}
}else $javascript->error_mesg("게시판 관리자만 삭제가 가능합니다.");
$javascript->mesg_link("", $PHP_SELF."?type=list&code=$code&page=$page$search");
break;
######################################################################
/*
글쓰기 & 글수정 & 답변
1. 글쓰기 & 글수정 & 답변 페이지
*/
######################################################################
case "write": case "modify": case "reply":
unset($row);
if($bbs_setup[top_html]) echo $bbs_setup[top_html];
//템플릿
$tpl->define(array(
"top" => "bbs/".$bbs_setup[skin]."/top.htm",
"body" => "bbs/".$bbs_setup[skin]."/write.htm",
"tail" => "bbs/".$bbs_setup[skin]."/tail.htm"
));
//글수정 & 답변달기
if($type == "modify" || $type == "reply"){
$sql = "select * from ".BBS." where id = '".$_GET["id"]."'";
$rs = $db -> query($sql);
$row = $db -> fetch_array($rs);
//답변일 경우 값지정
if($type == "reply"){
$subject = $row[subject];
$content = $row[content];
unset($row);
$row["subject"] = "Re: ".$subject;
//$row["content"] = "\n\n\n\n======================== 원문 ========================\n".str_replace("\n", "", $content)."\n";
}
}
$file_exp = explode(",", $row[filename]);
//파일수 지정
if($bbs_setup[filenum] != 0){
for ($i = 1 ; $i <= $bbs_setup[filenum] ; $i++){
$loop[] = array(
"j" => ($i-1),
"filenum" => $i,
"filename" => $file_exp[($i-1)],
"filename_path" => str_replace($DOCUMENT_ROOT,"",$bbs_setup[bbs_file_path])."data/$code/".urlencode($file_exp[($i-1)])
);
}
$tpl->assign("file", $loop);
}
//html 값지정 및 초기 설정
if($row[html] == 1) $html = "";
else if($row[html] == 2) $html = "checked";
else if(!$row[html]) $html = "";
//secret 값지정 및 초기 설정
if($row[secret] == 1) $secret = "";
else if($row[secret] == 2) $secret = "checked";
else if(!$row[secret]) $secret = "checked";
//타이틀 지정
switch($type){
case "write": $title = "글쓰기"; break;
case "modify": $title = "글수정"; break;
case "reply": $title = "답변쓰기"; break;
}
//Type 지정
$par_type = ($type == "write") ? "insert" : (($type == "reply") ? "reinsert" : "update");
$cate_list = '';
if($bbs_setup[category]){
$cate_list .= '';
}
//기본값 지정
$tpl->assign(
array(
"bbs_path" => $bbs_setup["bbs_path"]."bbs/".$bbs_setup[skin],
"title" => $title,
"bbs_name" => $bbs_setup[bbs_name],
"table_size" => $bbs_setup[table_size],
"bbs_page" => $PHP_SELF,
"page" => $page,
"word" => $word,
"part" => $part,
"id" => $id,
"type" => $par_type,
"code" => $code,
"html" => $html,
"name" => $row[name],
"email" => $row[email],
"homepage" => $row[homepage],
"notice" => $row[notice],
"secret" => $secret,
"subject" => $row[subject],
"content" => $row[content],
"userid" => $row[userid],
"wdate" => $row[wdate],
"rand" => time(),
"list_link" => $list_link,
"cate_list" => $cate_list,
"header" => ($row[header] == 1) ? "checked" : "",
)
);
//출력
$tpl->print_("body");
if($bbs_setup[bottom_html]) echo $bbs_setup[bottom_html];
break;
######################################################################
/*
게시물 목록
1. 게시물 목록
*/
######################################################################
case "list":
if($bbs_setup[top_html]) echo $bbs_setup[top_html];
//템플릿
if($bbs_setup["bbs_type"] == "1"){
$tpl->define(array(
"top" => "bbs/".$bbs_setup[skin]."/top.htm",
"body" => "bbs/".$bbs_setup[skin]."/list.htm",
"tail" => "bbs/".$bbs_setup[skin]."/tail.htm"
));
}else if($bbs_setup["bbs_type"] == "2"){
$tpl->define(array(
"top" => "bbs/".$bbs_setup[skin]."/top.htm",
"body" => "bbs/".$bbs_setup[skin]."/gallery.htm",
"tail" => "bbs/".$bbs_setup[skin]."/tail.htm"
));
}
//SQL (일반글)
if($domain) $sql_ .= " and domain = '$domain' ";
$where = " where code = '".$code."' and memo != 1 $sql_ and header = 2 order by grp desc, stp asc";
list($rs,$total,$totalpage,$j,$page) = $db->select_list_page(BBS,$where,$page,$bbs_setup[pagesize]);
//페이징
$pageing = $fun -> page_fun($totalpage, $total, $page, "&code=$code".$search, $bbs_setup[pagelimit]);
$cate_list = '';
if($bbs_setup[category]){
$cate_list .= '';
}
//기본값 지정
$tpl->assign(
array(
"bbs_path" => $bbs_setup["bbs_path"]."bbs/".$bbs_setup[skin],
"title" => "글보기",
"table_size" => $bbs_setup[table_size],
"bbs_name" => $bbs_setup[bbs_name],
"bbs_page" => $PHP_SELF,
"code" => $code,
"word" => $word,
"part" => $part,
"total" => $total,
"totalpage" => $totalpage,
"page" => $page,
"pageing" => $pageing,
"write_link" => $write_link,
"list_link" => $list_link,
"refresh_link" => $refresh_link,
"cate_list" => $cate_list,
)
);
if($total != 0){
if($bbs_setup["bbs_type"] == "1"){
//게시판 루프
while($row = $db -> fetch_array($rs)){
$row[subject] = ($row[html] == 2) ? $row[subject] : htmlspecialchars($row[subject]);
//답변일경우
if(is_file($bbs_setup[bbs_file_path]."_template/bbs/".$bbs_setup[skin]."/image/icon_re.gif"))
$re_icon = " ";
else $re_icon = "↘ ";
$subject .= $fun -> replay_subject($row[loc], $re_icon);
//제목설정
$subject .= "";
$subject .= $fun->search_str($fun->cutting($row[subject], $bbs_setup["subject_limit"]), $word);
$subject .= "";
//메모수 알기
$sql = "select count(*) from ".BBS." where code = '$code' and memo = 1 and grp = '$row[id]'";
$rsm = $db -> query($sql);
$rom = $db -> fetch_array($rsm);
if($rom[0] != 0) $subject .= " [".$rom[0]."]";
//비밀글 아이콘
if($bbs_setup[secret_use] == 1){
if($row[secret] == 2){
$subject .= "
";
}
}
//값지정
$loop[] = array(
"tr_color" => ($j%2) ? "#F4F4F4" : "#FFFFFF",
"color" => ($_GET["id"] == $row[id]) ? "#FCEDE9" : "#FFFFFF",
"j" => ($_GET["id"] == $row[id]) ? "→" : $j,
"id" => $row[id],
"subject" => $subject,
"name" => $row[name],
"content" => $row[content],
"homepage" => $row[homepage],
"email" => $row[email],
"domain" => $row[domain],
"date" => date($bbs_setup[date_format], strtotime($row[wdate])),
"hit" => number_format($row[hit])
);
$read_j = ($_GET["id"] == $row[id]) ? $j : "";
$j--;
unset($subject);
}
//루프 출력
$tpl->assign("row", $loop);
}else if($bbs_setup["bbs_type"] == "2"){
$tr = @ceil($db -> num_rows($rs)/$bbs_setup["td"]);
$loop1 = array();
for($i = 0 ; $i < $tr ; $i++){
$loop1[$i]["i"]= $i;
$loop2 = &$loop1[$i]["td"];
for($j = 0 ; $j < $bbs_setup["td"] ; $j ++){
$row = $db -> fetch_array($rs);
$link = "$PHP_SELF?type=read&code=$code&id=$row[id]&page=$page$search";
//제목설정
//$subject = "";
$subject = "";
$subject .= $fun->search_str($fun->cutting($row[subject], $bbs_setup["subject_limit"]), $word);
$subject .= "";
//메모수 알기
$sql = "select count(*) from ".BBS." where code = '$code' and memo = 1 and grp = '$row[id]'";
$rsm = $db -> query($sql);
$rom = $db -> fetch_array($rsm);
if($rom[0] != 0) $subject .= " [".$rom[0]."]";
//비밀글 아이콘
if($bbs_setup[secret_use] == 1){
if($row[secret] == 2){
$subject .= "
";
}
}
//파일불러오기
$exp = explode(",", $row[filename]);
$farray = array();
while(list($k, $v) = each($exp)) if($v) $farray[] = $v;
if(!sizeof($farray)) $filename = $bbs_setup[_bbs_path_]."_template/bbs/".$bbs_setup[skin]."/image/noimg.gif";
else $filename = $bbs_setup[_bbs_path_]."data/$code/".urlencode(array_shift($farray));
$size_wh = @getimagesize("..".urldecode($filename));
//echo "
"; //print_r($size_wh); $imglink = "window.open('/bbs/bbs.htm?type=multiimg&code=$code&id=$row[id]"; $imglink .= "&page=$page$search','MIMG_$row[id]','width=".($size_wh[0]+120).","; $imglink .= "height=".($size_wh[1]+40).",top=200,left=250,"; $imglink .= "resizable=yes,scrollbars=yes');"; unset($size_wh); $modify_link = "$PHP_SELF?type=modify&code=$code&id=$row[id]&page=$page$search"; $delete_link = "$PHP_SELF?type=delete_form&code=$code&id=$row[id]&page=$page$search"; //값지정 $loop2[] = array( "modify_link" => $modify_link, "delete_link" => $delete_link, "j" => $j, "id" => $row["id"], "px" => ($j == 0) ? 0 : 14, "subject" => $subject, "imglink" => $imglink, "homepage" => $row[homepage], "date" => date($bbs_setup[date_format], strtotime($row[wdate])), "size" => (int)(100/$bbs_setup["td"]), "image" => str_replace("+", "%20", $filename), "email" => $row[email], "content" => $row[content], "hit" => number_format($row[hit]), "link" => $link ); } unset($px,$farray); } //루프 출력 $tpl->assign("tr", $loop1); } } //게시물 이동 $sql = "select * from ".BBS_SETUP." where code != '$code' order by id desc"; $rs = $db -> query($sql); while($row = $db -> fetch_array($rs)){ //값지정 $move_loop[] = array( "code" => $row[code], "name" => $row[bbs_name] ); } //루프 출력 $tpl->assign("move", $move_loop); //출력 $tpl->print_("body"); if($bbs_setup[bottom_html]) echo $bbs_setup[bottom_html]; break; ###################################################################### /* 게시물 상세보기 1. 게시물 상세보기 */ ###################################################################### case "read": //게시물 정보 읽기 $sql = "select * from ".BBS." where code = '$code' and memo != 1 and id = '$id'"; $rs = $db -> query($sql); $row = $db -> fetch_array($rs); if($bbs_setup[secret_use] == 1){ if($row[secret] == 2){ if($_COOKIE["_secret_cookie_".$id] != md5($id)){ if($_COOKIE[_user_level]!=1 || $bbs_setup[bbs_admin] != $_COOKIE[_user_id]){ $link = $PHP_SELF."?type=secret&code=$code&id=$id&url=".urlencode($REQUEST_URI); $javascript->mesg_link("",$link); } } } } if($bbs_setup[top_html]) echo $bbs_setup[top_html]; //기본 템플릿 $tpl_array = array( "top" => "bbs/".$bbs_setup[skin]."/top.htm", "body" => "bbs/".$bbs_setup[skin]."/read.htm", "tail" => "bbs/".$bbs_setup[skin]."/tail.htm" ); //메모사용이 허용된다면 if($bbs_setup["memo_use"] == true) $tpl_array["memo"] = "bbs/".$bbs_setup[skin]."/memo.htm"; //템플릿 $tpl->define($tpl_array); //조회수 증가 $sql = "update ".BBS." set hit = hit + 1 where code = '$code' and memo != 1 and id = '$id'"; $rs = $db -> query($sql); if($domain) $sql_d = " and domain = '$domain' "; //이전 게시물 알아내기 $sql = "select id,grp,stp,loc,subject,wdate,name from ".BBS." where code = '$code' and memo != 1 and header = 2 "; $sql .= ($word) ? $sql_ : ""; $sql .= " $sql_d order by grp desc, stp asc"; $rsx = $db -> query($sql); for ($i = 0 ; $i < $db->num_rows($rsx) ; $i ++ ) { $rox = $db -> fetch_array($rsx); if($rox[id] == $id){ $db -> data_seek($rsx, $i + 1); $next = $db -> fetch_array($rsx); $db -> data_seek($rsx, ($i != 0) ? $i - 1 : 0); $prev = $db -> fetch_array($rsx); $page_loc = $i; break; } } //현재페이지 $page = ceil(($page_loc == 0) ? 1 : ($page_loc + 1) / $bbs_setup[pagesize]); //답변일경우 if(is_file($bbs_setup[bbs_file_path]."_template/bbs/".$bbs_setup[skin]."/image/icon_re.gif")) $re_icon = ""; else $re_icon = "↘ "; //다음 게시물 $next_link = "$PHP_SELF?type=read&code=$code&id=$next[id]&page=$page$search"; $next_subject = $fun -> replay_subject($next[loc], $re_icon); $next_subject .= ""; $next_subject .= $fun->search_str($fun->cutting($next[subject], $bbs_setup["subject_limit"]),$word); $next_subject .= ""; $next_date = date($bbs_setup[date_format], strtotime($next[wdate])); //이전게시물 $prev_link = "$PHP_SELF?type=read&code=$code&id=$prev[id]&page=$page$search"; $prev_subject = $fun -> replay_subject($prev[loc], $re_icon); $prev_subject .= ""; $prev_subject .= $fun->search_str($fun->cutting($prev[subject], $bbs_setup["subject_limit"]),$word); $prev_subject .= ""; $prev_date = date($bbs_setup[date_format], strtotime($prev[wdate])); //$row[content] = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $row[content]); //본문내용 뿌리기 $content = ($row[html] == 2) ? $row[content] : $fun->highlight($row[content]); //기본값 지정 $tpl->assign( array( "bbs_path" => $bbs_setup["bbs_path"]."bbs/".$bbs_setup[skin], "title" => "글읽기", "table_size" => $bbs_setup[table_size], "bbs_name" => $bbs_setup[bbs_name], "word" => $word, "part" => $part, "cate_name" => $row[domain], "page" => $page, "id" => $row[id], "code" => $code, "domain_read" => $row[domain], "subject" => $fun->search_str($row[subject], $word), "name" => $row[name], "date" => date($bbs_setup[date_format]." H시i분", strtotime($row[wdate])), "hit" => number_format($row[hit]), "email" => $fun->autolink($row[email]), "homepage" => $fun->autolink($row[homepage]), "filename" => $fun->upfile_list($row[filename]), "content" => $fun->search_str($content, $word), "fileview" => $fun->fileview($row[filename]), "prev_subject" => ($prev[id] != $id) ? $prev_subject : "", "next_subject" => ($next[id] != "") ? $next_subject : "", "next_date" => $next_date, "prev_date" => $prev_date, "prev_link" => $prev_link, "next_link" => $next_link, "write_link" => $write_link, "modify_link" => $modify_link, "delete_link" => $delete_link, "reply_link" => $reply_link, "list_link" => $list_link, "memo_icon_use" => $bbs_setup[memo_icon_use] ) ); ###################################################################### /* 메모 출력 1. 해당 글의 메모를 테이블에서 읽어와 출력한다. */ ###################################################################### exec("ls -1A ".$DOCUMENT_ROOT.$bbs_setup["bbs_path"]."bbs/".$bbs_setup[skin]."/memo_icon/", $icon_list); $fun->item_fun(@implode(",", $icon_list), "memo_icon_tr", "memo_icon_td", 8); if($bbs_setup[memo_use]){ $sql = "select * from ".BBS." where code = '$code' and memo = 1 and grp = $id order by id asc"; $rsm = $db -> query($sql); if($db -> num_rows($rsm) != 0){ //루프 while($memo = $db -> fetch_array($rsm)){ $del_link = "$PHP_SELF?type=memo_delete_form&code=$code&id=$memo[id]&page=$page$search"; $fun->highlight($memo[content]); $memo_loop[] = array( "memo_icon" => $memo[memo_icon], "id" => $memo[id], "name" => $memo[name], "content" => $fun->highlight($memo[content]), "date" => date($bbs_setup[date_format], strtotime($memo[wdate])), "del_link" => $del_link, ); } //루프 출력 $tpl->assign("memo", $memo_loop); } } //출력 $tpl->print_("body"); $type = "list"; if($bbs_setup[read_list] == 1) include (__FILE__); if($bbs_setup[bottom_html]) echo $bbs_setup[bottom_html]; break; case "multiimg": //템플릿 $tpl->define(array("body" => "bbs/".$bbs_setup[skin]."/$type.htm")); $sql = "select * from ".BBS." where code = '".$_GET[code]."' and id = '".$_GET[id]."'"; $rs = $db -> query($sql); $row = $db -> fetch_array($rs); $img_path = str_replace($DOCUMENT_ROOT,"",$bbs_setup[bbs_file_path]); //파일불러오기 $exp = explode(",", $row[filename]); $farray = array(); while(list($k, $v) = each($exp)) if($v) $farray[] = $v; if(!sizeof($farray)) $filename = $bbs_setup[_bbs_path_]."_template/bbs/".$bbs_setup[skin]."/image/noimg.gif"; else $filename = $bbs_setup[_bbs_path_]."data/$code/".urlencode(array_shift($farray)); reset($exp); //기본값 지정 $tpl->assign( array( "title" => "이미지 상세보기", "fileview" => str_replace("+", "%20", $fun->fileview($row[filename], " width=50 ", true)), "imgview" => str_replace("+", "%20", $fun->fileview($exp[0], "name=bodyimg")), "img" => str_replace("+","%20", urlencode($exp[0])) ) ); //출력 $tpl->print_("body"); break; ###################################################################### /* 게시물 삭제 1. 게시물 삭제 */ ###################################################################### case "delete_form": case "memo_delete_form": case "secret": if($bbs_setup[top_html]) echo $bbs_setup[top_html]; $sql = "select name from ".BBS." where code = '$code' and id = '$id'"; $rs = $db -> query($sql); $row = $db -> fetch_array($rs); //템플릿 $tpl->define(array( "top" => "bbs/".$bbs_setup[skin]."/top.htm", "body" => "bbs/".$bbs_setup[skin]."/delete.htm", "tail" => "bbs/".$bbs_setup[skin]."/tail.htm" )); switch($type){ case "delete_form": $title = "글삭제"; $msg = "$row[name]님의 글을 삭제 하려고 합니다. 비밀번호를 입력하세요."; break; case "memo_delete_form" : $title = "메모삭제"; $msg = "$row[name]님의 글을 삭제 하려고 합니다. 비밀번호를 입력하세요."; break; case "secret": $title = "비밀글 로그인"; $msg = "$row[name]님의 글은 비밀글 설정이 되어있습니다.
비밀번호를 입력하세요.
※ 답글일 경우 원글의 비밀번호를 입력하세요."; break; } //기본값 지정 $tpl->assign( array( "name" => $row[name], "bbs_path" => $bbs_setup["bbs_path"]."bbs/".$bbs_setup[skin], "title" => $title, "table_size" => $bbs_setup[table_size], "bbs_name" => $bbs_setup[bbs_name], "bbs_page" => $PHP_SELF, "type" => $type, "msg" => $msg, "code" => $code, "id" => $_GET["id"], "word" => $word, "part" => $part, "url" => $_GET[url], "page" => $page ) ); //출력 $tpl->print_("body"); if($bbs_setup[bottom_html]) echo $bbs_setup[bottom_html]; break; ###################################################################### /* 다운로드 1. 다운로드 */ ###################################################################### case "download": $fun -> download($filename); break; ###################################################################### /* 이미지 출력 1. 이미지 출력 */ ###################################################################### case "imgview": //템플릿 $tpl->define(array("body" => "bbs/".$bbs_setup[skin]."/imgview.htm")); $img_path = str_replace($DOCUMENT_ROOT,"",$bbs_setup[bbs_file_path]); $tpl->assign( array( "title" => "이미지 상세보기", "imgview" => $img_path."data/$code/".urlencode($_GET[filename]) ) ); $tpl->print_("body"); break; } //DB 연결닫기 $db -> close(); ?>