<%@ Language=VBScript %> <% Option Explicit %> <% '------------------------------------------------------------------------- ' Log_prop.asp: Serves in Editing Log Properties. ' Copyright (c) Microsoft Corporation. All rights reserved. '------------------------------------------------------------------------- %> <% '------------------------------------------------------------------------- 'Global Variables '------------------------------------------------------------------------- Dim page 'Variable that receives the output page object when 'creating a page Dim rc 'Return value for CreatePage 'wmi constant used to save the wmi settings Const WMICONST="131072" Const UINT_FORMAT=4294967296 '------------------------------------------------------------------------- 'Global Form Variables '------------------------------------------------------------------------- Dim F_strEvent 'To get the title from previous page Dim F_strSize 'LogFile size Dim F_strCreated 'Log File Created date Dim F_strModified 'Log File modified date Dim F_strAccessed 'Log file last accessed date Dim F_strMaxLogsize 'log file maximum size Dim F_strOverwritePolicy 'Overwrite policy Dim F_strOverwriteOutdated 'Overwrite outdated policy Dim arrTitle(1) 'getting the type of log from previous page F_strEvent=Request.QueryString("Title") 'Localisation of page title arrTitle(0) = GetLocalizationTitle(F_strEvent) L_PAGETITLE_PROP_TEXT = SA_GetLocString("event.dll", "403F0033", arrTitle) 'Create a Property Page Call SA_CreatePage(L_PAGETITLE_PROP_TEXT,"",PT_PROPERTY,page) Call SA_ShowPage(page) '------------------------------------------------------------------------- 'Function: OnInitPage() 'Description: Called to signal first time processing for this page. ' Use this method to do first time initialization tasks 'Input Variables: PageIn,EventArg 'Output Variables: None 'Returns: True/False 'Global Variables: None '------------------------------------------------------------------------- Public Function OnInitPage(ByRef PageIn,ByRef EventArg) 'Serves in Getting the Properties of selected Log OnInitPage = GetLogProp() End Function '------------------------------------------------------------------------- 'Function: OnServePropertyPage() 'Description: Called when the page needs to be served.Use this ' method to serve content 'Input Variables: PageIn,EventArg 'Output Variables: None 'Returns: True/False 'Global Variables: None '------------------------------------------------------------------------- Public Function OnServePropertyPage(ByRef PageIn,ByRef EventArg) Dim oEncoder Set oEncoder = new CSAEncoder Call ServeCommonJavaScript() %>
<%=oEncoder.EncodeElement(L_SIZE_TEXT)%>   <%=oEncoder.EncodeElement(F_strSize)%>
<%=oEncoder.EncodeElement(L_CREATEDDATE_TEXT)%>   <%=oEncoder.EncodeElement(F_strCreated)%>
<%=oEncoder.EncodeElement(L_MODIFIEDDATE_TEXT)%>   <%=oEncoder.EncodeElement(F_strModified)%>
<%=oEncoder.EncodeElement(L_ACCESSEDDATE_TEXT)%>   <%=oEncoder.EncodeElement(F_strAccessed)%>
 
<%=oEncoder.EncodeElement(L_LOGSIZE_TEXT)%>
      <%=oEncoder.EncodeElement(L_MAXIMUMLOGSIZE_TEXT)%>   OnKeyPress="JavaScript:checkKeyforNumbers(this);ClearErr()" onblur ="ValidatePage()" maxlength=7 >
  <%=oEncoder.EncodeElement(L_KB_TEXT)%>
 
      <%=oEncoder.EncodeElement(L_WHENMAXIMUMREACHED_TEXT)%>
 
     " else Response.Write " value='WhenNeeded'>" end if %> <%=oEncoder.EncodeElement(L_OVERWRITEEVENTS_ASNEEDED_TEXT)%>
     " else Response.Write " value='OutDated'>" end if %> <%=oEncoder.EncodeElement(L_OVERWRITEEVENTS_OLDERTHAN_TEXT)%>   onblur ="ValidatePage()" maxlength=3>
  <%=oEncoder.EncodeElement(L_DAYS_TEXT)%>
     " else Response.Write "value='Never'>" end if %> <%=oEncoder.EncodeElement(L_DONOTOVERWRITEEVENTS_TEXT)%>
