MyBB IP to Flags plugin. It uses the registration/last visit/additional IP to get the flag using one of 3 methods (Maxmind database, PECL extension, geoplugin.net).