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.

209 lines
7.4 KiB

  1. <%@Language=VbScript%>
  2. <% Option Explicit %>
  3. <% '-------------------------------------------------------------------------
  4. ' Text_Log_Clear.asp : This page serves in Deleting the log file
  5. ' Copyright (c) Microsoft Corporation. All rights reserved.
  6. '-------------------------------------------------------------------------
  7. %>
  8. <!-- #include virtual="/admin/inc_framework.asp"--->
  9. <!-- #include file="loc_Log.asp" -->
  10. <%
  11. '-------------------------------------------------------------------------
  12. ' Form Variables
  13. '-------------------------------------------------------------------------
  14. Dim F_strFileToDelete ' the file to be deleted
  15. Dim F_arrFilesToDelete ' the files to be deleted
  16. Dim F_strFilesPath ' path of the files to be deleted.
  17. Dim F_strFilesSubmit ' variable to hold all the files as a string.
  18. Dim F_arrFilesSubmitToDelete ' array variable to hold all the files submitted to delete.
  19. '-------------------------------------------------------------------------
  20. ' Global Variables
  21. '-------------------------------------------------------------------------
  22. 'frame work variables
  23. Dim page
  24. Dim rc
  25. '
  26. 'Create property page
  27. Call SA_CreatePage(L_PAGETITLE_CLEAR_TEXT,"",PT_PROPERTY,page)
  28. Call SA_ShowPage(page)
  29. '-------------------------------------------------------------------------
  30. 'Function: OnInitPage()
  31. 'Description: Called to signal first time processing for this page.
  32. ' Use this method to do first time initialization tasks
  33. 'Input Variables: PageIn,EventArg
  34. 'Output Variables: None
  35. 'Returns: True/False
  36. 'Global Variables: Out: F_strFileToDelete,F_arrFilesToDelete,F_strFilesPath
  37. '-------------------------------------------------------------------------
  38. Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  39. 'variables used for getting the selected ots entries
  40. Dim x
  41. Dim itemCount
  42. Dim itemKey
  43. ' get the file to be deleted as Query String from previous page
  44. If Instr(1,Request.QueryString(),"Single",1) then
  45. F_strFileToDelete = Request.QueryString("FilePath")
  46. Else
  47. F_strFilesPath = Request.QueryString("FilePath")
  48. ' Show a list of the items selected
  49. itemCount = OTS_GetTableSelectionCount("")
  50. Redim F_arrFilesToDelete(itemCount-1)
  51. For x = 1 to itemCount
  52. If ( OTS_GetTableSelection("", x, itemKey) ) Then
  53. F_arrFilesToDelete(x-1) = itemKey
  54. F_strFilesSubmit = F_strFilesSubmit & itemKey & "|"
  55. End If
  56. Next
  57. End if
  58. OnInitPage = True
  59. End Function
  60. '-------------------------------------------------------------------------
  61. 'Function: OnServePropertyPage()
  62. 'Description: Called when the page needs to be served.Use this
  63. ' method to serve content
  64. 'Input Variables: PageIn,EventArg
  65. 'Output Variables: None
  66. 'Returns: True/False
  67. 'Global Variables: F_strFilesPath,F_strFileToDelete,L_DELETE_CONFIRM_TEXT
  68. '-------------------------------------------------------------------------
  69. Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg)
  70. Call SA_ServeDefaultClientScript
  71. Dim oEncoder
  72. Set oEncoder = new CSAEncoder
  73. %>
  74. <table width="100%" border="0" cellspacing="0" cellpadding="0" >
  75. <tr>
  76. <td class="TasksBody">
  77. <%=oEncoder.EncodeElement(L_DELETE_CONFIRM_TEXT)%>
  78. </td>
  79. </tr>
  80. </table>
  81. <input type="hidden" name="hdnLogPath" value="<%=Server.HTMLEncode(F_strFilesPath)%>">
  82. <input type="hidden" name="hdnLogFile" value="<%=Server.HTMLEncode(F_strFileToDelete)%>">
  83. <input type="hidden" name="hdnDeleteLogFiles" value="<%=Server.HTMLEncode(F_strFilesSubmit)%>">
  84. <%
  85. OnServePropertyPage = True
  86. End Function
  87. '-------------------------------------------------------------------------
  88. 'Function: OnPostBackPage()
  89. 'Description: Called to signal that the page has been posted-back.
  90. 'Input Variables: PageIn,EventArg
  91. 'Output Variables: None
  92. 'Returns: True/False
  93. 'Global Variables: None
  94. '-------------------------------------------------------------------------
  95. Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
  96. ' get the file to be deleted
  97. F_strFileToDelete = Request.Form("hdnLogFile")
  98. F_strFilesSubmit = Request.Form("hdnDeleteLogFiles")
  99. F_arrFilesSubmitToDelete = Split(F_strFilesSubmit,"|")
  100. OnPostBackPage = True
  101. End Function
  102. '-------------------------------------------------------------------------
  103. 'Function: OnSubmitPage()
  104. 'Description: Called when the page has been submitted for processing.
  105. ' Use this method to process the submit request.
  106. 'Input Variables: PageIn,EventArg
  107. 'Output Variables: None
  108. 'Returns: True/False
  109. 'Global Variables: Out: F_strFileToDelete
  110. '-------------------------------------------------------------------------
  111. Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
  112. If F_strFileToDelete = "" then
  113. 'path of the files to be deleted.
  114. F_strFilesPath = Request.Form("hdnLogPath")
  115. OnSubmitPage = ClearLog("")
  116. Else
  117. OnSubmitPage = ClearLog(F_strFileToDelete)
  118. End if
  119. End Function
  120. '-------------------------------------------------------------------------
  121. 'Function: OnClosePage()
  122. 'Description: Called when the page is about closed.Use this method
  123. ' to perform clean-up processing
  124. 'Input Variables: PageIn,EventArg
  125. 'Output Variables: None
  126. 'Returns: True/False
  127. 'Global Variables: None
  128. '-------------------------------------------------------------------------
  129. Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
  130. OnClosePage = TRUE
  131. End Function
  132. '-------------------------------------------------------------------------
  133. 'Function name: ClearLog
  134. 'Description: Serves in clearing the log files
  135. 'Input Variables: strLogFileToDelete
  136. 'Output Variables: None
  137. 'Returns: True/False. True if successful else False
  138. 'Global Variables: F_strFilesPath,F_arrFilesSubmitToDelete,L_*
  139. 'Clears events for the selected log
  140. '------------------------------------------------------------------------
  141. Function ClearLog(strLogFileToDelete)
  142. Err.clear
  143. On Error Resume Next
  144. Dim objFSO 'fso Object
  145. Dim nRetVal 'variable to get the return value
  146. Dim x 'variable used for getting the selected ots entries
  147. Dim itemCount 'variable used for getting the selected ots entries
  148. Dim strFileDelete 'File to delete
  149. Set objFSO = CreateObject("Scripting.FileSystemObject")
  150. If strLogFileToDelete = "" then
  151. itemCount = Ubound(F_arrFilesSubmitToDelete)
  152. For x = 0 to itemCount-1
  153. strFileDelete = F_strFilesPath & "\" & F_arrFilesSubmitToDelete(x)
  154. If NOT (objFSO.FileExists(strFileDelete)) Then
  155. SA_SetErrMsg L_LOGFILE_NOTFOUND_ERRORMESSAGE
  156. ClearLog = False
  157. Exit Function
  158. End If
  159. nRetVal = objFSO.DeleteFile(strFileDelete)
  160. Next
  161. Else
  162. If NOT (objFSO.FileExists(strLogFileToDelete)) Then
  163. SA_SetErrMsg L_LOGFILE_NOTFOUND_ERRORMESSAGE
  164. ClearLog = False
  165. Exit Function
  166. End If
  167. nRetVal = objFSO.DeleteFile(strLogFileToDelete)
  168. Call SA_TraceOut(SA_GetScriptFileName(), "Deleted file: " & strLogFileToDelete)
  169. End If
  170. If Err.number <> 0 Then
  171. SA_SetErrMsg L_SHAREVIOLATION_ERRORMESSAGE
  172. ClearLog = False
  173. Exit Function
  174. End If
  175. ClearLog = TRUE
  176. 'Release the objects
  177. Set objFSO = nothing
  178. End function
  179. %>