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.

451 lines
12 KiB

  1. <%@ Language=VBScript %>
  2. <% '==================================================
  3. ' Microsoft Server Appliance
  4. ' Alert Details Page
  5. ' Copyright (c) Microsoft Corporation. All rights reserved.
  6. '================================================== %>
  7. <% Option Explicit %>
  8. <!-- #include file="inc_framework.asp" -->
  9. <%
  10. Dim page
  11. Dim g_sCookie
  12. Dim g_sAction
  13. Dim g_sReturnURL
  14. Dim g_bAlertCleared
  15. Dim g_sPageDescription
  16. Dim g_sPageTitle
  17. Dim g_sPageImage
  18. Dim g_bIsAreaPage
  19. Dim L_CLEARALERT_TEXT
  20. Dim L_ALERTVWRTITLE_TEXT
  21. Dim L_CLEARDESC_TEXT
  22. Dim L_PAGETITLE
  23. g_sAction = Request.Form("Method")
  24. g_sReturnURL = Request("ReturnURL")
  25. g_sCookie= Request("Cookie")
  26. If ( UCase(g_sAction) = "CLEAR" ) Then
  27. ClearAlert(g_sCookie)
  28. g_bAlertCleared = TRUE
  29. If ( Len(g_sReturnURL) > 0 ) Then
  30. '
  31. ' Area Page uses ServeClose
  32. '
  33. Call ServeClose()
  34. Response.End
  35. Else
  36. '
  37. ' Pagelet uses top.location.refresh()
  38. ' See OnServePageletPage()
  39. End If
  40. Else
  41. g_bAlertCleared = FALSE
  42. End If
  43. L_PAGETITLE = GetLocString("sakitmsg.dll", "&H4001002C", "")
  44. If ( UCase(g_sAction) = "CLEAR" ) Then
  45. ' Skip getting page image and title if we just cleared it. This is the case
  46. ' when we are dealing with a pagelet.
  47. Else
  48. Call GetPageImageAndTitle(g_sCookie, g_sPageImage, g_sPageTitle, g_sPageDescription)
  49. End If
  50. If ( Len(g_sReturnURL) > 0 ) Then
  51. '
  52. ' Area page
  53. '
  54. g_bIsAreaPage = TRUE
  55. Call SA_TraceOut("SH_ALERTDETAILS", "Creating as Area page")
  56. Call SA_CreatePage(g_sPageTitle, g_sPageImage, PT_AREA, page)
  57. Call SA_ShowPage(page)
  58. Else
  59. '
  60. ' Pagelet
  61. '
  62. g_bIsAreaPage = FALSE
  63. Call SA_TraceOut("SH_ALERTDETAILS", "Creating as Pagelet")
  64. Call SA_CreatePage(g_sPageTitle, g_sPageImage, PT_PAGELET, page)
  65. Call SA_ShowPage(page)
  66. End If
  67. Public Function OnInitPage(ByRef pageIn, ByRef EventArg)
  68. OnInitPage = TRUE
  69. L_CLEARALERT_TEXT = GetLocString("sakitmsg.dll", "&H4001002D", "")
  70. L_ALERTVWRTITLE_TEXT = GetLocString("sakitmsg.dll", "&H4001002E", "")
  71. L_CLEARDESC_TEXT = GetLocString("sakitmsg.dll", "&H4001002F", "")
  72. End Function
  73. Public Function OnServeAreaPage(ByRef PageIn, ByRef EventArg)
  74. OnServeAreaPage = TRUE
  75. Call ServeAlertDetailsPage()
  76. 'Call SA_ServeBackButton(FALSE, g_sReturnURL)
  77. End Function
  78. Public Function OnServePageletPage(ByRef PageIn, ByRef EventArg)
  79. OnServePageletPage = TRUE
  80. If ( TRUE = g_bAlertCleared ) Then
  81. %>
  82. <script language='javascript'>
  83. function Init()
  84. {
  85. top.location.reload();
  86. }
  87. </script>
  88. <%
  89. Else
  90. Call ServeAlertDetailsPage()
  91. End If
  92. End Function
  93. Private Function ServeAlertDetailsPage()
  94. ServeAlertDetailsPage = TRUE
  95. on error resume next
  96. Err.Clear
  97. Dim objAlert
  98. Dim objElementCol
  99. Dim objElement
  100. Dim strAlertSrc
  101. Dim intAlertID
  102. Dim intAlertType
  103. Dim strElementID
  104. Dim strContainerPrefix
  105. Dim varReplacementStrings
  106. Dim varReplacementStringsNone
  107. Dim bVirtualRootIsNeeded
  108. Dim returnURL
  109. Dim objElements
  110. Dim objItem
  111. Dim arrTitle
  112. Dim arrURL
  113. Dim arrHelpText
  114. Dim blnEnabled
  115. Dim i
  116. Dim oValidator
  117. Dim oEncoder
  118. Dim strIconPath
  119. Set oValidator = New CSAValidator
  120. Set oEncoder = New CSAEncoder
  121. Set objAlert = GetObject("WINMGMTS:" & SA_GetWMIConnectionAttributes() & "!\\" & GetServerName & "\root\cimv2:Microsoft_SA_Alert.Cookie=" & g_sCookie )
  122. If ( Err.Number <> 0 ) Then
  123. ServeAlertNotFound()
  124. Exit Function
  125. End If
  126. strAlertSrc = objAlert.AlertLog
  127. intAlertID = objAlert.AlertID
  128. intAlertType = objAlert.AlertType
  129. If ( Err.Number <> 0 ) Then
  130. ServeAlertNotFound()
  131. Exit Function
  132. End If
  133. strElementID = strAlertSrc & Hex(intAlertID)
  134. strContainerPrefix = Request.QueryString("AlertDefinitions")
  135. If ( Len(strContainerPrefix) > 0 ) Then
  136. If ( oValidator.IsValidIdentifier(strContainerPrefix) ) Then
  137. ' Valid container prefix name, use it.
  138. Else
  139. ' Invalid container prefix name
  140. Call SA_TraceOut("inc_alertdetails.asp", "Function ServeAlertDetailsPage detected invalid QueryString(AlertDefinitions) value: " & strContainerPrefix)
  141. ' Use default
  142. strContainerPrefix = "AlertDefinitions"
  143. End If
  144. Else
  145. ' Use default alert container name
  146. strContainerPrefix = "AlertDefinitions"
  147. End If
  148. Set objElementCol = GetElements(strContainerPrefix)
  149. Set objElement = objElementCol.Item(strContainerPrefix+strElementID)
  150. If ( Err.Number <> 0 ) Then
  151. Err.Clear
  152. strContainerPrefix = ""
  153. Set objElement = objElementCol.Item(strElementID)
  154. If (Err.Number <> 0) Then
  155. ServeAlertDetailsPage = FALSE
  156. Exit Function
  157. End If
  158. End If
  159. Set objAlert = Nothing
  160. Set objElementCol = Nothing
  161. Set objElement = Nothing
  162. %>
  163. <script language="JavaScript">
  164. function ClickClear()
  165. {
  166. document.TVData.Method.value="CLEAR";
  167. document.TVData.submit();
  168. }
  169. </script>
  170. <INPUT type=hidden name="Method" value=''>
  171. <INPUT type=hidden name="ReturnURL" value="<%=g_sReturnURL%>">
  172. <INPUT type=hidden name="Cookie" value="<%=g_sCookie%>">
  173. <%
  174. ' User Actions - keys off of AlertSource + AlertID (hex)
  175. intAlertID = Hex(intAlertID)
  176. Set objElements = GetElements(strContainerPrefix & strAlertSrc & intAlertID)
  177. Response.Write(oEncoder.EncodeElement(g_sPageDescription))
  178. Response.Write("<br>")
  179. Response.Write("<table class=TasksBody border=0 cellspacing=0>"+vbCrLf)
  180. Response.Flush
  181. returnURL = g_sReturnURL
  182. If ( Len(returnURL) <= 0 ) Then
  183. returnURL = "statuspage.asp"
  184. bVirtualRootIsNeeded = TRUE
  185. Else
  186. bVirtualRootIsNeeded = FALSE
  187. End If
  188. Call SA_TraceOut(SA_GetScriptFileName(), "ReturnURL: " + returnURL)
  189. Call SA_MungeURL(returnURL, "Tab1", GetTab1())
  190. Call SA_MungeURL(returnURL, SAI_FLD_PAGEKEY, SAI_GetPageKey())
  191. For Each objItem in objElements
  192. blnEnabled = true
  193. If Err <> 0 Then
  194. blnEnabled = True
  195. Err.Clear
  196. End If
  197. If blnEnabled Then
  198. Response.Write("<tr>")
  199. Response.Write("<td height=28 valign=middle>&nbsp;</td>")
  200. Response.Write("<td height=28 valign=middle>")
  201. strSourceName = ""
  202. strSourceName = objItem.GetProperty ("Source")
  203. If strSourceName = "" Then
  204. strSourceName = "svrapp"
  205. End If
  206. arrTitle = GetLocString(strSourceName, objItem.GetProperty("CaptionRID"), "")
  207. arrHelpText = GetLocString(strSourceName, objItem.GetProperty("DescriptionRID"), "")
  208. arrURL = objItem.GetProperty("URL")
  209. Call SA_MungeURL( arrURL, "Tab1", GetTab1())
  210. Call SA_MungeURL( arrURL, "Tab2", GetTab2())
  211. Call SA_MungeURL( arrURL, "Cookie", g_sCookie)
  212. Call SA_MungeURL( arrURL, SAI_FLD_PAGEKEY, SAI_GetPageKey())
  213. Dim bEmbedded
  214. Dim sPageType
  215. bEmbedded = TRUE
  216. sPageType = objItem.GetProperty("PageType")
  217. If ( Len(sPageType) > 0 ) Then
  218. If ( UCase(sPageType) = "NORMAL" ) Then
  219. bEmbedded = FALSE
  220. End IF
  221. End If
  222. If ( TRUE = bEmbedded ) Then
  223. If (TRUE = bVirtualRootIsNeeded) Then
  224. returnURL = m_VirtualRoot + returnURL
  225. End If
  226. If ( Left(returnURL, 1) <> "/") Then
  227. returnURL = "/" + returnURL
  228. End If
  229. %>
  230. <a class="PageBodyLink" href="JavaScript:OpenPage('<%=m_VirtualRoot%>', '<%=oEncoder.EncodeJScript(arrURL)%>', '<%=oEncoder.EncodeJScript(returnURL)%>', '<%=oEncoder.EncodeJScript(arrTitle)%>');"
  231. title=<%=oEncoder.EncodeAttribute(arrHelpText)%>
  232. onMouseOver="window.status='<%=Server.HTMLEncode(EscapeQuotes(arrHelpText))%>';return true;">
  233. <%
  234. Else
  235. Call SA_MungeURL( arrURL, "ReturnURL", returnURL)
  236. Call SA_TraceOut("SH_ALERTDETAILS", "Details URL: " + arrURL)
  237. %>
  238. <a class="PageBodyLink" href="JavaScript:OpenNormalPage('<%=m_VirtualRoot%>', '<%=oEncoder.EncodeJScript(arrURL) %>');"
  239. title=<%=oEncoder.EncodeAttribute(arrHelpText)%>
  240. onMouseOver="window.status='<%=Server.HTMLEncode(SA_EscapeQuotes(arrHelpText))%>';return true;">
  241. <%
  242. End If
  243. Response.Write(oEncoder.EncodeElement(arrTitle))
  244. Response.Write("</a>")
  245. Response.Write("</td></tr>"+vbCrLf)
  246. End If
  247. Next
  248. Response.Write("<tr><td>&nbsp;</td></tr>"+vbCrLf)
  249. Set objElements = Nothing
  250. Set objItem = Nothing
  251. Response.Flush
  252. Response.Write("<tr><td height=28 colspan=2>" & oEncoder.EncodeElement(L_CLEARDESC_TEXT))
  253. %>
  254. </td></tr><tr><td></td><td>
  255. <a class="PageBodyLink" href="JavaScript:ClickClear();"
  256. title=<%=oEncoder.EncodeAttribute(L_CLEARALERT_TEXT)%>
  257. onMouseOver="window.status='<%=Server.HTMLEncode(SA_EscapeQuotes(L_CLEARALERT_TEXT))%>';return true;">
  258. <%=oEncoder.EncodeElement(L_CLEARALERT_TEXT)%></a></td></tr>
  259. <%
  260. Response.Write("<tr><td>&nbsp;</td></tr>"+vbCrLf)
  261. Response.Write("<tr><td>&nbsp;</td></tr>"+vbCrLf)
  262. Response.Write("</table>"+vbCrLf)
  263. %>
  264. <script>
  265. function Init()
  266. {
  267. }
  268. </script>
  269. <%
  270. Set oValidator = Nothing
  271. Set oEncoder = Nothing
  272. End Function
  273. Private Function ServeAlertNotFound()
  274. '
  275. ' If alert is not found then all we need to output
  276. ' is the default Javascript.
  277. Call SA_ServeDefaultClientScript()
  278. End Function
  279. Private Function ClearAlert(Cookie)
  280. on error resume next
  281. err.clear
  282. Dim objAM
  283. Dim rc
  284. Set objAM = GetObject("WINMGMTS:" & SA_GetWMIConnectionAttributes() & "!\\" & GetServerName & "\root\cimv2:Microsoft_SA_Manager=@" )
  285. If ( Err.Number <> 0 ) Then
  286. Call SA_TraceOut(SA_GetScriptFileName(), "Get Microsoft_SA_Manager failed: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  287. Exit Function
  288. End If
  289. rc = objAM.ClearAlert(CInt(Cookie))
  290. If rc = 0 And Err = 0 Then
  291. ClearAlert = True
  292. Else
  293. ClearAlert = False
  294. End If
  295. Set objAM = Nothing
  296. End Function
  297. Private Function GetPageImageAndTitle(ByVal sCookie, ByRef sImage, ByRef sTitle, sDescription)
  298. GetPageImageAndTitle = TRUE
  299. on error resume next
  300. Err.Clear
  301. Dim objAlert
  302. Dim objElementCol
  303. Dim repStrings
  304. Dim objElement
  305. Dim strAlertSrc
  306. Dim intAlertID
  307. Dim intAlertType
  308. Dim strElementID
  309. Dim strContainerPrefix
  310. Set objAlert = GetObject("WINMGMTS:" & SA_GetWMIConnectionAttributes() & "!\\" & GetServerName & "\root\cimv2:Microsoft_SA_Alert.Cookie=" & sCookie )
  311. If ( Err.Number <> 0 ) Then
  312. sImage = "images/alert.gif"
  313. sTitle = GetLocString("sacoremsg.dll", "C02003ED", "")
  314. Exit Function
  315. End If
  316. strAlertSrc = objAlert.AlertLog
  317. intAlertID = objAlert.AlertID
  318. intAlertType = objAlert.AlertType
  319. strElementID = strAlertSrc & Hex(intAlertID)
  320. strContainerPrefix = Request.QueryString("AlertDefinitions")
  321. If ( Len(strContainerPrefix) <= 0 ) Then
  322. strContainerPrefix = "AlertDefinitions"
  323. End If
  324. Set objElementCol = GetElements(strContainerPrefix)
  325. Set objElement = objElementCol.Item(strContainerPrefix+strElementID)
  326. If ( Err.Number <> 0 ) Then
  327. Err.Clear
  328. strContainerPrefix = ""
  329. Set objElement = objElementCol.Item(strElementID)
  330. If (Err.Number <> 0) Then
  331. GetPageImageAndTitle = FALSE
  332. Exit Function
  333. End If
  334. Else
  335. strAlertSrc = objElement.GetProperty("Source")
  336. End If
  337. repStrings = objAlert.ReplacementStrings
  338. sTitle = GetLocString(strAlertSrc, objElement.GetProperty("CaptionRID"), repStrings)
  339. sDescription = GetLocString(strAlertSrc, objElement.GetProperty("DescriptionRID"), repStrings)
  340. Set objAlert = Nothing
  341. Set objElementCol = Nothing
  342. Set objElement = Nothing
  343. Select Case intAlertType
  344. Case 0
  345. sImage = "images/alert.gif"
  346. Case 1
  347. sImage = "images/critical_error.gif"
  348. Case 2
  349. sImage = "images/information.gif"
  350. Case Else
  351. sImage = "images/information.gif"
  352. Call SA_TraceOut(SA_GetScriptFileName(), "Unexpected AlertType: " + CStr(intAlertType))
  353. End Select
  354. End Function
  355. Private Function ServeCommonElements()
  356. %>
  357. <script>
  358. function Init()
  359. {
  360. }
  361. </script>
  362. <%
  363. End Function
  364. %>