Skip to content

Commit

Permalink
Math captcha rather than text
Browse files Browse the repository at this point in the history
The default captcha is cutting down spam a bit, but some is getting through.
The following has some advice...

  dapphp/securimage#66
  https://www.phpcaptcha.org/documentation/setting-options/

... but regardless of that I find the math problems as a sender less annoying
to solve. Lets give this a try for a bit.
  • Loading branch information
atagar committed Jan 9, 2020
1 parent 0cf8556 commit 244434e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions captcha.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
// Our configured variant of securimage/securimage_show.php

require_once dirname(__FILE__) . '/securimage/securimage.php';

$img = new Securimage();

$img->captcha_type = Securimage::SI_CAPTCHA_MATHEMATIC; // simple math problem
$img->perturbation = .75;
$img->use_random_baseline = true;
$img->use_random_boxes = true;
$img->num_lines = mt_rand(2, 4);

if (!empty($_GET['namespace'])) $img->setNamespace($_GET['namespace']);
$img->show(); // outputs the image and content headers to the browser
?>
4 changes: 2 additions & 2 deletions contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@

<p>Please type the text below:</p>

<img id="captcha" src="/securimage/securimage_show.php" alt="CAPTCHA image" />
<img id="captcha" src="/captcha.php" alt="CAPTCHA image" />

<br>
<input type="text" name="captcha_code" size="10" maxlength="6" />
<a href="#" onclick="document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random(); return false">&nbsp;<i class="fas fa-sync"></i>&nbsp;different image</a>
<a href="#" onclick="document.getElementById('captcha').src = '/captcha.php?' + Math.random(); return false">&nbsp;<i class="fas fa-sync"></i>&nbsp;different image</a>

<p>Message:</p>
<textarea class="contact-form" rows="11" name="message" cols="80"></textarea>
Expand Down

0 comments on commit 244434e

Please sign in to comment.