GeoIp

Using the GEOIP plugin in other plugins

8 months 2 weeks ago #78942

Simon Logan's Avatar Simon Logan

Hi Peter

I've inherited a site from another developer and they have written a custom plugin which redirects traffic based on IP address (but only for two locations - France and the Middle East). After upgrading the server to PHP5.6 the plugin generated errors and from my research it looks like it's because the plugin relied on the PECL extension ( www.php.net/manual/en/geoip.setup.php ) which is no longer packaged with PHP. The error being:

Fatal error: Call to undefined function geoip_country_code_by_name() in /path/to/plugins/system/ipredirect/ipredirect.php on line 52

My question is, am I able to use/adapt this existing plugin to use the info from the GEOIP plugin? It looks to me like the plugin just requests a country code for the visitor's IP address then checks if it equals FR or ME (with ME being an array of multiple countries which are defined in the plugin) then references the page set in the plugin's parameters for each to execute the redirect.

8 months 2 weeks ago #78949

Peter van Westen's Avatar Peter van Westen Admin

Here is an example of how you can use it.
www.regularlabs.com/forum/geoip/44497-ge...-custom-module#74152

8 months 2 weeks ago #78952

Simon Logan's Avatar Simon Logan

Great, thanks Peter, will give that go.