BotDetect Captcha имеет ошибку с японскими символами (laravel-captcha) - PullRequest
0 голосов
/ 02 мая 2018

Я использую Laravel 5.5, это происходит с символами Японии (неопределенное смещение: -1 в /CaptchaInclude.php) в последние дни (я ничего не менял, все было оштрафовано на несколько месяцев).

Причина этой проблемы НЕ моя плохая, поэтому, пожалуйста, "НЕ МАРКИРУЙТЕ" это как "дублирующую" проблему, я не нашел ответа на свой вопрос.

Это моя кодировка:

public function login(Request $request)
{
    // Delete old session (error validation)
    $request->session()->forget('wrong_captcha');
    $request->session()->forget('wrong_fivetimes');

    $throttler = Throttle::get($request, env('LOGIN_TIMES'), env('WAITING_TIME'));
    // login fail > 5 times
    if(count($throttler) > 5) {
        // message input invalid over 5 times
        $request->session()->put('wrong_fivetimes', 'Input wrong 5 times!');
        return redirect()->back()->withInput();
    }

    // Get data from 'Login form'
    $email = filter_var($request['email'], FILTER_SANITIZE_STRING);
    $password = filter_var($request['password'], FILTER_SANITIZE_STRING);
    $captcha_code = filter_var($request['captcha_code'], FILTER_SANITIZE_STRING);
    $isHuman = captcha_validate($captcha_code);

    // Validate the form data
    $this->validate($request, [
        'email'   => 'required|email|max:255',
        'password' => 'required|min:6|max:100',
        'captcha_code' => 'required'
    ]);

    // check count fail times
    if(count($throttler) <= 5) {
        // admin input captcha code equal to generated captcha system
        if ($isHuman) {
            // Attempt to log the user in
            if (Auth::guard('admin')->attempt(['email' => $email, 'password' => $password])) {
                Throttle::clear($request);

                // if successful, then redirect to their intended location
                return redirect()->intended('admin/dashboard');
            }
            // count up (login fail times)
            Throttle::hit($request);

            // if unsuccessful, then redirect back to the login with the form data
            return redirect()->back()->withInput($request->only('email'));
        }
        // count up (login fail times)
        Throttle::hit($request);

        // message input captcha code is wrong
        $request->session()->put('wrong_captcha', 'Input captcha is wrong!');
        return redirect()->back()->withInput();
    }
}

И это моя проблема:

Неопределенное смещение: -1 {"исключение": "[объект] (ErrorException (код: 0): Неопределенное смещение: -1 в ... / vendor / captcha-com / captcha / lib / botdetect / CaptchaIncludes.php : 2)

#0 .../vendor/captcha-com/captcha/lib/botdetect/CaptchaIncludes.php(2): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'Undefined offse...', '/home/reportbea...', 2, Array)
#1 .../vendor/captcha-com/captcha/lib/botdetect/CaptchaIncludes.php(2): BDC_StringHelper::ConvertCharToCase('\\xE3\\x81\\xBE\\xE3\\x81\\xBF\\xE3\\x82\\x8F\\xE3\\x81\\x8D\\xE3\\x81\\x91', 1425)
#2 .../vendor/captcha-com/captcha/lib/botdetect/CaptchaIncludes.php(2): BDC_CodeCollection->Validate('\\xE3\\x81\\xAD\\xE3\\x81\\x8D\\xE3\\x82\\x8C\\xE3\\x81\\x8D\\xE3\\x82\\x82', '2f4e2c7bb45326e...', 1425, 1, 1200)
#3 .../vendor/captcha-com/captcha/lib/botdetect/CaptchaClass.php(2): BDC_CaptchaBase->Validate('\\xE3\\x81\\xAD\\xE3\\x81\\x8D\\xE3\\x82\\x8C\\xE3\\x81\\x8D\\xE3\\x82\\x82', '2f4e2c7bb45326e...', 1, false)
#4 [internal function]: Captcha->Validate('\\xE3\\x81\\xAD\\xE3\\x81\\x8D\\xE3\\x82\\x8C\\xE3\\x81\\x8D\\xE3\\x82\\x82', '2f4e2c7bb45326e...')
#5 .../vendor/captcha-com/laravel-captcha/src/BotDetectCaptcha.php(101): call_user_func_array(Array, Array)
#6 .../vendor/captcha-com/laravel-captcha/src/BotDetectCaptcha.php(101): call_user_func_array(Array, Array)
#7 .../vendor/captcha-com/laravel-captcha/src/Support/helpers.php(84): LaravelCaptcha\\BotDetectCaptcha->__call('Validate', Array)
#8 Modules/Admin/Http/Controllers/Auth/AdminLoginController.php(55): captcha_validate('\\xE3\\x81\\xAD\\xE3\\x81\\x8D\\xE3\\x82\\x8C\\xE3\\x81\\x8D\\xE3\\x82\\x82')
#9 [internal function]: Modules\\Admin\\Http\\Controllers\\Auth\\AdminLoginController->login(Object(Illuminate\\Http\\Request))
#10 .../vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#11 .../vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('login', Array)
#12 .../vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(Modules\\Admin\\Http\\Controllers\\Auth\\AdminLoginController), 'login')
#13 .../vendor/laravel/framework/src/Illuminate/Routing/Route.php(169): Illuminate\\Routing\\Route->runController()
#14 .../vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\\Routing\\Route->run()
#15 .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#16 /app/Http/Middleware/RedirectIfAuthenticated.php(40): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#17 .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\\Http\\Middleware\\RedirectIfAuthenticated->handle(Object(Illuminate\\Http\\Request), Object(Closure), 'admin')
#18 .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#19 .../vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#20 .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#21 .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#22 .../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(67): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#23 .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#24 .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#25 .../vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#26 .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#27 .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 .../vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#28 .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 .../vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#31 .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#32 .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#33 .../vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#34 .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#35 .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#36 .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#37 .../vendor/laravel/framework/src/Illuminate/Routing/Router.php(660): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#38 .../vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#39 .../vendor/laravel/framework/src/Illuminate/Routing/Router.php(601): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#40 .../vendor/laravel/framework/src/Illuminate/Routing/Router.php(590): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#41 .../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#42 .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#43 .../vendor/fideloper/proxy/src/TrustProxies.php(56): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#44 .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#45 .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#46 .../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#47 .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#48 .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#49 .../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#50 .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#51 .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#52 .../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#53 .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#54 .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#55 .../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#56 .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#57 .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#58 .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#59 .../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#60 .../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#61 .../public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
...