YOURLS reCaptcha plugin

YOURLS is a great little PHP script for running your own short URL service like bit.ly or tinuyrl.

Unfortunately public YOURLS installations are a prime target for spammers looking for a way to cloak their spammy links and make them harder for other sites to recognise as spam. Out of the box (and by design) YOURLS doesn’t have any spam protection as the developers prefer to focus on the core functions and leave extra functions to the rather excellent plugin architecture.

I’ve written a plugin which implements Google’s new reCaptcha v2 for public YOURLS sites. It’s pretty straightforward to setup and achieved a 100% reduction in spam links on my public site.

You can download the plugin from Github where full install instructions are also provided in the readme file.

Let me know in the comments below if you find this plugin useful or have any feature ideas.

  • Doesn’t work for me. When it’s turned on it says that it always fails the recaptcha.

    • simon

      Hi Daniel. It looks like you’ve got the captcha code outside of your form so it’s not getting submitted back to the page.

      If you move the closing element below the spb_recaptcha_add_Captcha_Script(); statement it should work.

      • Hello Simon,

        i’ve installed your plugin and it’s a good work but…
        when i shorten an url, that’s say ALWAYS “Failed recaptcha etc”
        How do i put this code in my page ?

        Thanks, B96

        (i’m 14 years old, so, i’m not a pro.)

  • Thank you for your quick response. I’ve tried putting it before the and after as well as in the form. When I put it in the form it just shows as text. When I try to include it in the form in between the tags or it doesn’t show at all. I’m totally baffled as to what to do at this point. Thanks.

    • simon

      Have you had a look at the sample-public-index.php file to see how it’s done there?

      Depending on how your page is constructed you might need to wrap the function call in php tags if it just renders as text ie
      < ?php spb_recaptcha_add_Captcha_Script(); ?>