Ip Adress Banning.

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Ip Adress Banning.

Tramposch
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.xxxxxxxxxxxxxxxx
Person 2:
IP adress= another ip address
Person 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.

Reply

kobra500
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

Reply

Tramposch
but then if they choose to remember password, i dont wannt that, i want this very, very secure..

Reply

jlhaslip
QUOTE
<Limit GET POST>
order deny,allow
deny from all
allow from 199.166.210.
allow from XXX.XXX.XXX.XXX
allow from trap17.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 trap17.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

 

 

 


Reply

Imtay22
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.

Reply

Tramposch
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

Reply

gogoily
You can make it without .htaccess
Try this code:
CODE
$ip = $_SERVER['REMOTE_ADDR'];
if($ip != YourIP1 && $ip != YourIP2 && $ip != YourIP3)
    die("You're not welcome here.");

Reply

coolcat50
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.

Reply

hitmanblood
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.

CODE
<?

$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

<?

}

?>

Reply

galexcd
QUOTE(hitmanblood @ Jan 15 2008, 10:46 AM) *
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.

CODE
<?

$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.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. "change adress" gmail - 218.07 hr back. (1)
Similar Topics

Keywords : ip adress banning


    Looking for ip, adress, banning,

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for ip, adress, banning,

*MORE FROM TRAP17.COM*
advertisement



Ip Adress Banning.



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE