blob: 89a995984339c46e59e791c6715fa83dd3133a47 [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);
matheusfillipeabd513e2021-05-11 03:29:11 -030021 $_SESSION['captcha'] = $builder->getPhrase();
22 $builder->output();
23}else echo "huh?";