blob: 49ae8a16e6d1087269e25cb51cce741fb7403f01 [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);
matheusfillipe38706ea2021-05-12 02:45:42 -030020 if (isset($SIMPLECAPTCHA) && $SIMPLECAPTCHA) $builder->build(250, 40);
Marc Kupietz493198f2023-03-04 14:59:16 +010021 else $builder->buildAgainstOCR(250, 40);
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?";