So I want to check if the user is in specific county
$ip = user ip;
$countryIP = some number;
if($ip == $countryIP){echo 'okey';} else {echo 'not okey';}
I dont want to use database with geo location since I need it for only one country.Also i dont want to use third party services.
For example abc.go.com/watch is only for US and I want to do something similar to that
Thanks 🙂
Ok, provided you’re happy with checking Bulgaria against the block you indicated, then you can do it reasonably simply – all you need to do is convert the ip addresses to the numerical notation.
77.85.0.0/16 means any code from 77.85.0.0 to 77.85.255.255 – now convert these to a numerical values:
Now convert the IP you want to check in the same manner – and verify that it’s between these two numbers. Of course, it’s not as simple as you are saying. There are over 400 different blocks for Bulgaria. If you care about it all, here’s the full list of their numerical representation (as of the last update). Check yourself, for example, here: http://www.countryipblocks.net/country-blocks/select-formats/