Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Blocking access to website
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic ClosedBlocking access to website

 Post Reply Post Reply
Author
cfaulk View Drop Down
Newbie
Newbie


Joined: 26 September 2003
Status: Offline
Points: 1
Direct Link To This Post Topic: Blocking access to website
    Posted: 26 September 2003 at 8:08am
How do I block certain IP addresses from accessing my website?
Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Direct Link To This Post Posted: 26 September 2003 at 8:24am
See this thread for an example: http://forums.webwiz.net/forum_posts.asp?TID=4967
Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Direct Link To This Post Posted: 29 September 2003 at 10:36pm
Anyone has a formula to ban IP ranges?, not like 192.168.1.* but like 192.168.1.1-192.168.231.255...... I gotta make one and that kind of stuff gives me headaches..
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Direct Link To This Post Posted: 30 September 2003 at 9:27am

192.168.1.1 to
192.168.231.255 huh?

ill post in a sec a lil code for ya

 

Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Direct Link To This Post Posted: 30 September 2003 at 9:43am

ITs pretty crude, and also only works if the IP address has four sections each 3 digits long, so its a got structure to build up on:


<%
  Dim strMaxRange 'Upper bound IP blocking range
  Dim strMinRange 'Lower bound IP blocking range
  Dim intLoop 'Loop counter
  Dim strCurrentIP 'Visitors IP address
  Dim intSectionMin 'Lower bound IP address slice
  Dim intSectionMax 'Upper bound IP address slice
  Dim intVisIPSlice 'Slice of visitors IP
  Dim blnIsIPOK 'Is the IP address ok so far

  'Set variables
  strMinRange = "000.000.000.000"
  strMaxRange = "255.255.255.255"
  intLoop = 0
  strCurrentIP = Request.ServerVariables("REMOTE_ADDR")
  blnIsIPOK = True

  'Take out the dots
  strMinRange = Replace(strMinRange,".","")
  strMaxRange = Replace(strMaxRange,".","")
  strCurrentIP = Replace(strCurrentIP,".","")

  'Loop through all the sections
  Do until intLoop = 4 or blnIsIPOK = False
    intLoop = intLoop + 1
    'Get the slices of the IP range
    intSectionMin = mid(strMinRange,intLoop*3,3)
    intSectionMax = mid(strMaxRange,intLoop*3,3)
    intVisIPSlice = mid(strCurrentIP,intLoop*3,3)

    'If the slice falls out of range IP is blocked
    IF intVisIPSlice
< intSectionMax AND intVisIPSlice > intSectionMin then
      blnIsIPOK = False
    End if
  Loop

  Select case blnIsIPOK
    Case True
      Response.write("IP Address of current visitor is not in the blocked range")
    Case False
      Response.write("IP Address of current visitor is in the blocked range")
  End select

  Response.write("<BR><BR>Visitors current IP Address is " & Request.ServerVariables("REMOTE_ADDR"))
%>



Edited by Gullanian
Back to Top
 Post Reply Post Reply

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.