Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Compare Database
- Option Explicit
- Public Sub OpenQueryWW(sQuery As String)
- With DoCmd
- .SetWarnings False
- .OpenQuery sQuery
- .SetWarnings True
- End With
- End Sub
- Public Sub RunSQLWW(sSQL As String)
- With DoCmd
- .SetWarnings False
- .RunSQL sSQL
- .SetWarnings True
- End With
- End Sub
- Public Sub ScanFiles(bAutoDeleteDebugFiles As Long)
- Dim oFSO As New Scripting.FileSystemObject
- Dim oFolder As Scripting.Folder
- Dim sUserPath As String
- Dim sError As String
- Dim iFileFounds As Integer
- sUserPath = "C:\Users\" & Environ("USERNAME") & "\"
- If Not oFSO.FolderExists(sUserPath) Then
- Form_frmMain.UpdateStatus "User path " & sUserPath & " was not found"
- GoTo exit_sub
- Else
- Set oFolder = oFSO.GetFolder(sUserPath)
- iFileFounds = ReadData(oFolder, bAutoDeleteDebugFiles)
- End If
- If iFileFounds = 0 Then
- Form_frmMain.UpdateStatus "No debug files were found, make sure debug is enabled in Fightcade"
- GoTo exit_sub
- Else
- Form_frmMain.UpdateStatus "Idle - Last Scan " & Format(Hour(Time), "00") & ":" & Format(Minute(Time), "00") & ":" & Format(Second(Time), "00")
- End If
- exit_sub:
- Set oFSO = Nothing
- Set oFolder = Nothing
- End Sub
- Private Function scanIP(sArray() As String, iArrayPos, oRS As DAO.Recordset)
- Dim oRegEx As New RegExp
- Dim sPattern As String
- Dim sIP As String
- Dim m
- Dim iCursor As Integer
- Set oRegEx = Nothing
- sPattern = "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"
- oRegEx.Pattern = sPattern
- oRegEx.Global = False
- oRegEx.IgnoreCase = True
- For Each m In oRegEx.Execute(sArray(iArrayPos))
- On Error Resume Next
- With oRS
- iCursor = 1
- While sArray(iArrayPos - iCursor) <> "x17y" And sArray(iArrayPos - iCursor) <> "x17x" And sArray(iArrayPos - iCursor) <> "x17z" And sArray(iArrayPos - iCursor) <> "x17w" And sArray(iArrayPos - iCursor) <> "x17v"
- iCursor = iCursor + 1
- Wend
- .AddNew
- .Fields("IPAddress") = sArray(iArrayPos)
- Select Case sArray(iArrayPos - iCursor + 1)
- Case "x01", "x02", "x03", "x04", "x05", "x06", "x07", "x08", "x09"
- .Fields("Username") = sArray(iArrayPos - iCursor + 2)
- Case Else
- .Fields("Username") = sArray(iArrayPos - iCursor + 1)
- End Select
- .Fields("Country") = sArray(iArrayPos + 2)
- .Update
- End With
- Next
- End Function
- Public Function ReadData(oFolder As Scripting.Folder, bAutoDeleteDebugFiles As Long) As Integer
- Dim sTempFile As String
- Dim sTempFile2 As String
- Dim sLine As String
- Dim sArrayData() As String
- Dim oRS As DAO.Recordset
- Dim oFile As Scripting.File
- Dim oFSO As New Scripting.FileSystemObject
- Dim oStream As Scripting.TextStream
- Dim oStream2 As Scripting.TextStream
- Dim i As Long
- Dim j As Long
- Dim iPos As Integer
- Dim iFileFounds As Integer
- RunSQLWW "delete * from t_log_temp"
- Set oRS = CurrentDb.OpenRecordset("select * from t_log_temp")
- sTempFile = Application.CurrentProject.Path & "\TempData.txt"
- sTempFile2 = Application.CurrentProject.Path & "\TempData2.txt"
- If oFSO.FileExists(sTempFile2) Then oFSO.DeleteFile (sTempFile2)
- For Each oFile In oFolder.Files
- If Left(oFile.Name, 15) = "fightcade-debug" And InStr(1, oFile.Name, ".log") > 0 Then
- If CDate(oFile.DateLastModified) >= Date Then
- Form_frmMain.UpdateStatus "Reading " & oFile.Name
- Set oStream2 = oFSO.OpenTextFile(sTempFile2, ForAppending, True)
- If oFSO.FileExists(sTempFile) Then oFSO.DeleteFile (sTempFile)
- oFSO.CopyFile oFile.Path, sTempFile, True
- Set oStream = oFSO.OpenTextFile(sTempFile, ForReading, False)
- While Not oStream.AtEndOfStream
- sLine = oStream.ReadLine
- If Left(sLine, 12) = "Dispatch SEQ" And Not InStr(1, sLine, "Marvel vs Capcom - clash of super heroes") > 0 And Not InStr(1, sLine, "Welcome to FightCade") > 0 And Len(sLine) > 45 Then
- oStream2.WriteLine Replace(sLine, "\x00", "")
- End If
- Wend
- iFileFounds = iFileFounds + 1
- oStream.Close
- oStream2.Close
- End If
- End If
- Next oFile
- If iFileFounds = 0 Then GoTo exit_function
- Set oStream2 = oFSO.OpenTextFile(sTempFile2, ForReading, False)
- j = 0
- While Not oStream2.AtEndOfStream
- sLine = oStream2.ReadLine
- If Left(sLine, 12) = "Dispatch SEQ" Then
- Form_frmMain.UpdateStatus "Fetching data to temp log - " & j
- iPos = InStr(1, sLine, "'") + 1
- If Mid(sLine, iPos, 1) <> "\" Then
- sLine = Left(sLine, iPos - 1) & "\x17y" & Mid(sLine, iPos + 1, Len(sLine))
- End If
- sArrayData = Split(sLine, "\")
- sArrayData(1) = "x17y"
- For i = 0 To UBound(sArrayData)
- If sArrayData(i) = "x01" Or sArrayData(i) = "x02" Or sArrayData(i) = "x17y" Or sArrayData(i) = "x17x" Or sArrayData(i) = "x03" _
- Or sArrayData(i) = "x04" Or sArrayData(i) = "x05" Or sArrayData(i) = "x06" Or sArrayData(i) = "x07" Or sArrayData(i) = "x08" Or sArrayData(i) = "x09" _
- Or sArrayData(i) = "x17z" Or sArrayData(i) = "x17v" Or sArrayData(i) = "x17w" _
- Then
- 'leave as is
- ElseIf Left(sArrayData(i), 1) = "x" Then
- sArrayData(i) = Mid(sArrayData(i), 4, 255)
- Else
- sArrayData(i) = Mid(sArrayData(i), 2, 255)
- End If
- Next i
- j = j + 1
- For i = 0 To UBound(sArrayData)
- scanIP sArrayData, i, oRS
- Next i
- End If
- Wend
- OpenQueryWW "qry001AddLog"
- oStream2.Close
- exit_function:
- oRS.Close
- Set oStream = Nothing
- Set oStream2 = Nothing
- Set oFSO = Nothing
- ReadData = iFileFounds
- On Error Resume Next
- If bAutoDeleteDebugFiles = -1 Then
- For Each oFile In oFolder.Files
- If Left(oFile.Name, 15) = "fightcade-debug" And InStr(1, oFile.Name, ".log") > 0 Then
- oFile.Delete
- End If
- Next oFile
- End If
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement