Grav\Plugin\Admin\AdminBaseController::validateNonce PHP Метод

validateNonce() защищенный Метод

protected validateNonce ( )
    protected function validateNonce()
    {
        if (method_exists('Grav\\Common\\Utils', 'getNonce')) {
            if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
                if (isset($this->post['admin-nonce'])) {
                    $nonce = $this->post['admin-nonce'];
                } else {
                    $nonce = $this->grav['uri']->param('admin-nonce');
                }
                if (!$nonce || !Utils::verifyNonce($nonce, 'admin-form')) {
                    if ($this->task == 'addmedia') {
                        $message = sprintf($this->admin->translate('PLUGIN_ADMIN.FILE_TOO_LARGE', null), ini_get('post_max_size'));
                        //In this case it's more likely that the image is too big than POST can handle. Show message
                        $this->admin->json_response = ['status' => 'error', 'message' => $message];
                        return false;
                    }
                    $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN'), 'error');
                    $this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN')];
                    return false;
                }
                unset($this->post['admin-nonce']);
            } else {
                if ($this->task == 'logout') {
                    $nonce = $this->grav['uri']->param('logout-nonce');
                    if (!isset($nonce) || !Utils::verifyNonce($nonce, 'logout-form')) {
                        $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN'), 'error');
                        $this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN')];
                        return false;
                    }
                } else {
                    $nonce = $this->grav['uri']->param('admin-nonce');
                    if (!isset($nonce) || !Utils::verifyNonce($nonce, 'admin-form')) {
                        $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN'), 'error');
                        $this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN')];
                        return false;
                    }
                }
            }
        }
        return true;
    }