Jump to content

Recommended Posts

all users or specific users?  If you are wanting to prevent all users from viewing them, store the pages and directories in a directory outside of your publicly accessible directory.  If you only want to restrict some users, then it really depends on what your overall system/site looks like, what it's for etc.. but in general, that's where a login/membership system comes into play.

Well if you are not using an admin system you can use this ->

 

using array:

	$blockIPs = "192.168.1.1,127.0.0.1";
$blockIPs = explode(",",$blockIPs);
foreach($blockIPs as $IP){
	if($_SERVER['REMOTE_ADDR'] == trim($IP)){
		header("location: you-are-banned.html");
	}
}

 

using database:

	$result = mysql_query("SELECT * FROM ip_ban_list") or die(mysql_error());  
while($row = mysql_fetch_array( $result )) {
	if($_SERVER['REMOTE_ADDR'] == $row["ip"]){
		header("location: you-are-banned.html");
	}
}

 

 

oh and btw-CV, I just totally got suprised when I saw a quote of mine in your signature, haha!

@dezkit

 

There is no need to loop through an array or a database to use a method like yours.

 

If this person is using an array they simply just need to use in_array or for a database use a more specific SELECT statement

 

$sql = "SELECT * FROM `ip_bans` WHERE `ip`='".$_SERVER['REMOTE_ADDR']."'";

@dezkit

 

There is no need to loop through an array or a database to use a method like yours.

 

If this person is using an array they simply just need to use in_array or for a database use a more specific SELECT statement

 

$sql = "SELECT * FROM `ip_bans` WHERE `ip`='".$_SERVER['REMOTE_ADDR']."'";

 

Would it not be easier to create a whitelist instead of a blacklist as it's about a few select users?

@ignace

 

A whitelist would most likely have more entries than a blacklist. It depends on how you go about achieving the problem. Blacklists with less entries would be quicker to cycle through.

 

So if you want to limit access to your website for you (82.16.15.78) and 2 of your friends (86.57.15.63, 87.15.75.98) is more then the rest of the internet (~4 billion, as only your friends are allowed) to cycle through?

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.