how to allow two php queries every 5 seconds

56 views Asked by At

I've used this function for protection against spam queries: but i want to make it allow two queries every 5 seconds

function antiSpam($seconds) {
    if(!isset($_SESSION['last_query']))
        $_SESSION['last_query'] = microtime(true);

    if($_SESSION['last_query'] >= microtime(true))
        exit(header('Location: https://mywebsite.com/spammer.php'));

    $_SESSION['last_query'] = microtime(true)+$seconds;
}

antiSpam(5);

any idea about how to fix that ?

0

There are 0 answers