Due to the strong attack of spammers from specific region I want to block visitors from particular country. I think that there are several Ips from that country overuse my website. So what I wan to know is it possible to block country IP to avoid imbeciles spam attacks?
I am not sure, but I think it is possible through PHP script. However you can also do it through cPanel control panel, which is quite easier than doing modification in web site script.
Why you are not using Iptables firewall in Linux to block access to server from different IP address blocks. It is rather easier than modifying PHP script. You can use Google to get updated list of IP addresses for particular country.
Most probably it is the best solution to block IP range at the firewall level and if you are using CSF firewall, then there is an option where you can enter the country codes you want to block., just save and restart.