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.

235 lines
7.0 KiB

  1. <%
  2. Dim Today
  3. Dim iDefMon, iDefDay, iDefYear
  4. Dim i
  5. Dim strFileName
  6. Dim strResult
  7. iDefMon = Month (Now)
  8. iDefDay = Day (Now)
  9. iDefYear = Year (Now)
  10. If Request ("Month") <> "" Then
  11. iDefMon = CInt (Request ("Month"))
  12. End If
  13. If Request ("Day") <> "" Then
  14. iDefDay = CInt (Request ("Day"))
  15. End If
  16. If Request ("Year") <> "" Then
  17. iDefYear = CInt (Request ("Year"))
  18. End If
  19. strFileName = "ex" & Right (CStr (iDefYear), 2) & _
  20. Right ("0" & CStr (iDefMon), 2) & _
  21. Right ("0" & CStr (iDefDay), 2) & ".log"
  22. %>
  23. <html>
  24. <head>
  25. <title>Log File Summary for Everest Project</title>
  26. </head>
  27. <body text="#0000FF">
  28. <h1><center><font face="Arial">Log File Summary for Everest Project</font></h1></center>
  29. <p><font face="Arial">This web page is designed to view the summary of the internet log
  30. files. Please select the date of the log file and click on the submit button.</font></p>
  31. <center>
  32. <form method="POST" action="iislog.asp">
  33. <font face="Arial">
  34. Month
  35. <select name="Month" size="1">
  36. <% For i = 1 to 12
  37. If i = iDefMon Then
  38. Response.Write ("<option selected>" & i & "</option>")
  39. Else
  40. Response.Write ("<option>" & i & "</option>")
  41. End If
  42. Next%> </select> Day <select name="Day" size="1">
  43. <%
  44. For i = 1 to 31
  45. If i = iDefDay Then
  46. Response.Write ("<option selected>" & i & "</option>")
  47. Else
  48. Response.Write ("<option>" & i & "</option>")
  49. End If
  50. Next%> </select> Year <select name="Year" size="1">
  51. <% For i = iDefYear - 1 to iDefYear + 1
  52. If i = iDefYear Then
  53. Response.Write ("<option selected>" & i & "</option>")
  54. Else
  55. Response.Write ("<option>" & i & "</option>")
  56. End If
  57. Next%> </select> <input type="submit" value="Submit" name="B1"> </font></p>
  58. </form>
  59. <Script Runat=server Language="Vbscript">
  60. Function ProcessFile (strFileName)
  61. 'On Error Resume Next
  62. End Function
  63. Function GetOneTokenFromString(SrcString)
  64. Dim OneToken
  65. Dim Pos
  66. Pos = InStr(SrcString, " ")
  67. If (Pos > 0) Then
  68. OneToken = Left(SrcString, Pos - 1)
  69. SrcString = Mid(SrcString, Pos + 1)
  70. GetOneTokenFromString = OneToken
  71. Else
  72. GetOneTokenFromString = SrcString
  73. SrcString = ""
  74. End If
  75. End Function
  76. Sub ProcessFile(strFileName, TotalAspHits, TotalPPHits, TotalPPBytesRcved, AvgAspTime, AvgPPTime)
  77. On Error Resume Next
  78. Dim OneLine
  79. Dim OneToken
  80. Dim ByteRcved
  81. Dim ByteSent
  82. Dim TimeProcessed
  83. Dim AspTimeProcessed
  84. Dim RecvBytesIndex, TimeIndex, UrlIndex
  85. Dim I
  86. Dim bAsp
  87. Dim bPrinter
  88. Dim strDir
  89. Dim strLine
  90. Const strPrinter = "/.printer"
  91. Const strPrns = "/printers"
  92. Const strAsp = ".asp"
  93. Const strLog = "iislog.asp"
  94. strDir = Server.MapPath ("/iislogs/W3SVC1/" & strFileName)
  95. Set objFSO = CreateObject ("Scripting.FileSystemObject")
  96. Set objLogFile = objFSO.OpenTextFile (strDir)
  97. If Err Then
  98. Exit Sub
  99. End If
  100. TotalAspHits = 0
  101. TotalPPHits = 0
  102. ByteRcved = 0
  103. ByteSent = 0
  104. TimeProcessed = 0
  105. AspTimeProcessed = 0
  106. Do While Not objLogFile.AtEndOfStream
  107. OneLine = objLogFile.ReadLine
  108. If Left(OneLine, 1) = "#" Then
  109. If Left(OneLine, 8) = "#Fields:" Then
  110. OneToken = GetOneTokenFromString(OneLine)
  111. I = 0
  112. Do While OneToken <> ""
  113. OneToken = GetOneTokenFromString(OneLine)
  114. Select Case OneToken
  115. Case "cs-uri-stem"
  116. UrlIndex = I
  117. Case "cs-bytes"
  118. RecvBytesIndex = I
  119. Case "time-taken"
  120. TimeIndex = I
  121. Case Else
  122. End Select
  123. I = I + 1
  124. Loop
  125. End If
  126. Else
  127. I = 0
  128. bAsp = False
  129. bPrinter = False
  130. Do While I = 0 Or OneToken <> ""
  131. OneToken = GetOneTokenFromString(OneLine)
  132. 'Response.Write ("<br>" & OneToken)
  133. If I = UrlIndex Then
  134. 'Process the URL
  135. If Right(OneToken, Len(strPrinter)) = strPrinter Then
  136. bPrinter = True
  137. TotalPPHits = TotalPPHits + 1
  138. ElseIf Left(OneToken, Len(strPrns)) = strPrns And Right(OneToken, Len(strLog)) <> strLog Then 'And Right(OneToken, Len(strAsp)) = strAsp Then
  139. 'Response.Write ("<br>TotalAsp" )
  140. bAsp = True
  141. TotalAspHits = TotalAspHits + 1
  142. End If
  143. End If
  144. If bAsp Then
  145. If I = TimeIndex Then
  146. AspTimeProcessed = AspTimeProcessed + OneToken
  147. End If
  148. End If
  149. If bPrinter Then
  150. If I = RecvBytesIndex Then
  151. ByteRcved = ByteRcved + OneToken
  152. End If
  153. If I = TimeIndex Then
  154. TimeProcessed = TimeProcessed + OneToken
  155. End If
  156. End If
  157. I = I + 1
  158. Loop
  159. End If
  160. Loop
  161. objLogFile.Close
  162. If TotalAspHits > 0 Then
  163. AvgAspTime = AspTimeProcessed / TotalAspHits
  164. End If
  165. If ByteRcved > 0 Then
  166. AvgPPTime = TimeProcessed / ByteRcved
  167. End If
  168. TotalPPBytesRcved = ByteRcved
  169. End Sub
  170. </script>
  171. <%
  172. 'strFileName = "ex980210.log"
  173. 'Response.Write ("File name is <b>" & strFileName &"</b><br>")
  174. On Error Resume Next
  175. Call ProcessFile (strFileName, TotalAspHits, TotalPPHits, TotalPPBytesRcved, AvgAspTime, AvgPPTime)
  176. If Err Then
  177. strResult = "<b>The requested log file does not exist.</b>"
  178. Else
  179. strEol = "<br>"
  180. strBgnCol = "<tr><td width = 300>"
  181. strMidCol = "</td><td>"
  182. strEndCol = "</td><tr>"
  183. strResult = "<h2>Server Name - " & Request.Servervariables ("SERVER_NAME") & "</h2>"
  184. strResult = strResult & "<table><th colspan=2><b>Summary of Everest ASP Pages</b></th>"
  185. strResult = strResult & strBgnCol &"Total Hits" & strMidCol &TotalAspHits & strEndCol
  186. strResult = strResult & strBgnCol &"Average Processing Time (Msec/Hit) " & strMidCol & formatnumber(AvgAspTime, 1)& strEndCol
  187. strResult = strResult & "</table>"
  188. strResult = strResult & "<br><br><table><th colspan=2><b>Summary of Everest ISAPI</b></th>"
  189. strResult = strResult & strBgnCol &"Total Hits (AddPrinter + Printing)" & strMidCol & TotalPPHits & strEndCol
  190. strResult = strResult & strBgnCol &"Total Bytes" & strMidCol &TotalPPBytesRcved & strEndCol
  191. strResult = strResult & strBgnCol &"Average Processing Time (Sec/Kb) " & strMidCol &formatnumber(AvgPPTime,1) & strEndCol
  192. strResult = strResult & "</table>"
  193. End If
  194. %>
  195. <% =strResult%>
  196. <hr>
  197. Send comment to <a href="mailto:[email protected]">Weihai Chen</a>
  198. </center>
  199. </body>
  200. </html>