-
Notifications
You must be signed in to change notification settings - Fork 0
/
captcha.php
26 lines (23 loc) · 957 Bytes
/
captcha.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
require_once 'vendor/autoload.php';
require_once 'config.php';
require_once 'redis.php';
include_once 'utils.php';
use Gregwar\Captcha\CaptchaBuilder;
use Gregwar\Captcha\PhraseBuilder;
session_start();
error_reporting(0);
//if (isset($_SESSION['captcha_token']) && $_GET['token'] == $_SESSION['captcha_token']) {
header('Content-type: image/jpeg');
header('Cache-control: no-store');
if (redis_inc_ipdata(getClientIP(), "captcha") > $HOURLY_CAPTCHAS) die("blocked");
$phraseBuilder = new PhraseBuilder($CAPTCHA_LENGTH);
$builder = new CaptchaBuilder(null, $phraseBuilder);
$builder->setDistortion(1);
if (isset($SIMPLECAPTCHA) && $SIMPLECAPTCHA) $builder->build(250, 40);
else $builder->buildAgainstOCR(250, 40);
$builder = new CaptchaBuilder;
$builder->build();
$_SESSION['captcha'] = $builder->getPhrase();
$builder->output();
//} else echo "huh?";