Web Wiz - Green Windows Web Hosting - Celebrating 25 Years!

  New Posts New Posts RSS Feed - IP Banning issues
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

IP Banning issues

 Post Reply Post Reply Page  <12
Author
sfd19 View Drop Down
Senior Member
Senior Member


Joined: 20 December 2004
Status: Offline
Points: 263
Post Options Post Options   Thanks (0) Thanks(0)   Quote sfd19 Quote  Post ReplyReply Direct Link To This Post Posted: 22 January 2005 at 9:33am
You can also change these lines:
 
'Trim the users IP to the same length as the IP range to check
        strUserIPAddress = Mid(strUserIPAddress, 1, Len(strCheckIPAddress))
       'See if whats left of the IP matches
       If strCheckIPAddress = strUserIPAddress Then blnIPMatched = True
 
to:
 
If strCheckIPAddress = Mid(strUserIPAddress, 1, Len(strCheckIPAddress)) Then blnIPMatched = True
 
then you do not have to call the getIP() function each time.
 
 
Also, changing
 
Do while NOT rsIPAddr.EOF
 
to
 
Do while NOT rsIPAddr.EOF AND blnIPMatched = False
 
will exit the loop as soon as the IP matches a banned one.
Politics, economy & social issues: StudentsforDemocracy.net
Back to Top
jonahex2099 View Drop Down
Newbie
Newbie
Avatar

Joined: 09 April 2004
Location: United States
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote jonahex2099 Quote  Post ReplyReply Direct Link To This Post Posted: 25 January 2005 at 1:35pm
I've taken to blocking them at the website level AND at the firewall.  Little more work, AND it keeps them from accessing our main site, but at least they're not causing me forum problems anymore.  I'll try the fix above tho....
Back to Top
arthurk View Drop Down
Newbie
Newbie


Joined: 31 December 2004
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote arthurk Quote  Post ReplyReply Direct Link To This Post Posted: 15 February 2005 at 2:23pm
well theres an easier way
make a global.asa file like below in your web root
 
use the code below
 
edit Sub Session_OnStart()
put the ip addy(s) in place of the ones shown
redirect him to where you want him to go
remove the rest of the gubbins you dont want or leave it as is :P
 

<object runat="Server" scope="Application"
id="rstActiveUsers" progid="ADODB.Recordset">
</object>
<script language="VBScript" runat="Server">
' The first thing you should notice is the top line.
' It creates an application scoped recordset object
' named rstActiveUsers that I'll use to store all
' our user information.
'
' Note: I've wrapped it for readability
Sub Application_OnStart()
 ' Selected constants from adovbs.inc
 Const adInteger = 3
 Const adVarChar = 200
 Const adDate = 7
 
 ' Here I set up in memory active user recordset
 ' by adding the fields I want to it and defining
 ' their data types.
 
 rstActiveUsers.Fields.Append "id", adInteger
 rstActiveUsers.Fields.Append "ip", adVarChar, 15
 rstActiveUsers.Fields.Append "browser", adVarChar, 255
rstActiveUsers.Fields.Append "user", adVarChar, 50
 rstActiveUsers.Fields.Append "started", adDate
 ' Next I open our recordset so that we can use it.
 ' That basically gets everything ready for our
 ' first user.
 rstActiveUsers.Open
End Sub
Sub Session_OnStart()
 ' Set session timeout to 20 minutes
 Session.Timeout = 20
 if Request.ServerVariables("REMOTE_HOST") = "65.214.38.211" then
 response.redirect "robot.html"
 end if
 if Request.ServerVariables("REMOTE_HOST") = "207.46.98.139" then
 response.redirect "robot.html"
 end if
 if Request.ServerVariables("REMOTE_HOST") = "64.124.85.194" then
 response.redirect "robot.html"
 end if
 if Request.ServerVariables("REMOTE_HOST") = "64.124.85.97" then
 response.redirect "robot.html"
 end if
 
 
 ' Set a session start time.  This is pretty pointless,
 ' but it does ensure that we start a session and
 ' assign the user a session id and it can help
 ' troubleshooting if we ever need it.
 Session("Start") = Now()
 
 ' Move to the end so records are added in order.
 ' Again not of any real importance, but it keeps our
 ' user table nice and orderly.
 If Not rstActiveUsers.EOF Then rstActiveUsers.MoveLast
 ' Add a record and insert users data.  I'm just
 ' storing some basic info, but naturally you're free
 ' to store whatever you want.
 rstActiveUsers.AddNew
 
 rstActiveUsers.Fields("id").Value = _
  Session.SessionID
 
 rstActiveUsers.Fields("ip").Value = _
  Request.ServerVariables("REMOTE_HOST")
 
 rstActiveUsers.Fields("browser").Value = _
  Request.ServerVariables("HTTP_USER_AGENT")
username = Request.Cookies("user")("mynameis")
if username = "" then username = "Guest"
rstActiveUsers.Fields("user").Value = username
 
 rstActiveUsers.Fields("started").Value = _
  Now()
 
 rstActiveUsers.Update
 
 ' Now that we've got the information, all that's
 ' left is to display it.  See test_page.asp for a
 ' demo.  It includes the pages show_count.asp and
 ' show_users.asp which can also be used
 ' individually if desired.
End Sub
Sub Session_OnEnd()
 ' Selected constants from adovbs.inc
 Const adSearchForward = 1
 Const adBookmarkFirst = 1
 Const adAffectCurrent = 1
 ' Find the appropriate record.  Using session id is the
 ' easiest way since I use this as the primary key.
 ' This line positions us on the appropriate record.
 rstActiveUsers.Find "id = " & Session.SessionID, _
  0, adSearchForward, adBookmarkFirst
 
 ' Now that we're on the record, delete it.
 ' I use the EOF to make sure we've got one.
 If Not rstActiveUsers.EOF Then
  rstActiveUsers.Delete adAffectCurrent
 End If
End Sub
Sub Application_OnEnd()
 ' Not like it really matters, but for the sake of
 ' good coding practice I close the recordset when
 ' our application is shutting down.
 rstActiveUsers.Close
End Sub
</script>
Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.