1

My site is under repeated attacks by spammers who create accounts manually with nonsense email addresses and "fake" IP addresses (no way to block them).

I came up with the idea of blocking node creation with the Rules module, using data comparison, but it does not work. Here is a summary of the rule I have:

Event : Before saving content

Conditions: text comparison : Parameter: Text: [node:body:value], Matching text: lexapro, etc. [how to make the list of words/expression? One per line?]

Actions : page redirect

Update: starting from the rule in this answer, I created a rule which will redirect to a page and unpublish the node, but only if the words are both in the title and in the body. I've tried to put an OR in the rule, but it didn't work.

{ "rules_simple_antispam" :
  {
    "LABEL" : "Simple antispam",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_presave" : [] },
    "IF" : [
      { "text_matches" : { "text" : [ "node:title" ], "match" : "lexapro" } },
      { "text_matches" : { "text" : [ "node:body:value" ], "match" : "lexapro" } }
    ],
    "DO" : [
      { "redirect" : { "url" : "death-spam" } },
      { "node_unpublish" : { "node" : [ "node" ] } }
    ]
  }
}

What do I need to change in my rule to make it work?

PS: I'm not a coder.

2
  • Which version of Drupal are you using? Mar 24, 2016 at 12:29
  • I'm using Drupal 7 and looking forward to move to D8 eventually.
    – user54770
    Mar 24, 2016 at 13:01

2 Answers 2

1

IMO you should use a captcha, such as:

reCAPTCHA

Uses the Google reCAPTCHA web service to improve the CAPTCHA system and protect email addresses.

enter image description here

OR

Draggable Captcha

enter image description here

enter image description here

Here is an instruction video on how to set it up Drupal 7 Draggable Captcha - a more friendly way to prevent Spam

If spam still happening, which means they are indeed human and not bots, you could implement a point system. Where users need to gain points by doing something (login x amount of days or comment x amount of times etc..) To create nodes, users need to have x amount of points.

In addition, you could also implement spam flags, where users can flag content as spam and have the content be auto deleted if x amount of flags are raised.

1
  • thanks, but I have honeypot that works 100%. As for asking people to flag content, people don't really care and they prefer to go away than doing your job. There must be a simple way of using Rules to redirect on specific words.
    – user54770
    Mar 27, 2016 at 12:34
0

Have a look at this rule (in Rules export format):

{ "rules_block_specific_words_in_node_body" : {
    "LABEL" : "Block specific words in node body",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_presave" : [] },
    "IF" : [
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "2" : "2" } }
        }
      },
      { "OR" : [
          { "text_matches" : { "text" : [ "node:title" ], "match" : "lexapro" } },
          { "text_matches" : { "text" : [ "node:body:value" ], "match" : "lexapro" } },
          { "text_matches" : {
              "text" : [ "node:title" ],
              "match" : "ANotAllowedTextStringInTitle",
              "operation" : "regex"
            }
          },
          { "text_matches" : {
              "text" : [ "node:body:value" ],
              "match" : "ANotAllowedTextStringInBody",
              "operation" : "regex"
            }
          }
        ]
      }
    ],
    "DO" : [
      { "redirect" : { "url" : "no_spammers_allowed" } },
      { "node_unpublish" : { "node" : [ "node" ] } }
    ]
  }
}

Just import it in your own site (using the Rules UI) to experiment with it, and make it fit your needs.

Some more details about the logic included in the above sample:

  • It only applies to authenticated users (adapt and/or remove that Rules condition as needed).
  • It includes 4 verifications about the title or the actual body text (at least 1 one of these 4 Rules Conditions must be satisfied, as per the "OR" in these Rules conditions), ie:
    • an exact match (equal to) of either the title or the content of the body which is (just) "lexapro".
    • using a regular expression (regex) related to the string (in the title) ANotAllowedTextStringInTitle or (in the body) ANotAllowedTextStringInBody (use any regex that may fit your needs).
  • If the combination of Rules conditions is satisfied (ie the role matches AND at least 1 of the 4 of the text comparisons are satisfied), then these 2 Rules Actions are triggered:
    • issue a redirect "before saving the content" (which is the Rules Event) to a page with a path like no_spammers_allowed.
    • the node is unpublished.

Note: to make a list of words, the most straight forward way to do so is via the RegEx expressions (in which you could also use the "lexapro" word of course, which would make the first 2 Rules Conditions obsolete).

3
  • Thanks for tour time. I just cannot make it work. The node is saved. And how do I put more than one expression? I've tried comma separated and one per line. But didn't see any difference; doesnt work more. Thanks again for your time.
    – user54770
    Mar 24, 2016 at 23:17
  • So... I need an action for each word? I'm not shure to follow. Maybe someone else will take a look at this rule. I'm not the first one to come up with this. Its like if the saving process could not be stopped. And I will switch on debug... Thanks again.
    – user54770
    Mar 25, 2016 at 0:28
  • @user54770 : have a look at my refined answer. Curious to hear your feedback about it. Apr 19, 2016 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.