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.

676 lines
23 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' logs.asp: lists all the logs, events for the selected log and provides
  6. ' links for clearing, editing the properties and downloading
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '-------------------------------------------------------------------------
  9. %>
  10. <!-- #include virtual="/admin/inc_framework.asp" -->
  11. <!-- #include virtual="/admin/ots_main.asp" -->
  12. <!-- #include file="loc_event.asp" -->
  13. <%
  14. '-------------------------------------------------------------------------
  15. ' Global Constants
  16. '-------------------------------------------------------------------------
  17. Const TYPE_COLUMN = 1
  18. Const DATE_COLUMN = 2
  19. Const TIME_COLUMN = 3
  20. Const SOURCE_COLUMN = 4
  21. Const EVENT_COLUMN = 5
  22. Const CONST_WBEMPRIVILEGESECURITY=7 'Prilivilege constant
  23. Const NOOFRECORDS= 100 'fixing the constant value for getting the minimum records
  24. Dim SOURCE_FILE
  25. Const ENABLE_TRACING = TRUE
  26. SOURCE_FILE = SA_GetScriptFileName()
  27. Const CONST_HIDDEN="Hidden" ' Need not localize this variable as this is hidden
  28. '-------------------------------------------------------------------------
  29. ' Global Variables
  30. '-------------------------------------------------------------------------
  31. 'frame work variables
  32. Dim rc
  33. Dim page
  34. Dim g_bSearchChanged
  35. Dim g_iSearchCol
  36. Dim g_sSearchColValue
  37. Dim g_bPagingInitialized
  38. Dim g_bPageChangeRequested
  39. Dim g_sPageAction
  40. Dim g_iPageMin
  41. Dim g_iPageMax
  42. Dim g_iPageCurrent
  43. Dim g_iSortCol
  44. Dim g_sSortSequence
  45. Dim g_bSortRequested
  46. Dim G_strLogName 'Log name
  47. Dim G_objConnection 'Object to WMI connection
  48. '-------------------------------------------------------------------------
  49. ' Form Variables
  50. '-------------------------------------------------------------------------
  51. Dim F_strevent_title 'To get the title from previous page
  52. Dim F_pageTitle 'to get the page title.
  53. Dim arrTitle(1)
  54. '======================================================
  55. ' Entry point
  56. '======================================================
  57. ' Create Page
  58. 'Title localisation
  59. F_strevent_title = lcase(Request.QueryString("Title"))
  60. Select case F_strevent_title
  61. case Lcase("Applicationlog")
  62. F_pageTitle = L_APPLICATION_TEXT
  63. case Lcase("Systemlog")
  64. F_pageTitle = L_SYSTEM_TEXT
  65. case Lcase("Securitylog")
  66. F_pageTitle = L_SECURITY_TEXT
  67. End select
  68. arrTitle(0) = F_pageTitle
  69. L_PAGETITLE_LOGS_TEXT = SA_GetLocString("event.dll", "403F001A", arrTitle)
  70. Call SA_CreatePage(L_PAGETITLE_LOGS_TEXT, "", PT_AREA, page )
  71. Call SA_ShowPage( page )
  72. '---------------------------------------------------------------------
  73. ' Function name: OnInitPage
  74. ' Description: Called to signal first time processing for this page.
  75. ' Input Variables: PageIn and EventArg
  76. ' Output Variables: PageIn, EventArg
  77. ' Return Values: TRUE to indicate initialization was successful. FALSE to indicate
  78. ' errors. Returning FALSE will cause the page to be abandoned.
  79. ' Global Variables: Out: G_strLogName
  80. ' Called to signal first time processing for this page. Use this method
  81. ' to do first time initialization tasks.
  82. '---------------------------------------------------------------------
  83. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  84. OnInitPage = TRUE
  85. If ( ENABLE_TRACING ) Then
  86. Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  87. End If
  88. 'Getting the value of the log. and description from previous page.
  89. F_strevent_title = Request.QueryString("Title")
  90. G_strLogName = getWMILogFileName(F_strevent_title)
  91. 'Set default values
  92. '
  93. 'Sort hidden column in descending sequence as we have numbering in reverse order
  94. g_iSortCol = 6
  95. g_sSortSequence = "D"
  96. '
  97. ' Paging needs to be initialized
  98. g_bPagingInitialized = FALSE
  99. '
  100. 'Start on page #1
  101. g_iPageCurrent = 1
  102. End Function
  103. '---------------------------------------------------------------------
  104. ' Function name: OnServeAreaPage
  105. ' Description: Called when the page needs to be served.
  106. ' Input Variables: PageIn, EventArg
  107. ' Output Variables: PageIn, EventArg
  108. ' Return Values: TRUE to indicate no problems occured. FALSE to indicate errors.
  109. ' Returning FALSE will cause the page to be abandoned.
  110. ' Global Variables: None
  111. 'Called when the page needs to be served. Use this method to serve content.
  112. '---------------------------------------------------------------------
  113. Public Function OnServeAreaPage(ByRef PageIn, ByRef EventArg)
  114. OnServeAreaPage= getLogsEvents()
  115. 'Release the object
  116. Set G_objConnection = Nothing
  117. End Function
  118. '---------------------------------------------------------------------
  119. ' Function: OnSearchNotify()
  120. '
  121. ' Synopsis: Search notification event handler. When one or more columns are
  122. ' marked with the OTS_COL_SEARCH flag, the Web Framework fires
  123. ' this event in the following scenarios:
  124. '
  125. ' 1) The user presses the search Go button.
  126. ' 2) The user requests a table column sort
  127. ' 3) The user presses either the page next or page previous buttons
  128. '
  129. ' The EventArg indicates the source of this notification event which can
  130. ' be either a search change event (scenario 1) or a post back event
  131. ' (scenarios 2 or 3)
  132. '
  133. ' Returns: Always returns TRUE
  134. '
  135. '---------------------------------------------------------------------
  136. Public Function OnSearchNotify(ByRef PageIn, _
  137. ByRef EventArg, _
  138. ByVal sItem, _
  139. ByVal sValue )
  140. OnSearchNotify = TRUE
  141. '
  142. ' User pressed the search GO button
  143. '
  144. If SA_IsChangeEvent(EventArg) Then
  145. If ( ENABLE_TRACING ) Then
  146. Call SA_TraceOut(SOURCE_FILE, "OnSearchNotify() Change Event Fired")
  147. End If
  148. g_bSearchChanged = TRUE
  149. g_iSearchCol = Int(sItem)
  150. g_sSearchColValue = CStr(sValue)
  151. '
  152. ' User clicked a column sort, OR clicked either the page next or page prev button
  153. ElseIf SA_IsPostBackEvent(EventArg) Then
  154. If ( ENABLE_TRACING ) Then
  155. Call SA_TraceOut(SOURCE_FILE, "OnSearchNotify() Postback Event Fired")
  156. End If
  157. g_bSearchChanged = FALSE
  158. g_iSearchCol = Int(sItem)
  159. g_sSearchColValue = CStr(sValue)
  160. '
  161. ' Unknown event source
  162. Else
  163. If ( ENABLE_TRACING ) Then
  164. Call SA_TraceOut(SOURCE_FILE, "Unrecognized Event in OnSearchNotify()")
  165. End If
  166. End IF
  167. End Function
  168. '---------------------------------------------------------------------
  169. ' Function: OnPagingNotify()
  170. '
  171. ' Synopsis: Paging notification event handler. This event is triggered in one of
  172. ' the following scenarios:
  173. '
  174. ' 1) The user presses either the page next or page previous buttons
  175. ' 2) The user presses the search Go button.
  176. ' 3) The user requests a table column sort
  177. '
  178. ' The EventArg indicates the source of this notification event which can
  179. ' be either a paging change event (scenario 1) or a post back event
  180. ' (scenarios 2 or 3)
  181. '
  182. ' The iPageCurrent argument indicates which page the user has requested.
  183. ' This is an integer value between iPageMin and iPageMax.
  184. '
  185. ' Returns: Always returns TRUE
  186. '
  187. '---------------------------------------------------------------------
  188. Public Function OnPagingNotify(ByRef PageIn, _
  189. ByRef EventArg, _
  190. ByVal sPageAction, _
  191. ByVal iPageMin, _
  192. ByVal iPageMax, _
  193. ByVal iPageCurrent )
  194. OnPagingNotify = TRUE
  195. g_bPagingInitialized = TRUE
  196. '
  197. ' User pressed either page next or page previous
  198. '
  199. If SA_IsChangeEvent(EventArg) Then
  200. If ( ENABLE_TRACING ) Then
  201. Call SA_TraceOut(SOURCE_FILE, "OnPagingNotify() Change Event Fired")
  202. End If
  203. g_bPageChangeRequested = TRUE
  204. g_sPageAction = CStr(sPageAction)
  205. g_iPageMin = iPageMin
  206. g_iPageMax = iPageMax
  207. g_iPageCurrent = iPageCurrent
  208. '
  209. ' User clicked a column sort OR the search GO button
  210. ElseIf SA_IsPostBackEvent(EventArg) Then
  211. If ( ENABLE_TRACING ) Then
  212. Call SA_TraceOut(SOURCE_FILE, "OnPagingNotify() Postback Event Fired")
  213. End If
  214. g_bPageChangeRequested = FALSE
  215. g_sPageAction = CStr(sPageAction)
  216. g_iPageMin = iPageMin
  217. g_iPageMax = iPageMax
  218. g_iPageCurrent = iPageCurrent
  219. '
  220. ' Unknown event source
  221. Else
  222. If ( ENABLE_TRACING ) Then
  223. Call SA_TraceOut(SOURCE_FILE, "Unrecognized Event in OnPagingNotify()")
  224. End If
  225. End IF
  226. End Function
  227. '---------------------------------------------------------------------
  228. ' Function: OnSortNotify()
  229. '
  230. ' Synopsis: Sorting notification event handler. This event is triggered in one of
  231. ' the following scenarios:
  232. '
  233. ' 1) The user presses the search Go button.
  234. ' 2) The user presses either the page next or page previous buttons
  235. ' 3) The user requests a table column sort
  236. '
  237. ' The EventArg indicates the source of this notification event which can
  238. ' be either a sorting change event (scenario 1) or a post back event
  239. ' (scenarios 2 or 3)
  240. '
  241. ' The sortCol argument indicated which column the user would like to sort
  242. ' and the sortSeq argument indicates the desired sort sequence which can
  243. ' be either ascending or descending.
  244. '
  245. ' Returns: Always returns TRUE
  246. '
  247. '---------------------------------------------------------------------
  248. Public Function OnSortNotify(ByRef PageIn, _
  249. ByRef EventArg, _
  250. ByVal sortCol, _
  251. ByVal sortSeq )
  252. OnSortNotify = TRUE
  253. ' User pressed column sort
  254. If SA_IsChangeEvent(EventArg) Then
  255. Call SA_TraceOut("SOURCE_FILE", "OnSortNotify() Change Event Fired")
  256. g_bSearchChanged=TRUE
  257. g_iSortCol = Int(sortCol)
  258. g_sSortSequence = sortSeq
  259. ' User presed the search GO button OR clicked either the page next or page prev button
  260. ElseIf SA_IsPostBackEvent(EventArg) Then
  261. Call SA_TraceOut("SOURCE_FILE", "OnSortNotify() Postback Event Fired")
  262. g_iSortCol = sortCol
  263. g_bSortRequested = TRUE
  264. ' Unknown event source
  265. Else
  266. Call SA_TraceOut("SOURCE_FILE", "Unrecognized Event in OnSearchNotify()")
  267. End IF
  268. Call SA_TraceOut(SOURCE_FILE, "Sort col: " + CStr(sortCol) + " sequence: " + sortSeq)
  269. End Function
  270. '---------------------------------------------------------------------
  271. ' Function name: getLogsEvents
  272. ' Description: To get events for a log
  273. ' Input Variables: None
  274. ' Output Variables: None
  275. ' Return Values: TRUE to indicate no problems occured. FALSE to indicate errors.
  276. ' Returning FALSE will display error message.
  277. ' Global Variables: L_(*),G_strLogName
  278. 'Called to display events for a log in OTS table.
  279. '---------------------------------------------------------------------
  280. Function getLogsEvents()
  281. Err.Clear
  282. On Error Resume Next
  283. Dim objTableLog 'Object to table
  284. Dim objLognames
  285. Dim strTitle
  286. Dim strLogTitle, strLogName
  287. Dim strQuery, strDate , strTime , objInstances
  288. Dim colFlags
  289. Dim strRecordNumber
  290. Dim intRowCt
  291. Dim intArrIndex
  292. Dim intCount
  293. Dim arrLogs()
  294. Dim strLogType 'Logs type
  295. Dim arrLogType(1)
  296. Dim oEncoder
  297. Set oEncoder = new CSAEncoder
  298. 'This variable is only used to sort the entries this is temporary one As OTS allows only string sort
  299. 'we are making use of numbers to sort as string
  300. Dim strSortKeyNumber
  301. strSortKeyNumber=90000
  302. '
  303. '
  304. Const CONST_SESCURITY = "Security"
  305. intRowCt = 0
  306. intArrIndex = 0
  307. 'Forming the log title
  308. strTitle="?Title=" & G_strLogName
  309. 'To get the title for the log
  310. strLogTitle = Split(F_strevent_title, L_LOG_TXT)
  311. arrLogType(0) = strLogTitle(0)
  312. strLogName =SA_GetLocString("event.dll", "403F0014", arrLogType)
  313. F_strevent_title = strLogName
  314. 'Trying to connect to the server
  315. Set G_objConnection = getWMIConnection(CONST_WMI_WIN32_NAMESPACE) 'Connecting to the server
  316. 'setting the security previleges only in the case of security log
  317. If Lcase(G_strLogName) = Lcase(CONST_SESCURITY) then
  318. 'G_ObjConnection.Security_.Privileges.Add CONST_WBEMPRIVILEGESECURITY 'giving the req privileges
  319. End If
  320. 'Incase connection fails
  321. If Err.number <> 0 then
  322. Call SA_ServeFailurepage (L_FAILEDTOGETWMICONNECTION_ERRORMESSAGE)
  323. getLogsEvents = false
  324. Exit Function
  325. End if
  326. 'Querying to get the events for the log
  327. strQuery ="SELECT * FROM Win32_NTlogEvent WHERE Logfile=" & chr(34) & G_strLogName & chr(34)
  328. Set objLognames = G_objConnection.ExecQuery(strQuery,"WQL",48,null)
  329. For each objInstances in objLognames
  330. redim preserve arrLogs(5, intArrIndex)
  331. 'strDate=Mid(objInstances.TimeGenerated,5,2)& "/" & Mid(objInstances.TimeGenerated,7,2) & "/" & Mid(objInstances.TimeGenerated,1,4)
  332. strDate=Mid(objInstances.TimeGenerated,1,4) & "-" & Mid(objInstances.TimeGenerated,5,2) & "-" & Mid(objInstances.TimeGenerated,7,2)
  333. strTime=Mid(objInstances.TimeGenerated,9,2)& ":" & Mid(objInstances.TimeGenerated,11,2)& ":" & Mid(objInstances.TimeGenerated,13,2)
  334. strRecordNumber = objInstances.RecordNumber
  335. 'Assigning event fields to the array
  336. arrLogs(0,intArrIndex)=strRecordNumber
  337. arrLogs(1,intArrIndex)=objInstances.Type
  338. arrLogs(2,intArrIndex)=FormatDateTime(CDate(strDate),2)
  339. arrLogs(3,intArrIndex)=FormatDateTime(CDate(strTime),3)
  340. arrLogs(4,intArrIndex)=objInstances.sourceName
  341. arrLogs(5,intArrIndex)=objInstances.EventCode
  342. 'If the OS and SAKit languages are different,
  343. 'convert event type string to SAKit language
  344. 'It works only from English to Non-English
  345. 'If OS is not English, just use the string as it is.
  346. Select Case ucase(arrLogs(1,intArrIndex))
  347. case ucase("information")
  348. strLogType = L_INFORMATION_TYPE_TEXT
  349. case ucase("error")
  350. strLogType = L_ERROR_TYPE_TEXT
  351. case ucase("warning")
  352. strLogType = L_WARNING_TYPE_TEXT
  353. case ucase("audit success" )
  354. strLogType = L_SUCCESSAUDIT_TYPE_TEXT
  355. case ucase("audit failure")
  356. strLogType = L_FAILUREAUDIT_TYPE_TEXT
  357. case else
  358. strLogType = arrLogs(1,intArrIndex)
  359. End Select
  360. arrLogs(1,intArrIndex) = strLogType
  361. intArrIndex = intArrIndex + 1
  362. Next
  363. If Err.number <> 0 then
  364. Call SA_ServeFailurepage (L_FAILEDTOGETEVENTS_ERRORMESSAGE)
  365. getLogsEvents = false
  366. Exit Function
  367. End if
  368. 'Create table if events are there in the log
  369. If intArrIndex <> 0 then
  370. 'Create Appliance Log table with 7 coloumns
  371. objTableLog = OTS_CreateTable(F_strevent_title, L_DESCRIPTION_HEADING_TEXT )
  372. Else
  373. 'Description is changed if no events are available in the log
  374. objTableLog = OTS_CreateTable(F_strevent_title, L_DESCRIPTION_PROPERTIES_HEADING_TEXT)
  375. End if
  376. '
  377. ' If the search criteria changed then we need to recompute the paging range
  378. If ( TRUE = g_bSearchChanged ) Then
  379. '
  380. ' Need to recalculate the paging range
  381. g_bPagingInitialized = FALSE
  382. '
  383. ' Restarting on page #1
  384. g_iPageCurrent = 1
  385. End If
  386. '
  387. ' Create columns
  388. colFlags = (OTS_COL_FLAG_HIDDEN OR OTS_COL_SORT OR OTS_COL_KEY)
  389. Call OTS_AddTableColumn(objTableLog, OTS_CreateColumnEx(L_PRIMARY_TEXT,"left",colFlags ,15))
  390. colFlags = (OTS_COL_SEARCH OR OTS_COL_SORT OR OTS_COL_KEY)
  391. Call OTS_AddTableColumn(objTableLog, OTS_CreateColumn(L_TYPE_TEXT, "left", colFlags))
  392. colFlags = (OTS_COL_SEARCH OR OTS_COL_SORT)
  393. Call OTS_AddTableColumn(objTableLog, OTS_CreateColumnEx( L_DATE_TEXT, "left",colFlags,40))
  394. colFlags = (OTS_COL_SEARCH OR OTS_COL_SORT)
  395. Call OTS_AddTableColumn(objTableLog, OTS_CreateColumnEx(L_TIME_TEXT,"left",colFlags,70))
  396. colFlags = (OTS_COL_SEARCH OR OTS_COL_SORT)
  397. Call OTS_AddTableColumn(objTableLog, OTS_CreateColumnEx(L_SOURCE_TEXT, "left",colFlags,100))
  398. colFlags = (OTS_COL_SEARCH OR OTS_COL_SORT)
  399. Call OTS_AddTableColumn(objTableLog, OTS_CreateColumnEx(L_ID_TEXT,"left", colFlags,130))
  400. colFlags = (OTS_COL_FLAG_HIDDEN OR OTS_COL_SORT OR OTS_COL_KEY)
  401. Call OTS_AddTableColumn(objTableLog, OTS_CreateColumnEx(CONST_HIDDEN,"left",colFlags ,15))
  402. ' Set Tasks section title
  403. Call OTS_SetTableTasksTitle(objTableLog, L_TASKS_TEXT)
  404. ' Add the tasks associated with Logs objects
  405. Call OTS_AddTableTask( objTableLog, OTS_CreateTaskEx(L_ITEMDETAILS_TEXT,L_ITEMDETAILS_ROLLOVER_TEXT , "logs/log_details.asp" & strTitle,OTS_PT_AREA,"OTS_TaskAny") )
  406. Call OTS_AddTableTask( objTableLog, OTS_CreateTaskEx(L_DOWNLOAD_TEXT,L_DOWNLOAD_ROLLOVER_TEXT , "logs/log_download.asp" & strTitle, OTS_PT_AREA, "OTS_TaskAny") )
  407. Call OTS_AddTableTask( objTableLog, OTS_CreateTaskEx(L_PROPERTIES_TEXT,L_PROPERTIES_ROLLOVER_TEXT , "logs/log_prop.asp" & strTitle,OTS_PT_PROPERTY,"OTS_TaskAlways") )
  408. Call OTS_AddTableTask( objTableLog, OTS_CreateTaskEx(L_CLEAR_TEXT,L_CLEAR_ROLLOVER_TEXT , "logs/log_clear.asp" & strTitle,OTS_PT_PROPERTY,"OTS_TaskAny") )
  409. 'Adding items to the OTS table
  410. For intCount = 0 to intArrIndex-1
  411. 'This variable is only used to sort the entries this is temporary one As OTS allows only string sort
  412. 'we are making use of numbers to sort as string
  413. strSortKeyNumber = strSortKeyNumber - 1
  414. '
  415. '
  416. If ( Len( g_sSearchColValue ) <= 0 ) Then
  417. ' Search criteria blank, select all rows
  418. intRowCt=intRowCt+1
  419. ' Verify that the current user part of the current page
  420. If ( IsItemOnPage( intRowCt, g_iPageCurrent, NOOFRECORDS) ) Then
  421. Call OTS_AddTableRow( objTableLog, Array( arrLogs(0,intCount) ,arrLogs(1,intCount) ,arrLogs(2,intCount) ,arrLogs(3,intCount) ,arrLogs(4,intCount),arrLogs(5,intCount),strSortKeyNumber ) )
  422. End If
  423. Else
  424. ' Check the Search criteria
  425. Select Case (g_iSearchCol)
  426. Case TYPE_COLUMN
  427. If ( InStr(1, arrLogs(1,intCount), g_sSearchColValue, 1) ) Then
  428. intRowCt=intRowCt+1
  429. ' Verify that the current event part of the current page
  430. If ( IsItemOnPage( intRowCt, g_iPageCurrent, NOOFRECORDS) ) Then
  431. Call OTS_AddTableRow( objTableLog, Array( arrLogs(0,intCount) ,arrLogs(1,intCount) ,arrLogs(2,intCount) ,arrLogs(3,intCount) ,arrLogs(4,intCount),arrLogs(5,intCount),strSortKeyNumber ) )
  432. End If
  433. End If
  434. Case DATE_COLUMN
  435. If ( InStr(1, arrLogs(2,intCount), g_sSearchColValue, 1) ) Then
  436. intRowCt=intRowCt+1
  437. If ( IsItemOnPage( intRowCt, g_iPageCurrent, NOOFRECORDS) ) Then
  438. Call OTS_AddTableRow( objTableLog,Array( arrLogs(0,intCount) ,arrLogs(1,intCount) ,arrLogs(2,intCount) ,arrLogs(3,intCount) ,arrLogs(4,intCount),arrLogs(5,intCount),strSortKeyNumber ) )
  439. End if
  440. End If
  441. Case TIME_COLUMN
  442. If ( InStr(1, arrLogs(3,intCount), g_sSearchColValue, 1) ) Then
  443. intRowCt=intRowCt+1
  444. If ( IsItemOnPage( intRowCt, g_iPageCurrent, NOOFRECORDS) ) Then
  445. Call OTS_AddTableRow( objTableLog, Array( arrLogs(0,intCount) ,arrLogs(1,intCount) ,arrLogs(2,intCount) ,arrLogs(3,intCount) ,arrLogs(4,intCount),arrLogs(5,intCount),strSortKeyNumber ) )
  446. End if
  447. End If
  448. Case SOURCE_COLUMN
  449. If ( InStr(1, arrLogs(4,intCount), g_sSearchColValue, 1) ) Then
  450. intRowCt=intRowCt+1
  451. If ( IsItemOnPage( intRowCt, g_iPageCurrent, NOOFRECORDS) ) Then
  452. Call OTS_AddTableRow( objTableLog, Array( arrLogs(0,intCount) ,arrLogs(1,intCount) ,arrLogs(2,intCount) ,arrLogs(3,intCount) ,arrLogs(4,intCount),arrLogs(5,intCount),strSortKeyNumber ) )
  453. End if
  454. End If
  455. Case EVENT_COLUMN
  456. If ( InStr(1, arrLogs(5,intCount), g_sSearchColValue, 1) ) Then
  457. intRowCt=intRowCt+1
  458. If ( IsItemOnPage( intRowCt, g_iPageCurrent, NOOFRECORDS) ) Then
  459. Call OTS_AddTableRow( objTableLog, Array( arrLogs(0,intCount) ,arrLogs(1,intCount) ,arrLogs(2,intCount) ,arrLogs(3,intCount) ,arrLogs(4,intCount),arrLogs(5,intCount),strSortKeyNumber ) )
  460. End if
  461. End If
  462. Case Else
  463. Call SA_TraceOut(SOURCE_FILE, "Unrecognized search column: " + CStr(g_iSearchCol))
  464. intRowCt=intRowCt+1
  465. If ( IsItemOnPage( intRowCt, g_iPageCurrent, NOOFRECORDS) ) Then
  466. Call OTS_AddTableRow( objTableLog, Array( arrLogs(0,intCount) ,arrLogs(1,intCount) ,arrLogs(2,intCount) ,arrLogs(3,intCount) ,arrLogs(4,intCount),arrLogs(5,intCount),strSortKeyNumber ) )
  467. End if
  468. End Select
  469. End If
  470. Next
  471. ' Enable paging feature
  472. Call OTS_EnablePaging(objTableLog, true)
  473. If ( ENABLE_TRACING ) Then
  474. Call SA_TraceOut(SOURCE_FILE, "Total records: " + CStr(intArrIndex))
  475. End If
  476. '
  477. ' If paging range needs to be initialised then
  478. ' we need to figure out how many pages we are going to display
  479. If ( FALSE = g_bPagingInitialized ) Then
  480. g_iPageMin = 1
  481. g_iPageMax = Int(intRowCt / NOOFRECORDS )
  482. If ( (intRowCt MOD NOOFRECORDS) > 0 ) Then
  483. g_iPageMax = g_iPageMax + 1
  484. End If
  485. g_iPageCurrent = 1
  486. Call OTS_SetPagingRange( objTableLog, g_iPageMin, g_iPageMax, g_iPageCurrent)
  487. End If
  488. '
  489. ' Sort the table
  490. '
  491. Call OTS_SortTable(objTableLog, g_iSortCol, g_sSortSequence, SA_RESERVED)
  492. ' Send table to the response stream
  493. '
  494. Call OTS_ServeTable(objTableLog)
  495. 'Display msg if no events are there in log
  496. If intRowCt = 0 then
  497. Response.write "<br>" & oEncoder.EncodeElement(L_NOEVENTSAVAILABLE_TEXT) & "<br>"
  498. End if
  499. 'Set to nothing
  500. Set objInstances = Nothing
  501. Set objLognames=Nothing
  502. getLogsEvents = True
  503. End Function
  504. '-------------------------------------------------------------------------
  505. ' Function name: getWMILogFileName
  506. ' Description: returns WMI Log File name
  507. ' Input Variables: strTitle - Title or caption of the log
  508. ' Output Variables: None
  509. ' Return Values: Returns WMI Log File name
  510. ' Global Variables: None
  511. ' Return the WMI LogFile name. If the Title is not found Returns null
  512. '-------------------------------------------------------------------------
  513. Function getWMILogFileName(strTitle)
  514. Err.Clear
  515. On Error Resume Next
  516. const strDNS = "DNS Server"
  517. const strApplication = "Application"
  518. const strSecurity = "Security"
  519. const strSystem = "System"
  520. 'To get the Log name
  521. select case strTitle
  522. case "ApplicationLog"
  523. getWMILogFileName = strApplication
  524. case "SystemLog"
  525. getWMILogFileName = strSystem
  526. case "SecurityLog"
  527. getWMILogFileName = strSecurity
  528. case "DnsLog"
  529. getWMILogFileName = strDNS
  530. case else
  531. getWMILogFileName = ""
  532. end select
  533. End Function
  534. '-------------------------------------------------------------------------
  535. ' Function name: IsItemOnPage
  536. ' Description: Search for the item on page
  537. ' Input Variables: iCurrentItem, iCurrentPage, iItemsPerPage
  538. ' Output Variables: None
  539. ' Return Values: True/False
  540. ' Global Variables: None
  541. '-------------------------------------------------------------------------
  542. Private Function IsItemOnPage(ByVal iCurrentItem, iCurrentPage, iItemsPerPage)
  543. Dim iLowerLimit
  544. Dim iUpperLimit
  545. iLowerLimit = ((iCurrentPage - 1) * iItemsPerPage )
  546. iUpperLimit = iLowerLimit + iItemsPerPage + 1
  547. If ( iCurrentItem > iLowerLimit AND iCurrentItem < iUpperLimit ) Then
  548. IsItemOnPage = TRUE
  549. Else
  550. IsItemOnPage = FALSE
  551. End If
  552. End Function
  553. %>