can i ban website visitors after they visit a certain page?

smetten2

BANNED
Joined
Nov 1, 2008
Messages
37
Reaction score
15
Hi

Is it possible to ban an ip address after they visit a certain page on my website. Suppose i only want people to see this page 1 time, so when they come back or refresh they see another page or they see no page (banned by ip address).

Greetz

Nick
 
Do you want the ban to happen to the whole site, or everything in a folder including stuff in all subfolders, or only one page?
It's very easy to do with .htaccess and php, it's also possible by php only.

Answer the first question and also tell do you have htaccess support, and I will write you sample code.
 
can you tell me how this is done, if possible.

Thx in advance

Greetz

smetten
 
yeah i have access to the htaccess file.
I want people to be banned from the whole site.

Thx for the help

Smetten
 
Use PHP to grab the visitors IP and then write a deny line to your htaccess.
 
I belive its proberly possible with sesssions and php, If somebody hasnt pmed u the code already, pm me 2morrow, and il write and test it for u
 
While you can deny using .htaccess it is not at all an efficient way to work as you are basing your assumption that the user has a static IP. Doing the same thing with php and cookies would definitely be a better way to go. I am adding a sample code, you can use this, modify it or get someone to make another.

Place this right at the begining of the php document:
Code:
<?php
if (!isset($_COOKIE["blockafterview"])) {

  setcookie("blockafterview", $_POST["blockafterview"]);
  setcookie("visits", 1);

  $blockipviews= 1;

} else {
  setcookie("visits", ++$_COOKIE["visits"]);

  $blockipviews= 2;
}
?>

Now use the following to perform whatever action you want:

Code:
<?php if ($blockipviews == "1") : ?>
        ADD THE CODE OR INCLUDE ANOTHER PHP FILE FOR THE ACTION FOR FIRST VISIT
<?php else : ?>
        ADD THE CODE OR REDIRECT FOR THE ACTION TO BE TAKEN FOR BLOCKING HERE
<?php endif; ?>
 
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features and essential functions on BlackHatWorld and other forums. These functions are unrelated to ads, such as internal links and images. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock