Gérer les cookies utilisés pour la publicité, tels que la personnalisation des annonces, le remarketing et l’analyse des performances des annonces.
2.8.19. Detect visitor country in PHP
Every request to the site includes a special header called HTTP_GEOIP_COUNTRY_CODE, which contains the visitor's two-letter country code (ISO 3166). The country is determined based on the visitor's IP address using data from MaxMind GeoLite.
You can retrieve a two-letter country code in PHP using the server variable $_SERVER['HTTP_GEOIP_COUNTRY_CODE']. Here is an example of code to block POST requests from any country except Ukraine:
if ($_SERVER['HTTP_GEOIP_COUNTRY_CODE'] != 'UA' && !empty($_POST)) {
die('Access denied');
}
(2)
Commentaires
Велике ДЯКУЮ!
if ($_SERVER['HTTP_GEOIP_COUNTRY_CODE'] != 'UA' && !empty($_POST)) {
die('Русский военный корабль ...');
}