Jump to content

IP Banning


RickyF

Recommended Posts

Hi,

 

Ok so i have config.php, in this i need a var to be set as $bannedips

 

and in index.php the banned ips need to be collected from config.php and if the IP is banned a die error should show

 

I need it so that $bannedips is on like this: $bannedips = "1.1.1.1, 2.2.2.2, 3.3.3.3";

 

If its possible to do this not using quotes on each ip this would be useful, most essentially the ips need to be on one line seperated by a comma.

 

Using php 4.4.7

 

Thanks for any help!

Link to comment
Share on other sites

Similarly, how would i make it so that anything in $bannedurls stops the post being made?

 

$bannedurls = "1.com, 2.com, 3.com";

 

The var for the what the domains are, is $weburl, $weburl would be something like www.site.com

 

$bannedurls = "1.com, 2.com, 3.com";

 

if (in_array(eregi("$bannedurls", $weburl)) {

die ("Your website has been banned.");

}

 

I think it would be something like this.

Link to comment
Share on other sites

$bannedurls = "whatever.com";

$urls = explode(",", $bannedurls);

 

if (in_array("$bannedurls", $urls)){

die ("Your website is banned!");

}

 

This is different, as its part of a form, weburl is the input field being checked.

 

The script needs to ban *whatever.com*, not just whatever.com as people can bypass with www.whater.com or whatever.com/ etc

 

 

Thanks

Link to comment
Share on other sites

Sorry i think i have confused you.

 

I need the script to be able to ban a website in full, e.g. if i banned site.com, the script should ban any thing with site.com in it, this script doesn't do this, this is why i used eregi in an earlier post to you.

 

Thanks

 

Heres what i currently have:

 

$bannedurls = "website1.com,website2.com,website3.com";

$sites = explode(",", $bannedurls);

if (in_array("$bannedurls", $sites)){
die ("Your website is banned!");
}

Link to comment
Share on other sites

Hi, the ban ips part is working fine, its just the web url banning that isnt working fully

 

as explained, if site.com was banned by the script, and some one tried posting www.site.com it would let them, the script needs to check if anything like site.com is posted, e.g. *site.com*, meaning anything.site.com or www.site.com etc should also be banned.

Link to comment
Share on other sites

IP banning is pretty pointless... there are ways around it if they really want to..

 

However in this sitiation if you are going to store lots of ipp addresses or url's I would suggest simply having a table with just one field (a varchar) then in that table store all the ips and urls that are banned.  simply query that table when ever you need to check if the ip address or url is banned.  if the ipa/url is in the table you will get more than 0 results so use that to decide if the action is allowed or not.

Link to comment
Share on other sites

Here you go:

 

<?php

$bannedurls = "website1.com,website2.com,website3.com";
$sites = explode(",", $bannedurls);

//This is the website you are checking to see if it is banned
$check = "website2.com";

foreach ($sites as $site){
    $site = trim($site);
    
    if (strchr($check, $site)){
        echo "You are banned!";
        return FALSE;
    }
}

?>

Link to comment
Share on other sites

Liam - anyone can change their ip address in seconds - all you need to do is surf via a proxy and your are done. Even 'noobs' can do this it takes seconds to implement it and a couple of minutes to find out how with a google search.

 

There is no real solution to banning people - all you can do is make it as hard as possible for them - I have implemented a quite laboureous system in the past that uses cookies and ipaddresses that was still fairly easy to get round.

 

Forcing someone to logon means they will have to go through the registration process over and over and ultimately you could reference a list of proxy servers too and disable access for them.  Bottom line is all you can do is make it harder for them to circum vent.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.