matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame^] | 1 | <?php |
| 2 | require_once 'vendor/autoload.php'; |
| 3 | require_once 'config.php'; |
| 4 | require_once 'redis.php'; |
| 5 | include_once 'utils.php'; |
| 6 | use Gregwar\Captcha\CaptchaBuilder; |
| 7 | use Gregwar\Captcha\PhraseBuilder; |
| 8 | |
| 9 | session_start(); |
| 10 | error_reporting(0); |
| 11 | |
| 12 | if (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?"; |