<?php
function antibot($cartella){


    $bIP = file($cartella."/banip.txt", FILE_IGNORE_NEW_LINES);
    $blowords =  file($cartella."/banag.txt", FILE_IGNORE_NEW_LINES);

    if (in_array($_SERVER['REMOTE_ADDR'], $bIP)) {
        fine();
    } else {
        foreach($bIP as $ip) {
            if (preg_match('/' . $ip . '/', $_SERVER['REMOTE_ADDR'])) {
                fine(); 
            }
        }
    }


    $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
    foreach($blowords as $word) {
        if (substr_count($hostname, $word) > 0) {
            fine();
        }
    }

}

global $opt;

$bloccastato = $opt['bloccastato'];
    if($bloccastato){ 
        
    
}
function fine($country=""){

   $ip = getUserIP();
   $agent = $_SERVER['HTTP_USER_AGENT'];
   $file = 'bloccati.txt';
    $slog= $country."#".$agent."#".$ip;
   if(!file_exists( $file)){
    file_put_contents($file,"");
   }
   if( strpos(file_get_contents( $file),$slog) !== false) {
        
    }else{
        file_put_contents($file, $slog.PHP_EOL, FILE_APPEND | LOCK_EX);
    }

    


    echo("<h1>404 Not Found</h1>The page that you have requested could not be found.<!-- $slog -->");
    exit;
}
?>