⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 up_image_submit.jsp

📁 电信的网厅的整站代码
💻 JSP
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page language="java" contentType="text/html; charset=GBK"%>
<%@ page import="com.doone.util.*"%>
<%@ page import="com.doone.data.*"%>
<%@ page import="com.doone.fj1w.bbs.*"%>
<%@ page import="com.doone.uurm.*"%>
<%@ page import="com.doone.fj1w.fjmgr.config.UpImageBean"%>
<%@ page import="com.doone.fj1w.fjmgr.sysmgr.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%// 以下是必须的内容
			String action = request.getParameter("ACTION");

			UpImageBean contentBean = new UpImageBean();
            String sParentId = request.getParameter("PARENTID");
            String sTitle = request.getParameter("TITLE");
            String sContent = request.getParameter("LINK");//链接
 		    String sAttchment = request.getParameter("ATTCHMENT");
			long lboardId=Sys_Purview.getPurviewIdByCode(sParentId);//栏目ID
			boolean bIsint=contentBean.is_int(sContent);
			if ((sContent==null)||(sContent.trim().length()==0)||(!bIsint)){
				sContent = request.getParameter("LTITLE");//自己输入的链接
			}
			String sAttchs[] = null;
    
            // 权限检查。同时读取栏目编号。
            WebAuth auth = WebAuth.getInstance(request);
            if (sAttchment != null) {
                sAttchs = sAttchment.split("::");
            }
