@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - 'characters' => ['2','3','4','6','7','8','9','a','b','c','d','e','f','g','h','j','m','n','p','q','r','t','u','x','y','z','A','B','C','D','E','F','G','H','J','M','N','P','Q','R','T','U','X','Y','Z'], |
|
| 5 | + 'characters' => ['2','3','4','6','7','8','9','a','b','c','d','e','f','g','h','j','m','n','p','q','r','t','u','x','y','z','A','B','C','D','E','F','G','H','J','M','N','P','Q','R','T','U','X','Y','Z'], |
|
| 6 | 6 | |
| 7 | 7 | 'default' => [ |
| 8 | 8 | 'length' => 9, |
@@ -283,9 +283,9 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | return $api ? [ |
| 286 | - 'sensitive' => $generator['sensitive'], |
|
| 287 | - 'key' => $generator['key'], |
|
| 288 | - 'img' => $this->image->encode('data-url')->encoded |
|
| 286 | + 'sensitive' => $generator['sensitive'], |
|
| 287 | + 'key' => $generator['key'], |
|
| 288 | + 'img' => $this->image->encode('data-url')->encoded |
|
| 289 | 289 | ] : $this->image->response('png', $this->quality); |
| 290 | 290 | } |
| 291 | 291 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | $key .= ''; |
| 320 | 320 | } else { |
| 321 | 321 | for ($i = 0; $i < $this->length; $i++) { |
| 322 | - $char = $characters[rand(0, count($characters) - 1)]; |
|
| 322 | + $char = $characters[rand(0, count($characters) - 1)]; |
|
| 323 | 323 | $bag[] = $this->sensitive ? $char : $this->str->lower($char); |
| 324 | 324 | } |
| 325 | 325 | $key = implode('', $bag); |
@@ -332,9 +332,9 @@ discard block |
||
| 332 | 332 | ]); |
| 333 | 333 | |
| 334 | 334 | return [ |
| 335 | - 'value' => $bag, |
|
| 336 | - 'sensitive' => $this->sensitive, |
|
| 337 | - 'key' => $hash |
|
| 335 | + 'value' => $bag, |
|
| 336 | + 'sensitive' => $this->sensitive, |
|
| 337 | + 'key' => $hash |
|
| 338 | 338 | ]; |
| 339 | 339 | } |
| 340 | 340 | |
@@ -343,24 +343,24 @@ discard block |
||
| 343 | 343 | */ |
| 344 | 344 | protected function text() |
| 345 | 345 | { |
| 346 | - $marginTop = $this->image->height() / $this->length; |
|
| 347 | - |
|
| 348 | - $i = 0; |
|
| 349 | - foreach($this->text as $char) |
|
| 350 | - { |
|
| 351 | - $marginLeft = $this->textLeftPadding + ($i * ($this->image->width() - $this->textLeftPadding) / $this->length); |
|
| 352 | - |
|
| 353 | - $this->image->text($char, $marginLeft, $marginTop, function($font) { |
|
| 354 | - $font->file($this->font()); |
|
| 355 | - $font->size($this->fontSize()); |
|
| 356 | - $font->color($this->fontColor()); |
|
| 357 | - $font->align('left'); |
|
| 358 | - $font->valign('top'); |
|
| 359 | - $font->angle($this->angle()); |
|
| 360 | - }); |
|
| 361 | - |
|
| 362 | - $i++; |
|
| 363 | - } |
|
| 346 | + $marginTop = $this->image->height() / $this->length; |
|
| 347 | + |
|
| 348 | + $i = 0; |
|
| 349 | + foreach($this->text as $char) |
|
| 350 | + { |
|
| 351 | + $marginLeft = $this->textLeftPadding + ($i * ($this->image->width() - $this->textLeftPadding) / $this->length); |
|
| 352 | + |
|
| 353 | + $this->image->text($char, $marginLeft, $marginTop, function($font) { |
|
| 354 | + $font->file($this->font()); |
|
| 355 | + $font->size($this->fontSize()); |
|
| 356 | + $font->color($this->fontColor()); |
|
| 357 | + $font->align('left'); |
|
| 358 | + $font->valign('top'); |
|
| 359 | + $font->angle($this->angle()); |
|
| 360 | + }); |
|
| 361 | + |
|
| 362 | + $i++; |
|
| 363 | + } |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | /** |
@@ -434,26 +434,26 @@ discard block |
||
| 434 | 434 | return $this->image; |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - /** |
|
| 438 | - * Captcha check |
|
| 439 | - * |
|
| 440 | - * @param $value |
|
| 441 | - * @return bool |
|
| 442 | - */ |
|
| 443 | - public function check($value) |
|
| 444 | - { |
|
| 445 | - if ( ! $this->session->has('captcha')) |
|
| 446 | - { |
|
| 447 | - return false; |
|
| 448 | - } |
|
| 437 | + /** |
|
| 438 | + * Captcha check |
|
| 439 | + * |
|
| 440 | + * @param $value |
|
| 441 | + * @return bool |
|
| 442 | + */ |
|
| 443 | + public function check($value) |
|
| 444 | + { |
|
| 445 | + if ( ! $this->session->has('captcha')) |
|
| 446 | + { |
|
| 447 | + return false; |
|
| 448 | + } |
|
| 449 | 449 | |
| 450 | - $key = $this->session->get('captcha.key'); |
|
| 451 | - $sensitive = $this->session->get('captcha.sensitive'); |
|
| 450 | + $key = $this->session->get('captcha.key'); |
|
| 451 | + $sensitive = $this->session->get('captcha.sensitive'); |
|
| 452 | 452 | |
| 453 | - if ( ! $sensitive) |
|
| 454 | - { |
|
| 455 | - $value = $this->str->lower($value); |
|
| 456 | - } |
|
| 453 | + if ( ! $sensitive) |
|
| 454 | + { |
|
| 455 | + $value = $this->str->lower($value); |
|
| 456 | + } |
|
| 457 | 457 | |
| 458 | 458 | |
| 459 | 459 | $res = $this->hasher->check($value, $key); |
@@ -463,18 +463,18 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | return $res; |
| 466 | - } |
|
| 467 | - |
|
| 468 | - /** |
|
| 469 | - * Captcha check |
|
| 470 | - * |
|
| 471 | - * @param $value |
|
| 472 | - * @return bool |
|
| 473 | - */ |
|
| 474 | - public function check_api($value, $key) |
|
| 475 | - { |
|
| 476 | - return $this->hasher->check($value, $key); |
|
| 477 | - } |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + /** |
|
| 469 | + * Captcha check |
|
| 470 | + * |
|
| 471 | + * @param $value |
|
| 472 | + * @return bool |
|
| 473 | + */ |
|
| 474 | + public function check_api($value, $key) |
|
| 475 | + { |
|
| 476 | + return $this->hasher->check($value, $key); |
|
| 477 | + } |
|
| 478 | 478 | |
| 479 | 479 | /** |
| 480 | 480 | * Generate captcha image source |