Hope BS (haha) doesn't mind, here's that script's code (v.3 ):
Code: Select all
Option Explicit
Dim LogAtpt, LogSucc
' ---------------------------
Sub Main
' ---------------------------
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(".\ConnectLogs") Then fso.CreateFolder(".\ConnectLogs")
LogAtpt = 1 ' **** (Connection Attempts Loging / 1=Enable / 0=Disable)
LogSucc = 1 ' **** (Connection Successful Loging / 1=Enable / 0=Disable)
End Sub
' ---------------------------
Sub AttemptedConnection (RemoteHostIP)
' ---------------------------
If LogAtpt = 0 Then Exit Sub
Call WriteLog("Attempt from " &RemoteHostIP)
End Sub
' ---------------------------
Sub NewUserConnected (curUser)
' ---------------------------
If LogSucc = 0 Then Exit Sub
Call WriteLog("Success from " &curUser.IP() &" as user " &curUser.sName)
End Sub
' ---------------------------
Sub OpConnected (curUser)
' ---------------------------
' *** This event is fired when a registered user logs in (not necessarily an OP)
If LogSucc = 0 Then Exit Sub
If Not curUser.bOperator Then Call NewUserConnected(curUser) : Exit Sub
Call WriteLog("Success from " &curUser.IP() &" as OP " &curUser.sName)
End Sub
' ---------------------------
Sub WriteLog(sEntry)
' ---------------------------
Dim fso, objLogFile
Dim sFileName
Set fso = CreateObject("Scripting.FileSystemObject")
sFileName = ".\ConnectLogs\" &Year(Date)
If Month(Date) > 9 Then
sFileName = sFileName &Month(Date)
Else
sFileName = sFileName &"0" &Month(Date)
End If
If Day(Date) > 9 Then
sFileName = sFileName &Day(Date) &".log"
Else
sFileName = sFileName &"0" &Day(Date) &".log"
End If
frmHub.DoEventsForMe
Set objLogFile = fso.OpenTextFile(sFileName, 8, True)
With objLogFile
.WriteLine Time & " : " &sEntry
.Close
End With
End Sub
Thanks a bunch.
styler