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'; |
Matheus Fillipe | 3c3bf9e | 2021-05-14 09:58:52 +0300 | [diff] [blame^] | 6 | |
matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 7 | use Gregwar\Captcha\CaptchaBuilder; |
| 8 | use Gregwar\Captcha\PhraseBuilder; |
| 9 | |
| 10 | session_start(); |
| 11 | error_reporting(0); |
| 12 | |
Matheus Fillipe | 3c3bf9e | 2021-05-14 09:58:52 +0300 | [diff] [blame^] | 13 | //if (isset($_SESSION['captcha_token']) && $_GET['token'] == $_SESSION['captcha_token']) { |
matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 14 | 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); |
matheusfillipe | 38706ea | 2021-05-12 02:45:42 -0300 | [diff] [blame] | 20 | if (isset($SIMPLECAPTCHA) && $SIMPLECAPTCHA) $builder->build(250, 40); |
| 21 | else $builder->buildAgainstOCR(250, 40); |
Matheus Fillipe | 301684b | 2021-05-14 09:09:43 +0300 | [diff] [blame] | 22 | $builder = new CaptchaBuilder; |
| 23 | $builder->build(); |
matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 24 | $_SESSION['captcha'] = $builder->getPhrase(); |
| 25 | $builder->output(); |
Matheus Fillipe | 3c3bf9e | 2021-05-14 09:58:52 +0300 | [diff] [blame^] | 26 | //} else echo "huh?"; |