'******************************************
'**** Banned IP's *****
'******************************************
Private Function bannedIP()
'Declare variables
Dim rsIPAddr
Dim strCheckIPAddress
Dim strUserIPAddress
Dim blnIPMatched
'Intilise variable
blnIPMatched = False
'Get the users IP
strUserIPAddress = getIP()
'Intialise the ADO recordset object
Set rsIPAddr = Server.CreateObject("ADODB.Recordset")
'Get any banned IP address from the database
'Initalise the strSQL variable with an SQL statement to query the database to count the number of topics in the forums
If strDatabaseType = "SQLServer" Then
strSQL = "EXECUTE " & strDbProc & "BannedIPs"
Else
strSQL = "SELECT " & strDbTable & "BanList.IP FROM " & strDbTable & "BanList WHERE " & strDbTable & "BanList.IP Is Not Null;"
End If
'Query the database
rsIPAddr.Open strSQL, adoCon
'Loop through the IP address and check 'em out
Do while NOT rsIPAddr.EOF and NOT blnIPMatched
'Get the IP address to check from the recordset
strCheckIPAddress = rsIPAddr("IP")
'See if we need to check the IP range or just one IP address
'If the last character is a * then this is a wildcard range to be checked
If Right(strCheckIPAddress, 1) = "*" Then
'Remove the wildcard charcter form the IP
strCheckIPAddress = Replace(strCheckIPAddress, "*", "", 1, -1, 1)
'See if whats left of the IP matches
If strCheckIPAddress = Mid(strUserIPAddress, 1, Len(strCheckIPAddress)) Then blnIPMatched = True
'Else check the IP address metches
Else
'Else check to see if the IP address match
If strCheckIPAddress = strUserIPAddress Then blnIPMatched = True
End If
'Move to the next record
rsIPAddr.MoveNext
Loop
'Clean up
rsIPAddr.Close
Set rsIPAddr = Nothing
'Return the function
bannedIP = blnIPMatched
End Function
|