//			contentBean.delContent(lboardId);
            DacClient db = new DacClient();
     try {
                db.beginTransaction(-1);
                TF_Content content = new TF_Content(db);
 
 
                // 处理附件内容。
                List attchList = new ArrayList();
                boolean hasAttch = false;
				int isfail=0;
                for (int i = 0; sAttchs != null && i < sAttchs.length; i++) {
                    if (sAttchs[i] == null)
                        continue;
					
                    String aAttch[] = ExtString.split(sAttchs[i], "||", null);
                    if (aAttch.length != 2)
                        continue;
                    String sOldFileName = aAttch[1];
                    String sFileName = aAttch[0];
                    String sPathName = "/view/bbs/UploadFile/";
                    String sFullName = sPathName + sFileName;
                    String realName = application.getRealPath(sFullName);
                    File file = new File(realName);
					String sFullType=sFileName.substring(sFileName.lastIndexOf(".")).toUpperCase();
 					if ((( sFullType.indexOf("JPG"))==-1)&&(( sFullType.indexOf("GIF"))==-1)&&(( sFullType.indexOf("SWF"))==-1)){
					     out.write("<script language=javascript>alert('限制上传除JPG,GIF,SWF格式外的文件');history.go(-1);history.go(-1);</script>");
  						 isfail=1;
 					     break;
					}
					if (file.length()>2400000){
					     out.write("<script language=javascript>alert('限制上传大于2M的文件');history.go(-1);history.go(-1);</script>");
 					     isfail=1;
						 break;

					}
                    if (file.exists() && file.isFile()) {
                        TF_Attchment attchment = new TF_Attchment(db);
                        attchment.setFile_Name(sOldFileName);
                        attchment.setFile_Size(file.length());
                        String sExtName = sFileName.substring(sFileName.lastIndexOf("."));

                        attchment.setFile_Type(ContentType.getContentType(sExtName));
                        attchment.setUpLoad_Time(new Date());
                        attchment.setContent_ID(content.getContent_ID());
                        byte[] bs1 = new byte[(int) attchment.getFile_Size() + 1];
                        FileInputStream is = new FileInputStream(file);
                        if (is.read(bs1, 0, (int) attchment.getFile_Size()) != -1) {
                            attchment.setFile_Content(bs1);
                        }
                        else {
                            FileLogger.getLogger().warn("文件读取数据失败。");
                            continue;
                        }
                        is.close(); // 关闭连接。

                        int startIdx = sContent.indexOf(sFullName);
                        if (startIdx == -1) {
                            int si = sContent.indexOf(sPathName + "/" + sFileName);
                            if (si != -1) {
                                sFullName = sPathName + "/" + sFileName;
                                startIdx = si;
                            }
                        }
                        if (startIdx != -1) {
                            attchment.setAttch_Type("1"); // 设置附件类别为嵌入内容中的附件。

                            // 替换文件名。
                            while (startIdx != -1) {
                                int endIdx = startIdx + sFullName.length();
                                 String sUrl = "AttchMap/" + String.valueOf(attchment.getAttch_ID());
                                sUrl += "/" + sOldFileName;

                            }
                        }
                        else {
                            hasAttch = true;

                            // 将没有用到的附件作为独立附件处理。
                            attchment.setAttch_Type("2");
                        }

                        attchList.add(attchment);
                        if (!file.delete()) { // 删除文件系统中的附件。
                            FileLogger.getLogger().warn("附件删除失败:" + sFileName);
                        }
                    }
                    else {
                        FileLogger.getLogger().info("文件不存在:" + sFileName + ",可能内容中的图片无法显示。");
                        continue;
                    }
                }

                // 处理系统小图片内容。
                ExtString.replace(sContent, "<IMG src=\"/manager/view/bbs/sysimage/","<IMG src=\"sysimage/");
				if (isfail==0){
                // 插件新内容。
                if (hasAttch) {
                    content.setExist_Attch("1");
                }
                else {
                    content.setExist_Attch("0");
                }

                if (content.getFirst_Content_ID() == 0) {
                    content.setFirst_Content_ID(content.getContent_ID());
                }
                content.setBoard_ID(lboardId);
                content.setAccount_ID(auth.getUserID());
                content.setAccount_Name(auth.getUserCode());
                content.setUser_Name(auth.getUserName());
                content.setTitle(sTitle);
                content.setContent(sContent.toString());
                content.setCreate_Time(new Date());
                content.setTip_Order(0);
                content.setExtract_Sign("0");
                content.setReply_Count(0);
                content.setReply_Account_ID(auth.getUserID());
                content.setReply_User_Name(auth.getUserName());
                content.setLast_Click_Time(new Date());
                content.setLast_Reply_Time(new Date());
                content.setContentType("03");
                content.setDelete_Sign("E");
                content.save();

                // 保存嵌入内容中的附件。
                StringBuffer attchName = new StringBuffer();
                for (int i = 0; i < attchList.size(); i++) {
                    TF_Attchment attch = (TF_Attchment) attchList.get(i);
                    if (attchName.indexOf("||" + attch.getFile_Name() + "||") != -1) {
                        throw new RuntimeException("您上传的附件有重名,请检查后重新上传。");
                    }

                    attchName.append("||").append(attch.getFile_Name()).append("||");
                    attch.save();
                }

                // 处理独立的附件。

                db.endTransaction(true);

                if (content.getUp_Content_ID() > 0) {
                    String ref = request.getHeader("referer");
                    if (ref.toLowerCase().indexOf("replycontent.jsp") != -1) {
                        out.write("<script language=javascript>window.location.href='ViewContent.jsp?id="
                                        + String.valueOf(content.getFirst_Content_ID()) + "';</script>");
                    }
                    else {
                        out.write("<script language=javascript>window.location.href='"
                                        + request.getHeader("referer") + "';</script>");
                    }
                }
                else {                	
                   if(action!=null && action.equals("DSKZQK"))
                		out.write("<script language=javascript>alert('上传成功!');window.location.href='" + request.getContextPath()
                                    + "/view/edit_web_index/edit_webdsk_index.jsp';</script>");
                    else
	                    out.write("<script language=javascript>alert('上传成功!');window.location.href='" + request.getContextPath()
                                    + "/view/edit_web_index/edit_web_index.jsp';</script>");
                }}
            }
            catch (Exception ex) {
                try {
                    db.endTransaction(false);
                }
                catch (Exception e) {}

                out.write("<script language=javascript>window.location.href='" + request.getContextPath()
                                + "/view/sysmgr/OperFailure.jsp?error=" + Util.Replace(ex.getMessage())
                                + "';</script>");
                FileLogger.getLogger().warn(ex.getMessage(), ex);
            }
        %>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -