jsp¿¡¼ ÆÄÀÏ ¾÷·ÎµåÇÏ´Â ºÎºÐÀÔ´Ï´Ù.
Á¦°¡ jsp´Â Àß ¸ð¸£´Âµ¥ ´Ù¸¥ »ç¶÷ÀÌ ÇØ ³õÀº°ÍÀ» ¼öÁ¤ÇØ¾ß ÇÕ´Ï´Ù.
ÀÌ ¼Ò½º°¡ ÀÛÀº ¿ë·®ÀÇ ÆÄÀÏÀº Àß ¿Ã¶ó °¡´Âµ¥ ¿ë·®ÀÌ Å«°Í(¾à 80m)Àº Àß ¾È¿Ã¶ó °©´Ï´Ù.
¼ºí¸´À¸·Î ±¸µ¿ÇÏ°í ÀÖ½À´Ï´Ù.(¿©·¯°¡Áö ÀÌÀ¯·Î...)
¼Ò½º Àü¹®À» ¿Ã¸³´Ï´Ù.
¹«¾ùÀÌ ¹®Á¦ÀÎÁö ¾Æ´Ï¸é ¾î¶² ºÎºÐÀ» Á¡°ËÇØ ºÁ¾ß ÇÏ´ÂÁö µî ¸¹Àº Á¶¾ð ºÎŹµå¸³´Ï´Ù
¹ú½á 3ÀÏ° Çì¸Þ°í ÀÖ³×¿ä ºÎŹµå·Á¿ä
package newebn.ucc.servlet;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLDecoder;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import newebn.dbpool.DBConnectionMgr;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.log4j.Logger;
import newebn.ucc.domain.*;
import newebn.ucc.servlet.Encrypter;
/**
* Servlet implementation class FileUploadServlet
*/
public class FileUploadServlet extends HttpServlet {
Logger logger = Logger.getLogger(getClass());
private Connection con=null;
private PreparedStatement pstmt=null;
private ResultSet rs=null;
DBConnectionMgr mgr = DBConnectionMgr.getInstance();
String c_Host_Id;
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public FileUploadServlet() {
super();
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
HttpSession session = request.getSession();
FileUploadListener listener = null;
StringBuffer sb = new StringBuffer();
long bytesRead=0;
long contentLength=0;
String userPkid="";
if(session == null){
return;
}else if(session != null){
listener = (FileUploadListener)session.getAttribute("LISTENER");
userPkid = (String)session.getAttribute("USERPKID");
if(listener == null){
return;
}else{
bytesRead = listener.getBytesRead();
contentLength = listener.getContentLength();
}
}
/**
* Response·Î XML ¸¸µé±â
*/
logger.info("contentLength = " + contentLength);
logger.info("bytesRead = " + bytesRead);
response.setContentType("text/xml");
sb.append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
sb.append("<response>\n");
sb.append("\t<bytes_read>" + bytesRead + "</bytes_read>\n");
sb.append("\t<content_length>" + contentLength + "</content_length>\n");
if(bytesRead == contentLength){
sb.append("\n<finished />\n");
session.setAttribute("LISTENER", null);
session.setAttribute("USERPKID", null);
}else{
long percentComplete = ((100 * bytesRead) / contentLength);
sb.append("\t<percent_complete>" + percentComplete + "</percent_complete>\n");
}
sb.append("\t<user_pkid>" + userPkid + "</user_pkid>\n");
sb.append("</response>\n");
session.setAttribute("USERPKID", null);
out.println(sb.toString());
out.flush();
out.close();
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=euc-kr");
PrintWriter out = response.getWriter();
final String c_PathDir = "C:/newebn/ucc/public"; //Àý´ë°æ·Î
final String c_Pathfolder = "dataroom";//±âº» ÀúÀå Æú´õ °æ·Î
String conUserIdx=""; //»ç¿ëÀÚ °íÀ¯°ª
String conUserId=""; //·Î±×ÀξÆÀ̵ð
String conUserName=""; //·Î±×ÀÎÀ̸§
String conUserLevel=""; //·Î±×Àη¹º§
String conIpAddress = request.getRemoteAddr();
Cookie[] cookies2 = request.getCookies();
if(cookies2 != null && cookies2.length > 0)
{
for(int i=0; i<cookies2.length; i++)
{
if(cookies2[i].getName().equals("MEDIA_IDX")) conUserIdx = cookies2[i].getValue();
if(cookies2[i].getName().equals("MEDIA_ID")) conUserId = cookies2[i].getValue();
if(cookies2[i].getName().equals("MEDIA_NAME")) conUserName = URLDecoder.decode(cookies2[i].getValue(),"euc-kr");
if(cookies2[i].getName().equals("MEDIA_LEVEL")) conUserLevel = cookies2[i].getValue();
}
}
String strMid="";
String strUserId="";
String strUserIdx="";
String strCode="";
String strPkid="";
String strKind="";
String strM020Pkid="";
String strCategory="";
String strTitle="";
String strName="";
String strJumin="";
String strAddr="";
String strTel="";
String strEmail="";
String strNoticeU="";
String strAttach="";
String strCommName1="";
String strCommJumin1="";
String strCommName2="";
String strCommJumin2="";
String strCommName3="";
String strCommJumin3="";
String strCommName4="";
String strCommJumin4="";
String strCommName5="";
String strCommJumin5="";
String strCommName6="";
String strCommJumin6="";
String strCommName7="";
String strCommJumin7="";
String strCommName8="";
String strCommJumin8="";
String strCommName9="";
String strCommJumin9="";
String strCommName10="";
String strCommJumin10="";
String strPlace="";
String strPlan="";
String strOption1="";
String strOption2="";
String strAcoment="";
String strContent="";
String strStatus="";
String strFile="";
//»ý³â¿ùÀÏ º¯¼ö
String strYear="";
String strMonth="";
String strDay="";
String strCommYear1="";
String strCommMonth1="";
String strCommDay1="";
String strCommYear2="";
String strCommMonth2="";
String strCommDay2="";
String strCommYear3="";
String strCommMonth3="";
String strCommDay3="";
String strCommYear4="";
String strCommMonth4="";
String strCommDay4="";
String strCommYear5="";
String strCommMonth5="";
String strCommDay5="";
String strCommYear6="";
String strCommMonth6="";
String strCommDay6="";
String strCommYear7="";
String strCommMonth7="";
String strCommDay7="";
String strCommYear8="";
String strCommMonth8="";
String strCommDay8="";
String strCommYear9="";
String strCommMonth9="";
String strCommDay9="";
String strCommYear10="";
String strCommMonth10="";
String strCommDay10="";
//¼ºº° º¯¼ö
String strSex="";
String strCommSex1="";
String strCommSex2="";
String strCommSex3="";
String strCommSex4="";
String strCommSex5="";
String strCommSex6="";
String strCommSex7="";
String strCommSex8="";
String strCommSex9="";
String strCommSex10="";
boolean fileFlag=false;
//String strPath = c_PathDir + "/" + c_Pathfolder + "/";
String strPath = "//58.225.10.93/media/UCC/";
//String strPath2 = c_Pathfolder + "/";
String strPath2 = "";
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHmmss");
String strFormat = sf.format(new Date());
strPath += strFormat;
strPath2 += strFormat;
String strUploadFileNm="";
String FileWholdPath="";
int strPkid2=0;
int maxNum=0;
boolean flag=true;
int maxSize = 10*1024*1024*800;
String name="";
String value="";
String strSql="";
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
FileUploadListener listener = new FileUploadListener();
HttpSession session = request.getSession();
session.setAttribute("LISTENER", listener);
upload.setSizeMax(maxSize);
upload.setProgressListener(listener);
List uploadItems=null;
FileItem fileItem=null;
try{
if(request.getContentLength() > upload.getSizeMax()){
uploadItems = upload.parseRequest(request);
Iterator i = uploadItems.iterator();
while(i.hasNext()){
fileItem = (FileItem)i.next();
if(fileItem.isFormField()){
name = fileItem.getFieldName();
value = fileItem.getString("euc-kr");
if(name.equals("p_status")) strStatus=value;
if(name.equals("p_mid")) strMid=value;
if(name.equals("p_userId")) strUserId=value;
if(name.equals("p_userIdx")) strUserIdx=value;
if(name.equals("p_code")) strCode=value;
if(name.equals("p_M020Pkid")) strM020Pkid=value;
if(name.equals("p_pkid")) strPkid=value;
if(name.equals("p_kind")) strKind=value;
if(name.equals("p_title")) strTitle=value;
if(name.equals("p_name")) strName=value;
if(name.equals("p_jumin")) strJumin=value;
if(name.equals("p_addr")) strAddr=value;
if(name.equals("p_tel")) strTel=value;
if(name.equals("p_email")) strEmail=value;
if(name.equals("p_attach")) strAttach=value;
if(name.equals("p_comm_name1")) strCommName1=value;
if(name.equals("p_comm_jumin1")) strCommJumin1=value;
if(name.equals("p_comm_name2")) strCommName2=value;
if(name.equals("p_comm_jumin2")) strCommJumin2=value;
if(name.equals("p_comm_name3")) strCommName3=value;
if(name.equals("p_comm_jumin3")) strCommJumin3=value;
if(name.equals("p_comm_name4")) strCommName4=value;
if(name.equals("p_comm_jumin4")) strCommJumin4=value;
if(name.equals("p_comm_name5")) strCommName5=value;
if(name.equals("p_comm_jumin5")) strCommJumin5=value;
if(name.equals("p_comm_name6")) strCommName6=value;
if(name.equals("p_comm_jumin6")) strCommJumin6=value;
if(name.equals("p_comm_name7")) strCommName7=value;
if(name.equals("p_comm_jumin7")) strCommJumin7=value;
if(name.equals("p_comm_name8")) strCommName8=value;
if(name.equals("p_comm_jumin8")) strCommJumin8=value;
if(name.equals("p_comm_name9")) strCommName9=value;
if(name.equals("p_comm_jumin9")) strCommJumin9=value;
if(name.equals("p_comm_name10")) strCommName10=value;
if(name.equals("p_comm_jumin10")) strCommJumin10=value;
if(name.equals("p_place")) strPlace=value;
if(name.equals("p_plan")) strPlan=value;
if(name.equals("p_content")) strContent=value;
if(name.equals("p_aComent")) strAcoment=value;
if(name.equals("p_year")) strYear=value;
if(name.equals("p_month")) strMonth=value;
if(name.equals("p_day")) strDay=value;
if(name.equals("p_comm_year1")) strCommYear1=value;
if(name.equals("p_comm_month1")) strCommMonth1=value;
if(name.equals("p_comm_day1")) strCommDay1=value;
if(name.equals("p_comm_year2")) strCommYear2=value;
if(name.equals("p_comm_month2")) strCommMonth2=value;
if(name.equals("p_comm_day2")) strCommDay2=value;
if(name.equals("p_comm_year3")) strCommYear3=value;
if(name.equals("p_comm_month3")) strCommMonth3=value;
if(name.equals("p_comm_day3")) strCommDay3=value;
if(name.equals("p_comm_year4")) strCommYear4=value;
if(name.equals("p_comm_month4")) strCommMonth4=value;
if(name.equals("p_comm_day4")) strCommDay4=value;
if(name.equals("p_comm_year5")) strCommYear5=value;
if(name.equals("p_comm_month5")) strCommMonth5=value;
if(name.equals("p_comm_day5")) strCommDay5=value;
if(name.equals("p_comm_year6")) strCommYear6=value;
if(name.equals("p_comm_month6")) strCommMonth6=value;
if(name.equals("p_comm_day6")) strCommDay6=value;
if(name.equals("p_comm_year7")) strCommYear7=value;
if(name.equals("p_comm_month7")) strCommMonth7=value;
if(name.equals("p_comm_day7")) strCommDay7=value;
if(name.equals("p_comm_year8")) strCommYear8=value;
if(name.equals("p_comm_month8")) strCommMonth8=value;
if(name.equals("p_comm_day8")) strCommDay8=value;
if(name.equals("p_comm_year9")) strCommYear9=value;
if(name.equals("p_comm_month9")) strCommMonth9=value;
if(name.equals("p_comm_day9")) strCommDay9=value;
if(name.equals("p_comm_year10")) strCommYear10=value;
if(name.equals("p_comm_month10")) strCommMonth10=value;
if(name.equals("p_comm_day10")) strCommDay10=value;
if(name.equals("p_sex")) strSex=value;
if(name.equals("p_comm_sex1")) strCommSex1=value;
if(name.equals("p_comm_sex2")) strCommSex2=value;
if(name.equals("p_comm_sex3")) strCommSex3=value;
if(name.equals("p_comm_sex4")) strCommSex4=value;
if(name.equals("p_comm_sex5")) strCommSex5=value;
if(name.equals("p_comm_sex6")) strCommSex6=value;
if(name.equals("p_comm_sex7")) strCommSex7=value;
if(name.equals("p_comm_sex8")) strCommSex8=value;
if(name.equals("p_comm_sex9")) strCommSex9=value;
if(name.equals("p_comm_sex10")) strCommSex10=value;
}else{
if(fileItem.getSize() > 0){
File uploadFile=null;
int indexOf = fileItem.getName().lastIndexOf("\\");
if(indexOf == -1){
indexOf = fileItem.getName().lastIndexOf("/");
}
strFile = fileItem.getName().substring(indexOf+1);
if(!GetMovieFile(strFile)){
ExecJavaAlert("µ¿¿µ»ó ÆÄÀÏÀÌ ¾Æ´Õ´Ï´Ù.",0,out);
}else{
ExecFolderMake(strPath);
strUploadFileNm = strFile;
strUploadFileNm = strUploadFileNm.replace(" ","");
strUploadFileNm = strUploadFileNm.replace("'","");
FileWholdPath = GetUniqueName(strUploadFileNm, strPath);
if(FileWholdPath != null && !FileWholdPath.equals("")){
uploadFile = new File(FileWholdPath);
fileItem.write(uploadFile);
fileFlag = true;
}
}
}
}
}
//ÆÄÀÏ¸í °ø¹é Á¦°Å
strFile = strFile.replaceAll(" ","");
//strFile = strFile.replaceAll("&","&");
strJumin = strYear+"-"+strMonth+"-"+strDay;
if(NullCheck(strCommYear1) && NullCheck(strCommMonth1) && NullCheck(strCommDay1))
strCommJumin1 = strCommYear1+"-"+strCommMonth1+"-"+strCommDay1;
if(NullCheck(strCommYear2) && NullCheck(strCommMonth2) && NullCheck(strCommDay2))
strCommJumin2 = strCommYear2+"-"+strCommMonth2+"-"+strCommDay2;
if(NullCheck(strCommYear3) && NullCheck(strCommMonth3) && NullCheck(strCommDay3))
strCommJumin3 = strCommYear3+"-"+strCommMonth3+"-"+strCommDay3;
if(NullCheck(strCommYear4) && NullCheck(strCommMonth4) && NullCheck(strCommDay4))
strCommJumin4 = strCommYear4+"-"+strCommMonth4+"-"+strCommDay4;
if(NullCheck(strCommYear5) && NullCheck(strCommMonth5) && NullCheck(strCommDay5))
strCommJumin5 = strCommYear5+"-"+strCommMonth5+"-"+strCommDay5;
if(NullCheck(strCommYear6) && NullCheck(strCommMonth6) && NullCheck(strCommDay6))
strCommJumin6 = strCommYear6+"-"+strCommMonth6+"-"+strCommDay6;
if(NullCheck(strCommYear7) && NullCheck(strCommMonth7) && NullCheck(strCommDay7))
strCommJumin7 = strCommYear7+"-"+strCommMonth7+"-"+strCommDay7;
if(NullCheck(strCommYear8) && NullCheck(strCommMonth8) && NullCheck(strCommDay8))
strCommJumin8 = strCommYear8+"-"+strCommMonth8+"-"+strCommDay8;
if(NullCheck(strCommYear9) && NullCheck(strCommMonth9) && NullCheck(strCommDay9))
strCommJumin9 = strCommYear9+"-"+strCommMonth9+"-"+strCommDay9;
if(NullCheck(strCommYear10) && NullCheck(strCommMonth10) && NullCheck(strCommDay10))
strCommJumin10 = strCommYear10+"-"+strCommMonth10+"-"+strCommDay10;
Encrypter enc = new Encrypter();
strName = enc.returnEncryptCode(strName);
strJumin = enc.returnEncryptCode(strJumin);
strAddr = enc.returnEncryptCode(strAddr);
strTel = enc.returnEncryptCode(strTel);
strEmail = enc.returnEncryptCode(strEmail);
strAttach = enc.returnEncryptCode(strAttach);
if(NullCheck(strCommName1)) strCommName1 = enc.returnEncryptCode(strCommName1);
if(NullCheck(strCommJumin1)) strCommJumin1 = enc.returnEncryptCode(strCommJumin1);
if(NullCheck(strCommName2)) strCommName2 = enc.returnEncryptCode(strCommName2);
if(NullCheck(strCommJumin2)) strCommJumin2 = enc.returnEncryptCode(strCommJumin2);
if(NullCheck(strCommName3)) strCommName3 = enc.returnEncryptCode(strCommName3);
if(NullCheck(strCommJumin3)) strCommJumin3 = enc.returnEncryptCode(strCommJumin3);
if(NullCheck(strCommName4)) strCommName4 = enc.returnEncryptCode(strCommName4);
if(NullCheck(strCommJumin4)) strCommJumin4 = enc.returnEncryptCode(strCommJumin4);
if(NullCheck(strCommName5)) strCommName5 = enc.returnEncryptCode(strCommName5);
if(NullCheck(strCommJumin5)) strCommJumin5 = enc.returnEncryptCode(strCommJumin5);
if(NullCheck(strCommName6)) strCommName6 = enc.returnEncryptCode(strCommName6);
if(NullCheck(strCommJumin6)) strCommJumin6 = enc.returnEncryptCode(strCommJumin6);
if(NullCheck(strCommName7)) strCommName7 = enc.returnEncryptCode(strCommName7);
if(NullCheck(strCommJumin7)) strCommJumin7 = enc.returnEncryptCode(strCommJumin7);
if(NullCheck(strCommName8)) strCommName8 = enc.returnEncryptCode(strCommName8);
if(NullCheck(strCommJumin8)) strCommJumin8 = enc.returnEncryptCode(strCommJumin8);
if(NullCheck(strCommName9)) strCommName9 = enc.returnEncryptCode(strCommName9);
if(NullCheck(strCommJumin9)) strCommJumin9 = enc.returnEncryptCode(strCommJumin9);
if(NullCheck(strCommName10)) strCommName10 = enc.returnEncryptCode(strCommName10);
if(NullCheck(strCommJumin10)) strCommJumin10 = enc.returnEncryptCode(strCommJumin10);
bbsHost(strMid,response.getWriter());
if(strStatus == null || strStatus.equals(""))
strStatus="1";
con = mgr.getConnection();
strSql="";
strSql = "SELECT ISNULL(max(B030_PKID), 0) FROM BOD060TL";
try {
pstmt = con.prepareStatement(strSql);
rs = pstmt.executeQuery();
if(rs.next())
{
maxNum = rs.getInt(1)+1;
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
if(rs!=null) try{ rs.close(); }catch(SQLException e){}
if(pstmt!=null) try{ pstmt.close(); }catch(SQLException e){}
if(con!=null)
{
mgr.freeConnection();
try{ con.close(); }catch(SQLException e){}
}
}
if(strCode.equals("edit") || strCode.equals("del"))
strPkid2 = Integer.parseInt(strPkid);
else
strPkid2 = maxNum;
session.setAttribute("USERPKID",Integer.toString(strPkid2));
if(strCode.equals("edit") || strCode.equals("del")){
String oldFile="";
String oldPath=c_PathDir + "/";
con = mgr.getConnection();
strSql="";
strSql="SELECT B030_FILE,B030_PATH FROM BOD060TL WHERE B030_PKID=?";
try{
pstmt = con.prepareStatement(strSql);
pstmt.setInt(1,strPkid2);
rs = pstmt.executeQuery();
if(rs.next()){
oldFile = rs.getString("B030_FILE");
oldPath += rs.getString("B030_PATH");
ExecFileDelete(oldPath, oldFile);
}
}catch(SQLException e){
e.printStackTrace();
}
}
if(strCode.equals("add")){
if(fileFlag){
if(strUserIdx == null || strUserIdx.equals("")){
strUserIdx = "2";
strUserId = "guest";
}
con = mgr.getConnection();
strSql="";
strSql="INSERT INTO BOD060TL(";
strSql+="B030_PKID,B030_B010_PKID,B030_MENU_ID,";
strSql+="B030_CATEGORY,B030_TITLE,B030_USER_ID,";
strSql+="B030_NAME,B030_EMAIL,B030_NOTICE_U,";
strSql+="B030_READNUM,B030_FILE,B030_PATH,";
strSql+="B030_DOWN_NUM,B030_COMMENT_NUM,B030_VOTE_NUM,";
strSql+="B030_OPTION1,B030_OPTION2,B030_CONTENT,";
strSql+="B030_PLACE,B030_PLAN,B030_ACOMENT,";
strSql+="B030_EMP_ID,B030_STATUS,B030_KIND,B030_IP_ADDRESS,B030_M010_IDX,";
strSql+="B030_CATAL_ACTION,B030_TRANS_ACTION,B030_PROGRESS";
strSql+=")VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,'q','q',0)";
if(strCategory == null || strCategory.equals("")) strCategory="°ø¸ðÀü";
try{
pstmt = con.prepareStatement(strSql);
pstmt.setInt(1,strPkid2);
pstmt.setString(2,c_Host_Id);
pstmt.setString(3,strMid);
pstmt.setString(4,strCategory);
pstmt.setString(5,strTitle);
pstmt.setString(6,strUserId);
pstmt.setString(7,strName);
pstmt.setString(8,strEmail);
pstmt.setString(9,strNoticeU);
pstmt.setInt(10,0);
pstmt.setString(11,strFile);
pstmt.setString(12,strPath2);
pstmt.setInt(13,0);
pstmt.setInt(14,0);
pstmt.setInt(15,0);
pstmt.setString(16,strOption1);
pstmt.setString(17,strOption2);
pstmt.setString(18,strContent);
pstmt.setString(19,strPlace);
pstmt.setString(20,strPlan);
pstmt.setString(21,strAcoment);
pstmt.setString(22,conUserId);
pstmt.setString(23,strStatus);
pstmt.setString(24,strKind);
pstmt.setString(25,conIpAddress);
pstmt.setInt(26,Integer.parseInt(strUserIdx));
pstmt.execute();
flag=true;
}catch(SQLException e){
e.printStackTrace();
flag=false;
}finally{
if(flag){
strSql="";
strSql = "SELECT ISNULL(max(M020_PKID), 0) FROM MEM020TL";
try {
pstmt = con.prepareStatement(strSql);
rs = pstmt.executeQuery();
if(rs.next())
{
maxNum = rs.getInt(1)+1;
}
} catch (SQLException e) {
e.printStackTrace();
}
strSql="";
strSql="INSERT INTO MEM020TL(";
strSql+="M020_PKID,M020_M010_PKID,M020_B030_PKID,";
strSql+="M020_C020_PKID,M020_TITLE,M020_NAME,";
strSql+="M020_JUMIN,M020_ADDRESS,M020_TEL,";
strSql+="M020_EMAIL,M020_ATTACH,M020_COMM_NAME1,";
strSql+="M020_COMM_JUMIN1,M020_COMM_NAME2,M020_COMM_JUMIN2,";
strSql+="M020_COMM_NAME3,M020_COMM_JUMIN3,";
strSql+="M020_COMM_NAME4,M020_COMM_JUMIN4,";
strSql+="M020_COMM_NAME5,M020_COMM_JUMIN5,";
strSql+="M020_COMM_NAME6,M020_COMM_JUMIN6,";
strSql+="M020_COMM_NAME7,M020_COMM_JUMIN7,";
strSql+="M020_COMM_NAME8,M020_COMM_JUMIN8,";
strSql+="M020_COMM_NAME9,M020_COMM_JUMIN9,";
strSql+="M020_COMM_NAME10,M020_COMM_JUMIN10,";
strSql+="M020_SEX,M020_COMM_SEX1,M020_COMM_SEX2,M020_COMM_SEX3,M020_COMM_SEX4,M020_COMM_SEX5,M020_COMM_SEX6,M020_COMM_SEX7,M020_COMM_SEX8,M020_COMM_SEX9,M020_COMM_SEX10";
strSql+=")VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
try{
pstmt = con.prepareStatement(strSql);
pstmt.setInt(1, maxNum);
pstmt.setInt(2,Integer.parseInt(strUserIdx));
pstmt.setInt(3,strPkid2);
pstmt.setString(4,"E00001");
pstmt.setString(5,strTitle);
pstmt.setString(6,strName);
pstmt.setString(7,strJumin);
pstmt.setString(8,strAddr);
pstmt.setString(9,strTel);
pstmt.setString(10,strEmail);
pstmt.setString(11,strAttach);
pstmt.setString(12,strCommName1);
pstmt.setString(13,strCommJumin1);
pstmt.setString(14,strCommName2);
pstmt.setString(15,strCommJumin2);
pstmt.setString(16,strCommName3);
pstmt.setString(17,strCommJumin3);
pstmt.setString(18,strCommName4);
pstmt.setString(19,strCommJumin4);
pstmt.setString(20,strCommName5);
pstmt.setString(21,strCommJumin5);
pstmt.setString(22,strCommName6);
pstmt.setString(23,strCommJumin6);
pstmt.setString(24,strCommName7);
pstmt.setString(25,strCommJumin7);
pstmt.setString(26,strCommName8);
pstmt.setString(27,strCommJumin8);
pstmt.setString(28,strCommName9);
pstmt.setString(29,strCommJumin9);
pstmt.setString(30,strCommName10);
pstmt.setString(31,strCommJumin10);
pstmt.setString(32,strSex);
pstmt.setString(33,strCommSex1);
pstmt.setString(34,strCommSex2);
pstmt.setString(35,strCommSex3);
pstmt.setString(36,strCommSex4);
pstmt.setString(37,strCommSex5);
pstmt.setString(38,strCommSex6);
pstmt.setString(39,strCommSex7);
pstmt.setString(40,strCommSex8);
pstmt.setString(41,strCommSex9);
pstmt.setString(42,strCommSex10);
pstmt.execute();
}catch(SQLException e){
e.printStackTrace();
}finally{
if(pstmt!=null) try{ pstmt.close(); }catch(SQLException e){}
if(con!=null)
{
mgr.freeConnection();
try{ con.close(); }catch(SQLException e){}
}
}
}else{
if(pstmt!=null) try{ pstmt.close(); }catch(SQLException e){}
if(con!=null)
{
mgr.freeConnection();
try{ con.close(); }catch(SQLException e){}
}
}
}
}
}else if(strCode.equals("edit")){
if(strUserId == null || strUserId.equals("")) strUserId = "guest";
if(strUserIdx == null || strUserIdx.equals("")) strUserIdx = "2";
if(strCategory == null || strCategory.equals("")) strCategory="°ø¸ðÀü";
strSql="";
strSql="UPDATE BOD060TL SET ";
strSql+="B030_CATEGORY=?,B030_TITLE=?,B030_USER_ID=?,";
strSql+="B030_NAME=?,B030_EMAIL=?,B030_NOTICE_U=?,";
strSql+="B030_FILE=?,B030_PATH=?,B030_OPTION1=?,";
strSql+="B030_OPTION2=?,B030_CONTENT=?,B030_PLACE=?,";
strSql+="B030_PLAN=?,B030_ACOMENT=?,B030_EMP_ID=?,";
strSql+="B030_STATUS=?,B030_KIND=?,B030_IP_ADDRESS=?,B030_M010_IDX=?";
strSql+=" WHERE B030_PKID=?";
try{
pstmt = con.prepareStatement(strSql);
pstmt.setString(1,strCategory);
pstmt.setString(2,strTitle);
pstmt.setString(3,strUserId);
pstmt.setString(4,strName);
pstmt.setString(5,strEmail);
pstmt.setString(6,strNoticeU);
pstmt.setString(7,strFile);
pstmt.setString(8,strPath2);
pstmt.setString(9,strOption1);
pstmt.setString(10,strOption2);
pstmt.setString(11,strContent);
pstmt.setString(12,strPlace);
pstmt.setString(13,strPlan);
pstmt.setString(14,strAcoment);
pstmt.setString(15,conUserId);
pstmt.setString(16,strStatus);
pstmt.setString(17,strKind);
pstmt.setString(18,conIpAddress);
pstmt.setInt(19,Integer.parseInt(strUserIdx));
pstmt.setInt(20,strPkid2);
pstmt.executeUpdate();
flag=true;
}catch(SQLException e){
System.out.println("B030UPDATE = " + e);
e.printStackTrace();
flag=false;
}finally{
if(flag){
strSql="";
strSql="UPDATE MEM020TL SET ";
strSql+="M020_TITLE=?,M020_NAME=?,M020_JUMIN=?,";
strSql+="M020_ADDRESS=?,M020_TEL=?,M020_EMAIL=?,";
strSql+="M020_ATTACH=?,M020_COMM_NAME1=?,M020_COMM_JUMIN1=?,";
strSql+="M020_COMM_NAME2=?,M020_COMM_JUMIN2=?,M020_COMM_NAME3=?,";
strSql+="M020_COMM_JUMIN3=? ";
strSql+="M020_COMM_NAME4=?,M020_COMM_JUMIN4=?, ";
strSql+="M020_COMM_NAME5=?,M020_COMM_JUMIN5=?, ";
strSql+="M020_COMM_NAME6=?,M020_COMM_JUMIN6=?, ";
strSql+="M020_COMM_NAME7=?,M020_COMM_JUMIN7=?, ";
strSql+="M020_COMM_NAME8=?,M020_COMM_JUMIN8=?, ";
strSql+="M020_COMM_NAME9=?,M020_COMM_JUMIN9=?, ";
strSql+="M020_COMM_NAME10=?,M020_COMM_JUMIN10=?, ";
strSql+="M020_SEX=?, ";
strSql+="M020_COMM_SEX1=?, ";
strSql+="M020_COMM_SEX2=?, ";
strSql+="M020_COMM_SEX3=?, ";
strSql+="M020_COMM_SEX4=?, ";
strSql+="M020_COMM_SEX5=?, ";
strSql+="M020_COMM_SEX6=?, ";
strSql+="M020_COMM_SEX7=?, ";
strSql+="M020_COMM_SEX8=?, ";
strSql+="M020_COMM_SEX9=?, ";
strSql+="M020_COMM_SEX10=? ";
strSql+=" WHERE M020_PKID=?";
try{
pstmt = con.prepareStatement(strSql);
pstmt.setString(1,strTitle);
pstmt.setString(2,strName);
pstmt.setString(3,strJumin);
pstmt.setString(4,strAddr);
pstmt.setString(5,strTel);
pstmt.setString(6,strEmail);
pstmt.setString(7,strAttach);
pstmt.setString(8,strCommName1);
pstmt.setString(9,strCommJumin1);
pstmt.setString(10,strCommName2);
pstmt.setString(11,strCommJumin2);
pstmt.setString(12,strCommName3);
pstmt.setString(13,strCommJumin3);
pstmt.setString(14,strCommJumin4);
pstmt.setString(15,strCommJumin5);
pstmt.setString(16,strCommJumin6);
pstmt.setString(17,strCommJumin7);
pstmt.setString(18,strCommJumin8);
pstmt.setString(19,strCommJumin9);
pstmt.setString(20,strCommJumin10);
pstmt.setString(21,strSex);
pstmt.setString(22,strCommSex1);
pstmt.setString(23,strCommSex2);
pstmt.setString(24,strCommSex3);
pstmt.setString(25,strCommSex4);
pstmt.setString(26,strCommSex5);
pstmt.setString(27,strCommSex6);
pstmt.setString(28,strCommSex7);
pstmt.setString(29,strCommSex8);
pstmt.setString(30,strCommSex9);
pstmt.setString(31,strCommSex10);
pstmt.setInt(32,Integer.parseInt(strM020Pkid));
pstmt.executeUpdate();
flag=true;
}catch(SQLException e){
System.out.println("M020UPDATE = " + e);
e.printStackTrace();
flag=false;
}finally{
if(pstmt!=null) try{ pstmt.close(); }catch(SQLException e){}
if(con!=null)
{
mgr.freeConnection();
try{ con.close(); }catch(SQLException e){}
}
}
}else{
if(pstmt!=null) try{ pstmt.close(); }catch(SQLException e){}
if(con!=null)
{
mgr.freeConnection();
try{ con.close(); }catch(SQLException e){}
}
}
}
}else if(strCode.equals("del")){
con = mgr.getConnection();
strSql="";
strSql="DELETE FROM BOD060TL WHERE B030_PKID=?";
try{
pstmt = con.prepareStatement(strSql);
pstmt.setInt(1,strPkid2);
pstmt.executeUpdate();
flag=true;
}catch(SQLException e){
e.printStackTrace();
flag=false;
}finally{
if(pstmt!=null) try{ pstmt.close(); }catch(SQLException e){}
if(con!=null){
mgr.freeConnection();
try{ con.close(); }catch(SQLException e){}
}
}
}
//out.write("strMid = " + strMid);
//out.write("c_Host_Id = " + c_Host_Id);
//if(true) return;
if(flag){
ExecJavaAlert2("¾÷·Îµå°¡ ¿Ï·áµÇ¾ú½À´Ï´Ù",0,out);
//ExecJavaAlertLocation("¾÷·Îµå°¡ ¿Ï·áµÇ¾ú½À´Ï´Ù.º¯È¯ÀÛ¾÷ÆäÀÌÁö·Î À̵¿ÇÕ´Ï´Ù.","/board/active2.jsp?p_mbs=05-01&p_mid="+strMid+"p_pkid="+strPkid2,out);
}else{
ExecJavaAlert("¾Ë¼ö ¾ø´Â ¿¡·¯°¡ ¹ß»ý ÇÏ¿´½À´Ï´Ù.°ü¸®ÀÚ¿¡°Ô ¹®ÀÇÇØ ÁÖ¼¼¿ä.",0,out);
}
}else{
ExecJavaAlert("¾÷·Îµå ¿ë·® ÃÊ°úÀÔ´Ï´Ù.",0,out);
}
}catch(FileUploadException e){
e.printStackTrace();
logger.info("FileUploadExecption : " + e);
}catch(Exception e){
e.printStackTrace();
logger.info("Exception : " + e);
}
}
public void bbsHost(String n,PrintWriter out)
{
Connection con;
PreparedStatement pstmt;
ResultSet rs;
DBConnectionMgr mgr = DBConnectionMgr.getInstance();
con = mgr.getConnection();
String strSql = "SELECT * FROM BOD010TL ";
strSql += "WHERE B010_MENU_ID=?";
try{
pstmt = con.prepareStatement(strSql);
pstmt.setString(1, n);
rs = pstmt.executeQuery();
if(rs.next())
{
//È£½ºÆ® Çʵå
c_Host_Id = rs.getString("B010_PKID");
}
else
{
ExecJavaAlert("ÀÏÄ¡Çϴ ȣ½ºÆ®°¡¾ø½À´Ï´Ù.",0,out);
}
}catch(SQLException e){
e.printStackTrace();
}
}
////***************************************************************************************
////* ÇÔ¼ö¼³¸í : ¾÷·Îµå ÆÄÀÏ µ¿¿µ»ó ¿©ºÎ È®ÀÎ *
////* º¯¼ö¼³¸í : strFileName = ¾÷·Îµå ÆÄÀϸí *
////***************************************************************************************
public boolean GetMovieFile(String strFileName)
{
String strFileExt="";
boolean flag=false;
int indexOf = strFileName.lastIndexOf('.');
strFileExt = strFileName.substring(indexOf+1).toUpperCase(); //¼Ò¹®ÀÚ ´ë¹®ÀÚ·Î º¯°æ
if(strFileExt.equals("mp4") || strFileExt.equals("MP4") || strFileExt.equals("wmv") || strFileExt.equals("WMV") || strFileExt.equals("mov") || strFileExt.equals("MOV") || strFileExt.equals("avi") || strFileExt.equals("AVI") || strFileExt.equals("flv") || strFileExt.equals("FLV"))
flag=true;
else
flag=false;
return flag;
}
////***************************************************************************************
////* ÇÔ¼ö¼³¸í : ÀÚ¹Ù½ºÅ©¸³Æ® ¸Þ¼¼Áöâ Ãâ·ÂÈÄ À̵¿ *
////* º¯¼ö¼³¸í : str,strUrl = ¸Þ¼¼Áö¸í , À̵¿ÇÒÁÖ¼Ò *
////***************************************************************************************
public void ExecJavaAlertLocation(String strMsg,String strUrl,PrintWriter out)
{
out.println("<script language='javascript'>");
out.println("<!--");
out.println("alert('"+strMsg+"');");
out.println("self.location='"+strUrl+"';");
out.println("//-->");
out.print("</script>");
}
////***************************************************************************************
//// * ÇÔ¼ö¼³¸í : Æú´õ »ý¼º *
//// * º¯¼ö¼³¸í : strPath = »ý¼ºÇÒ Æú´õ °æ·Î ¹× Æú´õ¸í *
//// ***************************************************************************************
public void ExecFolderMake(String strPath)
{
String FSO;
String fldr;
File file = new File(strPath);
if(!file.exists())
{
file.mkdirs();
}
}
///// À¯´ÏÅ©ÇÑ ÆÄÀÏ°æ·Î¹× ÆÄÀÏÀ̸§À» ¾ò¾î³»´Â ÇÔ¼ö
public String GetUniqueName(String strFileName, String DirectoryPath)
{
//È®ÀåÀÚ¸¦ Á¦¿ÜÇÑ ÆÄÀϸíÀ» ¾ò´Â´Ù.
int indexOf = strFileName.lastIndexOf('.');
String strName=strFileName.substring(0, indexOf);
String strExt=strFileName.substring(indexOf+1);
boolean bExist=true;
//¿ì¼± °°ÀºÀ̸§ÀÇ ÆÄÀÏÀÌ Á¸ÀçÇÑ´Ù°í °¡Á¤
String strFileWhloePath=DirectoryPath + "/" + strName + "." + strExt;
//ÀúÀåÇÒ ÆÄÀÏÀÇ ¿ÏÀüÇÑ À̸§(¿ÏÀüÇÑ ¹°¸®ÀûÀÎ °æ·Î) ±¸¼º
int countFileName = 0;
File file = new File(strFileWhloePath);
while(bExist) //¿ì¼± ÀÖ´Ù°í »ý°¢ÇÔ.
{
if(file.exists()) // °°Àº À̸§ÀÇ ÆÄÀÏÀÌ ÀÖÀ» ¶§
{
countFileName++; //ÆÄÀÏ¸í¿¡ ¼ýÀÚ¸¦ ºÙÀÎ »õ·Î¿î ÆÄÀÏ À̸§ »ý¼º
strFileName = strName + "(" + countFileName + ")." + strExt;
strFileWhloePath = DirectoryPath + "/" + strFileName;
file = new File(strFileWhloePath);
}
else
{
bExist=false;
}
System.out.println(bExist);
}
return strFileWhloePath;
}
////***************************************************************************************
////* ÇÔ¼ö¼³¸í : ÆÄÀÏ»èÁ¦ ÇÔ¼ö *
////* º¯¼ö¼³¸í : strPath : »èÁ¦ÇÒ ÆÄÀÏÀÇ °æ·Î *
////* strFileName : »èÁ¦ÇÒ ÆÄÀÏÀÇ À̸§ *
////***************************************************************************************
public void ExecFileDelete(String strPath, String strFileName)
{
File file = new File(strPath, strFileName);
if(file.exists())
{
file.delete();
}
}
////***************************************************************************************
////* ÇÔ¼ö¼³¸í : ÀÚ¹Ù½ºÅ©¸³Æ® ¸Þ½ÃÁö Ãâ·Â *
////* º¯¼ö¼³¸í : strMsg = Ãâ·Â¸Þ½ÃÁö *
////* strExec = ½ºÅ©¸³Æ® ó¸® (0:ÀÌÀüȸé / 1:â´Ý±â) *
////***************************************************************************************
public void ExecJavaAlert(String strMsg,int strExec,PrintWriter out)
{
String str="";
str = "<script language='javascript'>";
str += "alert('"+strMsg+"');";
if(strExec == 0)
str += "history.go(-1);";
else
str += "self.close();";
str += "</script>";
out.print(str);
}
public void ExecJavaAlert2(String strMsg,int strExec,PrintWriter out)
{
String str="";
str = "<script language='javascript'>";
str += "alert('"+strMsg+"');";
}
public boolean NullCheck(String strData)
{
boolean flag=false;
if(strData != null && !strData.equals("") && !strData.equals("null"))
flag=true;
else
flag=false;
return flag;
}
}