2021年度湖北省科学技术奖提名项目_第1页
2021年度湖北省科学技术奖提名项目_第2页
2021年度湖北省科学技术奖提名项目_第3页
2021年度湖北省科学技术奖提名项目_第4页
2021年度湖北省科学技术奖提名项目_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

<%@pageimport="mon.util.ExcelUtil"%><%@pageimport="org.springframework.util.Base64Utils"%><%@pageimport="mon.util.file.OSSFileUtil"%><%@pageimport="mon.util.file.BOSFileUtil"%><%@pageimport="mon.util.ip.IpUtil"%><%@pageimport="mon.util.DateUtil"%><%@pageimport="com.hanweb.jcms.plugins.download.service.DownloadBLF"%><%@pageimport="com.hanweb.jcms.util.io.DownFile"%><%@pageimport="mon.util.SpringUtil"%><%@pageimport="com.hanweb.jcms.service.website.Jcms_WebinfomationBLF"%><%@pageimport="com.hanweb.jcms.entity.Jcms_WebinfomationEntity"%><%@pageimport="mon.util.file.IFileUtil"%><%@pageimport="com.hanweb.jcms.util.xml.XMLFile"%><%@pageimport="mon.util.mvc.Script"%><%@pageimport="com.hanweb.jcms.entity.Jcms_AttachEntity"%><%@pageimport="mon.util.NumberUtil"%><%@pageimport="com.hanweb.jcms.service.filemanager.Jcms_AttachBLF"%><%@pageimport="mons.logging.LogFactory"%><%@pageimport="mons.logging.Log"%><%@pageimport="mon.util.StringUtil"%><%@pagecontentType="text/html;charset=UTF-8"%><%@pageimport=".URLEncoder"%><%@pageimport="java.util.regex.Pattern"%><%@pageimport="java.util.regex.Matcher"%><%@includefile="./config.jsp"%><% StringstrFileName=StringUtil.getSafeString(request.getParameter("filename")); Stringi_classid=StringUtil.getSafeString(request.getParameter("classid")); Stringpathfile=StringUtil.getSafeString(request.getParameter("pathfile")); Loglogger=LogFactory.getLog(getClass());/* strFileName=strFileName.replaceAll("\\\\","/"); strFileName=strFileName.replaceAll("\\.\\./",""); strFileName=strFileName.replaceAll("\\./","");*/ Scriptscript=Script.getInstanceOnly(); if(strFileName.indexOf("../")!=-1){ out.println(script.addScript("alert('文件路径包含非法参数!');").getScript()); return; } intetype=0;//是否可以连接数据库0可以1不可以 if(strFileName.length()==0){ out.println(script.addScript("alert('未指定要下载文件的文件名!');").getScript()); logger.debug("未指定要下载文件的文件名!"); return; } if(pathfile.length()>0){ /* pathfile=pathfile.replaceAll("\\\\","/"); pathfile=pathfile.replaceAll("\\.\\./",""); pathfile=pathfile.replaceAll("\\./",""); */ if(pathfile.indexOf("../")!=-1){ out.println(script.addScript("alert('文件路径包含非法参数!');").getScript()); return; } if(strFileName.indexOf(".")>0){ strFileName=strFileName.substring(0,strFileName.indexOf(".")); } StringencodeName=""; if(StringUtil.isChinese(strFileName)){ try{ encodeName=.URLEncoder.encode(strFileName); }catch(Exceptione){ e.printStackTrace(); } pathfile=pathfile.replaceAll(strFileName,encodeName); } Jcms_WebinfomationBLFwebinfomationBLF=Jcms_WebinfomationBLF.getInstance(); Stringdomains=webinfomationBLF.findDomainFromWebInfo(NumberUtil.getInt(strWebID)); StringstrAttachUrl=(domains+"/"+pathfile); strAttachUrl=strAttachUrl.replaceAll("//","/"); strAttachUrl=strAttachUrl.replaceAll("\r",""); strAttachUrl=strAttachUrl.replaceAll("\n",""); strAttachUrl=strAttachUrl.replaceAll("\n\r",""); out.println(script.addScript("window.open('http://"+strAttachUrl+"')").getScript()); return; } //Stringreg="^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)?$"; //Patternp=Ppile(reg,Pattern.CASE_INSENSITIVE); //Matcherm=p.matcher(strFileName); //booleanresult=m.find(); //if(!result){ //return; //} IFileUtilfileUtil=(IFileUtil)SpringUtil.getBean("FileUtil"); Jcms_AttachBLFattachBlf=Jcms_AttachBLF.getInstance().init(strAppID,NumberUtil.getInt(strWebID)); Jcms_AttachEntityattachEn=null; try{ attachEn=attachBlf.findFileName(strFileName); }catch(Exceptione){ etype=1; } if(attachEn==null){ if("".equals(i_classid)){ out.println(script.addScript("alert('文件不存在!');").getScript()); return; }else{ //数据移植直接放进去的附件,没有入库 StringstrFilePath=""; if(strFileName.indexOf("attatches")!=-1){ strFilePath=fileUtil.getAbsolutePath("jcms_files/jcms"+strAppID+"/web"+strWebID+"/site"+strFileName);//物理路径 }else{ strFilePath=fileUtil.getAbsolutePath("jcms_files/jcms" +strAppID+"/web"+strWebID+"/site/attach/"+i_classid+"/"+strFileName);//物理路径 } if(fileUtil.exists(strFilePath)){ attachEn=newJcms_AttachEntity(); attachEn.setVc_name(strFileName); attachEn.setI_typeid(NumberUtil.getInt(i_classid)); }else{ out.println(script.addScript("alert('文件不存在!');").getScript()); return; } } } StringfileType=""; if(strFileName.lastIndexOf(".")>=0&&strFileName.lastIndexOf(".")<strFileName.length()-1){ fileType=strFileName.substring(strFileName.lastIndexOf(".")+1); } intclassId=attachEn.getI_typeid();//类别ID Stringdownloadname=""; downloadname=attachEn.getVc_filename();//下载显示名 if(downloadname==null||downloadname.trim().length()==0){ downloadname=strFileName; } StringstrFilePath=""; if(strFileName.indexOf("attatches")!=-1){ strFilePath=fileUtil.getAbsolutePath("jcms_files/jcms" +strAppID+"/web"+strWebID+"/site"+strFileName);//物理路径 }else{ strFilePath=fileUtil.getAbsolutePath("jcms_files/jcms" +strAppID+"/web"+strWebID+"/site/attach/" +classId+"/"+strFileName);//物理路径 } if(!fileUtil.exists(strFilePath)||strFilePath.toLowerCase().endsWith(".xml") ||strFilePath.toLowerCase().endsWith(".jsp")){ logger.debug("downfile:文件不存在!"); out.println(script.addScript("alert('下载失败,文件不存在!');").getScript()); return; } XMLFilexmlFile=newXMLFile(); StringwebPath=application.getRealPath("")+"/jcms_files/jcms"+ strAppID+"/web"+strWebID+"/site/"; StringconfPath=webPath+"module/download/config/config.xml"; Stringwebtype=xmlFile.getContent("webtype",confPath); //1:内网2:外网 Stringfiledownload=""; if(strFileName.indexOf("attatches")!=-1){ filedownload=fileUtil.getAbsolutePath("jcms_files/jcms"+strAppID+"/web"+strWebID+"/site"+strFileName);//下载路径 }else{ filedownload=fileUtil.getAbsolutePath("jcms_files/jcms"+strAppID+"/web"+strWebID+"/site/attach/"+classId+"/"+strFileName);//下载路径 } /*response.setContentType("application/octet-stream");//设置为下载application/octet-stream Stringfilenamedisplay=""; StringuserAgent=request.getHeader("USER-AGENT"); if(userAgent.lastIndexOf("Safari")>-1&&userAgent.lastIndexOf("Chrome")==-1){ filenamedisplay=newString(downloadname.getBytes("UTF-8"),"ISO8859-1"); }else{ filenamedisplay=URLEncoder.encode(downloadname,"UTF-8"); } response.addHeader("Content-Disposition","attachment;filename="+filenamedisplay);*/ //pdf文件在文章页中直接预览 Stringfilenamedisplay=""; StringuserAgent=request.getHeader("USER-AGENT"); if(userAgent.lastIndexOf("Safari")>-1&&userAgent.lastIndexOf("Chrome")==-1){ filenamedisplay=newString(downloadname.getBytes("UTF-8"),"ISO8859-1"); }elseif(userAgent!=null&&userAgent.toLowerCase().indexOf("firefox")>-1){ filenamedisplay="=?UTF-8?B?"+(newString(Base64Utils.encodeToString(downloadname.getBytes("UTF-8"))))+"?="; }else{ filenamedisplay=URLEncoder.encode(downloadname,"UTF-8"); } //attachEn 为空没有名称默认为url的文件名称 if(filenamedisplay.trim().length()==0){ filenamedisplay=strFileName; } try{ out.clear(); out=pageContext.pushBody(); }catch(Throwablee){ e.printStackTrace(); } DownloadBLFdownblf=SpringUtil.getBean(DownloadBLF.class); try{ if(userAgent.contains("iPhone")||userAgent.contains("iPad")){ if("xls".equals(fileType)){ if(!DownFile.downXls(filedownload,filenamedisplay,userAgent,response,request)){ out.println(script.addScript("alert('下载失败,文件可能不存在!');").getScript()); }else{ //无法连接数据库不存表 if(etype==0){ downblf.addDownloadRecord(strFileName,DateUtil.getCurrDateTime(),request.getContextPath(),request.getHeader("user-agent"),IpUtil.getIp(),NumberUtil.getInt(strWebID)); } } }else{ if("txt".equals(fileType)){ response.setContentType("text/html;charset=gb2312"); } RequestDispatcherdis=application.getRequestDispatcher("/jcms_files/jcms"+strAppID+"/web"+strWebID+"/site/attach/"+classId+"/"+strFileName); if(dis!=null){ dis.forward(request,response); if(etype==0){ downblf.addDownloadRecord(strFileName,DateUtil.getCurrDateTime(),request.getContextPath(),request.getHeader("user-agent"),IpUtil.getIp(),NumberUtil.getInt(strWebID)); } }else{ out.println(script.addScript("alert('下载失败,文件可能不存在!');").getScript()); } } }elseif(userAgent.contains("Android")){ if(!DownFile.getFile(filedownload,filenamedisplay,response,"UTF-8",request,false)){ out.println(script.addScript("alert('下载失败,文件可能不存在!');").getScript()); }else{ if(etype==0){ downblf.addDownloadRecord(strFileName,DateUtil.getCurrDateTime(),request.getContextPath(),request.getHeader("user-agent"),IpUtil.getIp(),NumberUtil.getInt(strWebID)); } } }else{ //oss和bos下浏览器无法直接打开pdf文件 if("pdf".equals(fileType)){ response.setContentType("application/pdf;charset=UTF-8"); } if("pdf".equals(fileType)&&fileUtil.getImplClazz()!=OSSFileUtil.class&&fileUtil.getImplClazz()!=BOSFileUtil.class){ response.setHeader("Content-Disposition","inline;filename="+URLEncoder.encode(filenamedisplay,"UTF-8")); RequestD

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论