473,394 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Ban and allow IP

Hello, is it possible with PHP to ban a certain range of IPs but at the same
time allow access from one specific IP from this range? Code example?
May 18 '06 #1
3 4611

John wrote:
Hello, is it possible with PHP to ban a certain range of IPs but at the same
time allow access from one specific IP from this range? Code example?


Yes it is :

if ($_SERVER['REMOTE_ADDR'] != '123.45.67.89')
{
exit;
}

But its not the best way. The better way would be to do it using your
web server's settings. In Apache you would do something like this in
httpd.conf :

<Directory /usr/local/cgi-bin/>
Order deny,allow
Deny from all
Allow from 123.45.67.89
</Directory>

Or in a file called .htconfig in the directory in which you wish to
deny access :

Order deny,allow
Deny from all
Allow from 123.45.67.89

(I think, I've never used Deny, Allow in .htconfig myself check out the
docs for your webserver)

HTH

Sam

May 18 '06 #2
sa************@gmail.com wrote:

John wrote:
Hello, is it possible with PHP to ban a certain range of IPs but at
the same time allow access from one specific IP from this range?
Code example?


Yes it is :

if ($_SERVER['REMOTE_ADDR'] != '123.45.67.89')
{
exit;
}

But its not the best way. The better way would be to do it using your
web server's settings. In Apache you would do something like this in
httpd.conf :

<Directory /usr/local/cgi-bin/>
Order deny,allow
Deny from all
Allow from 123.45.67.89
</Directory>

Or in a file called .htconfig in the directory in which you wish to
deny access :

Order deny,allow
Deny from all
Allow from 123.45.67.89

(I think, I've never used Deny, Allow in .htconfig myself check out
the docs for your webserver)


Default filename for this directory configuration file is .htaccess,
though.

--
Kim André Akerĝ
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
May 18 '06 #3
Lets say the IP you want to ban is 192.168.1.10. The following htaccess
code will ban this IP:

deny from 192.168.1.10

Hope you will understand this.

Regards,
Rupom
http://www.rupom.info

May 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John | last post by:
Hi. I am in the httpd file in the Apache folder and need to change the part that says AllowOverride from None to All, so that when I create a ..htaccess file it wont ignore it. However in the...
2
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
14
by: ford_desperado | last post by:
Why isn't ALLOW REVERSE SCANS the default? Why do we have to - drop PK - create an index - recreate PK What are the advantages of indexes that do not allow reverse scans?
6
by: Cro | last post by:
Dear Access Developers, The 'Allow Additions' property of my form is causing unexpected results. I am developing a form that has its 'Default View' property set to 'Continuous Forms' and am...
11
by: tlyczko | last post by:
Hello Rob B posted this wonderful code in another thread, http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/c84d8538025980dd/6ead9d5e61be85f0#6ead9d5e61be85f0 I could not...
5
by: profdotnet | last post by:
Below is the code of web.config file: <configuration> <system.web> <authentication mode="Forms" /> <authorization> <allow users="Admin"/> <deny users="Jack,Mary" /> <deny users="?">...
0
by: Scott_from_Carematic | last post by:
I'm trying to use a strongly typed dataset in my asp.net (2.0) project with visual studio 2005. I have generated the dataset and tableadapters in the designer. I'm using SQL server EE 2005 as the...
3
by: Dave Marden | last post by:
Is it possible to allow a person whom navigates to a particular page to type in a URL to a website they visit often, and have it be treated like code on the page itself for them to use it as a...
0
by: Douglas J. Badin | last post by:
Hi, The problem with Authorization is it stops at the first match and doesn't permit Grouping. On the Web Site, I am trying to Secure Page Access and SiteNaviagation by implementing the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.