blob: db93f84db823e8e92a5bfd8058c7026c76edc7d4 [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);
19 $builder->buildAgainstOCR(250, 40);
20 $_SESSION['captcha'] = $builder->getPhrase();
21 $builder->output();
22}else echo "huh?";