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.

555 lines
16 KiB

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