}
// MultipartRequest�� ���ڵ��� ������ ��� �ϱ� ������ request�� ���ڵ��� �̾Ƽ� �־�����մϴ�.
String encoding = CommonUtil.nchk(req.getCharacterEncoding(), "euc-kr");
MultipartRequest multi =
new MultipartRequest(
req,
uploadDir,
200 * 1024 * 1024,
encoding);
// 200MB
ArrayList<DownFile> arrdf = new ArrayList<DownFile>();
Article article = null;
long sid = CommonUtil.getCookieLong(req, "sid");
try {
int seq = 0, ref = 0, lev = 0, step = 0;
String writer = multi.getParameter("writer");
String bbs = multi.getParameter("bbs");
String content = multi.getParameter("content");
String email = multi.getParameter("email");
String subject = multi.getParameter("subject");
String homepage = multi.getParameter("homepage");
String password = multi.getParameter("password");
String html = multi.getParameter("html");
String ccl_id = multi.getParameter("ccl_id");
String ip = req.getRemoteAddr();
//id
boolean isLogin = sid > 0 && !"".equals(writer);
if (!isLogin) {
res.sendRedirect(Navigation.getPath("LOGFORM"));
return null;
}
// Multipart �� ���� ������ 8859_1�� ���� ��.��
article =
new Article(
bbs,
seq,
ref,
step,
lev,
null,
sid,
writer,
subject,
content,
password,
email,
homepage,
0,
null,
html,
ip, ccl_id);
int cnt = 0;
Enumeration<String> files = multi.getFileNames();
while (files.hasMoreElements()) {
String name = files.nextElement();
File f = multi.getFile(name);
if (f != null) {
arrdf.add(new DownFile(f, cnt++));
}
}
} catch (Exception e) {
System.out.println("WriteServlet:" + CommonUtil.a2k(e.toString()));
}
if (hasNothing(article)) {
throw new SecurityException("no content");
} else if (Spam.checkContent(article)) {
throw new SecurityException("rejected");
}
/*
db �Է�
*/
DbCon dbCon = new DbCon();
Connection conn = null;
ArticleDao articleDao = new ArticleDao();
String act = multi.getParameter("act");
try {
conn = dbCon.getConnection();
conn.setAutoCommit(false);
String[] delFiles = null;
int seq = 0;
if ("MODIFY".equals(act)) {
seq = Integer.parseInt(multi.getParameter("seq"));
delFiles = multi.getParameterValues("delFile");
article.setSeq(seq);
}
if ("REPLY".equals(act)) {
article.setSeq(articleDao.getSeq(conn));
article.setRef(Integer.parseInt(multi.getParameter("ref")));
article.setLev(Integer.parseInt(multi.getParameter("lev")));
article.setStep(
Integer.parseInt(multi.getParameter("step")));
articleDao.reply(conn, article);
} else if ("MODIFY".equals(act)) {
articleDao.modify(conn, article);
articleDao.deleteFiles(conn, delFiles);