Optimize formatting for Symfony coding standards
This commit is contained in:
parent
9fc82c8453
commit
fef3e306fd
|
@ -139,17 +139,16 @@ class CaptchaGenerator
|
||||||
$size = $width / strlen($captchaValue);
|
$size = $width / strlen($captchaValue);
|
||||||
$font = $options['font'];
|
$font = $options['font'];
|
||||||
$box = imagettfbbox($size, 0, $font, $captchaValue);
|
$box = imagettfbbox($size, 0, $font, $captchaValue);
|
||||||
$txt_width = $box[2] - $box[0];
|
$textWidth = $box[2] - $box[0];
|
||||||
$txt_height = $box[1] - $box[7];
|
$textHeight = $box[1] - $box[7];
|
||||||
|
|
||||||
imagettftext($i, $size, 0, ($width-$txt_width)/2, ($height-$txt_height)/2+$size, $col, $font, $captchaValue);
|
imagettftext($i, $size, 0, ($width - $textWidth) / 2, ($height - $textHeight) / 2 + $size, $col, $font, $captchaValue);
|
||||||
|
|
||||||
// Distort the image
|
// Distort the image
|
||||||
$X = $this->rand(0, $width);
|
$X = $this->rand(0, $width);
|
||||||
$Y = $this->rand(0, $height);
|
$Y = $this->rand(0, $height);
|
||||||
$Phase=$this->rand(0,10);
|
$phase = $this->rand(0, 10);
|
||||||
$Scale = 1.3 + $this->rand(0,10000)/30000;
|
$scale = 1.3 + $this->rand(0, 10000) / 30000;
|
||||||
$Amp=1+$this->rand(0,1000)/1000;
|
|
||||||
$out = imagecreatetruecolor($width, $height);
|
$out = imagecreatetruecolor($width, $height);
|
||||||
|
|
||||||
for ($x = 0; $x < $width; $x++) {
|
for ($x = 0; $x < $width; $x++) {
|
||||||
|
@ -166,7 +165,7 @@ class CaptchaGenerator
|
||||||
$nX = $X;
|
$nX = $X;
|
||||||
$nY = $Y;
|
$nY = $Y;
|
||||||
}
|
}
|
||||||
$nY = $nY+$Scale*sin($Phase + $nX*0.2);
|
$nY = $nY + $scale * sin($phase + $nX * 0.2);
|
||||||
|
|
||||||
$p = $this->bilinearInterpolate($nX - floor($nX), $nY - floor($nY),
|
$p = $this->bilinearInterpolate($nX - floor($nX), $nY - floor($nY),
|
||||||
$this->getCol($i, floor($nX), floor($nY)),
|
$this->getCol($i, floor($nX), floor($nY)),
|
||||||
|
|
|
@ -57,8 +57,7 @@ class CaptchaValidator
|
||||||
$code = $form->getData();
|
$code = $form->getData();
|
||||||
$expectedCode = $this->getExpectedCode();
|
$expectedCode = $this->getExpectedCode();
|
||||||
|
|
||||||
if (!($code && is_string($code)
|
if (!($code && is_string($code) && ($this->compare($code, $expectedCode) || $this->compare($code, $this->bypassCode)))) {
|
||||||
&& ($this->compare($code, $expectedCode) || $this->compare($code, $this->bypassCode)))) {
|
|
||||||
$form->addError(new FormError($this->invalidMessage));
|
$form->addError(new FormError($this->invalidMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue