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.

554 lines
16 KiB

  1. <%@ CODEPAGE=65001 %>
  2. <%
  3. '------------------------------------------------------------
  4. '
  5. ' Microsoft Internet Printing Project
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Default SNMP page. This page is used if there is nothing
  10. ' supplied by the printer vendor.
  11. '
  12. '------------------------------------------------------------
  13. option explicit
  14. %>
  15. <!-- #include file = "ipp_util.inc" -->
  16. <!-- #include file = "ipp_0000.inc" -->
  17. <%
  18. On Error Resume Next
  19. Err.Clear
  20. CheckSession
  21. Response.expires = 0
  22. Response.Buffer = TRUE
  23. Dim bRefresh
  24. bRefresh = Request ("refresh") = 1
  25. %>
  26. <%
  27. const L_NotEmpty_Text = "Not Empty" 'The input tray is not empty
  28. const L_Empty_Text = "Empty" 'The input tray is empty
  29. const L_Name_Text = "Name" 'The name of the input tray
  30. const L_PaperSize_Text = "Paper Size"
  31. const L_Media_Text = "Media"
  32. const L_Current_Text = "Current" 'The Current number of the paper in the input tray
  33. const L_Maximum_Text = "Maximum" 'The Maximum number of the paper in the input tray
  34. const L_Tray_Text = "Tray "
  35. const L_Seperator_Text = " - "
  36. const L_Printer_Text = "Printer"
  37. const L_Output_Text = "Output"
  38. Function ErrorHandler (strErr)
  39. Dim strHref
  40. strHref = "ipp_0013.asp?notes=" & strErr
  41. Response.Redirect (strHref)
  42. Response.End
  43. End Function
  44. Function ErrorHandler2 (strErr)
  45. Dim strScript
  46. strScript = "<script language=javascript>function noerror(){" &_
  47. "var strHref;" &_
  48. "strHref = ""ipp_0013.asp?notes" & strErr &_
  49. "window.location.href = strHref;}</script>"
  50. Response.Write (strScript)
  51. Response.End
  52. End Function
  53. Function GenConsoleTable(iRow, iColumn, strArray, strLang)
  54. Dim strHTML
  55. Dim strBgnCol, strEndCol
  56. Dim strBgnRow, strEndRow
  57. Dim i, j, srcIndex, c
  58. Dim tmpArray
  59. ReDim tmpArray (iColumn)
  60. strHTML = ""
  61. strBgnCol = "<tr>"
  62. strEndCol = "</tr>"
  63. If strLang = "JP" then
  64. strBgnRow = "<td width=10 class=jpnfont><center><font face = ""MS Pゴシック, Osaka"" size=2>"
  65. Else
  66. strBgnRow = "<td width=10 ><center>" & DEF_FONT_TAG
  67. End If
  68. strEndRow = END_FONT & "</center></td>"
  69. For i = 1 To iRow
  70. srcIndex = 1
  71. j = 1
  72. While j <= iColumn
  73. c = Mid (strArray(i - 1), srcIndex, 1)
  74. If c = "" Then
  75. tmpArray(j) = "&nbsp;"
  76. Else
  77. if Asc(c) <= 32 Then
  78. tmpArray(j) = "&nbsp;"
  79. Else
  80. If strLang = "JP" Then
  81. tmpArray(j) = OleCvt.ToUnicode (c, 932)
  82. Else
  83. tmpArray(j) = c
  84. End If
  85. End If
  86. End If
  87. j = j + 1
  88. srcIndex = srcIndex + 1
  89. Wend
  90. strHTML = strHTML & strBgnCol
  91. For j = 1 To iColumn
  92. strHTML = strHTML & strBgnRow & tmpArray(j) & strEndRow
  93. Next
  94. strHTML = strHTML & strEndCol
  95. Next
  96. GenConsoleTable = strHTML
  97. End Function
  98. Function GenOneLight (rgLights, i, strId)
  99. Dim strHTML
  100. strHTML = "<td width=50 align=right>&nbsp;&nbsp;&nbsp;"
  101. If rgLights(SNMP_LIGHT_ON, i) <> "0" And strId <> "IBM Network Printer 24 2.34F" Then
  102. If rgLights(SNMP_LIGHT_OFF, i) <> "0" Then
  103. strHTML = strHTML & "<img src=""images/ipp_0012.GIF"">"
  104. Else
  105. strHTML = strHTML & "<img src=""images/ipp_0005.GIF"">"
  106. End If
  107. Else
  108. strHTML = strHTML & "<img src=""images/ipp_0015.GIF"">"
  109. End If
  110. strHTML = strHTML & "&nbsp;&nbsp;&nbsp;&nbsp;</td><td nowrap>" & DEF_FONT_TAG
  111. strHTML = strHTML & strCleanString(rgLights(SNMP_LIGHT_DESCRIPTION, i)) & "&nbsp;" & END_FONT & "</td>"
  112. GenOneLight = strHTML
  113. End Function
  114. Function GenLightTable(iLights, rgLights, strId)
  115. Dim i
  116. Dim strHTML
  117. Dim strBgnHdrCol, strEndHdrCol, strOneHeader
  118. Const L_State_Text = "State /"
  119. Const L_Light_Text = "Light"
  120. strBgnHdrCol = "<td bgcolor=""#000000"">" & MENU_FONT_TAG & "<b>"
  121. strEndHdrCol = "</b>" & END_FONT & "</td>"
  122. strOneHeader = "<td align=right nowrap bgcolor=""#000000"">" & MENU_FONT_TAG & "<b>" & L_State_Text & strEndHdrCol & "</td>" & strBgnHdrCol & L_Light_Text & strEndHdrCol
  123. strHTML = "<tr>" & strOneHeader & strOneHeader & strOneHeader & "</tr>"
  124. If iLights <= 25 then
  125. For i = 0 To iLights
  126. If i Mod 3 = 0 Then
  127. If i <> 0 Then strHTML = strHTML & "</tr>"
  128. strHTML = strHTML & "<tr>" & GenOneLight (rgLights, i, strId)
  129. Else
  130. strHTML = strHTML & GenOneLight (rgLights, i, strId)
  131. End If
  132. Next
  133. strHTML = strHTML & "</tr>"
  134. Else
  135. For i = 0 To iLights Step 2
  136. strHTML = strHTML & "<tr>" & GenOneLight (rgLights, i, strId)
  137. If i + 1 < iLights Then
  138. strHTML = strHTML & GenOneLight (rgLights, i + 1, strId)
  139. Else
  140. strHTML = strHTML & "<td></td><td></td>"
  141. End If
  142. strHTML = strHTML & "</tr>"
  143. Next
  144. End If
  145. GenLightTable = strHTML
  146. End Function
  147. Function GetCurrentNumberOfPaper (iCurrent)
  148. Dim strCount
  149. Select Case iCurrent
  150. Case -1, -2
  151. strCount = "&nbsp;"
  152. Case 0
  153. strCount = L_Empty_Text
  154. Case -3
  155. strCount = L_NotEmpty_Text
  156. Case Else
  157. strCount = cstr(iCurrent)
  158. End Select
  159. GetCurrentNumberOfPaper = strCount
  160. End Function
  161. Function GenTrayTable (bPaperSize, bPaperMedia, iTrays, rgTrays)
  162. Dim strHTML
  163. Dim strBgnHdrCol, strEndHdrCol
  164. Dim strBgnCol, strEndCol
  165. Dim strBgnRow, strEndRow
  166. Dim i, j, srcIndex, c
  167. Dim tmpArray
  168. strBgnHdrCol = "<td nowrap bgcolor=""#000000"">" & MENU_FONT_TAG & "<b>"
  169. strEndHdrCol = "</b>" & END_FONT & "</td>"
  170. strHTML = "<tr>"
  171. strHTML = strHTML & strBgnHdrCol & L_Name_Text & strEndHdrCol
  172. If bPaperSize Then
  173. strHTML = strHTML & strBgnHdrCol & L_PaperSize_Text & strEndHdrCol
  174. End If
  175. If bPaperMedia Then
  176. strHTML = strHTML & strBgnHdrCol & L_Media_Text & strEndHdrCol
  177. End If
  178. strHTML = strHTML & strBgnHdrCol & L_Current_Text & strEndHdrCol
  179. strHTML = strHTML & strBgnHdrCol & L_Maximum_Text & strEndHdrCol
  180. 'strHTML = strHTML & strBgnHdrCol & L_State_Text & strEndHdrCol
  181. strHTML = strHTML & "</tr>"
  182. Dim strTrayName
  183. For i = 0 to iTrays
  184. strBgnCol = "<td>" & DEF_FONT_TAG
  185. strEndCol = END_FONT & "</td>"
  186. strHTML = strHTML & "<tr>" & strBgnCol
  187. if rgTrays(SNMP_INTRAY_UNIT, i) = "" or rgTrays(SNMP_INTRAY_UNIT, i) = " " then
  188. If rgTrays(SNMP_INTRAY_NAME, i) = "" Then
  189. strTrayName = L_Tray_Text & Cstr (i + 1)
  190. Else
  191. strTrayName = rgTrays(SNMP_INTRAY_NAME, i)
  192. End If
  193. Else
  194. strTrayName = rgTrays(SNMP_INTRAY_UNIT, i)
  195. End If
  196. strHTML = strHTML & strCleanString(strTrayName) & strEndCol
  197. rgTrays(SNMP_INTRAY_UNIT, i) = strTrayName
  198. If bPaperSize Then
  199. strHTML = strHTML & strBgnCol
  200. dim strLongName
  201. strLongName = objHelper.LongPaperName (rgTrays(SNMP_INTRAY_MEDIA, i))
  202. If strLongName = "Unknown" Then
  203. strLongName = rgTrays(SNMP_INTRAY_MEDIA, i)
  204. End If
  205. strHTML = strHTML & strLongName & strEndCol
  206. End If
  207. If bPaperMedia Then
  208. strHTML = strHTML & strBgnCol & getMedia (rgTrays(SNMP_INTRAY_MEDIA, i)) & strEndCol
  209. End If
  210. strHTML = strHTML & strBgnCol & GetCurrentNumberOfPaper( rgTrays(SNMP_INTRAY_CURRENT, i)) & strEndCol
  211. strHTML = strHTML & strBgnCol & rgTrays(SNMP_INTRAY_MAX, i) & strEndCol
  212. strHTML = strHTML & "</tr>"
  213. Next
  214. GenTrayTable = strHTML
  215. End Function
  216. Function GenAlertTable (iAlerts, rgAlerts, rgTrays)
  217. Dim strHTML
  218. Dim i, j, bDup, code, strDscp
  219. strHTML = ""
  220. For i = 0 to iAlerts
  221. code = rgAlerts(SNMP_ALERT_CODE, i)
  222. j = 0
  223. bDup = FALSE
  224. While j <= i - 1 And Not bDup
  225. If code = rgAlerts(SNMP_ALERT_CODE, j) Then
  226. If rgAlerts(SNMP_ALERT_SUBUNIT, i) = rgAlerts(SNMP_ALERT_SUBUNIT, j) And rgAlerts(SNMP_ALERT_INDEX, i) = rgAlerts(SNMP_ALERT_INDEX, j) Then
  227. bDup = TRUE
  228. End If
  229. End If
  230. j = j + 1
  231. Wend
  232. If Not bDup Then
  233. strHTML = strHTML & "<tr><td width=""10%"">"
  234. Select Case rgAlerts(SNMP_ALERT_SEVERITY, i)
  235. Case 3,5
  236. strHTML = strHTML & "<img src=""images/ipp_0004.GIF"" width=""20"">"
  237. Case 4
  238. strHTML = strHTML & "<img src=""images/ipp_0003.GIF"" width=""20"">"
  239. Case Else
  240. strHTML = strHTML & "&nbsp;"
  241. End Select
  242. strHTML = strHTML & "</td><td>" & DEF_FONT_TAG
  243. Select Case rgAlerts(SNMP_ALERT_SUBUNIT, i)
  244. Case 8
  245. If rgAlerts(SNMP_ALERT_INDEX, i) > 0 Then
  246. strHTML = strHTML & strCleanString(rgTrays(SNMP_INTRAY_UNIT, rgAlerts(SNMP_ALERT_INDEX, i) - 1)) & L_Seperator_Text
  247. Else
  248. strHTML = strHTML & L_Tray_Text & L_Seperator_Text
  249. End If
  250. Case 5
  251. strHTML = strHTML & L_Printer_Text & L_Seperator_Text
  252. Case 9
  253. strHTML = strHTML & L_Output_Text & L_Seperator_Text
  254. Case Else
  255. '
  256. End Select
  257. strHTML = strHTML & strCleanString(rgAlerts(SNMP_ALERT_DESCRIPTION, i)) & END_FONT & "</td></tr>"
  258. End If
  259. Next
  260. GenAlertTable = strHTML
  261. End Function
  262. Function getMedia(mediaName)
  263. Dim media, i, mediaList
  264. Dim L_MediaList_Text(3)
  265. mediaList = Array("-white", "-envelope", "-colored", "-transparent")
  266. L_MediaList_Text(0) = "White Paper"
  267. L_MediaList_Text(1) = "Envelope"
  268. L_MediaList_Text(2) = "Colored Paper"
  269. L_MediaList_Text(3) = "Transparecy"
  270. i = 0
  271. For Each media In mediaList
  272. If InStr(mediaName, media) > 0 Then
  273. getMedia = L_MediaList_Text(i)
  274. Exit Function
  275. End If
  276. i = i + 1
  277. Next
  278. getMedia = ""
  279. End Function
  280. Const L_WrongIP_Message = "The IP Address is not correct."
  281. Const L_PageTitle_Text = "Microsoft Default SNMP status"
  282. Const strFileID = "page1.asp"
  283. Dim rgState, rgAlerts, rgLights, rgTrays, rgConsole, strLight
  284. Dim bRet, objHelper
  285. Dim iRow, iColumn, iAlerts, iTrays, iLights
  286. Dim bPaperSize, bPaperMedia, i
  287. Dim strLang
  288. Dim strId
  289. Dim objSNMP
  290. Dim strIP, strCommunity, iDevice, strDevice
  291. Dim strPrinter, strEncodedPrinter, strComputer, strNewURL
  292. Dim strHTML
  293. Err.Clear
  294. strIP = Request(IPADDRESS)
  295. If strIP = "" Then
  296. Err.Number = 1
  297. Err.Description = L_WrongIP_Message
  298. ErrorHandler (strFileID)
  299. End If
  300. strCommunity = Request (COMMUNITY)
  301. iDevice = Request(DEVICE)
  302. strDevice = CStr(iDevice)
  303. strEncodedPrinter = Request(PRINTER)
  304. strPrinter = OleCvt.DecodeUnicodeName ( strEncodedPrinter )
  305. Set objSNMP = Server.CreateObject(PROGID_SNMP)
  306. If Err Then ErrorHandler (strFileID)
  307. objSNMP.open strIP, strCommunity, 3, 2000
  308. If Err Then ErrorHandler (strFileID)
  309. strComputer = session(COMPUTER)
  310. strNewURL = "page1.asp?refresh=1" & ATIPADDRESS & strIP & ATCOMMUNITY & strCommunity &_
  311. ATPRINTER & strEncodedPrinter & ATDEVICE & strDevice
  312. Set objHelper = Server.CreateObject (PROGID_HELPER)
  313. objHelper.open "\\" & strComputer & "\" & strPrinter
  314. If Err Then ErrorHandler (strFileID)
  315. 'Get Printer Id
  316. strId = objSNMP.Get ("25.3.2.1.3." & CStr (iDevice))
  317. If Err.Number <> 0 Then
  318. ErrorHandler (strFileID)
  319. End If
  320. 'Get basic state
  321. rgState = rgSNMPGetState(objSNMP, iDevice)
  322. If Err.Number <> 0 Or Not IsArray (rgState) Then ErrorHandler (strFileID)
  323. If bRefresh Then
  324. bRet = rgSNMPConsole(objSNMP, iDevice, iRow, iColumn, rgConsole, strLang)
  325. If Not bRet Then ErrorHandler (strFileID)
  326. rgLights = rgSNMPLights(objSNMP, iDevice, iLights)
  327. If Err.Number <> 0 Then ErrorHandler (strFileID)
  328. rgTrays = rgSNMPGetInputTrays(objSNMP, iDevice, iTrays)
  329. If Err.Number <> 0 Then ErrorHandler (strFileID)
  330. If iTrays >= 0 then
  331. bPaperSize = not (rgTrays(SNMP_INTRAY_MEDIA, 0) = "" or rgTrays(SNMP_INTRAY_MEDIA, 0) = " " )
  332. bPaperMedia = (getMedia (rgTrays(SNMP_INTRAY_MEDIA, 0)) <> "")
  333. End if
  334. 'Get alerts
  335. rgAlerts = rgSNMPGetAlerts(objSNMP, objHelper, iDevice, iAlerts)
  336. End If
  337. %>
  338. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  339. <html lang=<%=L_Language%>>
  340. <head>
  341. <meta http-equiv="refresh" content="120; url=<%=strNewURL%>" >
  342. <Meta Http-equiv="Content-Type" Content="text/html; CHARSET=UTF-8">
  343. <title><%=Write(L_PageTitle_Text) %></title>
  344. </head>
  345. <body bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="#000000" alink="#000000"
  346. topmargin="0" leftmargin="0" onload="noerror()">
  347. <%=Write(DEF_BASEFONT_TAG)%>
  348. <%
  349. If Not bRefresh Then
  350. Response.Flush
  351. bRet = rgSNMPConsole(objSNMP, iDevice, iRow, iColumn, rgConsole, strLang)
  352. If Not bRet Then ErrorHandler2 (strFileID)
  353. End If
  354. Const L_FrontPanelColon_Text = "Front Panel:"
  355. Const L_DeviceStatus_Text = "Device Status:"
  356. Const L_FrontPanel_Text = "FrontPanel"
  357. Const L_RealTimeTitle_Text = "Real time display of the printer front panel"
  358. %>
  359. <table width="100%" border=0 cellspacing="0" cellpadding="2">
  360. <tr>
  361. <td nowrap>
  362. <b><%=Write(DEF_FONT_TAG & L_DeviceStatus_Text & END_FONT)%></b>
  363. </td>
  364. <% If IsArray (rgConsole) Then
  365. Response.Write(Write("<td><b>" & DEF_FONT_TAG & L_FrontPanelColon_Text & END_FONT & "</b></td>") )
  366. End If
  367. %>
  368. </tr>
  369. <tr>
  370. <td>
  371. <% =Write(strSnmpStatus(rgState)) %>
  372. </td>
  373. <% If IsArray (rgConsole) Then
  374. strHTML = "<td><table border=""2"" bgcolor=""#C0C0C0"" ><tr>" &_
  375. "<td><table border=""0"" width=""" & CStr(iColumn*10) & """ bgcolor=""#C0C0C0"" cellspacing=""0"" cellpadding=""0"" title = """ & L_RealTimeTitle_Text & """>" &_
  376. GenConsoleTable(iRow, iColumn, rgConsole, strLang) &_
  377. "</table></td>" &_
  378. "</tr></table></td>"
  379. Response.Write( Write(strHTML) )
  380. End If
  381. %>
  382. </tr>
  383. </table>
  384. <br>
  385. <% Const L_PaperTrays_Text = "Paper Trays:" %>
  386. <b><%=Write(DEF_FONT_TAG & L_PaperTrays_Text & END_FONT)%></b><br>
  387. <%
  388. If Not bRefresh Then
  389. Response.Flush
  390. rgTrays = rgSNMPGetInputTrays(objSNMP, iDevice, iTrays)
  391. If Err.Number <> 0 Then ErrorHandler2 (strFileID)
  392. If iTrays >= 0 Then
  393. bPaperSize = not (rgTrays(SNMP_INTRAY_MEDIA, 0) = "" or rgTrays(SNMP_INTRAY_MEDIA, 0) = " " )
  394. bPaperMedia = (getMedia (rgTrays(SNMP_INTRAY_MEDIA, 0)) <> "")
  395. End If
  396. End If
  397. %>
  398. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  399. <%=Write(GenTrayTable (bPaperSize, bPaperMedia, iTrays, rgTrays))%>
  400. </table>
  401. <%
  402. If Not bRefresh Then
  403. Response.Flush
  404. rgLights = rgSNMPLights(objSNMP, iDevice, iLights)
  405. If Err.Number <> 0 Then ErrorHandler2 (strFileID)
  406. End If
  407. %>
  408. <%If iLights >= 0 Then %>
  409. <br>
  410. <% const L_ConsoleLights_Text = "Console Lights:" %>
  411. <b><%=Write(DEF_FONT_TAG & L_ConsoleLights_Text & END_FONT)%></b><br>
  412. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  413. <%=Write(GenLightTable (iLights, rgLights, strId))%>
  414. </table>
  415. <% End If%>
  416. <br>
  417. <% Const L_DetailedErr_Text = "Detailed Errors and Warnings:" %>
  418. <b><%=Write(DEF_FONT_TAG & L_DetailedErr_Text & END_FONT)%></b><br>
  419. <%
  420. If Not bRefresh Then
  421. Response.Flush
  422. 'Get alerts
  423. rgAlerts = rgSNMPGetAlerts(objSNMP, objHelper, iDevice, iAlerts)
  424. 'If Err.Number <> 0 Then Exit Function
  425. End If
  426. %>
  427. <table border="0" width="100%">
  428. <%=Write(GenAlertTable (iAlerts, rgAlerts, rgTrays))%>
  429. </table>
  430. <%
  431. objHelper.close
  432. %>
  433. </body>
  434. </html>
  435. <script language=javascript>
  436. function noerror()
  437. {
  438. }
  439. </script>
  440. <%
  441. Response.End
  442. %>