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); |
matheusfillipe | 38706ea | 2021-05-12 02:45:42 -0300 | [diff] [blame] | 19 | if (isset($SIMPLECAPTCHA) && $SIMPLECAPTCHA) $builder->build(250, 40); |
| 20 | else $builder->buildAgainstOCR(250, 40); |
matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 21 | $_SESSION['captcha'] = $builder->getPhrase(); |
| 22 | $builder->output(); |
| 23 | }else echo "huh?"; |