118 lines
4.0 KiB
Plaintext
118 lines
4.0 KiB
Plaintext
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
|
|
<%@ page import="java.util.*"%>
|
|
<%@ page import="java.io.*"%>
|
|
<%@ page import="com.oreilly.servlet.MultipartRequest" %>
|
|
<%@ page import="com.oreilly.servlet.multipart.DefaultFileRenamePolicy" %>
|
|
<%@ page import="java.util.GregorianCalendar" %>
|
|
<%@ include file="/manager_for_cms/include/manager_head.jsp"%>
|
|
<%
|
|
|
|
GregorianCalendar now = new GregorianCalendar();
|
|
String c_date = String.format("%TF", now);//yyyy-mm-dd
|
|
String fileName = "";
|
|
String imageName = "";
|
|
String realFolder = "";
|
|
String saveFolder = "/menu_file/";
|
|
String encType = "utf-8";
|
|
int maxSize = 10 * 1024 * 1024;
|
|
|
|
ServletContext scontext = getServletContext();
|
|
ArrayList saveFiles = new ArrayList();
|
|
ArrayList orgFiles = new ArrayList();
|
|
|
|
realFolder = scontext.getRealPath(saveFolder);
|
|
realFolder = "/home/apply/cms_for_bcb/contents/";
|
|
MultipartRequest multi = new MultipartRequest( request
|
|
, realFolder
|
|
, maxSize
|
|
, encType
|
|
, new DefaultFileRenamePolicy() );
|
|
|
|
|
|
Enumeration files = multi.getFileNames();
|
|
int ty = 0;
|
|
while( files.hasMoreElements() ){
|
|
ty = ty + 1;
|
|
String name = (String)files.nextElement();
|
|
String fName = multi.getFilesystemName( name );
|
|
|
|
String oName = multi.getOriginalFileName( name );
|
|
String type = multi.getContentType( name );
|
|
File f = multi.getFile( name );
|
|
if(ty == 1){
|
|
fileName = fName;
|
|
}else{
|
|
imageName = fName;
|
|
}
|
|
}
|
|
if(fileName == null){
|
|
fileName = "";
|
|
}
|
|
if(imageName == null){
|
|
imageName = "";
|
|
}
|
|
String c_home = r_call(multi.getParameter("c_home"));
|
|
String c_maker = r_call(multi.getParameter("c_maker"));
|
|
String c_up_no = r_call(multi.getParameter("c_up_no"));
|
|
String c_name = r_call(multi.getParameter("c_name"));
|
|
String c_type = r_call(multi.getParameter("c_type"));
|
|
String c_content2 = r_call(multi.getParameter("c_content2"));
|
|
String c_content3 = r_call(multi.getParameter("c_content3"));
|
|
String c_content4 = r_call(multi.getParameter("c_content4"));
|
|
String c_content5 = r_call2(multi.getParameter("c_content5"));
|
|
String c_use = r_call(multi.getParameter("c_use"));
|
|
String c_content = "";
|
|
if(c_type.equals("1")){
|
|
c_content = fileName;
|
|
}
|
|
if(c_type.equals("2")){
|
|
c_content = c_content2;
|
|
}
|
|
if(c_type.equals("3")){
|
|
c_content = c_content3;
|
|
}
|
|
if(c_type.equals("4")){
|
|
c_content = c_content4;
|
|
}
|
|
if(c_type.equals("5")){
|
|
c_content = c_content5;
|
|
}
|
|
int c_no = 1;
|
|
int c_order = 1;
|
|
int cc_relation = 1;
|
|
int cc_relation2 = 1;
|
|
String sql_ok = "select max(c_order) as max_order from tbl_menu where c_home = "+ c_home + " and c_maker = " + c_maker ;
|
|
ResultSet rss = stmt.executeQuery(sql_ok);
|
|
if(rss.next()){
|
|
c_order = rss.getInt("max_order") + 1;
|
|
}
|
|
rss.close();
|
|
sql_ok = "select max(c_relation) as max_relation, max(c_relation2) as max_relation2 from tbl_menu " ;
|
|
rss = stmt.executeQuery(sql_ok);
|
|
if(rss.next()){
|
|
cc_relation = rss.getInt("max_relation") + 1;
|
|
cc_relation2 = rss.getInt("max_relation2") + 1;
|
|
}
|
|
rss.close();
|
|
sql_ok = "insert into tbl_menu (c_home,c_maker,c_up_no,c_order,c_relation,c_relation2,c_type,c_name,c_content,c_view,c_use,c_date) values(";
|
|
sql_ok = sql_ok + c_home + " ";
|
|
sql_ok = sql_ok + ","+ c_maker + " ";
|
|
sql_ok = sql_ok + ","+ c_up_no + " ";
|
|
sql_ok = sql_ok + ","+ c_order + " ";
|
|
sql_ok = sql_ok + ","+ cc_relation + " ";
|
|
sql_ok = sql_ok + ","+ cc_relation2 + " ";
|
|
sql_ok = sql_ok + ","+ c_type + " ";
|
|
sql_ok = sql_ok + ",'"+ c_name + "' ";
|
|
sql_ok = sql_ok + ",'"+ c_content + "' ";
|
|
sql_ok = sql_ok + ",0,"+ c_use + " ";
|
|
sql_ok = sql_ok + ",now())";
|
|
stmt.execute(sql_ok);
|
|
|
|
%>
|
|
<script>
|
|
alert("Insert OK");
|
|
location.href="list.jsp?c_home=<%=c_home%>&c_maker=<%=c_maker%>"
|
|
</script>
|
|
|
|
<%@ include file="/manager_for_cms/include/manager_bottom.jsp"%>
|