blob: af7f3c1bff5208974525fd3b0d7ba37d99d9c059 [file] [log] [blame]
matheusfillipeabd513e2021-05-11 03:29:11 -03001<?php
2require_once 'vendor/autoload.php';
3require_once 'config.php';
4require_once 'redis.php';
5include_once 'utils.php';
6use Gregwar\Captcha\CaptchaBuilder;
7use Gregwar\Captcha\PhraseBuilder;
8
9session_start();
10error_reporting(0);
11
12if (isset($_SESSION['captcha_token']) && $_GET['token']==$_SESSION['captcha_token']) {
13 header('Content-type: image/jpeg');
14 header('Cache-control: no-store');
15 if (redis_inc_ipdata(getClientIP(), "captcha") > $HOURLY_CAPTCHAS) die("blocked");
16 $phraseBuilder = new PhraseBuilder($CAPTCHA_LENGTH);
17 $builder = new CaptchaBuilder(null, $phraseBuilder);
18 $builder->setDistortion(1);
matheusfillipe38706ea2021-05-12 02:45:42 -030019 if (isset($SIMPLECAPTCHA) && $SIMPLECAPTCHA) $builder->build(250, 40);
20 else $builder->buildAgainstOCR(250, 40);
Matheus Fillipe301684b2021-05-14 09:09:43 +030021 $builder = new CaptchaBuilder;
22 $builder->build();
matheusfillipeabd513e2021-05-11 03:29:11 -030023 $_SESSION['captcha'] = $builder->getPhrase();
24 $builder->output();
25}else echo "huh?";