@@ -36,23 +36,23 @@ |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | if ( ! function_exists('captcha_check')) { |
39 | - /** |
|
40 | - * @param $value |
|
41 | - * @return bool |
|
42 | - */ |
|
43 | - function captcha_check($value) |
|
44 | - { |
|
45 | - return app('captcha')->check($value); |
|
46 | - } |
|
39 | + /** |
|
40 | + * @param $value |
|
41 | + * @return bool |
|
42 | + */ |
|
43 | + function captcha_check($value) |
|
44 | + { |
|
45 | + return app('captcha')->check($value); |
|
46 | + } |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | if ( ! function_exists('captcha_api_check')) { |
50 | - /** |
|
51 | - * @param $value |
|
52 | - * @return bool |
|
53 | - */ |
|
54 | - function captcha_api_check($value, $key) |
|
55 | - { |
|
56 | - return app('captcha')->check_api($value, $key); |
|
57 | - } |
|
50 | + /** |
|
51 | + * @param $value |
|
52 | + * @return bool |
|
53 | + */ |
|
54 | + function captcha_api_check($value, $key) |
|
55 | + { |
|
56 | + return app('captcha')->check_api($value, $key); |
|
57 | + } |
|
58 | 58 | } |
@@ -24,29 +24,29 @@ |
||
24 | 24 | |
25 | 25 | // HTTP routing |
26 | 26 | if (strpos($this->app->version(), 'Lumen') !== false) { |
27 | - $this->app->get('captcha[/api/{config}]', 'Mews\Captcha\LumenCaptchaController@getCaptchaApi'); |
|
28 | - $this->app->get('captcha[/{config}]', 'Mews\Captcha\LumenCaptchaController@getCaptcha'); |
|
27 | + $this->app->get('captcha[/api/{config}]', 'Mews\Captcha\LumenCaptchaController@getCaptchaApi'); |
|
28 | + $this->app->get('captcha[/{config}]', 'Mews\Captcha\LumenCaptchaController@getCaptcha'); |
|
29 | 29 | } else { |
30 | 30 | if ((double) $this->app->version() >= 5.2) { |
31 | - $this->app['router']->get('captcha/api/{config?}', '\Mews\Captcha\CaptchaController@getCaptchaApi')->middleware('web'); |
|
32 | - $this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha')->middleware('web'); |
|
31 | + $this->app['router']->get('captcha/api/{config?}', '\Mews\Captcha\CaptchaController@getCaptchaApi')->middleware('web'); |
|
32 | + $this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha')->middleware('web'); |
|
33 | 33 | } else { |
34 | - $this->app['router']->get('captcha/api/{config?}', '\Mews\Captcha\CaptchaController@getCaptchaApi'); |
|
35 | - $this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha'); |
|
34 | + $this->app['router']->get('captcha/api/{config?}', '\Mews\Captcha\CaptchaController@getCaptchaApi'); |
|
35 | + $this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha'); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | - // Validator extensions |
|
40 | - $this->app['validator']->extend('captcha', function($attribute, $value, $parameters) |
|
41 | - { |
|
42 | - return captcha_check($value); |
|
43 | - }); |
|
39 | + // Validator extensions |
|
40 | + $this->app['validator']->extend('captcha', function($attribute, $value, $parameters) |
|
41 | + { |
|
42 | + return captcha_check($value); |
|
43 | + }); |
|
44 | 44 | |
45 | - // Validator extensions |
|
46 | - $this->app['validator']->extend('captcha_api', function($attribute, $value, $parameters) |
|
47 | - { |
|
48 | - return captcha_api_check($value, $parameters[0]); |
|
49 | - }); |
|
45 | + // Validator extensions |
|
46 | + $this->app['validator']->extend('captcha_api', function($attribute, $value, $parameters) |
|
47 | + { |
|
48 | + return captcha_api_check($value, $parameters[0]); |
|
49 | + }); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -11,32 +11,32 @@ |
||
11 | 11 | class CaptchaController extends Controller |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * get CAPTCHA |
|
16 | - * |
|
17 | - * @param \Mews\Captcha\Captcha $captcha |
|
18 | - * @param string $config |
|
19 | - * @return \Intervention\Image\ImageManager->response |
|
20 | - */ |
|
21 | - public function getCaptcha(Captcha $captcha, $config = 'default') |
|
22 | - { |
|
23 | - if (ob_get_contents()) |
|
24 | - { |
|
25 | - ob_clean(); |
|
26 | - } |
|
27 | - return $captcha->create($config); |
|
28 | - } |
|
14 | + /** |
|
15 | + * get CAPTCHA |
|
16 | + * |
|
17 | + * @param \Mews\Captcha\Captcha $captcha |
|
18 | + * @param string $config |
|
19 | + * @return \Intervention\Image\ImageManager->response |
|
20 | + */ |
|
21 | + public function getCaptcha(Captcha $captcha, $config = 'default') |
|
22 | + { |
|
23 | + if (ob_get_contents()) |
|
24 | + { |
|
25 | + ob_clean(); |
|
26 | + } |
|
27 | + return $captcha->create($config); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * get CAPTCHA api |
|
32 | - * |
|
33 | - * @param \Mews\Captcha\Captcha $captcha |
|
34 | - * @param string $config |
|
35 | - * @return \Intervention\Image\ImageManager->response |
|
36 | - */ |
|
37 | - public function getCaptchaApi(Captcha $captcha, $config = 'default') |
|
38 | - { |
|
39 | - return $captcha->create($config, true); |
|
40 | - } |
|
30 | + /** |
|
31 | + * get CAPTCHA api |
|
32 | + * |
|
33 | + * @param \Mews\Captcha\Captcha $captcha |
|
34 | + * @param string $config |
|
35 | + * @return \Intervention\Image\ImageManager->response |
|
36 | + */ |
|
37 | + public function getCaptchaApi(Captcha $captcha, $config = 'default') |
|
38 | + { |
|
39 | + return $captcha->create($config, true); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | } |
@@ -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,10 +343,10 @@ discard block |
||
343 | 343 | */ |
344 | 344 | protected function text() |
345 | 345 | { |
346 | - $marginTop = $this->image->height() / $this->length; |
|
346 | + $marginTop = $this->image->height() / $this->length; |
|
347 | 347 | |
348 | - $text = $this->text; |
|
349 | - if (is_string($text)) { |
|
348 | + $text = $this->text; |
|
349 | + if (is_string($text)) { |
|
350 | 350 | $text = str_split($text); |
351 | 351 | } |
352 | 352 | |
@@ -435,26 +435,26 @@ discard block |
||
435 | 435 | return $this->image; |
436 | 436 | } |
437 | 437 | |
438 | - /** |
|
439 | - * Captcha check |
|
440 | - * |
|
441 | - * @param $value |
|
442 | - * @return bool |
|
443 | - */ |
|
444 | - public function check($value) |
|
445 | - { |
|
446 | - if ( ! $this->session->has('captcha')) |
|
447 | - { |
|
448 | - return false; |
|
449 | - } |
|
438 | + /** |
|
439 | + * Captcha check |
|
440 | + * |
|
441 | + * @param $value |
|
442 | + * @return bool |
|
443 | + */ |
|
444 | + public function check($value) |
|
445 | + { |
|
446 | + if ( ! $this->session->has('captcha')) |
|
447 | + { |
|
448 | + return false; |
|
449 | + } |
|
450 | 450 | |
451 | - $key = $this->session->get('captcha.key'); |
|
452 | - $sensitive = $this->session->get('captcha.sensitive'); |
|
451 | + $key = $this->session->get('captcha.key'); |
|
452 | + $sensitive = $this->session->get('captcha.sensitive'); |
|
453 | 453 | |
454 | - if ( ! $sensitive) |
|
455 | - { |
|
456 | - $value = $this->str->lower($value); |
|
457 | - } |
|
454 | + if ( ! $sensitive) |
|
455 | + { |
|
456 | + $value = $this->str->lower($value); |
|
457 | + } |
|
458 | 458 | |
459 | 459 | |
460 | 460 | $res = $this->hasher->check($value, $key); |
@@ -464,18 +464,18 @@ discard block |
||
464 | 464 | } |
465 | 465 | |
466 | 466 | return $res; |
467 | - } |
|
468 | - |
|
469 | - /** |
|
470 | - * Captcha check |
|
471 | - * |
|
472 | - * @param $value |
|
473 | - * @return bool |
|
474 | - */ |
|
475 | - public function check_api($value, $key) |
|
476 | - { |
|
477 | - return $this->hasher->check($value, $key); |
|
478 | - } |
|
467 | + } |
|
468 | + |
|
469 | + /** |
|
470 | + * Captcha check |
|
471 | + * |
|
472 | + * @param $value |
|
473 | + * @return bool |
|
474 | + */ |
|
475 | + public function check_api($value, $key) |
|
476 | + { |
|
477 | + return $this->hasher->check($value, $key); |
|
478 | + } |
|
479 | 479 | |
480 | 480 | /** |
481 | 481 | * Generate captcha image source |