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.

286 lines
8.6 KiB

  1. <%@ CODEPAGE=65001 %>
  2. <%
  3. '------------------------------------------------------------
  4. '
  5. ' Microsoft Internet Printing Project
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Printer Job List
  10. '
  11. '------------------------------------------------------------
  12. Option Explicit
  13. %>
  14. <!-- #include file = "ipp_util.inc" -->
  15. <%
  16. Const CHECKED_TAG = " checked "
  17. Randomize
  18. CheckSession
  19. Response.Expires = 0
  20. Const SelectedColor = "#c0c0c0"
  21. Const UnselectedColor = "#ffffff"
  22. Const iJobLength = 10
  23. Const L_OpenQueue_Text = "Open Queue"
  24. Const L_GetJobs_Text = "Get Jobs"
  25. Dim strPrinter, strAction, strComputer, strJobid, objQueue, objJobs, objJob, iRes, bDHTML
  26. Dim objPrinter
  27. Dim iStart, iEnd
  28. Dim index
  29. index = -1
  30. strPrinter = OleCvt.DecodeUnicodeName (request ("eprinter"))
  31. strAction = Request("action")
  32. strJobid = Request("jobid")
  33. strComputer = Session(COMPUTER)
  34. bDHTML = Session(DHTML_ENABLED)
  35. On Error Resume Next
  36. Err.Clear
  37. If Request("startid") = "" Or Request ("endid") = "" Then
  38. iStart = 1
  39. iEnd = iStart+ iJobLength
  40. Else
  41. iStart = Int (Request ("startid"))
  42. iEnd = Int (Request ("endid"))
  43. End If
  44. Set objQueue = GetObject("WinNT://" & strComputer & "/" & strPrinter & ",PrintQueue")
  45. If Err Then ErrorHandler (L_OpenQueue_Text)
  46. Set objJobs = objQueue.PrintJobs
  47. If Err Then ErrorHandler (L_GetJobs_Text)
  48. Function strJobStatus(iStatus)
  49. Dim L_JobStatus_Text(11)
  50. Dim bit, i
  51. Dim strTemp, bFirst
  52. Const L_Seperator_Text = " - "
  53. L_JobStatus_Text(0) = "Paused"
  54. L_JobStatus_Text(1) = "Error"
  55. L_JobStatus_Text(2) = "Deleting"
  56. L_JobStatus_Text(3) = "Spooling"
  57. L_JobStatus_Text(4) = "Printing"
  58. L_JobStatus_Text(5) = "Offline"
  59. L_JobStatus_Text(6) = "Out of Paper"
  60. L_JobStatus_Text(7) = "Printed"
  61. L_JobStatus_Text(8) = "Deleted"
  62. L_JobStatus_Text(9) = "Blocked"
  63. L_JobStatus_Text(10) = "User Intervention Required"
  64. L_JobStatus_Text(11) = "Restarting"
  65. bit = 1
  66. i = 0
  67. bFirst = True
  68. strTemp = ""
  69. For i = 0 To 11
  70. If iStatus And bit Then
  71. If Not bFirst Then
  72. strTemp = strTemp + L_Seperator_Text
  73. End If
  74. strTemp = strTemp + L_JobStatus_Text(i)
  75. bFirst = False
  76. End If
  77. bit = bit * 2
  78. Next
  79. If strTemp = "" Then strTemp = "&nbsp;"
  80. strJobStatus = strTemp
  81. End Function
  82. Function GenQueueViewHead ()
  83. Dim L_TableHeader1_Text, L_TableHeader2_Text, L_TableHeader3_Text
  84. Dim L_TableHeader4_Text, L_TableHeader5_Text, L_TableHeader6_Text
  85. L_TableHeader1_Text = "<b>Document</b>"
  86. L_TableHeader2_Text = "<b>Status</b>"
  87. L_TableHeader3_Text = "<b>Owner</b>"
  88. L_TableHeader4_Text = "<b>Pages</b>"
  89. L_TableHeader5_Text = "<b>Size</b>"
  90. L_TableHeader6_Text = "<b>Submitted</b>"
  91. GenQueueViewHead = "<tr>" & _
  92. "<td width=""30%"" bgcolor=""#000000"" nowrap>" & MENU_FONT_TAG & L_TableHeader1_Text & END_FONT & "</td>" &_
  93. "<td width=""10%"" bgcolor=""#000000"" nowrap>" & MENU_FONT_TAG & L_TableHeader2_Text & END_FONT & "</td>" &_
  94. "<td width=""10%"" bgcolor=""#000000"" nowrap>" & MENU_FONT_TAG & L_TableHeader3_Text & END_FONT & "</td>" &_
  95. "<td width=""10%"" bgcolor=""#000000"" nowrap>" & MENU_FONT_TAG & L_TableHeader4_Text & END_FONT & "</td>" &_
  96. "<td width=""10%"" bgcolor=""#000000"" nowrap>" & MENU_FONT_TAG & L_TableHeader5_Text & END_FONT & "</td>" &_
  97. "<td width=""20%"" bgcolor=""#000000"" nowrap>" & MENU_FONT_TAG & L_TableHeader6_Text & END_FONT & "</td>" &_
  98. "</tr>"
  99. End Function
  100. Function GenQueueViewBody (objJob, i)
  101. Dim strHTML
  102. Dim TdStart, TdEnd
  103. TdStart = "<td nowrap>" & DEF_FONT_TAG
  104. TdEnd = END_FONT & "</td>"
  105. If objJob.Name = strJobid Then
  106. index = i
  107. End If
  108. strHTML = strHTML & "<tr bgcolor=" & UnselectedColor & " id=" & (i-1) & ">" &_
  109. TdStart & "&nbsp;<input type=radio name=jobid value=""" & objJob.name & """"
  110. If objJob.name = strJobid Then
  111. strHTML = strHTML & CHECKED_TAG
  112. End If
  113. strHTML = strHTML & ONCLICK_EQUALS & """return setJobId(" & objJob.name & ");"">" &_
  114. strCleanString (objjob.Description) & TdEnd &_
  115. TdStart & strJobStatus(objJob.status) & TdEnd &_
  116. TdStart & objJob.user & TdEnd
  117. If objJob.totalpages > 0 Then
  118. strHTML = strHTML & TdStart & objJob.totalpages & TdEnd
  119. Else
  120. strHTML = strHTML & TdStart & "&nbsp;" & TdEnd
  121. End If
  122. If objJob.size > 0 Then
  123. strHTML = strHTML & TdStart & strFormatJobSize (objJob.size) & TdEnd
  124. Else
  125. strHTML = strHTML & TdStart & "&nbsp;" & TdEnd
  126. End If
  127. strHTML = strHTML & TdStart & formatdatetime(objJob.timesubmitted, 3) & " " &_
  128. formatdatetime(objJob.timesubmitted, 2) & TdEnd & "</tr>"
  129. GenQueueViewBody = strHTML
  130. End Function
  131. %>
  132. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  133. <html lang=<%=L_Language%>>
  134. <head>
  135. <meta http-equiv="refresh" content="30">
  136. <Meta Http-equiv="Content-Type" Content="text/html; CHARSET=UTF-8">
  137. <title><%=Write (L_DocumentList_Text)%></title>
  138. </head>
  139. <body bgcolor="#FFFFFF" text="#000000" topmargin="0" leftmargin="0" link="#000000"
  140. vlink="#000000" alink="#000000">
  141. <script language="javascript">
  142. function setJobId (id)
  143. {
  144. document.forms[1].elements[0].value = id;
  145. return true;
  146. }
  147. </script>
  148. <form>
  149. <%if bDHTML then %>
  150. <div
  151. ONCLICK="colorSelector()"><script LANGUAGE="JavaScript">
  152. var oldTr = 0;
  153. function colorSelector() {
  154. var jlist = document.all.JOBLIST.rows;
  155. if (!jlist[0].contains (event.srcElement)) {
  156. if (oldTr != null) {
  157. oldTr.bgColor = "<%=UnselectedColor%>";
  158. }
  159. for (i = 1; i < jlist.length; i++) {
  160. if (jlist[i].contains (event.srcElement)) {
  161. oldTr = jlist[i];
  162. oldTr.bgColor = "<%=SelectedColor%>";
  163. document.forms[0].elements[oldTr.id - <%=iStart%> + 1].checked = true;
  164. setJobId (document.forms[0].elements[oldTr.id - <%=iStart%> + 1].value);
  165. }
  166. }
  167. }
  168. }
  169. </script>
  170. <% end if%>
  171. <table id="JOBLIST" border="0" cellpadding="2" cellspacing="0" width="100%">
  172. <%= Write (GenQueueViewHead) %>
  173. <%
  174. Dim i
  175. Dim bShowNext
  176. bShowNext = FALSE
  177. i = 1
  178. For Each objJob In objJobs
  179. If (i >= iEnd) Then
  180. bShowNext = TRUE
  181. Exit For
  182. End If
  183. If (i >= istart) Then
  184. Response.Write (Write (GenQueueViewBody (objJob, i)))
  185. 'Response.Write (GenQueueViewBody (objJob, i))
  186. End If
  187. i = i + 1
  188. Next
  189. %>
  190. </table>
  191. </form>
  192. <form >
  193. <input type="hidden" name="selectedid" value="<%=strJobid%>">
  194. <input type="hidden" name="startid" value="<%=iStart%>">
  195. <input type="hidden" name="endid" value="<%=iEnd%>">
  196. </form>
  197. <%
  198. If i = 1 Then 'No job in the printer queue
  199. Const L_NoJob_Text = "<br><br><center><b>There is no document in the printer queue.</b></center>"
  200. Response.Write (Write(DEF_FONT_TAG & L_NoJob_Text & END_FONT))
  201. End If
  202. Dim strUrl
  203. const L_Prev_Text = "Prev %1 documents"
  204. Const L_Next_Text = "Next %1 documents"
  205. strUrl = "<a target=""_top"" href=ipp_0004.asp?eprinter=" & Request("eprinter") & VIEW_EQUALS & Request("view") & "&startid=" & CStr(iStart - iJobLength) & "&endid=" & CStr(iEnd - iJobLength) & ATPAGE & CStr(Int(Rnd*10000)) & ">" &_
  206. RepString1(L_Prev_Text, CStr (iJobLength)) & "</a>&nbsp;&nbsp;&nbsp;&nbsp;"
  207. If iStart > 1 Then
  208. Response.Write ( Write(DEF_FONT_TAG & strUrl & END_FONT))
  209. End If
  210. strUrl = "<a target=""_top"" href=ipp_0004.asp?eprinter=" & Request("eprinter") & VIEW_EQUALS & Request("view") & "&startid=" & CStr(iStart + iJobLength) & "&endid=" & CStr(iEnd+iJobLength) & ATPAGE & CStr(Int(Rnd*10000)) & ">" &_
  211. RepString1(L_Next_Text, CStr (iJobLength)) & "</a>"
  212. If bShowNext Then
  213. Response.Write ( Write(DEF_FONT_TAG & strUrl & END_FONT))
  214. End If
  215. %>
  216. <%if bDHTML then%>
  217. </div>
  218. <% end if %>
  219. <%if index > 0 then%>
  220. <script LANGUAGE="JavaScript">
  221. window.onerror=windowError;
  222. function windowError ()
  223. { return true; }
  224. if (document.all) {
  225. oldTr = document.all.JOBLIST.rows[<%=index - iStart + 1%>];
  226. oldTr.bgColor = "<%=SelectedColor%>";
  227. }
  228. </script>
  229. <%end if%>
  230. </body>
  231. </html>