
<%
/**********************************************************************************
	프로그램명		: popup_board_view.jsp
	프로그램설명	: 
	작 성 자			: 조 용 준
	작 성 일			: 2004. 11. 08
	최신변경일		: 
***********************************************************************************/
%>
<%@ page contentType="text/html; charset=UTF-8"%>

<%@ page import="kr.co.kihyun.text.html.ServletUtil"%>
<%@ page import="kr.co.kihyun.lang.StringConverter"%>
<%@ page import="kr.co.kihyun.moumi.Moumi"%>
<%@ page import="kr.co.kihyun.beans.user.HttpSSOLogin"
	import="java.net.URLEncoder" import="kr.co.kihyun.lang.MLong"
	import="javax.jdo.PersistenceManager" import="javax.jdo.Transaction"
	import="kr.co.kihyun.beans.entity.util.*"
	import="kr.co.kihyun.beans.entity.Board"%>
<%@ page import="java.util.Map.Entry"%>
<%@ page import="java.util.List"%>

<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>

<%
PersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
Transaction tx = pm.currentTransaction();
try{
	/*********** Parameter values ***********/
	Long boardID = MLong.parseLong(request.getParameter("boardID"),null);

	/*********** Board View vlaues ***********/	
	tx.begin();
	Board board = boardID == null ? null : pm.getObjectById(Board.class, boardID);
	String boardGroupID = board.getCategory().getId();
	String boardTitle = board.getTitle();	
	String boardContents = StringConverter.toHtmlBr(board.getContents());
	String usrFilenames = "";
	String svrFilenames = "";
	for (Entry<String, List<Byte>> entry : board.getAttachments().entrySet()) {
		usrFilenames += entry.getKey() + ";";
		svrFilenames += entry.getKey() + ";";
	}
	int visit = board.getVisit();
	board.setVisit(visit+1);
	pm.makePersistent(board);
	tx.commit();

	/*********** append file name vlaues ***********/
	String[] usrFilenameList = usrFilenames.split(";");
	String[] svrFilenameList = svrFilenames.split(";");

	/****** 본인 유무 처리 ******/
	boolean isManager = false;
	//if(usID.equals(regID)){
	//	isManager = true;	
	//}
	session.setAttribute("delTargetURI", "location='/totsys/sysadm/board/board_list.jsp?boardGroupID="+boardGroupID);
	%>

<html>
<head>
<title><%=Moumi.getTitle()%></title>
<link rel="stylesheet" href="/totsys/common/images/text.css"
	type="text/css">
<script src="/totsys/common/images/rollover.js"></script>
</head>

<body style='' bgcolor="#FFFFFF" text="#000000" leftmargin="0"
	topmargin="0" marginwidth="0" marginheight="0">
<table width="650" border="0" cellspacing="0" cellpadding="0"
	height="516">
	<tr>
		<td width="29"><img
			src="/totsys/common/images/popupt_top_left.gif" width="29"
			height="19"></td>
		<td background="/totsys/common/images/popupt_top_center.gif"
			height="19">&nbsp;</td>
		<td width="30"><img
			src="/totsys/common/images/popupt_top_right.gif" width="30"
			height="19"></td>
	</tr>
	<tr>
		<td background="/totsys/common/images/popupt_center_left.gif">&nbsp;</td>
		<td valign="top">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<!----타이틀 이미지 (공지사항) ---->
			<tr>
				<td
					background="/totsys/common/images/popup_receive_choice_titleb.gif"><img
					src="/totsys/common/images/notice_view_title.gif" width="119"
					height="44"></td>
			</tr>
			<tr>
				<td height="10">&nbsp;</td>
			</tr>
			<tr>
				<td height="66" valign="top">
				<table width="95%" border="0" cellspacing="0" cellpadding="1"
					height="306" bgcolor="E2E2E2" align="center">
					<tr>
						<td valign="top">
						<table width="100%" border="0" cellspacing="0" cellpadding="0"
							height="306">
							<!-----제목 ---->
							<tr valign="middle">
								<TD vAlign=top bgColor=#ffffff colSpan=2 height=27>
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr bgcolor="#f9fee7">
										<td width="51" height="27" style="PADDING-LEFT: 11px"><IMG
											src="/totsys/common/images/notice_write_subtitle.gif"
											height="10" width="51"></td>
										<td height="27" style="padding-top: 3px;"><%= boardTitle %></td>
									</tr>
								</table>
								</TD>
							</tr>
							<tr>
								<td bgcolor="#FFFFFF" valign="top" colspan="2" height="290">
								<table width="95%" border="0" cellspacing="0" cellpadding="0"
									height="100%" align="center">
									<tr>
										<td valign="top" height="10">&nbsp;</td>
									</tr>
									<!----- 내용 시작---->
									<tr>
										<td valign="top"><%= boardContents %></td>
									</tr>
									<!----- 내용 끝---->
								</table>
								</td>
							</tr>
							<!----- 첨부파일 시작 ---->
							<tr>
								<td bgcolor="#FFFFFF" valign="bottom" colspan="2">
								<table width="95%" border="0" cellspacing="0" cellpadding="0"
									align="center">
									<%
															for(int i=0; i < svrFilenameList.length; i++){%>
									<tr>
										<td height="17" style="padding-left: 3;"><font
											color="#FF6600"><b>+</b><a
											href="/servlet/kr.co.kihyun.text.html.HttpViewer?<%= URLEncoder.encode(usrFilenameList[i], "UTF-8") %>&fileName=<%= URLEncoder.encode(svrFilenameList[i], "UTF-8") %>&boardID=<%=boardID %>"
											target="new"><%= usrFilenameList[i] %></a></font></td>
									</tr>
									<tr>
										<td background="/totsys/common/images/green_botline.gif"
											height="1"></td>
									</tr>
									<tr>
										<td height="17">&nbsp;</td>
									</tr>
									<%}%>
								</table>
								</td>
							</tr>
							<!----- 첨부파일 끝 ---->
						</table>
						</td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
		<td background="/totsys/common/images/popupt_center_right.gif">&nbsp;</td>
	</tr>
	<tr>
		<td><img src="/totsys/common/images/popupt_bottom_left.gif"
			width="29" height="24"></td>
		<td background="/totsys/common/images/popupt_bottom_center.gif"
			height="24">&nbsp;</td>
		<td><img src="/totsys/common/images/popupt_bottom_right.gif"
			width="30" height="24"></td>
	</tr>
</table>
</body>
</html>

<%
}catch(Exception ex){
        //38.오류메세지를 통한 정보 노출(getMessage)_CWE-209 : Update by YOUNGJUN,CHO
	ex.printStackTrace();
	//out.println(ex);//앤개
	//out.println("<html><body style='overflow=auto' bgcolor='white'><h1>Can't contact servlet runner</h1><br><br>Message : "+ex.getMessage()+"</body></html>");
	//out.println("<META HTTP-EQUIV='refresh' CONTENT='0.1; URL=/error/exception.jsp'>");
        //================================================
}finally{
	if(tx.isActive())
		tx.rollback();
	pm.close();
}
%>
