blob: 51143f76eaa21215f0f5776e03d0b69288fdd8a0 [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';
Matheus Fillipe3c3bf9e2021-05-14 09:58:52 +03006
matheusfillipeabd513e2021-05-11 03:29:11 -03007use Gregwar\Captcha\CaptchaBuilder;
8use Gregwar\Captcha\PhraseBuilder;
9
10session_start();
11error_reporting(0);
12
Matheus Fillipe3c3bf9e2021-05-14 09:58:52 +030013//if (isset($_SESSION['captcha_token']) && $_GET['token'] == $_SESSION['captcha_token']) {
matheusfillipeabd513e2021-05-11 03:29:11 -030014 header('Content-type: image/jpeg');
15 header('Cache-control: no-store');
16 if (redis_inc_ipdata(getClientIP(), "captcha") > $HOURLY_CAPTCHAS) die("blocked");
17 $phraseBuilder = new PhraseBuilder($CAPTCHA_LENGTH);
18 $builder = new CaptchaBuilder(null, $phraseBuilder);
19 $builder->setDistortion(1);
Marc Kupietz15703662023-03-28 21:44:20 +020020 if (isset($SIMPLECAPTCHA) && $SIMPLECAPTCHA) $builder->build(250, 80);
21 else $builder->buildAgainstOCR(250, 80);
matheusfillipeabd513e2021-05-11 03:29:11 -030022 $_SESSION['captcha'] = $builder->getPhrase();
23 $builder->output();
Matheus Fillipe3c3bf9e2021-05-14 09:58:52 +030024//} else echo "huh?";