CVS edit link for jboukes

I have developed a Drupal 6 module tentatively called 'Country Ban', which I would like to share with others, as well as maintain.

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

Comments

jboukes’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new828.46 KB

I am attaching a zip of the Country Ban module below for review.

Regards,

--JB

avpaderno’s picture

Issue tags: +Module review
avpaderno’s picture

Status: Needs review » Needs work
  1. Files available from third-party sites should not be committed in CVS.
  2. 	 // Fetching the record set into an array
    	 $ccode_array=mysql_fetch_array($country_exec);
    

    There is a Drupal function that needs to be called instead.

  3. See Apply for contributions CVS access to understand how a module should be written; in particular, see how the code should be formatted, and which string functions should be used.
jboukes’s picture

StatusFileSize
new7.07 KB

Greetings,

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

jboukes’s picture

Status: Needs work » Needs review

Changing to "needs review" for the updated changes above ;)

Anonymous’s picture

Status: Needs review » Needs work

countryban_install(), countryban_schema(), countryban_admin(), and countryban_admin(), and countryban_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:

/**
 * Impements hook_<hook_type>().
 */

where <hook_type> is replaced with the hook type implemented by the function.

jboukes’s picture

Status: Needs work » Needs review
StatusFileSize
new7.06 KB

Greetings,

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

jboukes’s picture

StatusFileSize
new7.77 KB

Please 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

avpaderno’s picture

Status: Needs review » Fixed
/**
 * Impements hook_admin().
 */
function countryban_admin() {
$form = array();
$form['countryban_readonly'] = array(

There are not the indentation spaces after the curly bracket; Impements hook_admin().

jboukes’s picture

Hi 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

avpaderno’s picture

The code should be written as

/**
* Impements hook_admin().
*/
function countryban_admin() {
  $form = array();
  $form['countryban_readonly'] = array(

There are two spaces for each indentation level of the code, after the open curly bracket.

jboukes’s picture

Ahhhh! I was looking too hard at the comment and not at the code. Got it - it will be fixed.

Thank you,

--JB

Status: Fixed » Closed (fixed)
Issue tags: -Module review

Automatically closed -- issue fixed for 2 weeks with no activity.