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.

683 lines
24 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' Log_prop.asp: Serves in Editing Log Properties.
  6. ' Copyright (c) Microsoft Corporation. All rights reserved.
  7. '-------------------------------------------------------------------------
  8. %>
  9. <!-- #include virtual="/admin/inc_framework.asp" -->
  10. <!-- #include file="loc_event.asp" -->
  11. <!-- #include file="inc_log.asp" -->
  12. <% '-------------------------------------------------------------------------
  13. 'Global Variables
  14. '-------------------------------------------------------------------------
  15. Dim page 'Variable that receives the output page object when
  16. 'creating a page
  17. Dim rc 'Return value for CreatePage
  18. 'wmi constant used to save the wmi settings
  19. Const WMICONST="131072"
  20. Const UINT_FORMAT=4294967296
  21. '-------------------------------------------------------------------------
  22. 'Global Form Variables
  23. '-------------------------------------------------------------------------
  24. Dim F_strEvent 'To get the title from previous page
  25. Dim F_strSize 'LogFile size
  26. Dim F_strCreated 'Log File Created date
  27. Dim F_strModified 'Log File modified date
  28. Dim F_strAccessed 'Log file last accessed date
  29. Dim F_strMaxLogsize 'log file maximum size
  30. Dim F_strOverwritePolicy 'Overwrite policy
  31. Dim F_strOverwriteOutdated 'Overwrite outdated policy
  32. Dim arrTitle(1)
  33. 'getting the type of log from previous page
  34. F_strEvent=Request.QueryString("Title")
  35. 'Localisation of page title
  36. arrTitle(0) = GetLocalizationTitle(F_strEvent)
  37. L_PAGETITLE_PROP_TEXT = SA_GetLocString("event.dll", "403F0033", arrTitle)
  38. 'Create a Property Page
  39. Call SA_CreatePage(L_PAGETITLE_PROP_TEXT,"",PT_PROPERTY,page)
  40. Call SA_ShowPage(page)
  41. '-------------------------------------------------------------------------
  42. 'Function: OnInitPage()
  43. 'Description: Called to signal first time processing for this page.
  44. ' Use this method to do first time initialization tasks
  45. 'Input Variables: PageIn,EventArg
  46. 'Output Variables: None
  47. 'Returns: True/False
  48. 'Global Variables: None
  49. '-------------------------------------------------------------------------
  50. Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  51. 'Serves in Getting the Properties of selected Log
  52. OnInitPage = GetLogProp()
  53. End Function
  54. '-------------------------------------------------------------------------
  55. 'Function: OnServePropertyPage()
  56. 'Description: Called when the page needs to be served.Use this
  57. ' method to serve content
  58. 'Input Variables: PageIn,EventArg
  59. 'Output Variables: None
  60. 'Returns: True/False
  61. 'Global Variables: None
  62. '-------------------------------------------------------------------------
  63. Public Function OnServePropertyPage(ByRef PageIn,ByRef EventArg)
  64. Dim oEncoder
  65. Set oEncoder = new CSAEncoder
  66. Call ServeCommonJavaScript()
  67. %>
  68. <table>
  69. <tr>
  70. <td class="TasksBody" nowrap>
  71. <%=oEncoder.EncodeElement(L_SIZE_TEXT)%>
  72. </td>
  73. <td class="TasksBody" nowrap> &nbsp;
  74. </td>
  75. <td class="TasksBody"> <%=oEncoder.EncodeElement(F_strSize)%>
  76. </td>
  77. </tr>
  78. <tr>
  79. <td nowrap class="TasksBody">
  80. <%=oEncoder.EncodeElement(L_CREATEDDATE_TEXT)%>
  81. </td>
  82. <td class="TasksBody"> &nbsp;
  83. </td>
  84. <td class="TasksBody" nowrap> <%=oEncoder.EncodeElement(F_strCreated)%>
  85. </td>
  86. </tr>
  87. <tr>
  88. <td nowrap class="TasksBody">
  89. <%=oEncoder.EncodeElement(L_MODIFIEDDATE_TEXT)%>
  90. </td>
  91. <td class="TasksBody"> &nbsp;
  92. </td>
  93. <td class="TasksBody" nowrap> <%=oEncoder.EncodeElement(F_strModified)%>
  94. </td>
  95. </tr>
  96. <tr>
  97. <td nowrap class="TasksBody">
  98. <%=oEncoder.EncodeElement(L_ACCESSEDDATE_TEXT)%>
  99. </td>
  100. <td class="TasksBody"> &nbsp;
  101. </td>
  102. <td class="TasksBody" nowrap>
  103. <%=oEncoder.EncodeElement(F_strAccessed)%>
  104. </td>
  105. </tr>
  106. <tr>
  107. <td nowrap colspan=3 class="TasksBody"> &nbsp;</td>
  108. </tr>
  109. <tr>
  110. <td nowrap colspan=3 class="TasksBody">
  111. <%=oEncoder.EncodeElement(L_LOGSIZE_TEXT)%>
  112. </td>
  113. </tr>
  114. <tr>
  115. <td nowrap colspan=3 class="TasksBody">
  116. <table>
  117. <tr>
  118. <td nowrap class="TasksBody">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=oEncoder.EncodeElement(L_MAXIMUMLOGSIZE_TEXT)%></td>
  119. <td class="TasksBody">&nbsp;<INPUT class ="FormField" TYPE = "text" size=10 Name ="txtMaximumlogsize" id=txtMaximumlogsize value=<%=oEncoder.EncodeAttribute(F_strMaxLogsize)%> OnKeyPress="JavaScript:checkKeyforNumbers(this);ClearErr()" onblur ="ValidatePage()" maxlength=7 ></td>
  120. <td class="TasksBody"><table cellpadding=0 cellspacing=0 border=0>
  121. <tr>
  122. <td class="TasksBody"><img src="/admin/images/up.gif" onclick =IncrementLogSize() name=incrMaxSize></td>
  123. </tr>
  124. <tr>
  125. <td class="TasksBody"><img src="/admin/images/down.gif" onclick = DecrementLogSize() name=decrMaxSize></td>
  126. </tr>
  127. </table>
  128. </td>
  129. <td nowrap class="TasksBody">&nbsp;&nbsp;<%=oEncoder.EncodeElement(L_KB_TEXT)%></td>
  130. </tr>
  131. </table>
  132. </td>
  133. </tr>
  134. <tr><td class="TasksBody">&nbsp</td></tr>
  135. <tr>
  136. <td nowrap colspan=3 class="TasksBody">
  137. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=oEncoder.EncodeElement(L_WHENMAXIMUMREACHED_TEXT)%>
  138. </td>
  139. </tr>
  140. </tr><tr><td class="TasksBody">&nbsp</td></tr>
  141. <tr>
  142. <td nowrap colspan=3 class="TasksBody"><table>
  143. <tr>
  144. <td class="TasksBody" nowrap>
  145. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT class ="FormField" TYPE = "radio" Name ="rdoOverwrite" onclick="JavaScript:Changemode(this.value);ClearErr()"
  146. <%IF F_strOverwritePolicy="WhenNeeded" then
  147. Response.Write "checked value='WhenNeeded'>"
  148. else
  149. Response.Write " value='WhenNeeded'>"
  150. end if %>
  151. <%=oEncoder.EncodeElement(L_OVERWRITEEVENTS_ASNEEDED_TEXT)%>
  152. </td>
  153. </tr>
  154. </table>
  155. </td>
  156. </tr>
  157. <tr>
  158. <td nowrap colspan=3 class="TasksBody"><table>
  159. <tr>
  160. <td class="TasksBody" nowrap>
  161. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT class ="FormField" TYPE = "radio" Name ="rdoOverwrite" onclick="JavaScript:Changemode(this.value);ClearErr()" onfocus="JavaScript:Changemode(this.value);ClearErr()"
  162. <%IF F_strOverwritePolicy="OutDated" then
  163. Response.Write "checked value='OutDated'>"
  164. else
  165. Response.Write " value='OutDated'>"
  166. end if %>
  167. <%=oEncoder.EncodeElement(L_OVERWRITEEVENTS_OLDERTHAN_TEXT)%>
  168. </td>
  169. <td class="TasksBody">&nbsp;<INPUT class ="FormField" TYPE = "text" size=10 Name ="txtTimeindays" OnKeyPress="checkKeyforNumbers(this)" value=<%=oEncoder.EncodeAttribute(F_strOverwriteOutdated)%> onblur ="ValidatePage()" maxlength=3></td>
  170. <td class="TasksBody"><table cellpadding=0 cellspacing=0 border=0>
  171. <tr>
  172. <td class="TasksBody"><img src="/admin/images/up.gif" onclick ="IncrementTimeinDays()" name="incrTimeinDays"></td>
  173. </tr>
  174. <tr>
  175. <td class="TasksBody"><img src="/admin/images/down.gif" onclick = "DecrementTimeinDays()" name="decrTimeinDays"></td>
  176. </tr>
  177. </table>
  178. </td><td class="TasksBody" nowrap>&nbsp;&nbsp;<%=oEncoder.EncodeElement(L_DAYS_TEXT)%></td></tr></table>
  179. </td>
  180. </tr>
  181. <tr>
  182. <td nowrap colspan=3 class="TasksBody">
  183. <table>
  184. <tr>
  185. <td class="TasksBody" nowrap>
  186. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT class ="FormField" TYPE = "radio" Name ="rdoOverwrite" onclick="Changemode(this.value)" <%IF F_strOverwritePolicy="Never" then
  187. Response.Write "checked value='Never'>"
  188. else
  189. Response.Write "value='Never'>"
  190. end if %>
  191. <%=oEncoder.EncodeElement(L_DONOTOVERWRITEEVENTS_TEXT)%>
  192. </td>
  193. </tr>
  194. </table>
  195. </td>
  196. </tr>
  197. </table>
  198. <input type="hidden" name="hidTempTimeinDays">
  199. <input type="hidden" name="hidEvent" Value="<%=F_strEvent%>">
  200. <input type="hidden" name="hidFileSize" Value="<%=F_strSize%>">
  201. <input type="hidden" name="hidFileCreated" Value="<%=F_strCreated%>">
  202. <input type="hidden" name="hidFileModified" Value="<%=F_strModified%>">
  203. <input type="hidden" name="hidFileAccessed" Value="<%=F_strAccessed%>">
  204. <input type="hidden" name="hidMaxLogsize" Value="<%=F_strMaxLogsize%>">
  205. <input type="hidden" name="hidOverWritePolicy" Value="<%=F_strOverwritePolicy%>">
  206. <input type="hidden" name="hidOverWriteOutDated" Value="<%=F_strOverwriteOutdated%>">
  207. <%
  208. OnServePropertyPage=TRUE
  209. End Function
  210. '-------------------------------------------------------------------------
  211. 'Function: OnPostBackPage()
  212. 'Description: Called to signal that the page has been posted-back.
  213. 'Input Variables: PageIn,EventArg
  214. 'Output Variables: None
  215. 'Returns: True/False
  216. 'Global Variables: None
  217. '-------------------------------------------------------------------------
  218. Public Function OnPostBackPage(ByRef PageIn,ByRef EventArg)
  219. OnPostBackPage=TRUE
  220. End Function
  221. '-------------------------------------------------------------------------
  222. 'Function: OnSubmitPage()
  223. 'Description: Called when the page has been submitted for processing.
  224. ' Use this method to process the submit request.
  225. 'Input Variables: PageIn,EventArg
  226. 'Output Variables: None
  227. 'Returns: True/False
  228. 'Global Variables: None
  229. '-------------------------------------------------------------------------
  230. Public Function OnSubmitPage(ByRef PageIn,ByRef EventArg)
  231. 'getting the values from form after form submission
  232. F_strEvent=Request.Form("hidEvent")
  233. F_strSize=Request.Form("hidFileSize")
  234. F_strCreated=Request.Form("hidFileCreated")
  235. F_strModified=Request.Form("hidFileModified")
  236. F_strAccessed=Request.Form("hidFileAccessed")
  237. F_strMaxLogsize=Request.Form("hidMaxLogSize")
  238. F_strOverwritePolicy=Request.Form("hidOverWritePolicy")
  239. F_strOverwriteOutdated=Request.Form("hidOverWriteOutDated")
  240. OnSubmitPage=EditLogProp()
  241. End Function
  242. '-------------------------------------------------------------------------
  243. 'Function: OnClosePage()
  244. 'Description: Called when the page is about to be closed.Use this method
  245. ' to perform clean-up processing
  246. 'Input Variables: PageIn,EventArg
  247. 'Output Variables: None
  248. 'Returns: True/False
  249. 'Global Variables: None
  250. '-------------------------------------------------------------------------
  251. Public Function OnClosePage(ByRef PageIn,ByRef EventArg)
  252. 'ServeClose()
  253. OnClosePage=TRUE
  254. End Function
  255. '---------------------------------------------------------------------
  256. ' Function: ServeCommonJavaScript
  257. '
  258. ' Synopsis: Serve common javascript that is required for this page type.
  259. '
  260. '---------------------------------------------------------------------
  261. Function ServeCommonJavaScript()
  262. %>
  263. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  264. </script>
  265. <script language="JavaScript">
  266. // Set the initial form values
  267. function Init()
  268. {
  269. document.frmTask.txtMaximumlogsize.focus()
  270. if(getRadioButtonValue(document.frmTask.rdoOverwrite)=="OutDated")
  271. document.frmTask.txtTimeindays.disabled=false
  272. else
  273. document.frmTask.txtTimeindays.disabled=true
  274. }
  275. function ValidatePage()
  276. {
  277. var intMaxLogsize=4194240 //Maximum log size
  278. var intMinLogsize=64 //Minimum log size
  279. var intMaxLogdays=365 //Maximum Log days
  280. var intMinLogdays=1 //Minimum Log days
  281. var intLogIncrement=64 //Log Increment
  282. var intMaximumlogsize = parseInt(document.frmTask.txtMaximumlogsize.value,10)
  283. var intTimeindays = parseInt(document.frmTask.txtTimeindays.value,10)
  284. var intLogMultiple
  285. if(isNaN(document.frmTask.txtTimeindays.value))
  286. {
  287. if(parseInt(document.frmTask.hidTempTimeinDays.value)> intMinLogdays)
  288. document.frmTask.txtTimeindays.value = parseInt(document.frmTask.hidTempTimeinDays.value)
  289. else
  290. {
  291. document.frmTask.txtTimeindays.value = intMinLogdays
  292. intDays = intTimeindays;
  293. return false;
  294. }
  295. }
  296. if(isNaN(document.frmTask.txtMaximumlogsize.value))
  297. {
  298. document.frmTask.txtMaximumlogsize.value = intMinLogsize
  299. return false;
  300. }
  301. else if(intMaximumlogsize > intMaxLogsize)
  302. {
  303. document.frmTask.txtMaximumlogsize.value=intMaxLogsize
  304. return false;
  305. }
  306. else if (document.frmTask.txtMaximumlogsize.value=="")
  307. {
  308. document.frmTask.txtMaximumlogsize.value =intLogIncrement
  309. return false;
  310. }
  311. else if(intMaximumlogsize < intMinLogsize)
  312. {
  313. document.frmTask.txtMaximumlogsize.value = intLogIncrement
  314. return false;
  315. }
  316. else if(intTimeindays > intMaxLogdays)
  317. {
  318. document.frmTask.txtTimeindays.value =parseInt(document.frmTask.txtTimeindays.value)-365
  319. return false;
  320. }
  321. else if(intTimeindays < intMinLogdays)
  322. {
  323. document.frmTask.txtTimeindays.value=intMinLogdays
  324. return false;
  325. }
  326. else if((intMaximumlogsize)%intLogIncrement!= 0)
  327. {
  328. //Rounding the number to next multiple of 64
  329. intLogMultiple=intMaximumlogsize/intLogIncrement;
  330. intLogMultiple=Math.floor(intLogMultiple)+1;
  331. document.frmTask.txtMaximumlogsize.value = intLogIncrement*intLogMultiple;
  332. return false;
  333. }
  334. else if(document.frmTask.txtTimeindays.value =="")
  335. {
  336. intDays = intTimeindays;
  337. document.frmTask.txtTimeindays.value = intMinLogdays
  338. return false;
  339. }
  340. else
  341. {
  342. return true;
  343. }
  344. }
  345. //Function to increment the Maximum log size text box
  346. function IncrementLogSize()
  347. {
  348. var intLogIncr=64;
  349. var intMaximumlogsize = parseInt(document.frmTask.txtMaximumlogsize.value,10);
  350. var intMultiple;
  351. var intMod;
  352. if (intMaximumlogsize==4194240)
  353. {
  354. document.frmTask.txtMaximumlogsize.value=intLogIncr;
  355. }
  356. else
  357. {
  358. document.frmTask.txtMaximumlogsize.value=intMaximumlogsize + intLogIncr;
  359. }
  360. }
  361. //Function to decrement the Maximum log size text box
  362. function DecrementLogSize()
  363. {
  364. var intLogDecr = 64;
  365. var intMaxLog = 4194240;
  366. var intMaximumlogsize = parseInt(document.frmTask.txtMaximumlogsize.value,10);
  367. var intMultiple;
  368. var intMod;
  369. if(intMaximumlogsize<=64)
  370. {
  371. document.frmTask.txtMaximumlogsize.value = intMaxLog;
  372. }
  373. else
  374. document.frmTask.txtMaximumlogsize.value = intMaximumlogsize -intLogDecr
  375. }
  376. //Function to increment Overwrite events older than text box
  377. function IncrementTimeinDays()
  378. {
  379. if (parseInt(document.frmTask.txtTimeindays.value)==365)
  380. document.frmTask.txtTimeindays.value =0
  381. if (parseInt(document.frmTask.txtTimeindays.value)>365)
  382. document.frmTask.txtTimeindays.value =parseInt(document.frmTask.txtTimeindays.value)-365
  383. if (isNaN(document.frmTask.txtTimeindays.value))
  384. {
  385. document.frmTask.txtTimeindays.value = parseInt(document.frmTask.hidTempTimeinDays.value)+1
  386. }else
  387. {
  388. document.frmTask.txtTimeindays.value =parseInt(document.frmTask.txtTimeindays.value,10) + 1
  389. document.frmTask.hidTempTimeinDays.value =document.frmTask.txtTimeindays.value
  390. }
  391. }
  392. //Function to decrement Overwrite events older than text box
  393. function DecrementTimeinDays()
  394. {
  395. if (isNaN(document.frmTask.txtTimeindays.value))
  396. {
  397. document.frmTask.txtTimeindays.value = parseInt(document.frmTask.hidTempTimeinDays.value)-1
  398. }else
  399. {
  400. document.frmTask.txtTimeindays.value =parseInt(document.frmTask.txtTimeindays.value,10)- 1
  401. document.frmTask.hidTempTimeinDays.value =document.frmTask.txtTimeindays.value
  402. }
  403. if (document.frmTask.txtTimeindays.value < 1)
  404. {
  405. document.frmTask.txtTimeindays.value = 365;
  406. }
  407. }
  408. //Function to set the hidden varibales to be sent to the server
  409. function SetData()
  410. {
  411. document.frmTask.hidMaxLogsize.value=document.frmTask.txtMaximumlogsize.value
  412. document.frmTask.hidOverWritePolicy.value=getRadioButtonValue(document.frmTask.rdoOverwrite)
  413. document.frmTask.hidOverWriteOutDated.value=document.frmTask.txtTimeindays.value
  414. }
  415. //Function to Enable\Disable the Textbox Timeindays
  416. function Changemode(Overwritevalue)
  417. {
  418. if(Overwritevalue!="OutDated")
  419. document.frmTask.txtTimeindays.disabled=true
  420. else
  421. document.frmTask.txtTimeindays.disabled=false
  422. }
  423. </script>
  424. <%
  425. End Function
  426. '-------------------------------------------------------------------------
  427. 'Function name: GetLogProp
  428. 'Synopsis: Serves in Getting the Properties of selected Log
  429. 'Input Variables: None
  430. 'Output Variables: None
  431. 'Returns: True/False. True if successful in getting the properties of a selected log,
  432. ' false to indicate errors in getting the properties.
  433. 'Global Variables: L_BYTES_TEXT,L_KB_TEXT,L_RETREIVEVALUES_ERRORMESSAGE,
  434. ' L_FAILEDTOGETWMICONNECTION_ERRORMESSAGE
  435. ' F_strEvent,F_strCreated,F_strModified,F_strAccessed,F_strMaxLogsize,
  436. ' F_strOverwritePolicy,F_strOverwriteOutdated
  437. '-------------------------------------------------------------------------
  438. Function GetLogProp()
  439. Err.Clear
  440. On Error Resume Next
  441. Dim objConnection 'To get WMI connection
  442. Dim objLogs 'To capture results after query execution
  443. Dim objLog 'To process query results
  444. Dim strQuery 'To capture the query
  445. Call SA_TraceOut(SA_GetScriptFileName(), "Entering GetLogProp")
  446. Dim oValidator
  447. Set oValidator = new CSAValidator
  448. If ( FALSE = oValidator.IsValidIdentifier(F_strEvent)) Then
  449. Call SA_TraceOut(SA_GetScriptFileName(), "LogName is invalid: " & F_strEvent)
  450. Call SA_ServeFailurepage(L_RETREIVEVALUES_ERRORMESSAGE)
  451. Set oValidator = Nothing
  452. Exit Function
  453. End If
  454. Set oValidator = Nothing
  455. strQuery ="SELECT * FROM Win32_NTEventlogFile WHERE LogfileName=" & chr(34) & F_strEvent & chr(34)
  456. 'getting wmi connection
  457. set objConnection = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  458. If Err.number<>0 then
  459. SA_ServeFailurepage L_FAILEDTOGETWMICONNECTION_ERRORMESSAGE
  460. GetLogProp=False
  461. Exit Function
  462. End if
  463. 'executing the query necessary to get the log properties
  464. Set objLogs = objConnection.ExecQuery(strQuery)
  465. For each objLog in objLogs
  466. 'getting the values from system into form variables
  467. F_strSize=FormatNumber((objLog.FileSize)/1024, 0) & L_KB_TEXT & "(" & FormatNumber(objLog.FileSize,0) &" "& L_BYTES_TEXT &")"
  468. F_strCreated=Formatdates(objLog.CreationDate)
  469. F_strModified=Formatdates(objLog.LastModified)
  470. F_strAccessed=Formatdates(objLog.LastAccessed)
  471. F_strMaxLogsize=ConvertSINT_UINT((objLog.MaxFileSize))/1024
  472. F_strOverwritePolicy=(objLog.OverWritePolicy)
  473. If objLog.OverWriteOutdated=0 or objLog.OverWriteOutdated=-1 then
  474. F_strOverwriteOutdated=7
  475. else
  476. F_strOverwriteOutdated=objLog.OverWriteOutdated
  477. end if
  478. next
  479. If Err.number <> 0 then
  480. SA_ServeFailurepage L_RETREIVEVALUES_ERRORMESSAGE
  481. GetLogProp=False
  482. Exit Function
  483. End If
  484. GetLogProp=True
  485. 'Destroying dynamically created objects after usage
  486. Set objConnection=Nothing
  487. Set objLogs=Nothing
  488. End Function
  489. '-------------------------------------------------------------------------
  490. 'Function name: ConvertSINT_UINT
  491. 'Synopsis: Converts Signed int to Unsigned int
  492. 'Input Variables: number (Signed)
  493. 'Output Variables: number (Unsigned)
  494. 'Returns: None
  495. 'Global Variables: None
  496. '-------------------------------------------------------------------------
  497. Function ConvertSINT_UINT(MaxFileSize)
  498. if( MaxFileSize >= 0 ) then
  499. ConvertSINT_UINT = MaxFileSize
  500. Exit function
  501. end if
  502. ConvertSINT_UINT = UINT_FORMAT + MaxFileSize
  503. End Function
  504. '-------------------------------------------------------------------------
  505. 'Function name: Formatdates
  506. 'Synopsis: Serves in formatting date according to display mode
  507. 'Input Variables: strDate -date to be formatted
  508. 'Output Variables: None
  509. 'Returns: strCreated 'Formatted date
  510. 'Global Variables: None
  511. '-------------------------------------------------------------------------
  512. Function Formatdates(strDate)
  513. Err.Clear
  514. On Error Resume Next
  515. Dim strDates
  516. Dim strTime
  517. Dim strTimeCreated
  518. Dim strCreated
  519. strDates=Mid(strDate,1,4)& "-" & Mid(strDate,5,2) & "-" & Mid(strDate,7,2)
  520. strTime=Mid(strDate,9,6)
  521. if Mid(strTime,1,2)>12 then
  522. strTimeCreated=((Mid(strTime,1,2))-12)& ":"& Mid(strTime,3,2)&":"&Mid(strTime,5,2) &" PM"
  523. else
  524. strTimeCreated=Mid(strTime,1,2)& ":"& Mid(strTime,3,2)&":"&Mid(strTime,5,2)& " AM"
  525. end if
  526. strCreated= FormatDateTime(CDate(strDates),1)&","&" " &strTimeCreated
  527. Formatdates=strCreated
  528. End Function
  529. '-------------------------------------------------------------------------
  530. 'Function name: EditLogProp
  531. 'Synopsis: Serves in editing the Properties of selected Log
  532. 'Input Variables: None
  533. 'Output Variables: None
  534. 'Returns: True - if successful in editing the properties of a selected log
  535. ' False - to indicate errors.
  536. 'Global Variables: F_strEvent,F_strOverwritePolicy,F_strSize,F_strOverwriteOutdated,
  537. ' L_UPDATEVALUES_ERRORMESSAGE,L_FAILEDTOGETWMICONNECTION_ERRORMESSAGE
  538. ' LL_RETREIVEVALUES_ERRORMESSAGE
  539. '-------------------------------------------------------------------------
  540. Function EditLogProp
  541. Err.Clear
  542. On Error Resume Next
  543. Dim objConnection 'To get WMI connection
  544. Dim objLogs 'To capture results after query execution
  545. Dim objLog 'To process query results
  546. Dim strQuery 'To capture the query
  547. const OVERWRITEOUTDATED=4294967295
  548. Call SA_TraceOut(SA_GetScriptFileName(), "Entering EditLogProp")
  549. Dim oValidator
  550. Set oValidator = new CSAValidator
  551. If ( FALSE = oValidator.IsValidIdentifier(F_strEvent)) Then
  552. Call SA_TraceOut(SA_GetScriptFileName(), "LogName is invalid: " & F_strEvent)
  553. Call SA_ServeFailurepage(L_RETREIVEVALUES_ERRORMESSAGE)
  554. Set oValidator = Nothing
  555. Exit Function
  556. End If
  557. Set oValidator = Nothing
  558. strQuery ="SELECT * FROM Win32_NTEventlogFile WHERE LogfileName=" & chr(34) & F_strEvent & chr(34)
  559. 'getting wmi connection
  560. set objConnection = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  561. If Err.number<>0 then
  562. SA_SetErrMsg L_FAILEDTOGETWMICONNECTION_ERRORMESSAGE
  563. EditLogProp=false
  564. Exit Function
  565. End if
  566. 'execute the necessary query to set the log properties
  567. Set objLogs = objConnection.ExecQuery(strQuery)
  568. If Err.number <> 0 then
  569. SA_SetErrMsg L_RETREIVEVALUES_ERRORMESSAGE
  570. EditLogProp=false
  571. Exit Function
  572. End If
  573. 'editing log properties
  574. For each objLog in objLogs
  575. objLog.MaxFileSize=F_strMaxLogsize*1024
  576. if F_strOverwritePolicy="WhenNeeded" then
  577. objLog.OverWriteOutdated =0
  578. elseif F_strOverwritePolicy="OutDated" then
  579. objLog.OverWriteOutdated =F_strOverwriteOutdated
  580. elseif F_strOverwritePolicy="Never" then
  581. objLog.OverWriteOutdated =OVERWRITEOUTDATED
  582. end if
  583. objLog.OverWritePolicy=F_strOverwritePolicy
  584. objLog.Put_(WMICONST)
  585. next
  586. If Err.number <> 0 then
  587. SA_SetErrMsg L_UPDATEVALUES_ERRORMESSAGE
  588. EditLogProp=false
  589. Exit Function
  590. End If
  591. EditLogProp=true
  592. 'Destroying dynamically created objects after usage
  593. Set objConnection=Nothing
  594. Set objLogs=Nothing
  595. End Function
  596. %>