boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Ban IP addresses?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    boardom Forum Index -> How to ?
View previous topic :: View next topic  
Author Message
.Chris



Joined: 30 Apr 2002
Posts: 186
Location: Hawaii

PostPosted: Sun May 26, 2002 10:28 pm    Post subject: Ban IP addresses? Reply with quote

If someone is posting harassing comments on your blog, can you ban an IP address?

And if you can't, wouldn't this be a nice addition to B2?
Back to top
View user's profile Send private message Visit poster's website
.Chris



Joined: 30 Apr 2002
Posts: 186
Location: Hawaii

PostPosted: Tue May 28, 2002 4:06 pm    Post subject: Reply with quote

http://nucleuscms.org/features.php Nucleus seems to have a "ban IP" address feature and its php.. Perhaps b2 could too? I don't want to switch again and I hate stalkers posting constantly in my journal..
Back to top
View user's profile Send private message Visit poster's website
Nodecam



Joined: 05 Apr 2002
Posts: 66
Location: Saskatoon, Saskatchewan, Canada

PostPosted: Tue May 28, 2002 7:51 pm    Post subject: Reply with quote

I can see you're quite anxious to have this ability Very Happy

Anyway, you can probably just ban that IP from your website entirely, using the .htaccess file. http://www.freewebmasterhelp.com/tutorials/htaccess/index.htm will tell you how to do it.

Hope this helps.
Back to top
View user's profile Send private message Visit poster's website
.Chris



Joined: 30 Apr 2002
Posts: 186
Location: Hawaii

PostPosted: Tue May 28, 2002 9:11 pm    Post subject: Reply with quote

I should have thought about that and after you posted it I tried, however I was unable to block even myself.
Back to top
View user's profile Send private message Visit poster's website
Nodecam



Joined: 05 Apr 2002
Posts: 66
Location: Saskatoon, Saskatchewan, Canada

PostPosted: Tue May 28, 2002 9:54 pm    Post subject: Reply with quote

Ok, well, give me a bit of time, and I'll figure out how to do it from within the comments system itself...

Gotta learn more php sometime - might as well be now
Back to top
View user's profile Send private message Visit poster's website
Nodecam



Joined: 05 Apr 2002
Posts: 66
Location: Saskatoon, Saskatchewan, Canada

PostPosted: Tue May 28, 2002 10:08 pm    Post subject: Reply with quote

Quick fix - A more permanent solution needs to be built up using a database table, but for the time being, this should do the trick for you.
in b2comments.post.php, right after the line
Code:
/* end flood-protection */


Add in the following section:
Code:
if ("255.255.255.255" == $user_ip) {
    die("Your IP has been banned from posting comments");
}


You change the 255.255.255.255 to whatever IP you want to ban, and you should be able to repeat that if statement as many times as you want.

Alternately, you could put that code into the top of your template, replacing $user_ip with $REMOTE_ADDR, and the person(s) would not be able to load your page at all.

I haven't tested this on my own site, since I can't update my site at work (other than through b2 of course) but it should work just fine.

Let me know if it works!
Back to top
View user's profile Send private message Visit poster's website
.Chris



Joined: 30 Apr 2002
Posts: 186
Location: Hawaii

PostPosted: Tue May 28, 2002 10:52 pm    Post subject: Reply with quote

It works!!!

thank you thank you thank you!!

Ok now how do I ban more than one?
Back to top
View user's profile Send private message Visit poster's website
Nodecam



Joined: 05 Apr 2002
Posts: 66
Location: Saskatoon, Saskatchewan, Canada

PostPosted: Tue May 28, 2002 11:15 pm    Post subject: Reply with quote

lather, rinse, repeat

all you have to do is keep pasting in the same if statement, changing the ip as you go... ie. you'll have code that looks like:

Code:
if ("255.255.255.255" == $user_ip) {
    die("Your IP has been banned from posting comments");
}
if ("255.255.255.254" == $user_ip) {
    die("Your IP has been banned from posting comments");
}
if ("255.255.255.253" == $user_ip) {
    die("Your IP has been banned from posting comments");
}


Should do the trick Smile

