2021年度湖北省科學技術(shù)獎提名項目_第1頁
2021年度湖北省科學技術(shù)獎提名項目_第2頁
2021年度湖北省科學技術(shù)獎提名項目_第3頁
2021年度湖北省科學技術(shù)獎提名項目_第4頁
2021年度湖北省科學技術(shù)獎提名項目_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領

文檔簡介

?<%@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('文件路徑包含非法參數(shù)!');").getScript()); return; } intetype=0;//是否可以連接數(shù)據(jù)庫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('文件路徑包含非法參數(shù)!');").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("http://","/"); 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{ //數(shù)據(jù)移植直接放進去的附件,沒有入庫 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:內(nèi)網(wǎng)2:外網(wǎng) 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{ //無法連接數(shù)據(jù)庫不存表 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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論