blob: a060db9c7aa495edfecbc22b960b1e4d676e12cf [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 Kupietz18fc33d2023-03-30 17:11:38 +020020 if (isset($SIMPLECAPTCHA) && $SIMPLECAPTCHA) $builder->build(250, 120);
21 else $builder->buildAgainstOCR(250, 120);
matheusfillipeabd513e2021-05-11 03:29:11 -030022 $_SESSION['captcha'] = $builder->getPhrase();
Marc Kupietz18fc33d2023-03-30 17:11:38 +020023 #$log->debug("captcha: " .$_SESSION['captcha']);
matheusfillipeabd513e2021-05-11 03:29:11 -030024 $builder->output();
Matheus Fillipe3c3bf9e2021-05-14 09:58:52 +030025//} else echo "huh?";