-1

我使用 Laravel 5.5,但日语验证码有错误。

我找不到原因,最近几天有时会发生(我没有改变任何东西):

未定义的偏移量:-1 {"exception":"[object] (ErrorException(code: 0): Undefined offset: -1 at .../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))

请帮我解决这个问题,这对我来说非常重要。

感谢和问候。

编辑: 我的功能

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();
        }
    }
4

1 回答 1

0

我不能提供完整的答案,但也许我可以让你更接近一点。

这是ConvertCharToCase函数(变量名被混淆了,所以我用更容易阅读的东西替换了它们):

<?php

function ConvertCharToCase($first_arg, $second_arg)
    {
    $second_arg_split = str_split(decbin($second_arg) , 1);
    $count_of_split = count($second_arg_split);
    $first_arg_split = str_split($first_arg, 1);
    $upperorlower = "";
    $result = "";
    for ($first_arg_strlen = strlen($first_arg) - 1; $first_arg_strlen >= 0; $first_arg_strlen--)
        {
        $second_arg_split_element = null;
        $second_arg_split_element = $second_arg_split[$count_of_split-- - 1];
        if ($second_arg_split_element != null && strcasecmp($second_arg_split_element, "\61") == 0)
            {
            $upperorlower = strtoupper($first_arg_split[$first_arg_strlen]);
            }
          else
            {
            $upperorlower = strtolower($first_arg_split[$first_arg_strlen]);
            }

        $result = $upperorlower . $result;
        }

    return $result;
}

echo ConvertCharToCase("\xE3\x81\xBE\xE3\x81\xBF\xE3\x82\x8F\xE3\x81\x8D\xE3\x81\x91", 1425);

?>

这个被调用1425确实会打印如下通知:

PHP Notice:  Undefined offset: -1 in /home/sneep/src/stackoverflow/japanese/captcha/test.php on line 13
PHP Notice:  Undefined offset: -2 in /home/sneep/src/stackoverflow/japanese/captcha/test.php on line 13
PHP Notice:  Undefined offset: -3 in /home/sneep/src/stackoverflow/japanese/captcha/test.php on line 13
PHP Notice:  Undefined offset: -4 in /home/sneep/src/stackoverflow/japanese/captcha/test.php on line 13
まみわきけ

通常,这些通知不会使程序崩溃,但也许您无意中打开了导致它们被视为错误的模式?

如果您需要一个起点,这里有一个线程可以帮助您:Laravel 5 Error Reporting Suppression

于 2018-04-06T13:52:11.570 回答