netdisk_getfile.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:7k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html;charset=gb2312"%>
  2. <%@page import="cn.js.fan.util.*"%>
  3. <%@page import="cn.js.fan.web.*"%>
  4. <%@page import="com.redmoon.oa.*"%>
  5. <%@page import="com.redmoon.oa.dept.*"%>
  6. <%@page import="com.redmoon.oa.netdisk.*"%>
  7. <%@page import="java.util.*"%>
  8. <%@page import="java.io.*"%>
  9. <%@page import="java.net.*"%>
  10. <jsp:useBean id="fchar" scope="page" class="cn.js.fan.util.StrUtil"/>
  11. <jsp:useBean id="fsecurity" scope="page" class="cn.js.fan.security.SecurityUtil"/>
  12. <jsp:useBean id="privilege" scope="page" class="com.redmoon.oa.pvg.Privilege"/>
  13. <%
  14. String priv = request.getParameter("priv");
  15. if (priv==null)
  16. priv = "read";
  17. if (!privilege.isUserPrivValid(request, priv))
  18. {
  19. //response.setContentType("text/html;charset=gb2312"); 
  20. out.print("<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>");
  21. out.println(fchar.makeErrMsg(SkinUtil.LoadString(request, "pvg_invalid")));
  22. return;
  23. }
  24. int id = ParamUtil.getInt(request, "id");
  25. int attId = ParamUtil.getInt(request, "attachId");
  26. Document mmd = new Document();
  27. mmd = mmd.getDocument(id);
  28. if (mmd==null || !mmd.isLoaded()) {
  29. out.print("<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>");
  30. out.println("文件不存在!");
  31. return;
  32. }
  33. Attachment att = mmd.getAttachment(1, attId);
  34. LeafPriv lp = new LeafPriv(att.getDirCode());
  35. if (!lp.canUserSee(privilege.getUser(request))) {
  36. // 如果没有共享的权限,则检查文件是否为已发布
  37. String[] depts = StrUtil.split(att.getPublicShareDepts(), ",");
  38. int len = 0;
  39. if (depts!=null)
  40. len = depts.length;
  41. boolean isValid = false;
  42. if (len==0)
  43. isValid = true;
  44. else {
  45. DeptUserDb du = new DeptUserDb();
  46. for (int i=0; i<len; i++) {
  47. if (du.isUserOfDept(privilege.getUser(request), depts[i])) {
  48. isValid = true;
  49. break;
  50. }
  51. }
  52. }
  53. if (!isValid) {
  54. out.print(SkinUtil.makeErrMsg(request, SkinUtil.LoadString(request, "pvg_invalid")));
  55. return;
  56. }
  57. }
  58. String ext = att.getExt();
  59. if (ext.equals("rm") || ext.equals("rmvb")) {
  60. %>
  61. <table width="100%" align="center"><tr><td align="center">
  62. <object ID="video1" CLASSID="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" HEIGHT="300" WIDTH="400">
  63. <param name="_ExtentX" value="22304">
  64. <param name="_ExtentY" value="14288">
  65. <param name="AUTOSTART" value="-1">
  66. <param name="SHUFFLE" value="0">
  67. <param name="PREFETCH" value="0">
  68. <param name="NOLABELS" value="0">
  69. <param name="SRC" value="<%=Global.getRealPath() + "/" + att.getVisualPath() + "/" + att.getDiskName()%>">
  70. <param name="CONTROLS" value="ImageWindow">
  71. <param name="CONSOLE" value="Clip1">
  72. <param name="LOOP" value="0">
  73. <param name="NUMLOOP" value="0">
  74. <param name="CENTER" value="0">
  75. <param name="MAINTAINASPECT" value="0">
  76. <param name="BACKGROUNDCOLOR" value="#000000">
  77. </object>
  78. <object ID="video1" CLASSID="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" HEIGHT="60" WIDTH="400">
  79. <param name="controls" value="ControlPanel,StatusBar">
  80. <param name="console" value="Clip1">
  81. <embed type="audio/x-pn-realaudio-plugin" CONSOLE="Clip1" CONTROLS="ControlPanel,StatusBar" HEIGHT="60" WIDTH="400" AUTOSTART="true"/>
  82. </object>
  83. </td></tr></table>
  84. <%
  85. } else if (ext.equals("wmv") || ext.equals("asf") || ext.equals("mp3") || ext.equals("mpeg") || ext.equals("wma") || ext.equals("mpg")) {
  86. %>
  87. <table width="100%" align="center"><tr><td align="center">
  88. <object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="MediaPlayer1" width="428" height="330">
  89.         <param name="AudioStream" value="-1">
  90.         <param name="AutoSize" value="0">
  91.         <param name="AutoStart" value="-1">
  92.         <param name="AnimationAtStart" value="-1">
  93.         <param name="AllowScan" value="-1">
  94.         <param name="AllowChangeDisplaySize" value="-1">
  95.         <param name="AutoRewind" value="0">
  96.         <param name="Balance" value="0">
  97.         <param name="BaseURL" value>
  98.         <param name="BufferingTime" value="5">
  99.         <param name="CaptioningID" value>
  100.         <param name="ClickToPlay" value="-1">
  101.         <param name="CursorType" value="0">
  102.         <param name="CurrentPosition" value="-1">
  103.         <param name="CurrentMarker" value="0">
  104.         <param name="DefaultFrame" value>
  105.         <param name="DisplayBackColor" value="0">
  106.         <param name="DisplayForeColor" value="16777215">
  107.         <param name="DisplayMode" value="0">
  108.         <param name="DisplaySize" value="2">
  109.         <param name="Enabled" value="-1">
  110.         <param name="EnableContextMenu" value="-1">
  111.         <param name="EnablePositionControls" value="-1">
  112.         <param name="EnableFullScreenControls" value="0">
  113.         <param name="EnableTracker" value="-1">
  114.         <param name="Filename" value="<%=Global.getRealPath() + "/" + att.getVisualPath() + "/" + att.getDiskName()%>">
  115.         <param name="InvokeURLs" value="-1">
  116.         <param name="Language" value="-1">
  117.         <param name="Mute" value="0">
  118.         <param name="PlayCount" value="1">
  119.         <param name="PreviewMode" value="0">
  120.         <param name="Rate" value="1">
  121.         <param name="SAMILang" value>
  122.         <param name="SAMIStyle" value>
  123.         <param name="SAMIFileName" value>
  124.         <param name="SelectionStart" value="-1">
  125.         <param name="SelectionEnd" value="-1">
  126.         <param name="SendOpenStateChangeEvents" value="-1">
  127.         <param name="SendWarningEvents" value="-1">
  128.         <param name="SendErrorEvents" value="-1">
  129.         <param name="SendKeyboardEvents" value="0">
  130.         <param name="SendMouseClickEvents" value="0">
  131.         <param name="SendMouseMoveEvents" value="0">
  132.         <param name="SendPlayStateChangeEvents" value="-1">
  133.         <param name="ShowCaptioning" value="0">
  134.         <param name="ShowControls" value="-1">
  135.         <param name="ShowAudioControls" value="-1">
  136.         <param name="ShowDisplay" value="0">
  137.         <param name="ShowGotoBar" value="0">
  138.         <param name="ShowPositionControls" value="-1">
  139.         <param name="ShowStatusBar" value="-1">
  140.         <param name="ShowTracker" value="-1">
  141.         <param name="TransparentAtStart" value="0">
  142.         <param name="VideoBorderWidth" value="0">
  143.         <param name="VideoBorderColor" value="0">
  144.         <param name="VideoBorder3D" value="0">
  145.         <param name="Volume" value="-40">
  146.         <param name="WindowlessVideo" value="0">
  147.       </object>
  148. </td></tr></table>   
  149. <%
  150. } else {
  151. // response.setContentType(MIMEMap.get(StrUtil.getFileExt(att.getDiskName())));
  152. response.setContentType(MIMEMap.get(att.getExt()));
  153. response.setHeader("Content-disposition","filename=" + StrUtil.GBToUnicode(att.getName()));
  154. // 以询问下载的方式打开,会覆盖父窗口
  155. // response.setContentType("application/octet-stream");
  156. // response.setHeader("Content-disposition","attachment; filename=" + StrUtil.GBToUnicode(att.getName()));
  157. BufferedInputStream bis = null;
  158. BufferedOutputStream bos = null;
  159. try {
  160. bis = new BufferedInputStream(new FileInputStream(Global.getRealPath() + "/" + att.getVisualPath() + "/" + att.getDiskName()));
  161. bos = new BufferedOutputStream(response.getOutputStream());
  162. byte[] buff = new byte[2048];
  163. int bytesRead;
  164. while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
  165. bos.write(buff,0,bytesRead);
  166. }
  167. } catch(final IOException e) {
  168. System.out.println( "IOException: " + e );
  169. } finally {
  170. if (bis != null)
  171. bis.close();
  172. if (bos != null)
  173. bos.close();
  174. }
  175. }
  176. %>