I maintain a Drupal website, http://www.pretty-scary.net, which has on occasion been the target of spam bots (and some 'human' spammers as well). In researching these posts, I found that they very often came from China, India, and Viet Nam, as well as some odd Arabic spam posts from Saudi Arabia and Yemen. This website focuses on women's roles in horror films, and we find it very doubtful that we have any real readership from any of these countries.
We did try more well known solutions. Those behind these posts were very clever and tenacious. Mollom weeded many out, but not all. Captcha didn't stop them all either. Some were consistently getting through to spam the forums and articles, and it was always a pain to clean up.
The final solution is this module, which I first developed as a 'hack' to user.module, and then worked on as a separate 'legitimate' module that could be more easily maintained and shared with others. This module can be used to set a Drupal website to 'Read Only' for any country; setting it so disables all account creation and account access for any IP in the configured region, making it impossible for them to post (assuming, of course, that anonymous posting is also disabled). This is the setting we personally use. I did also include a "Complete" ban setting, which will white out the entire website if access is attempted from the configured region.
Since I have implemented this restriction on Pretty Scary, the occurrence of actual spam has utterly ceased. By using both this package and Mollom, we, so far, are currently winning the spam war.
The module uses the ip-to-country.csv hosted at webhosting.info (http://ip-to-country.webhosting.info/node/view/6), and does also borrow from one of the coding snippets they offer there as well. It is reasonable to assume there should be an upgrade every couple of months to at least refresh this CSV file. There may be other updates as well; this is the first iteration of my first module, so it is reasonable to presume that there might be a bug lurking, somewhere (there always is).
If you may need more information regarding myself or this module in order for a CVS account to be created and this module shared, please do let me know.
Regards,
--JB
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | Country Ban.zip | 7.77 KB | jboukes |
| #7 | Country Ban.zip | 7.06 KB | jboukes |
| #4 | Country Ban.zip | 7.07 KB | jboukes |
| #1 | Country Ban.zip | 828.46 KB | jboukes |
Comments
Comment #1
jboukes commentedI am attaching a zip of the Country Ban module below for review.
Regards,
--JB
Comment #2
avpadernoComment #3
avpadernoThere is a Drupal function that needs to be called instead.
Comment #4
jboukes commentedGreetings,
I'm attaching an updated version with the following changes:
1.) The CVS file has been removed; however, instructions are included in a README.txt file which prompt the user to download the file from the maintainer's website.
2.) Usage of mysql_fetch_array changed to db_fetch_array
3.) Usage of strtolower changed to drupal_strtolower.
4.) Various and mild formatting cleanup (indentations, brackets, etc).
Thank you,
--JB
Comment #5
jboukes commentedChanging to "needs review" for the updated changes above ;)
Comment #6
Anonymous (not verified) commentedcountryban_install(),countryban_schema(),countryban_admin(), andcountryban_admin(), andcountryban_user()are still not formatted as the coding standards suggests; in particular, see there the curly brackets should be placed, and what the indentation character is.Implementations of hook should have the following comment:
where <hook_type> is replaced with the hook type implemented by the function.
Comment #7
jboukes commentedGreetings,
I combed through it pretty extensively this morning, and further corrected indentation and brackets, as well as other mild formatting. Please let me know if you might spot anything else.
Thank you and regards,
--JB
Comment #8
jboukes commentedPlease disregard the code above, and see this attached file instead. I have added a little extra functionality to make it easier on the user. As we have removed the .csv file from the release, I made it more "obvious" to the user that it needs to be added. There is now an instruction and refresh button offered on the admin panel which will refresh the user's database with the ip-to-country.csv data once they have pushed it up to the Country Ban module directory.
This makes it very easy for the user to update future ip-to-country.csv files, as they just need to push the newer file up, and hit the 'refresh' button again to have it added to their database.
--JB
Comment #9
avpadernoThere are not the indentation spaces after the curly bracket; .
Comment #10
jboukes commentedHi kiamlaluno,
I apologize - I'm not sure what you might mean. I'm looking at that code and I'm not understanding where it needs indentation spaces. I did run the 'code review' module on this code, setting it to complain even about 'mild' problems, and it is coming up clean.
I do see that my account was created however, and I am working to get the project together. Thank you for your time and patience in reviewing this for me ;)
--JB
Comment #11
avpadernoThe code should be written as
There are two spaces for each indentation level of the code, after the open curly bracket.
Comment #12
jboukes commentedAhhhh! I was looking too hard at the comment and not at the code. Got it - it will be fixed.
Thank you,
--JB