How can I block an ip to a redirect php file?

1

This is my redirect file in php

<?php
header("Location: https://www.ejemplo.org/anuncio1.php");
?>

What code do I need so that when a person with an ip. for example 192.168.1.1 can only be redirected once a day or once per hour to that file anuncio.php , and when you try it a second time in a certain time. send it for example to https://wwww.ejemplo.org/solosepermiteunavisitaporhora.php or print a message that says: You have visited this website recently, return in 1 hour.

    
asked by Luis Cesar 18.04.2018 в 22:40
source

1 answer

0

first you should have the client's ip something like this:

<?php $ip = $_SERVER['REMOTE_ADDR'];?>

validate

 if($ip == "192.168.1.10") {
    die("Lo sentimos, estas baneado . $ip"); 
  }

that would be a simple way, you could also create a list of ips blocked in an array or in turn in a database

    
answered by 18.04.2018 в 23:20