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.

271 lines
11 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------------------
  5. ' Single_Log_Details.asp: provides links for clearing and downloading the logs
  6. ' Copyright (c) Microsoft Corporation. All rights reserved.
  7. '-------------------------------------------------------------------------------------
  8. %>
  9. <meta http-equiv="Content-Type" content="text/html; charset=<%=GetCharSet()%>">
  10. <!-- #include virtual="/admin/inc_framework.asp" -->
  11. <!-- #include file="loc_Log.asp" -->
  12. <!-- #include file="inc_Log.asp" -->
  13. <%
  14. '-------------------------------------------------------------------------
  15. ' Global Variables
  16. '-------------------------------------------------------------------------
  17. Dim rc 'Return value for CreatePage
  18. Dim page 'Variable that receives the output page object when
  19. 'creating a page
  20. Dim G_strLogFilePath 'FilePath
  21. Dim G_strLogFileName 'FileName
  22. Dim G_PageTitle 'To get the title accordingly
  23. Const CONST_BUTTON_DISABLE = "disabled" ' button status - doesnot need localization
  24. '-------------------------------------------------------------------------
  25. ' Form Variables
  26. '-------------------------------------------------------------------------
  27. Dim F_strevent_title 'To get the title from previous page
  28. Dim F_strPKeyValue 'Key val consists of filename
  29. 'this code is placed here to get the page title
  30. G_PageTitle = GetTitle(Request.QueryString("logtitle"))
  31. Call SA_CreatePage(G_PageTitle ,"",PT_AREA, page )
  32. Call SA_ShowPage( page )
  33. '---------------------------------------------------------------------
  34. ' Function name: OnInitPage
  35. ' Description: Called to signal first time processing for this page.
  36. ' Input Variables: PageIn and EventArg
  37. ' Output Variables: None
  38. ' Return Values: TRUE to indicate initialization was successful. FALSE to indicate
  39. ' errors. Returning FALSE will cause the page to be abandoned.
  40. ' Global Variables: None
  41. ' Called to signal first time processing for this page.
  42. '---------------------------------------------------------------------
  43. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  44. OnInitPage = TRUE
  45. End Function
  46. '---------------------------------------------------------------------
  47. ' Function name: OnServeAreaPage
  48. ' Description: Called when the page needs to be served.
  49. ' Input Variables: PageIn, EventArg
  50. ' Output Variables: None
  51. ' Return Values: TRUE to indicate no problems occured. FALSE to indicate errors.
  52. ' Returning FALSE will cause the page to be abandoned.
  53. ' Global Variables: None
  54. 'Called when the page needs to be served. Use this method to serve content.
  55. '---------------------------------------------------------------------
  56. Public Function OnServeAreaPage(ByRef PageIn, ByRef EventArg)
  57. On Error Resume Next
  58. Err.Clear
  59. Dim strPassValue ' the value to be passed through the query string
  60. Dim strButtonStatus ' the status of the button ( ""<empty> or Disabled)
  61. Dim strViewUrl ' url to be passed to the iframe
  62. Dim blnFileExists
  63. Dim objFso ' the file system object
  64. Dim strDownloadUrl
  65. 'frame work variables
  66. Dim x
  67. Dim itemCount
  68. Dim itemKey
  69. Call ServeCommonJavaScript()
  70. itemCount = OTS_GetTableSelectionCount("")
  71. F_strevent_title = Request.QueryString("logtitle")
  72. If instr(1,F_strevent_title,"NFS",1) = 0 then
  73. For x = 1 to itemCount
  74. If ( OTS_GetTableSelection("", x, itemKey) ) Then
  75. F_strPKeyValue = itemKey
  76. Call SA_TraceOut("Single_Log_Details.asp", "PKey value: " + F_strPKeyValue)
  77. End If
  78. Next
  79. End If
  80. blnFileExists = True
  81. ' initially the button is enabled
  82. strButtonStatus = ""
  83. 'Getting the FilePath of the selected log file
  84. G_strLogFilePath=GetPath(F_strevent_title)
  85. 'Checking for the pkey value
  86. If F_strPKeyValue <> "" Then
  87. 'Getting the filename from the earliear form
  88. G_strLogFileName=F_strPKeyValue
  89. Else
  90. 'check for null if so go for alternative
  91. If G_strLogFileName = "" Then
  92. 'Getting the FileName through FSO
  93. G_strLogFileName=getFileNameInFolder(G_strLogFilePath)
  94. End IF
  95. End IF
  96. If ( (Len(Trim(G_strLogFilePath)) = 0) OR (Len(Trim(G_strLogFileName)) <=0) _
  97. OR (Err.number <> 0) ) Then
  98. ' disable the buttons
  99. strButtonStatus = CONST_BUTTON_DISABLE
  100. blnFileExists = False
  101. strPassValue = "" ' set the value to be passed to query string to null
  102. Err.Clear
  103. Else
  104. ' create the FSO
  105. Set objFso = CreateObject("Scripting.FileSystemObject")
  106. If Err.number <> 0 Then
  107. WriteFileData = L_FSO_OBJECTCREATE_ERRORMESSAGE & "( "& Hex(Err.number) & " )"
  108. Err.Clear
  109. Exit Function
  110. End If
  111. 'checking for the file existence
  112. If NOT (objFso.FileExists(G_strLogFilePath & "\" & G_strLogFileName)) Then
  113. 'make blnFileExists false if file does not exists
  114. blnFileExists = False
  115. strButtonStatus = CONST_BUTTON_DISABLE
  116. End IF
  117. 'Name of the log along with the path
  118. strPassValue=Server.URLEncode(G_strLogFilePath & "\" & G_strLogFileName)
  119. 'Take care of escape chars
  120. G_strLogFilePath=Server.URLEncode(G_strLogFilePath)
  121. End If
  122. strViewUrl = "log_view.asp?FileToView=" & strPassValue & "&" & _
  123. SAI_FLD_PAGEKEY & "=" & SAI_GetPageKey()
  124. %>
  125. <table width=95% border=0 cellspacing=0 cellpadding=0 >
  126. <tr>
  127. <td colspan=4 height=30 class="TasksBody">&nbsp;</td>
  128. </tr>
  129. <tr>
  130. <td width="20px" class="TasksBody">&nbsp;</td>
  131. <td width="600px" class="TasksBody">
  132. <iframe width="100%" height="275px" src="<%=Server.HTMLEncode(SA_EscapeQuotes(strViewUrl))%>" frameborder="yes" >
  133. </iframe>
  134. </td>
  135. <td class="TasksBody" width="20px">&nbsp;</td>
  136. <td VALIGN = TOP class="TasksBody">
  137. <%
  138. If blnFileExists = False then
  139. Call SA_ServeOnClickButton(SA_EscapeQuotes(L_DOWNLOAD_TEXT), "",_
  140. "",_
  141. 90,"", CONST_BUTTON_DISABLE )
  142. Response.write "<BR>"
  143. Else
  144. strDownloadUrl = m_VirtualRoot & "logs/Text_Log_download.asp?FilePath=" & _
  145. strPassValue & "&" & SAI_FLD_PAGEKEY & "=" & SAI_GetPageKey()
  146. %>
  147. <iframe name=IFDownload src='<%=Server.HTMLEncode(SA_EscapeQuotes(strDownloadUrl))%>' height="36px" frameborder="0" scrolling="no">
  148. </iframe>
  149. <%
  150. End If %>
  151. <BR><BR>
  152. <%
  153. Call SA_ServeOpenPageButton( PT_PROPERTY, _
  154. "logs/Text_Log_clear.asp?FilePath="& strPassValue & _
  155. "&tab1=" & GetTab1() & "&tab2=" & GetTab2() & "&" & _
  156. SAI_FLD_PAGEKEY & "=" & SAI_GetPageKey(),_
  157. Request.QueryString("URL"),_
  158. Server.HTMLEncode(SA_EscapeQuotes(L_CLEAR_TEXT)),_
  159. SA_EscapeQuotes(L_CLEAR_TEXT),_
  160. "",_
  161. 90, "", strButtonStatus)
  162. %>
  163. </td>
  164. </tr>
  165. </table>
  166. <%
  167. OnServeAreaPage=TRUE
  168. End Function
  169. '-------------------------------------------------------------------------
  170. 'Function name: getFileNameInFolder
  171. 'Description: Serves in Getting the file name present in the given folder
  172. 'Input Variables: strFilePath
  173. 'Output Variables: String
  174. 'Returns: the file name or empty string
  175. 'This returns the First file name in the given folder containing set of files.
  176. 'In case ANY error occurs, this returns empty string
  177. '-------------------------------------------------------------------------
  178. Function getFileNameInFolder(strFilePath)
  179. Err.Clear
  180. On Error Resume Next
  181. Dim objFso ' the file system object
  182. Dim objFolder ' the folder object, where to look for the file ?
  183. Dim objFiles ' the files in the folder
  184. Dim objFile ' the required file
  185. Dim strFileName ' the file name to be returned
  186. Set objFso = CreateObject("Scripting.FileSystemObject")
  187. If Err.number <> 0 Then
  188. getFileNameInFolder = ""
  189. Exit Function
  190. End If
  191. 'Checking for the folder existence
  192. IF NOT objFso.FolderExists(strFilePath) Then
  193. getFileNameInFolder = ""
  194. Exit Function
  195. End IF
  196. Set objFiles = objFso.GetFolder(strFilePath).Files
  197. If objFiles.Count <=0 Then
  198. 'No files available
  199. getFileNameInFolder = ""
  200. Exit Function
  201. End If
  202. For each objFile in objFiles
  203. strFileName = objFile.name
  204. Exit For ' just pick the first file name
  205. Next
  206. getFileNameInFolder = strFileName
  207. ' clean up
  208. Set objFiles = Nothing
  209. Set objFolder = Nothing
  210. Set objFSO = Nothing
  211. End Function
  212. '-------------------------------------------------------------------------
  213. 'Function: ServeCommonJavaScript
  214. 'Description: Serves in initialiging the values,setting the form
  215. ' data and validating the form values
  216. 'Input Variables: None
  217. 'Output Variables: None
  218. 'Returns: True/False
  219. 'Global Variables: None
  220. '-------------------------------------------------------------------------
  221. Function ServeCommonJavaScript()
  222. %>
  223. <script language="JavaScript">
  224. function Init()
  225. {
  226. return true;
  227. }
  228. </script>
  229. <%End Function
  230. %>