Getting a Visitor's IP Address
Moderator: General Moderators
Here is a bit of my ip-banning-script (using mysql)... It simply bans ips... Should take the time to implements range-banning etc someday...
Adding ips is done with a simple INSERT IGNORE....
Code: Select all
CREATE TABLE mytable (
spammer_ip INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (spammer_ip)
);
Code: Select all
$result = mysql_query("SELECT COUNT(*) AS count FROM mytable WHERE spammer_ip=INET_ATON({$_SERVER['REMOTE_ADDR']}");
$row = mysql_fetch_assoc($result);
if ($row['count'] > 0) {
header('Location: http://' . $_SERVER['REMOTE_ADDR']);
exit;
}- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
OK guys - one more bickering comment from either of you and the topic will be locked and further action may be taken. Seriously... it's just not acceptable to speak to each other like that full-stop; in the street, in a bar, in a web forum, anywhere. It's quite simple really... if you don't want to help then don't reply. Insulting people is very bad idea here and those who've been around for long enough will be more than aware of it.
Bigun: You're number one resource to check before posting questions = http://php.net/ If it were legal I'd marry it!
Bigun: You're number one resource to check before posting questions = http://php.net/ If it were legal I'd marry it!
1) I make every attempt to cool off the RTFM zealots without starting a fire, they sometimes get antsy when people don't comprehend when they read something that is a new language.... literally. I hope I made a decent attempt at such. Not everyone learns by reading, some of us learn by doing, maybe one day they will all understand.d11wtq wrote:OK guys - one more bickering comment from either of you and the topic will be locked and further action may be taken. Seriously... it's just not acceptable to speak to each other like that full-stop; in the street, in a bar, in a web forum, anywhere. It's quite simple really... if you don't want to help then don't reply. Insulting people is very bad idea here and those who've been around for long enough will be more than aware of it.
Bigun: You're number one resource to check before posting questions = http://php.net/ If it were legal I'd marry it!
2) I'm aware of php.net, it's great for looking up functions I may use every 6 months or so, it's not a good start for beginners though.
3) This is one of the more friendly forums I've been in. I'd guess it is simply because of how quickly your responses are on flame wars. For an example of what I deal with in my most active forum - head to forums.gentoo.org and do a search for cokehabit under "Off the Wall" forums. If there is a flame war.... he's there. So, I do appreciate what you guys do. But please, to everyone else, everyone has the right to comprehend information, not just read it. And to those who answer my questions, thanks.
Last edited by Bigun on Fri Jun 30, 2006 7:29 am, edited 1 time in total.
O.otimvw wrote:Here is a bit of my ip-banning-script (using mysql)... It simply bans ips... Should take the time to implements range-banning etc someday...
Code: Select all
CREATE TABLE mytable ( spammer_ip INT(10) UNSIGNED NOT NULL, PRIMARY KEY (spammer_ip) );Adding ips is done with a simple INSERT IGNORE....Code: Select all
$result = mysql_query("SELECT COUNT(*) AS count FROM mytable WHERE spammer_ip=INET_ATON({$_SERVER['REMOTE_ADDR']}"); $row = mysql_fetch_assoc($result); if ($row['count'] > 0) { header('Location: http://' . $_SERVER['REMOTE_ADDR']); exit; }
I have a long ways to go...
I was just going to make every php page check the user's IP with a table of IP's logged, and if they match, the scripts stop cold.