getting Users ips

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

getting Users ips

Post by Smackie »

Alright i need some help with getting a script that will help me get users
IP adresses and getting codes so i can have
like ways to ban people i want a Ip ban, a 6 hour ban and a perm ban
and other kind of ban's please help if you can....


Smackie

~To those who disrespect the one they call Smackie you will be bannished from the face of the earth at midnight on the birth of your first child~
hunterhp
Forum Commoner
Posts: 46
Joined: Sat Jan 22, 2005 5:20 pm
Contact:

Post by hunterhp »

To get users ip, $_SERVER['REMOTE_ADDR']
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

smackie is the gayest name i have ever heard

$HTTP_SERVER_VARS["REMOTE_ADDR"]

get the ip's of the ppl who are visiting ur site, one good way to ban ppl is to make a txt file, chmod it to 777. 1st check the file to see if their ip is located in the ban list. if it does redirect em to a page that laughs at them, if it isnt continue to the site

the txt file could be like this
1.123.543.2, 123.564.78.32,

and u could use explode() to seperate the ips and individually match them up to the ip of the person visiting ur site

do it
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

databases are a better storage media for ban lists.
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post by Smackie »

When i put this

Code: Select all

$_SERVERї'REMOTE_ADDR']
it only gives me my ip address i need to get other peoples ip address same with

Code: Select all

$HTTP_SERVER_VARSї"REMOTE_ADDR"]
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

It is because you are using an older version of PHP, I believe.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the IP returned is the current user's IP. There is no built-in list of ip's currently accessing the site, you have to build it. This is why I said that databases are best for this.
Post Reply