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.

274 lines
8.8 KiB

  1. <% @Language=VbScript%>
  2. <% Option Explicit %>
  3. <% '-------------------------------------------------------------------------
  4. ' Log_clear.asp : This page serves in clearing the logs
  5. ' Copyright (c) Microsoft Corporation. All rights reserved.
  6. '-------------------------------------------------------------------------
  7. %>
  8. <!-- #include virtual="/admin/inc_framework.asp"--->
  9. <!-- #include file="loc_event.asp"--->
  10. <!-- #include file="inc_log.asp"-->
  11. <%
  12. '-------------------------------------------------------------------------
  13. ' Global Variables
  14. '-------------------------------------------------------------------------
  15. Dim page
  16. Dim rc
  17. Const G_wbemPrivilegeSecurity=7 'Prilivilege constant
  18. '-------------------------------------------------------------------------
  19. ' Form Variables
  20. '-------------------------------------------------------------------------
  21. Dim F_strLogname 'Selected log name
  22. '-------------------------------------------------------------------------
  23. ' Start of localization content
  24. '-------------------------------------------------------------------------
  25. Dim arrTitle(1) 'Title text
  26. Dim arrConfirm(1) 'Confirmation text
  27. F_strLogname=Request.QueryString("title")
  28. If F_strLogname ="" Then
  29. F_strLogname=Request.Form("hdnlogname")
  30. End If
  31. 'Localisation of page title
  32. arrTitle(0) = GetLocalizationTitle(F_strLogname)
  33. L_PAGETITLE_CLR_TEXT = SA_GetLocString("event.dll", "403F0097", arrTitle)
  34. L_DELETE_CONFIRM_CLR_TEXT = SA_GetLocString("event.dll", "403F0099", arrTitle)
  35. 'Create property page
  36. Call SA_CreatePage(L_PAGETITLE_CLR_TEXT, "", PT_PROPERTY,page)
  37. Call SA_ShowPage(Page)
  38. '-------------------------------------------------------------------------
  39. 'Function: OnInitPage()
  40. 'Description: Called to signal first time processing for this page.
  41. ' Use this method to do first time initialization tasks
  42. 'Input Variables: PageIn,EventArg
  43. 'Output Variables: None
  44. 'Returns: True/False
  45. 'Global Variables: None
  46. '-------------------------------------------------------------------------
  47. Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  48. OnInitPage = True
  49. End Function
  50. '-------------------------------------------------------------------------
  51. 'Function: OnServePropertyPage()
  52. 'Description: Called when the page needs to be served.Use this
  53. ' method to serve content
  54. 'Input Variables: PageIn,EventArg
  55. 'Output Variables: None
  56. 'Returns: True/False
  57. 'Global Variables: None
  58. '-------------------------------------------------------------------------
  59. Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg)
  60. Call ServeCommonJavaScript()
  61. Call ServePage()
  62. OnServePropertyPage = True
  63. End Function
  64. '-------------------------------------------------------------------------
  65. 'Function: OnPostBackPage()
  66. 'Description: Called to signal that the page has been posted-back.
  67. 'Input Variables: PageIn,EventArg
  68. 'Output Variables: None
  69. 'Returns: True/False
  70. 'Global Variables: None
  71. '-------------------------------------------------------------------------
  72. Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
  73. OnPostBackPage = True
  74. End Function
  75. '-------------------------------------------------------------------------
  76. 'Function: OnSubmitPage()
  77. 'Description: Called when the page has been submitted for processing.
  78. ' Use this method to process the submit request.
  79. 'Input Variables: PageIn,EventArg
  80. 'Output Variables: None
  81. 'Returns: True/False
  82. 'Global Variables: None
  83. '-------------------------------------------------------------------------
  84. Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
  85. OnSubmitPage = ServeVariablesFromForm()
  86. End Function
  87. '-------------------------------------------------------------------------
  88. 'Function: OnClosePage()
  89. 'Description: Called when the page is about closed.Use this method
  90. ' to perform clean-up processing
  91. 'Input Variables: PageIn,EventArg
  92. 'Output Variables: None
  93. 'Returns: True/False
  94. 'Global Variables: None
  95. '-------------------------------------------------------------------------
  96. Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
  97. OnClosePage = TRUE
  98. End Function
  99. '-------------------------------------------------------------------------
  100. 'Function: ServeCommonJavaScript
  101. 'Description: Serves in initialiging the values,setting the form
  102. ' data and validating the form values
  103. 'Input Variables: None
  104. 'Output Variables: None
  105. 'Returns: True/False
  106. 'Global Variables: None
  107. '-------------------------------------------------------------------------
  108. Function ServeCommonJavaScript()
  109. %>
  110. <script language="JavaScript" src ="<%=m_VirtualRoot%>inc_global.js">
  111. </script>
  112. <script language="JavaScript">
  113. //Initialization
  114. function Init()
  115. {
  116. SetPageChanged(false);
  117. }
  118. //To validate user input
  119. function ValidatePage()
  120. {
  121. return true;
  122. }
  123. //Dummy function for Framework
  124. function SetData()
  125. {
  126. }
  127. </script>
  128. <% End Function
  129. '-------------------------------------------------------------------------
  130. 'Function: ServePage()
  131. 'Description: For displaying outputs HTML to the user
  132. 'Input Variables: None
  133. 'Output Variables: None
  134. 'Returns: None
  135. 'Global Variables: L_DELETE_CONFIRM_TEXT
  136. '-------------------------------------------------------------------------
  137. Function ServePage
  138. Dim oEncoder
  139. Set oEncoder = new CSAEncoder
  140. %>
  141. <table width="100%" border="0" cellspacing="0" cellpadding="0" >
  142. <tr>
  143. <td class="TasksBody">
  144. <%=oEncoder.EncodeElement(L_DELETE_CONFIRM_CLR_TEXT)%>
  145. </td>
  146. </tr>
  147. </table>
  148. <input type="hidden" name="hdnlogname" value="<%=F_strLogname%>">
  149. <%
  150. End Function
  151. '-------------------------------------------------------------------------
  152. 'Function name: ServeVariablesFromForm()
  153. 'Description: Serves in getting the data from Client
  154. 'Input Variables: None
  155. 'Output Variables: None
  156. 'Returns: True/False
  157. 'Global Variables: None
  158. '-------------------------------------------------------------------------
  159. Function ServeVariablesFromForm
  160. 'Getting the selected log
  161. If LogClear()then
  162. ServeVariablesFromForm = true
  163. else
  164. ServeVariablesFromForm = false
  165. end if
  166. End Function
  167. '-------------------------------------------------------------------------
  168. 'Function name: LogClear
  169. 'Description: Serves in clearing the log
  170. 'Input Variables: None
  171. 'Output Variables: None
  172. 'Returns: True/False. True if successful else False
  173. 'Global Variables: F_strLogname
  174. 'Clears events for the selected log
  175. '------------------------------------------------------------------------
  176. Function LogClear()
  177. Err.clear
  178. on Error Resume Next
  179. Dim objLog
  180. Dim objConnection
  181. Dim objLognames
  182. Dim strQuery
  183. Dim intResult
  184. Const strDefault="Default"
  185. Dim oValidator
  186. '
  187. ' Validate the log name, it's a QueryString argument.
  188. Set oValidator = new CSAValidator
  189. If ( FALSE = oValidator.IsValidIdentifier(F_strLogname)) Then
  190. SA_SetErrMsg L_INVALIDPARAMETERS_ERRORMESSAGE
  191. Call SA_TraceOut(SA_GetScriptFileName(), "Log name not valid: " & F_strLogname)
  192. LogClear = False
  193. Set oValidator = Nothing
  194. Exit Function
  195. End If
  196. Set oValidator = Nothing
  197. strQuery="SELECT * FROM Win32_NTEventlogFile WHERE LogfileName=" & "'" & F_strLogname & "'"
  198. 'Getting the WMI connection
  199. set objConnection = getWMIConnection(strDefault)
  200. 'Passing the Privileges
  201. 'objConnection.Security_.Privileges.Add G_wbemPrivilegeSecurity
  202. Set objLognames = objConnection.ExecQuery(strQuery)
  203. If Err.number <> 0 Then
  204. SA_SetErrMsg L_INVALIDPARAMETERS_ERRORMESSAGE
  205. Call SA_TraceOut(SA_GetScriptFileName(), "ExecQuery(" & strQuery & ") failed: " & Hex(Err.Number) & " " & Err.Description)
  206. LogClear = False
  207. Exit Function
  208. End If
  209. 'Clearing events in the selected log
  210. For Each objLog in objLognames
  211. intResult=objLog.ClearEventlog()
  212. Next
  213. If (Err.number <> 0 OR intResult <> 0 )Then
  214. 'Checking for access error
  215. If Err.number = -2147217405 Then
  216. SA_SetErrMsg L_LOGACCESSDENIED_ERRORMESSAGE
  217. 'Log clear error
  218. Elseif Err.number = 438 then
  219. SA_SetErrMSG L_LOGCLEARFAIL_ERRORMESSAGE
  220. Else
  221. 'Log not cleared
  222. SA_SetErrMsg L_LOGNOTCLEARED_ERRORMESSAGE
  223. End If
  224. Call SA_TraceOut(SA_GetScriptFileName(), "ClearEventLog failed: " & Hex(Err.Number) & " " & Err.Description)
  225. LogClear = FALSE
  226. Exit Function
  227. End IF
  228. LogClear = TRUE
  229. 'Setting object to nothing
  230. Set objConnection=Nothing
  231. 'Setting logname to nothing
  232. Set objLognames=Nothing
  233. End function
  234. %>