captcha improved
This commit is contained in:
parent
24cd4d6c7d
commit
570c06ae65
BIN
assets/fonts/luxisr.ttf
Normal file
BIN
assets/fonts/luxisr.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/yudit.ttf
Normal file
BIN
assets/fonts/yudit.ttf
Normal file
Binary file not shown.
|
@ -32,7 +32,7 @@ const LOG_ERRORS = true;
|
|||
const CAPTCHA_WIDTH = 120;
|
||||
const CAPTCHA_HEIGHT = 40;
|
||||
const CAPTCHA_NAME = 'captcha';
|
||||
const CAPTCHA_FONT = 'Lobster';
|
||||
const CAPTCHA_FONT = 'yudit';
|
||||
const CAPTCHA_SLEEP_TIME = 60;
|
||||
const CAPTCHA_SLEEP_MAX_REQUESTS = 10;
|
||||
const CRON_MIN_INTERVAL = 3600;
|
||||
|
|
|
@ -247,7 +247,7 @@ class Form {
|
|||
$digit1 = rand(1,9);
|
||||
$digit2 = rand(1,9);
|
||||
|
||||
$result = $digit1 + $digit2;
|
||||
$result = $digit1 * $digit2;
|
||||
Session::set(self::getFieldName($token, CAPTCHA_NAME),$result);
|
||||
|
||||
$image = imagecreatetruecolor(CAPTCHA_WIDTH,CAPTCHA_HEIGHT);
|
||||
|
@ -272,7 +272,7 @@ class Form {
|
|||
imagestring($image,$size,CAPTCHA_WIDTH/5+(CAPTCHA_WIDTH/5-$size)/2,(CAPTCHA_HEIGHT-$size)/2+$size/4,$digit1,$color);
|
||||
}
|
||||
|
||||
$sign = '+';
|
||||
$sign = 'x';
|
||||
$color= imagecolorallocate($image, rand(0,155), rand(0,155), rand(0,155));
|
||||
try {
|
||||
imagettftext($image,$size,rand(-5,5),CAPTCHA_WIDTH*2/5+(CAPTCHA_WIDTH/5-$size)/2,CAPTCHA_HEIGHT-(CAPTCHA_HEIGHT-$size)/2,$color,$captcha_font,$sign);
|
||||
|
@ -295,7 +295,18 @@ class Form {
|
|||
imagestring($image,$size,CAPTCHA_WIDTH*4/5+(CAPTCHA_WIDTH/5-$size)/2,(CAPTCHA_HEIGHT-$size)/2+$size/4,$sign,$color);
|
||||
}
|
||||
|
||||
imagejpeg($image,null,90);
|
||||
for ($i=0;$i<20;$i++) {
|
||||
$color= imagecolorallocate($image, rand(160,255), rand(160,255), rand(160,255));
|
||||
imagefilledellipse($image,rand(0,CAPTCHA_WIDTH),rand(0,CAPTCHA_HEIGHT),CAPTCHA_HEIGHT/10,CAPTCHA_HEIGHT/10,$color);
|
||||
}
|
||||
|
||||
$image_copy = imagecreatetruecolor(CAPTCHA_WIDTH,CAPTCHA_HEIGHT);
|
||||
imagecopy($image_copy, $image, 0, 0, 0, 0, CAPTCHA_WIDTH, CAPTCHA_HEIGHT);
|
||||
imagecopy($image_copy, $image, 2, 0, 0, 0, CAPTCHA_WIDTH-2, CAPTCHA_HEIGHT/4);
|
||||
imagecopy($image_copy, $image, 4, CAPTCHA_HEIGHT/4, 0, CAPTCHA_HEIGHT/4, CAPTCHA_WIDTH-4, CAPTCHA_HEIGHT/4);
|
||||
imagecopy($image_copy, $image, 2, CAPTCHA_HEIGHT/2, 0, CAPTCHA_HEIGHT/2, CAPTCHA_WIDTH-2, CAPTCHA_HEIGHT/4);
|
||||
imagedestroy($image);
|
||||
imagejpeg($image_copy,null,90);
|
||||
}
|
||||
|
||||
public static function isCaptchaValid($token,$method=Request::POST) {
|
||||
|
|
Loading…
Reference in a new issue