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.

108 lines
3.0 KiB

  1. <% '==================================================
  2. ' Microsoft Server Appliance
  3. '
  4. ' Context Help driver routines
  5. '
  6. ' Copyright (c) Microsoft Corporation. All rights reserved.
  7. '================================================== %>
  8. <% Option explicit %>
  9. <!-- #include file="sh_page.asp" -->
  10. <!-- Copyright (c) Microsoft Corporation. All rights reserved.-->
  11. <%
  12. Dim G_strRequestContext
  13. Dim G_strHelpURL
  14. G_strRequestContext = StripContextParams(Request.QueryString("URL"))
  15. If FindContextHelpURL(G_strRequestContext, G_strHelpURL) Then
  16. Call SA_TraceOut("CONTEXTHELP", "Context: " + G_strRequestContext + " Help URL: " + G_strHelpURL)
  17. Response.Redirect(G_strHelpURL)
  18. Else
  19. Dim sRootDir
  20. Call SA_GetHelpRootDirectory(sRootDir)
  21. Call SA_TraceOut("CONTEXTHELP", "Unable to locate Context: " + G_strRequestContext + " Defaulting to Help URL: " + sRootDir+"_sak_no_topic_available.htm")
  22. Response.Redirect(sRootDir+"_sak_no_topic_available.htm")
  23. End If
  24. Function FindContextHelpURL(ByVal context, ByRef strContextHelpURL )
  25. Dim objElements
  26. Dim element
  27. Dim sRootDir
  28. on error resume next
  29. Err.Clear
  30. FindContextHelpURL = FALSE
  31. Call SA_GetHelpRootDirectory(sRootDir)
  32. 'SA_TraceOut "CONTEXTHELP", "Searching for HELP url on context: " + context
  33. Set objElements = GetElements("CONTEXTHELP")
  34. for each element in objElements
  35. Dim strContextURL
  36. strContextURL = element.GetProperty("ContextURL")
  37. If (Err.Number <> 0) Then
  38. SA_TraceOut "CONTEXTHELP", "Invalid/missing ContextURL in ElementID "+ element.GetProperty("ElementID")
  39. Exit For
  40. End If
  41. If IsSameURL( context, StripContextParams(m_VirtualRoot + strContextURL) ) Or IsSameSubText(context, StripContextParams(m_VirtualRoot + strContextURL)) Then
  42. strContextHelpURL = element.GetProperty("URL")
  43. If (Err.Number <> 0) Then
  44. SA_TraceOut "CONTEXTHELP", "Invalid/missing URL in ElementID "+ element.GetProperty("ElementID")
  45. Exit For
  46. End If
  47. strContextHelpURL = sRootDir + strContextHelpURL
  48. Call SA_MungeURL(strContextHelpURL, SAI_FLD_PAGEKEY, SAI_GetPageKey())
  49. FindContextHelpURL = TRUE
  50. Exit For
  51. End If
  52. Next
  53. Set objElements = nothing
  54. End Function
  55. Function IsSameURL(ByVal s1, ByVal s2)
  56. Const vbTextCompare = 1
  57. 'SA_TraceOut "CONTEXTHELP", "IsSameURL( " + s1 + ", " + s2 + ")"
  58. If ( 0 = StrComp( UCase(s1), UCase(s2), vbTextCompare )) Then
  59. IsSameURL = TRUE
  60. Else
  61. IsSameURL = FALSE
  62. End If
  63. End Function
  64. Function IsSameSubText(ByVal s1, ByVal s2)
  65. Const vbTextCompare = 1
  66. 'SA_TraceOut "CONTEXTHELP", "IsSameSubText( " + s1 + ", " + s2 + ")"
  67. If Instr( 1, s1, s2,0 ) > 0 Or Instr( 1, s2, s1,0 ) > 0 Then
  68. IsSameSubText = TRUE
  69. Else
  70. IsSameSubText = FALSE
  71. End If
  72. End Function
  73. Function StripContextParams(ByRef s)
  74. Dim offset
  75. 'offset = InStr(s, "?")
  76. 'If ( offset > 0 ) Then
  77. ' s = Left(s, offset-1)
  78. 'End If
  79. StripContextParams = s
  80. End Function
  81. %>