The user interface works okay for blacklisting, but is ill suited toward whitelisting (unless one is willing to check 231 radio buttons). Some situations, such as community oriented sites, may wish to close their systems to all but those in their country (or an even smaller region).
Rather than display options as a matrix of radio buttons, how about two selectable lists? One for “Read Only” and one for “Complete Ban.” If a country doesn’t appear on either list, “No Ban” may be assumed. If a country (perhaps mistakenly) appears on both lists, “Complete Ban” can be assumed to prevail. By using selectable, scrollable lists, users can easily perform a select all, then deselect individual items, as desired, to quickly create a whitelist.
Note: Borders of counties are arbitrary. In some situations, it may be more useful to specify longitude, latitude & a radius. Anything falling within the bullseye is whitelisted; anything else is blacklisted. But this may be too much to ask?
Comments
Comment #1
Leeteq commentedRef. https://www.drupal.org/node/1120092#comment-9218275
Comment #2
mclinn commentedHere is what I did for "quick and dirty" whitelisting, starting with the file in #19 above.
Note that this returns a "Complete Ban" for any ip not returning an approved country code. This is easily modified to "Read Only" by changing the $rval below to 1 vs. 2. You could add some logic to return different bans for different countries without too much trouble.
Starting at line 188, near the end of countryban.module:
ORIGINAL
MODIFIED
Here is function mclmod01_ipblock() from a custom module file. You could work this into the original code but I prefer keeping new stuff like this as separate as possible:
That's it. Plug in your allowed countries, and be sure to add any IP addresses to ignore as shown. This is skipping the user access check and debug portion of the code so it will block any IP that doesn't return an approved country code, regardless of debug or privileges set.
I've also added "watchdog" recording, including a link to double check the IP location once it's recorded.
This could obviously be improved, new admin screen to modify approved countries without touching the code etc. But it is working fine for me in its present state. Maybe if there is an "official" release of a D7 version I'll figure out how to do patches and spruce this up a bit. I'm actually surprised this module hasn't received more attention as it does a superb job of eliminating a huge portion of the spammers and others who just want to mess with a website.