Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
4.3 KiB

  1. <%
  2. Option explicit
  3. Response.Expires = 0
  4. Dim Conn,Comm,RS,bf,lid,v,FileSys,reof
  5. %>
  6. <!--
  7. upload attachment file for a specified bug
  8. Form : bugid=# ( bug # )
  9. a unique filename is generated and inserted in links table, then update is made
  10. using Posting Acceptor ( RFC 1867 ) using <input type=file> on the client and
  11. Site Server posting acceptor on the server side.
  12. upload is temp directory on server : /scripts/raid/uploadd/[unique file name]
  13. repost is made to path /scripts/raid/[UNC vdir]/[unique file name].pac so that
  14. DLL associated with .pac extension ( should be pacopy.dll ) is invoked using
  15. credentials associated with UNC share. This DLL copies file from temp dir
  16. to UNC share
  17. at upload time another request is sent to repost.asp to rename temp filename
  18. to filename specified by user
  19. -->
  20. <html>
  21. <head>
  22. <title>Attach file</title>
  23. <script language="JavaScript">
  24. <%
  25. rem generate new file name
  26. Set Conn = Server.CreateObject("ADODB.Connection")
  27. Set Comm = Server.CreateObject("ADODB.Command")
  28. Set RS = Server.CreateObject("ADODB.Recordset")
  29. Conn.Open Session("DSN")
  30. Set Comm.ActiveConnection = Conn
  31. Set RS.Source = Comm
  32. rem dt = Now
  33. rem bf = CLng(dt)*24*60 + Hour(dt)*60 + Minute(dt)
  34. bf = CLng(Request.QueryString("bugid")) * 30
  35. rem generate unique file name by checking for existence in links table
  36. rem then insert new link entry using temp filename, must be updated
  37. rem during repost with real filename as specified by user
  38. rem we must create entry now because we must guarantee that no one else
  39. rem uses our generated unique file name
  40. Conn.BeginTrans
  41. Comm.CommandText = "Select IsNull(Max(LinkID)+1,1) from links"
  42. RS.Open
  43. lid = RS(0)
  44. RS.Close
  45. do while true
  46. Comm.CommandText = "Select LinkID from links where BugID=" & Request.QueryString("bugid") & " AND Type=3 AND fDeleted=0 AND OriginalName<>'temp' AND FileName='h" & CStr(bf) & ".'"
  47. RS.Open
  48. reof = RS.EOF
  49. RS.Close
  50. if reof then
  51. exit do
  52. end if
  53. bf = bf + 1
  54. loop
  55. v = "insert into links(LinkID, BugID, FileName, OriginalName, LinkedBugID, DataString, TokenID, Type, fDeleted, Rev) VALUES(" & lid & ", " & Request.QueryString("bugid") & ", 'h" & CStr(bf) & ".', 'temp', 0, '', 2, 3, 0, 1)"
  56. rem set the default window return value (as a JS var ), which will be used if user
  57. rem does not actually attach any file. In this case we need to return
  58. rem the LinkID so that caller client script can invoke server script to delete
  59. rem temporary record created in links table
  60. Response.Write "window.returnValue=" & chr(34) & lid & chr(34) & ";"
  61. Conn.Execute v
  62. Conn.CommitTrans
  63. Conn.Close
  64. Set FileSys = Server.CreateObject("Scripting.FileSystemObject")
  65. On Error Resume Next
  66. FileSys.CreateFolder( Server.MapPath("/scripts/raid/uploadd/h" & CStr(bf) ) )
  67. rem if err <> 58 AND err<>0 then
  68. rem Response.Write Err.Number
  69. rem end if
  70. %>
  71. function updlink(lid) {
  72. wi = window.open();
  73. document.all.updl.target = wi;
  74. document.all.updl.ulid.value = lid;
  75. document.all.updl.uorg.value = document.all.pr.org.value;
  76. document.all.updl.submit();
  77. wi.close();
  78. //alert( lid + "," + document.all.updl.ulid.value + "," + document.all.updl.uorg.value );
  79. window.returnValue = "uploaded";
  80. document.all.pr.attach.disabled = true;
  81. }
  82. </script>
  83. </head>
  84. <body bgcolor=#c0c0c0>
  85. <div style="display:none">
  86. <form id="updl" action="/scripts/raid/repost.asp" method=POST>
  87. <input type=hidden id="ulid" name="lid"></input>
  88. <input type=hidden id="uorg" name="org"></input>
  89. </form>
  90. </div>
  91. <form id="pr" enctype="multipart/form-data" action="http://<%= Request.ServerVariables("SERVER_NAME") %>/scripts/cpshost.dll?PUBLISH?http://<%= Request.ServerVariables("SERVER_NAME") %>/scripts/raid/<%=Application("dbFileShareDir")(Session("DBSOURCE"))%>/h<%=CStr(bf)%>.pac" method=post>
  92. File to Attach: <input id="org" name="my_file" type="file"><br>
  93. <input name="TargetURL" value="/scripts/raid/uploadd/h<%=CStr(bf)%>" style="display:none">
  94. <br>
  95. <input OnClick="updlink('<%=lid%>')" type="submit" id=attach value="Attach">
  96. <input OnClick="window.close()" type="button" value="Close">
  97. </form>
  98. </body>
  99. </html>