Blocking Spammers - Posted (1025 Views)
Starting Member
youngboy
Posts: 1
1
Many spammers are from country's not from your location. We have a .NET page that sits in front of our default page that when you click the forum hyperlink from the menu tests where they are coming from and shows them a message or redirects them to the forum. In the page load event:

Code:


Imports System.Net
Imports WorldDomination.Net


Dim dottedip As String = Request.UserHostAddress.ToString
Dim Dot2LongIP As Double
Dim PrevPos As Double
Dim pos As Double
Dim num As Double


For i = 1 To 4
pos = InStr(PrevPos + 1, dottedip, ".", 1)
If i = 4 Then
pos = Len(dottedip) + 1
End If
num = Int(Mid(dottedip, PrevPos + 1, pos - PrevPos - 1))
PrevPos = pos
Dot2LongIP = ((num Mod 256) * (256 ^ (4 - i))) + Dot2LongIP
Next

Dim ipAddress As IPAddress = New IPAddress(Dot2LongIP)
Dim country As String = ipAddress.Country
Dim iso3166TwoLetterCode As String = ipAddress.Iso3166TwoLetterCode

If iso3166TwoLetterCode.ToString.Trim.ToUpper = "US" Then
Response.Redirect("~/forum/default.asp")
End If


It's not perfect but it sure helps. We are based in the US and only expect US visitors. If you get people from outside the US then modify it appropriately.
Hope this helps.
Regards;
Dave
http://www.nbizmag.com

You'll need this binary:

http://ipaddressextensions.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=11046
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Forum Admin
HuwR
Posts: 20611
20611
we already have plenty of very satisfactory ways of preventing spammers without blocking entire nations from accessing our site, the web is global it is not meant to be limited to a particular country.
oh and ipaddresses are not a fool proof method of determining location either