blob: 7c4eb6d071d9bf3ac0dddd73a0e81d7ff9153168 [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);
21 else $builder->buildAgainstOCR(250, 40);
Matheus Fillipe301684b2021-05-14 09:09:43 +030022 $builder = new CaptchaBuilder;
23 $builder->build();
matheusfillipeabd513e2021-05-11 03:29:11 -030024 $_SESSION['captcha'] = $builder->getPhrase();
25 $builder->output();
Matheus Fillipe3c3bf9e2021-05-14 09:58:52 +030026//} else echo "huh?";