Jump to content
xisto Community
Tramposch

Ip Adress Banning.

Recommended Posts

Ok, you know IP address banning on websites, right?Well i want kind of a reverse effect of that.Can i make a required IP adress to access a website?like say i want three people to access a website.Person1:IP address= 72.106.xxxxxxxxxxxxxxxxPerson 2:IP adress= another ip addressPerson 3:Ip address= ect...So i want only those three people to access my website, and ban all other IP's (not we an IP list, but just like.... if an IP isnt applicable in the list, or something like that)Do you understand me?Is there a script that can do this? is there a name for this? like IP restricting, or something.

Share this post


Link to post
Share on other sites

spend days typing out every possible ip except some lol... i'm sure there is a script... couldn't you have a set username and only give it to people who you wan't?edited after below post:- I'm suprised you didn't google it anyway I thought the script would be alot longer thats suprisingly simple

Edited by kobra500 (see edit history)

Share this post


Link to post
Share on other sites

<Limit GET POST>order deny,allow
deny from all
allow from 199.166.210.
allow from XXX.XXX.XXX.XXX
allow from Xisto.com
</Limit>


The line "order deny,allow" says the restrictions are in the order to deny first followed by allow criteria.
The line "deny from all" says to Deny all IP's and Domains.
The line "allow from 199.166.210." says to allow IP's starting with these numbers.
List each allowed IP on its own line.
The line "allow from XXX.XXX.XXX.XXX" where XXX is an integer between 0 and 255 representing the allowed IP #.
Your can truncate the list, but only in order from first triplet to the last.
List each allowed Domain on its own line.
The line "allow from Xisto.com" where this is an allowed Domain Name.

Found this on the net using Google "htaccess IP allow".

Excerpted from http://home.golden.net/htaccess.html

Share this post


Link to post
Share on other sites

The only thing Jim forgot to mention is that you put that in your .htaccess file. If you don't have one, just create a file called .htaccess in the directory you want to be blocked.

Share this post


Link to post
Share on other sites

Ah thanks, i was thinking of the htaccess.. also the only reason i couldnt find anything was.. i didnt know what termonology to use in google. but i guess this isnt really PHP lol

Share this post


Link to post
Share on other sites

Well, you can use MySQL and the PHP global variable $_SERVER['REMOTE_ADDR'] which will give you IP addresses. You can create a database containing allowed IP address and run a MySQL check to make sure the IP address is correct. You can also use this to log the database with that visitor visiting your site.

Share this post


Link to post
Share on other sites

Well this topic already has two solutions and both are valid and probably for beginners the second one is better then the first one because many people are trying to avoid tempering with htaccess files.

Also another thing I would like to note is that you do not require any mysql ddatabases this might in fact prove to be nsecure the best way if you need only three codes that is ip addresses is to write and use small script above it is very simple and usuful however I would like to add something to it. I hope gogoily will not be angry.

<?$ip = $_SERVER['REMOTE_ADDR'];if($ip != YourIP1 && $ip != YourIP2 && $ip != YourIP3){	die("You're not welcome here.");}else{?>you may now write your code of the page you would like to provide to these guys in here<?}?>

Share this post


Link to post
Share on other sites

Well this topic already has two solutions and both are valid and probably for beginners the second one is better then the first one because many people are trying to avoid tempering with htaccess files.
Also another thing I would like to note is that you do not require any mysql ddatabases this might in fact prove to be nsecure the best way if you need only three codes that is ip addresses is to write and use small script above it is very simple and usuful however I would like to add something to it. I hope gogoily will not be angry.

<?$ip = $_SERVER['REMOTE_ADDR'];if($ip != YourIP1 && $ip != YourIP2 && $ip != YourIP3){	die("You're not welcome here.");}else{?>you may now write your code of the page you would like to provide to these guys in here<?}?>

Once again I shall rain on sombody's over-codyness... You do not need that else statement. The die function will terminate the rest of the code outputed on the page. If you really want to do this in php and not through htaccess all you would need is the if and the die.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.