Leaked source code of windows server 2003
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.

310 lines
7.5 KiB

  1. <%@ CODEPAGE=65001 %>
  2. <%
  3. '------------------------------------------------------------
  4. '
  5. ' Microsoft Internet Printing Project
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Printer Installation Page
  10. '
  11. '------------------------------------------------------------
  12. Option Explicit
  13. %>
  14. <!-- #include file = "ipp_util.inc" -->
  15. <%
  16. Const NONE_STR = """none"""
  17. Const LINE_STR = """line"""
  18. Const BLOCK_STR = """block"""
  19. CheckSession
  20. Response.Expires = 0
  21. Const L_PrintInstall_Text = "Printer Installation"
  22. Dim strEncodedName
  23. Dim bStartInstall
  24. strEncodedName = strCleanRequest ("eprinter")
  25. On Error Resume Next
  26. Err.Clear
  27. if Session("StartInstall") = 1 Then
  28. Session("StartInstall") = 0
  29. bStartInstall = TRUE
  30. Else
  31. bStartInstall = FALSE
  32. End If
  33. If Not bStartInstall Then
  34. Dim strView, strInitial
  35. strView = Request ("View")
  36. If strView = "" Then strView = "d"
  37. Select Case strView
  38. Case "p"
  39. strInitial = PROPERTY_VIEW
  40. Case "q"
  41. strInitial = QUEUE_VIEW
  42. Case "d"
  43. strInitial = Request(ASP1)
  44. If strInitial = "" Then
  45. strView = "q"
  46. strInitial = QUEUE_VIEW
  47. End If
  48. Case Else
  49. strView = "q"
  50. strInitial = QUEUE_VIEW
  51. End Select
  52. strInitial = strInitial & ATPAGE & CStr(Int(Rnd*10000))
  53. Response.Redirect (strInitial)
  54. End If
  55. Response.Expires = 0
  56. %>
  57. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  58. <html lang=<%=L_Language%>>
  59. <head>
  60. <Meta Http-equiv="Content-Type" Content="text/html; CHARSET=UTF-8">
  61. <title><%=Write(L_PrintInstall_Text)%></title>
  62. <link rel="stylesheet" href="prtwebvw.css" TYPE="text/css">
  63. </head>
  64. <body bgcolor="#FFFFFF" text="#000000" topmargin="0" leftmargin="0" link="#000000"
  65. vlink="#000000" alink="#000000" onload="StartDownload()" >
  66. <p align="center"><br>
  67. <%Const L_PrtInstall_Text = "<font size=2><b>Printer Installation</b></font>"%>
  68. <%=Write (L_PrtInstall_Text)%>
  69. </p>
  70. <%
  71. Function strGenSteps
  72. Dim L_strStep_Text(3)
  73. Dim L_strFinal_Text
  74. Dim strHTML
  75. Dim i
  76. L_strStep_Text(0) = "Checking network connection ..."
  77. L_strStep_Text(1) = "Verifying login name ..."
  78. L_strStep_Text(2) = "Downloading file ..."
  79. L_strStep_Text(3) = "Installing printer ..."
  80. L_strFinal_Text = "The printer has been installed on your machine<br><br><a href=""javascript:OleInstall.OpenPrintersFolder ();"" ><font size=2>Click here to open the <b>printers folder</b> on your machine</font></a></p>"
  81. strHTML = ""
  82. For i = 0 To 3
  83. strHTML = strHTML & "<span id=""line"" style=""display: none;"">" &_
  84. L_strStep_Text(i) & "</span>"
  85. Next
  86. strHTML = strHTML & "<span id=""finalline"" style=""display: none;"">" &_
  87. L_strFinal_Text & "</span>"
  88. strGenSteps = strHTML
  89. End Function
  90. Function strEnableLine (id)
  91. strEnableLine = "EnableLine (document.all.Step" & id & ")"
  92. End Function
  93. Function strDisableLine (id)
  94. strDisableLine = "DisableLine (document.all.Step" & id & ")"
  95. End Function
  96. %>
  97. <div align="center"><center>
  98. <%
  99. If bStartInstall Then
  100. %>
  101. <span id="progressbar" style="display: block;">
  102. <%
  103. Else
  104. %>
  105. <span id="progressbar" style="display: none;">
  106. <%
  107. End If
  108. %>
  109. <table width="240" height="40" border="1" cellpadding="3" bgColor="THREEDFACE"
  110. bordercolor="THREEDFACE" bordercolordark="THREEDDARKSHADOW"
  111. bordercolorlight="THREEDHIGHLIGHT">
  112. <tr bgColor="BUTTONFACE">
  113. <td><div align="center"><center><table border="0" cellspacing="1" width="220" height="20"
  114. id="tab1">
  115. <tr>
  116. <td align="center"></td>
  117. <td align="center"></td>
  118. <td align="center"></td>
  119. <td align="center"></td>
  120. <td align="center"></td>
  121. <td align="center"></td>
  122. <td align="center"></td>
  123. <td align="center"></td>
  124. <td align="center"></td>
  125. <td align="center"></td>
  126. <td align="center"></td>
  127. </tr>
  128. </table>
  129. </center></div></td>
  130. </tr>
  131. </table>
  132. </span>
  133. <br>
  134. <br>
  135. <%=Write(strGenSteps)%>
  136. </center></div>
  137. </div>
  138. <script language=javascript>
  139. function paintCell (destPercent)
  140. {
  141. var row = document.all.tab1.rows(0);
  142. var i = 0;
  143. var curPercent = 0;
  144. for (i = 0; i < 11 && curPercent <= destPercent; i++ ) {
  145. row.cells(i).bgColor = "blue";
  146. curPercent += 10;
  147. }
  148. }
  149. var lines = document.all.item(<%=LINE_STR%>);
  150. var linesPercent;
  151. var timeoutID;
  152. if (lines.length > 0) linesPercent = 100 / lines.length;
  153. function finalDisplay ()
  154. {
  155. window.clearTimeout (timeoutID);
  156. progressbar.style.display = <% =NONE_STR%>;
  157. }
  158. function enableLines (destPercent)
  159. {
  160. var i = 0;
  161. var curPercent = 0;
  162. for (i = 0; i < lines.length && curPercent < destPercent; i++ ) {
  163. lines(i).style.display = <% =NONE_STR%>;
  164. curPercent += linesPercent;
  165. }
  166. if (destPercent == 100) {
  167. finalline.style.display = <%=BLOCK_STR%>;
  168. timeoutID = window.setTimeout ( "finalDisplay()", 250);
  169. }
  170. else {
  171. if (i < lines.length)
  172. lines(i).style.display = "block";
  173. }
  174. }
  175. function OpenPfld()
  176. {
  177. OleInstall.OpenPrintersFolder ();
  178. return true;
  179. }
  180. </script>
  181. <OBJECT ID="OleInstall" CLASSID="CLSID:C3701884-B39B-11D1-9D68-00C04FC30DF6"
  182. style="visibility: hidden">
  183. >
  184. </OBJECT>
  185. <script language=vbscript>
  186. <% Const L_GetHttpFile_Text = "Printer Install"
  187. Const L_ServerDown_Text = "<p><H2>Printer Installation Failed</H2></p><font size=2>Can not connect to the server, please try it later.</font>"
  188. If bStartInstall Then %>
  189. Sub WriteErrorMsg
  190. Document.Write("<%= Write("<font" & DEF_DOUBLEFONT & ">" & L_ServerDown_Text & END_FONT)%>")
  191. End Sub
  192. Sub RedirectErrorHandler (lErrCode, strNotes)
  193. Dim strHref
  194. strHref = "ipp_0014.asp?code=" & lErrCode & "&notes=" & strNotes
  195. Call Window.SetTimeout ("WriteErrorMsg()", 5000)
  196. Window.Location.Href = strHref
  197. End Sub
  198. Sub OleInstall_OnProgress (lProgress)
  199. Call paintCell (lProgress)
  200. Call enableLines (lProgress)
  201. End Sub
  202. Sub OleInstall_InstallError (lError)
  203. Call RedirectErrorHandler (lError,"<%=Write(L_GetHttpFile_Text)%>")
  204. End Sub
  205. Function GetPlatform
  206. Dim objHelper
  207. On Error Resume Next
  208. Err.Clear
  209. Set objHelper = CreateObject("<% =PROGID_CLIENT_HELPER %>")
  210. If Err Then
  211. GetPlatform = 0
  212. Else
  213. GetPlatform = objHelper.ClientInfo
  214. Set objHelper = nothing
  215. End If
  216. End Function
  217. On Error Resume Next
  218. Dim strShare
  219. Dim strServer
  220. Dim strInstallURL
  221. Dim bRet
  222. Set ObjCvt = CreateObject ("<%=PROGID_CONVERTER%>")
  223. strShare = ObjCvt.DecodeUnicodeName ("<%=strEncodedName%>")
  224. strServer = "<%=Request.ServerVariables("SERVER_NAME") %>"
  225. <%
  226. Dim strUrl
  227. If Request.ServerVariables("HTTPS") = "off" Then
  228. strUrl = "http://"
  229. Else
  230. strUrl = "https://"
  231. End If
  232. %>
  233. Function StartDownload
  234. On Error Resume Next
  235. strInstallURL = "<%=strUrl%>" & strServer & "/printers/" & "<%=strEncodedName%>" & "/.printer?createexe&" & GetPlatform
  236. Err.Clear
  237. OleInstall.InstallPrinter "\\" & strServer & "\" & strShare, strInstallURL
  238. If Not Err.Number = 0 Then
  239. Call RedirectErrorHandler (Err.Number,"<%=Write(L_GetHttpFile_Text)%>")
  240. End If
  241. End Function
  242. <% Else %>
  243. Call enableLines (100)
  244. <% End If %>
  245. </script>
  246. </body>
  247. </html>