News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Another anti-spam wall

Started by Helgi, September 05, 2024, 09:52:13 AM

Previous topic - Next topic

Helgi

Of course, this will not solve all problems with spam on the forum. But after I did this, there was a lot less bot-spam.


In file Register.template.php
<input type="submit" name="accept_agreement" value="', $context['agree'], '" class="button" />replace with
<div id="button-container"></div>
<script>
  document.addEventListener("DOMContentLoaded", function() {
    var button = document.createElement("input");
    button.type = "submit";
    button.name = "accept_agreement";
    button.value = "'. $context['agree']. '";
    button.className = "button";
    document.getElementById("button-container").appendChild(button);
  });
</script>

For users with disabled JS:
        echo '<div id="button-container" style="height:25.5px">
                    <noscript>
                          <p>Please enable JavaScript in your browser to accept the agreement and sign up.</p>
                    </noscript>
              </div>
              <script>
                    $(document).ready(function() {
                          var button = $(\'<input type="submit" name="accept_agreement" value="' . $context['agree'] . '" class="button">\');
                          $("#button-container").append(button);
                    });
              </script>';

style="height:25.5px" optional. This is so that the height is displayed immediately and there is no flickering.

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Diego Andrés

Unless bots have JavaScript disabled, this isn't useful at all.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Helgi

Quote from: Diego Andrés on September 05, 2024, 12:17:23 PMUnless bots have JavaScript disabled, this isn't useful at all.

If bots have JS disabled, now they will not be able to register. And the fact remains: before the change there were 50-100 bot registrations, now only live people register. Clarification: captcha and verification question were enabled before. But it wasn't helping.

You can check it out for yourself on a forum where bots often register.

Kindred

I have 30 questions, asking 2 at registration.
I have no bots that complete the registration at all.

You have to have a good set of questions and you have to change them every year or so.

And why would they not be able to register with JS disabled?

I don't see this as useful...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Helgi

Quote from: Kindred on September 06, 2024, 09:21:55 AMAnd why would they not be able to register with JS disabled?
I don't see this as useful...
Even if it cuts off bots that have JS turned off - it's still useful.
And complex questions sometimes can't be solved by living people either. :)

Diego Andrés

Fine.

Please include a <noscript></noscript> notice in the code about enabling JavaScript to sign up.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Helgi

        echo '<div id="button-container" style="height:25.5px">
                    <noscript>
                          <p>Please enable JavaScript in your browser to accept the agreement and sign up.</p>
                    </noscript>
              </div>
              <script>
                    $(document).ready(function() {
                          var button = $(\'<input type="submit" name="accept_agreement" value="' . $context['agree'] . '" class="button">\');
                          $("#button-container").append(button);
                    });
              </script>';

style="height:25.5px" optional. This is so that the height is displayed immediately and there is no flickering.

Advertisement: