Web Projects Outsourcing

Making outdated Block Countries plugin for WordPress work

Attention
You must have a local LAMP installation for painless processing of the following.

Download the plugin from //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 //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 EXISTS wp_iptocountry (
  ip_from int(4) unsigned NOT NULL DEFAULT '0',
  ip_to int(4) unsigned NOT NULL DEFAULT '0',
  country_code2 char(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  country_code3 char(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  country_name varchar(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:

Convert ip2country file into Mysql format

Convert ip2country file into Mysql format

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

<td><select multiple size="10" name="bccodes[]">

to:

<td><select multiple="multiple" size="10" name="bccodes[]" style="height:350px">

You can use normal configuration page now enjoying the working interface.

Making outdated block country plugin for Worpress work

Making outdated block country plugin for Worpress work

Please make sure you do not block yourself :mrgreen: . The warning in the plugin reads:

Plugin Warning
If 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 FROM MARKDOWN_HASHc86362c3421349f3283f134bedaa5b36MARKDOWN_HASH WHERE MARKDOWN_HASH16f709d34f3920863720f4ef0af239eaMARKDOWN_HASH LIKE ‘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

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.