<% OnServePropertyPage=TRUE End Function '------------------------------------------------------------------------- 'Function: OnPostBackPage() 'Description: Called to signal that the page has been posted-back. 'Input Variables: PageIn,EventArg 'Output Variables: None 'Returns: True/False 'Global Variables: None '------------------------------------------------------------------------- Public Function OnPostBackPage(ByRef PageIn,ByRef EventArg) OnPostBackPage=TRUE End Function '------------------------------------------------------------------------- 'Function: OnSubmitPage() 'Description: Called when the page has been submitted for processing. ' Use this method to process the submit request. 'Input Variables: PageIn,EventArg 'Output Variables: None 'Returns: True/False 'Global Variables: None '------------------------------------------------------------------------- Public Function OnSubmitPage(ByRef PageIn,ByRef EventArg) 'getting the values from form after form submission F_strEvent=Request.Form("hidEvent") F_strSize=Request.Form("hidFileSize") F_strCreated=Request.Form("hidFileCreated") F_strModified=Request.Form("hidFileModified") F_strAccessed=Request.Form("hidFileAccessed") F_strMaxLogsize=Request.Form("hidMaxLogSize") F_strOverwritePolicy=Request.Form("hidOverWritePolicy") F_strOverwriteOutdated=Request.Form("hidOverWriteOutDated") OnSubmitPage=EditLogProp() End Function '------------------------------------------------------------------------- 'Function: OnClosePage() 'Description: Called when the page is about to be closed.Use this method ' to perform clean-up processing 'Input Variables: PageIn,EventArg 'Output Variables: None 'Returns: True/False 'Global Variables: None '------------------------------------------------------------------------- Public Function OnClosePage(ByRef PageIn,ByRef EventArg) 'ServeClose() OnClosePage=TRUE End Function '--------------------------------------------------------------------- ' Function: ServeCommonJavaScript ' ' Synopsis: Serve common javascript that is required for this page type. ' '--------------------------------------------------------------------- Function ServeCommonJavaScript() %> <% End Function '------------------------------------------------------------------------- 'Function name: GetLogProp 'Synopsis: Serves in Getting the Properties of selected Log 'Input Variables: None 'Output Variables: None 'Returns: True/False. True if successful in getting the properties of a selected log, ' false to indicate errors in getting the properties. 'Global Variables: L_BYTES_TEXT,L_KB_TEXT,L_RETREIVEVALUES_ERRORMESSAGE, ' L_FAILEDTOGETWMICONNECTION_ERRORMESSAGE ' F_strEvent,F_strCreated,F_strModified,F_strAccessed,F_strMaxLogsize, ' F_strOverwritePolicy,F_strOverwriteOutdated '------------------------------------------------------------------------- Function GetLogProp() Err.Clear On Error Resume Next Dim objConnection 'To get WMI connection Dim objLogs 'To capture results after query execution Dim objLog 'To process query results Dim strQuery 'To capture the query Call SA_TraceOut(SA_GetScriptFileName(), "Entering GetLogProp") Dim oValidator Set oValidator = new CSAValidator If ( FALSE = oValidator.IsValidIdentifier(F_strEvent)) Then Call SA_TraceOut(SA_GetScriptFileName(), "LogName is invalid: " & F_strEvent) Call SA_ServeFailurepage(L_RETREIVEVALUES_ERRORMESSAGE) Set oValidator = Nothing Exit Function End If Set oValidator = Nothing strQuery ="SELECT * FROM Win32_NTEventlogFile WHERE LogfileName=" & chr(34) & F_strEvent & chr(34) 'getting wmi connection set objConnection = getWMIConnection(CONST_WMI_WIN32_NAMESPACE) If Err.number<>0 then SA_ServeFailurepage L_FAILEDTOGETWMICONNECTION_ERRORMESSAGE GetLogProp=False Exit Function End if 'executing the query necessary to get the log properties Set objLogs = objConnection.ExecQuery(strQuery) For each objLog in objLogs 'getting the values from system into form variables F_strSize=FormatNumber((objLog.FileSize)/1024, 0) & L_KB_TEXT & "(" & FormatNumber(objLog.FileSize,0) &" "& L_BYTES_TEXT &")" F_strCreated=Formatdates(objLog.CreationDate) F_strModified=Formatdates(objLog.LastModified) F_strAccessed=Formatdates(objLog.LastAccessed) F_strMaxLogsize=ConvertSINT_UINT((objLog.MaxFileSize))/1024 F_strOverwritePolicy=(objLog.OverWritePolicy) If objLog.OverWriteOutdated=0 or objLog.OverWriteOutdated=-1 then F_strOverwriteOutdated=7 else F_strOverwriteOutdated=objLog.OverWriteOutdated end if next If Err.number <> 0 then SA_ServeFailurepage L_RETREIVEVALUES_ERRORMESSAGE GetLogProp=False Exit Function End If GetLogProp=True 'Destroying dynamically created objects after usage Set objConnection=Nothing Set objLogs=Nothing End Function '------------------------------------------------------------------------- 'Function name: ConvertSINT_UINT 'Synopsis: Converts Signed int to Unsigned int 'Input Variables: number (Signed) 'Output Variables: number (Unsigned) 'Returns: None 'Global Variables: None '------------------------------------------------------------------------- Function ConvertSINT_UINT(MaxFileSize) if( MaxFileSize >= 0 ) then ConvertSINT_UINT = MaxFileSize Exit function end if ConvertSINT_UINT = UINT_FORMAT + MaxFileSize End Function '------------------------------------------------------------------------- 'Function name: Formatdates 'Synopsis: Serves in formatting date according to display mode 'Input Variables: strDate -date to be formatted 'Output Variables: None 'Returns: strCreated 'Formatted date 'Global Variables: None '------------------------------------------------------------------------- Function Formatdates(strDate) Err.Clear On Error Resume Next Dim strDates Dim strTime Dim strTimeCreated Dim strCreated strDates=Mid(strDate,1,4)& "-" & Mid(strDate,5,2) & "-" & Mid(strDate,7,2) strTime=Mid(strDate,9,6) if Mid(strTime,1,2)>12 then strTimeCreated=((Mid(strTime,1,2))-12)& ":"& Mid(strTime,3,2)&":"&Mid(strTime,5,2) &" PM" else strTimeCreated=Mid(strTime,1,2)& ":"& Mid(strTime,3,2)&":"&Mid(strTime,5,2)& " AM" end if strCreated= FormatDateTime(CDate(strDates),1)&","&" " &strTimeCreated Formatdates=strCreated End Function '------------------------------------------------------------------------- 'Function name: EditLogProp 'Synopsis: Serves in editing the Properties of selected Log 'Input Variables: None 'Output Variables: None 'Returns: True - if successful in editing the properties of a selected log ' False - to indicate errors. 'Global Variables: F_strEvent,F_strOverwritePolicy,F_strSize,F_strOverwriteOutdated, ' L_UPDATEVALUES_ERRORMESSAGE,L_FAILEDTOGETWMICONNECTION_ERRORMESSAGE ' LL_RETREIVEVALUES_ERRORMESSAGE '------------------------------------------------------------------------- Function EditLogProp Err.Clear On Error Resume Next Dim objConnection 'To get WMI connection Dim objLogs 'To capture results after query execution Dim objLog 'To process query results Dim strQuery 'To capture the query const OVERWRITEOUTDATED=4294967295 Call SA_TraceOut(SA_GetScriptFileName(), "Entering EditLogProp") Dim oValidator Set oValidator = new CSAValidator If ( FALSE = oValidator.IsValidIdentifier(F_strEvent)) Then Call SA_TraceOut(SA_GetScriptFileName(), "LogName is invalid: " & F_strEvent) Call SA_ServeFailurepage(L_RETREIVEVALUES_ERRORMESSAGE) Set oValidator = Nothing Exit Function End If Set oValidator = Nothing strQuery ="SELECT * FROM Win32_NTEventlogFile WHERE LogfileName=" & chr(34) & F_strEvent & chr(34) 'getting wmi connection set objConnection = getWMIConnection(CONST_WMI_WIN32_NAMESPACE) If Err.number<>0 then SA_SetErrMsg L_FAILEDTOGETWMICONNECTION_ERRORMESSAGE EditLogProp=false Exit Function End if 'execute the necessary query to set the log properties Set objLogs = objConnection.ExecQuery(strQuery) If Err.number <> 0 then SA_SetErrMsg L_RETREIVEVALUES_ERRORMESSAGE EditLogProp=false Exit Function End If 'editing log properties For each objLog in objLogs objLog.MaxFileSize=F_strMaxLogsize*1024 if F_strOverwritePolicy="WhenNeeded" then objLog.OverWriteOutdated =0 elseif F_strOverwritePolicy="OutDated" then objLog.OverWriteOutdated =F_strOverwriteOutdated elseif F_strOverwritePolicy="Never" then objLog.OverWriteOutdated =OVERWRITEOUTDATED end if objLog.OverWritePolicy=F_strOverwritePolicy objLog.Put_(WMICONST) next If Err.number <> 0 then SA_SetErrMsg L_UPDATEVALUES_ERRORMESSAGE EditLogProp=false Exit Function End If EditLogProp=true 'Destroying dynamically created objects after usage Set objConnection=Nothing Set objLogs=Nothing End Function %>