( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
eeeeeeeeeeeeeeeee
<?php
require 'vendor/autoload.php';
use GeoIp2\Database\Reader;
// Define the country codes you want to block
$blocked_countries = ['CN', 'KE']; // Example: Block China and Russia
// Path to the MaxMind GeoLite2-Country database
$databaseFile = 'GeoLite2-Country.mmdb';
// Get the visitor's IP address
$ip_address = $_SERVER['REMOTE_ADDR'];
try {
$reader = new Reader($databaseFile);
$record = $reader->country($ip_address);
echo $country_code = $record->country->isoCode;
if (in_array($country_code, $blocked_countries)) {
// If the country code is in the blocked list, deny access
header('HTTP/1.1 403 Forbidden');
echo "Access denied.";
exit;
}
} catch (Exception $e) {
// Handle errors if the IP address is not found in the database
error_log($e->getMessage());
}
// The rest of your application code goes here
?>