Download the plugin from http://www.jasonlitka.com/2007/04/16/wordpress-plugin-block-countries/ . Install in a regular way. Do not go to options now.
Download ip database from http://ip-to-country.webhosting.info/node/view/6
Convert to mysql dump using phpmyadmin interface.
For that, use any local database to create a table:
CREATE TABLE IF NOT EXISTSwp_iptocountry(ip_fromint(4) unsigned NOT NULL DEFAULT '0',ip_toint(4) unsigned NOT NULL DEFAULT '0',country_code2char(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',country_code3char(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',country_namevarchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (ip_from,ip_to) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Uncompress ip-to-country.csv and import it into this table using standard phpMyAdmin interface and watching for the Windows-type line ending in the export file:
Create a local export file :
mysqldump -u root -p --opt YOUR_DB wp_iptocountry > ip2country.sql
Upload to server, insert into the Wordpress db on server:
mysql -u USERNAME -p WORDPRESS_DB < ip2country.sql
Now, make the final modifications to the block countries plugin. Edit the file on server, PATH_TO_WEB_ROOT/wp-content/plugins/block-countries/block-countries.php, change
to:
You can use normal configuration page now enjoying the working interface.
Please make sure you do not block yourself :mrgreen: . The warning in the plugin reads:
Plugin WarningIf you block the country you are in you will not be able to access your Blog or the Blog’s Site Admin section. If you do it anyway, you can run the MySQL query “DELETE FROMMARKDOWN_HASHc86362c3421349f3283f134bedaa5b36MARKDOWN_HASHWHEREMARKDOWN_HASH16f709d34f3920863720f4ef0af239eaMARKDOWN<em>HASHLIKE ‘bc%’;” to restore the plugin settings to their defaults.As a result of plugin work (I just blocked myself to test), you see a not very beautiful but quite an effective empty page with text: HTTP/1.1 403 Forbidden – Users from your country are not permitted to browse this site.
Enjoy!
One thought on “Making outdated Block Countries plugin for WordPress work”
Leave a Reply



i love to listen on audiobooks while travelling on a bus, i could learn a lot from it while travelling ‘::