You should implement this system (only one connection per IP) on emulator side, not website. I can think of atleast one way to avoid your little protection. Client is authenticated by SSO, so i can spawn a ton of SSO tickets and then connect trough a html page on another web server.
There are also other ways to fight advertisement bots, just think out of the box.
-Create a spam detection system based on repeated messages
-Create a system that requires manual approval to active the user account based on username.
-Use cookies stored on the clients computer to track frequent registrations
-Think outside of the box
I wish you goodluck on the journey on defeating the spam bots :-)
- - - Updated - - -
I am also going to answer your question very specifically
If you want to block specific countries trough PHP, not that I can recommend this at all, because there are better ways todo this. You can use this piece of code i just made. However, this requires you to use CloudFlare. Because it uses the
CF-IPCountry HTTP Header provioded by CloudFlare. I guess you're already using CloudFlare as it is very common for people to use now-a-days.
PHP Code:
<?php
// Block some countries from seeing this page
switch($_SERVER["HTTP_CF_IPCOUNTRY"])
{
// Norway
case 'BV': // (Bouvet Island) apperently according to Wikipedia, it belongs to Norway?
case 'NO': // (Norway) Mainland
case 'SJ': // (Svalbard and Jan Mayen) also belongs to Norway, according to Wikipedia
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
exit;
break;
// Denmark
case 'DK': // (Denmark) Mainland
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
exit;
break;
// Sweden
case 'SE': // (Sweden) Mainland
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
exit;
break;
}
If you want to add more countries
CloudFlare's CF-IPCountry HTTP Header is in a
ISO 3166-1 Alpha 2 format