Glad to know I can still code blind (ie without being able to test what I'm doing) - even if it is a simple piece of code.

I'll work on a more elegant solution for you later this week, one that lets you just add IP's in by clicking on them in the b2edit.php comment editor or something.
Back to top
View user's profile Send private message Visit poster's website
.Chris



Joined: 30 Apr 2002
Posts: 186
Location: Hawaii

PostPosted: Tue May 28, 2002 11:24 pm    Post subject: Reply with quote

I think IP banning NEEDS to be in the next version of B2. I know there has to be other people out there that accumulate stalkers as I do..

Thank you SO much for your help. Very Happy
Back to top
View user's profile Send private message Visit poster's website
.Chris



Joined: 30 Apr 2002
Posts: 186
Location: Hawaii

PostPosted: Wed May 29, 2002 3:11 am    Post subject: Reply with quote

This person still has not stopped. Can I ban wild cards? Like:
Code:
if ("62.7.*.*" == $user_ip) {
    die("Your IP has been banned from posting comments!");
}
I really want to thank you for your help. Hopefully I can make this person (if you want to call it a person) go away..
Back to top
View user's profile Send private message Visit poster's website
kaiden



Joined: 20 Mar 2002
Posts: 43

PostPosted: Wed May 29, 2002 4:06 am    Post subject: Reply with quote

I would assume wildcard bans would work as well. It works in a form I made, it should work here.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Nodecam



Joined: 05 Apr 2002
Posts: 66
Location: Saskatoon, Saskatchewan, Canada

PostPosted: Wed May 29, 2002 5:22 am    Post subject: Reply with quote

Wildcard bans won't work with this method, though with a little pattern matching work, it should be possible. Try:
Code:
if (ereg("^62.7.",$user_ip)) {
    die("Your IP has been banned from posting comments!");
}


This will match any ip starting with 62.7 - I'll have to spend some time to come up with a better pattern matching system to go with the planned ip banning system that I'm going to work on later this week (when I've got more time)

Enjoy

[edit] - I missed a bracket...
Back to top
View user's profile Send private message Visit poster's website
mattmargolis



Joined: 20 Jul 2003
Posts: 15
Location: Boston, MA

PostPosted: Sat Jul 26, 2003 9:38 pm    Post subject: Reply with quote

praise you! this is a great help....
_________________
www.mattmargolis.com

part of the vast right wing conspiracy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Mon Jul 28, 2003 3:47 am    Post subject: Reply with quote

mattmargolis wrote:
praise you! this is a great help....
this is what i use
[php:1:9daa5ddf28]
// Get IP Address
if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$ip_address = $_SERVER["REMOTE_ADDR"];
} else {
$ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
}

// Banned Users
$banlist['ip'] = array ('');
$banlist['host'] = array ('');

function banned ($banarray, $against) {
global $domainurl;
foreach ($banarray as $cban) {
$regexp = str_replace ('.', '\\.', $cban);
$regexp = str_replace ('*', '.+', $regexp);

if (ereg ("^$regexp$", $against)) {
echo "<html>\n";
echo "<header>\n";
echo "<title>++ GaMerZ WebPage | You Are Banned ++</title>\n";
echo "</header>\n";
echo "<body>\n";
echo "<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>\n";
echo "<div align=\"center\"><b><font size=\"3\">";
echo "Sorry You Could Not Access This Site.<br>You Have Been Ban By The Administrator.";
echo "</font></b></div>";
echo "</body>\n";
echo "</html>\n";
exit;
}
}
return;
}

banned ($banlist['ip'], $ip_address);
banned ($banlist['host'], gethostbyaddr($ip_address));[/php:1:9daa5ddf28]to use it just filll in the $bandlist array. wildcard can be used.
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Ozymandia



Joined: 02 Aug 2003
Posts: 1

PostPosted: Sat Aug 02, 2003 1:40 pm    Post subject: Banning an IP address Reply with quote

I have tried the small bit of code to block the address I am trying to avoid, and have tried the ".htaccess", neither of which has worked.

The larger piece of php code, as posted by GamerZ, I have a question about. Is this dropped into the b2commentspost.php file, and if so is it placed as the smaller piece of code is?

Thanks for your help, as php is a new experience for me.

Ozymandia
_________________
Canadian_Gaters -- a Yahoogroup for Canadian Stargate fans http://stargatecan.popullus.net
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> How to ? All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group