CAPTCHA_LENGTH=0 disables captchas
Change-Id: I4c7ec6e2176019a86240bfda3cbabe3644a7afe6
diff --git a/captcha.php b/captcha.php
index 7c4eb6d..49ae8a1 100644
--- a/captcha.php
+++ b/captcha.php
@@ -18,9 +18,7 @@
$builder = new CaptchaBuilder(null, $phraseBuilder);
$builder->setDistortion(1);
if (isset($SIMPLECAPTCHA) && $SIMPLECAPTCHA) $builder->build(250, 40);
- else $builder->buildAgainstOCR(250, 40);
- $builder = new CaptchaBuilder;
- $builder->build();
+ else $builder->buildAgainstOCR(250, 40);
$_SESSION['captcha'] = $builder->getPhrase();
$builder->output();
//} else echo "huh?";
diff --git a/index.php b/index.php
index 1df4cc6..ec70b9f 100755
--- a/index.php
+++ b/index.php
@@ -110,7 +110,7 @@
$error .= validate_password($password);
- if (!(isset($_SESSION['captcha']) && PhraseBuilder::comparePhrases($_SESSION['captcha'], $_POST['captcha']))) {
+ if ($CAPTCHA_LENGTH > 0 && !(isset($_SESSION['captcha']) && PhraseBuilder::comparePhrases($_SESSION['captcha'], $_POST['captcha']))) {
$error = $error . $STRINGS->wrong_captcha;
}
unset($_SESSION["captcha"]);
@@ -193,7 +193,7 @@
$error = $error . $STRINGS->recover_email_not_registered;
}
- if (!(isset($_SESSION['captcha']) && PhraseBuilder::comparePhrases($_SESSION['captcha'], $_POST['captcha']))) {
+ if ($CAPTCHA_LENGTH > 0 && !(isset($_SESSION['captcha']) && PhraseBuilder::comparePhrases($_SESSION['captcha'], $_POST['captcha']))) {
$error = $error . $STRINGS->wrong_captcha;
}
diff --git a/templates/recover_email_form.htm b/templates/recover_email_form.htm
index 6560354..c0593d6 100644
--- a/templates/recover_email_form.htm
+++ b/templates/recover_email_form.htm
@@ -10,6 +10,7 @@
value="<?php echo isset($_POST['email']) ? htmlspecialchars($_POST['email']) : '' ?>" />
</div>
+ <?php if($CAPTCHA_LENGTH > 0): ?>
<!--captcha here-->
<div class="form-outline mb-3">
@@ -24,6 +25,7 @@
<input pattern="[^\s]{<?php echo $CAPTCHA_LENGTH; ?>,}" required title="Please fill the captcha. It has 5 characters" name="captcha"
type="text" id="form3Example6" class="form-control" placeholder="Type what you see on the image above" />
</div>
+ <?php endif; ?>
<!-- Submit button -->
<button name="type" value="recover" type="submit" class="btn btn-primary float-right btn-md">Confirm</button>
diff --git a/templates/register.htm b/templates/register.htm
index cc15175..87753f8 100644
--- a/templates/register.htm
+++ b/templates/register.htm
@@ -144,6 +144,8 @@
</div>
</div>
</div>
+
+ <?php if($CAPTCHA_LENGTH > 0): ?>
<!--captcha here-->
<div class="form-outline mb-3">
<label class="form-label font-weight-bold" for="form3Example4">Captcha</label>
@@ -161,6 +163,7 @@
Type what you see on the image above.
</div>
</div>
+ <?php endif; ?>
<!-- Submit button -->
<button name="type" value="register" type="submit" class="btn btn-primary float-right btn-md">Sign up</button>