@@ -133,7 +133,7 @@ |
||
| 133 | 133 | $token = self::encode(hash_hmac('sha256', ClientIp::getIp($request), base64_decode($token), true)); |
| 134 | 134 | |
| 135 | 135 | return '<input type="hidden" name="'.$this->formIndex.'" value="'.htmlentities($index, ENT_QUOTES, 'UTF-8').'">' |
| 136 | - .'<input type="hidden" name="'.$this->formToken.'" value="'.htmlentities($token, ENT_QUOTES, 'UTF-8').'">'; |
|
| 136 | + .'<input type="hidden" name="'.$this->formToken.'" value="'.htmlentities($token, ENT_QUOTES, 'UTF-8').'">'; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -69,13 +69,13 @@ discard block |
||
| 69 | 69 | return $next($request, $response); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $tokens =& self::getStorage($request, self::KEY); |
|
| 72 | + $tokens = & self::getStorage($request, self::KEY); |
|
| 73 | 73 | |
| 74 | 74 | if (Utils\Helpers::isPost($request) && !$this->validateRequest($request, $tokens)) { |
| 75 | 75 | return $response->withStatus(403); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $generator = function ($action = null) use ($request, &$tokens) { |
|
| 78 | + $generator = function($action = null) use ($request, &$tokens) { |
|
| 79 | 79 | if (empty($action)) { |
| 80 | 80 | $action = $request->getUri()->getPath(); |
| 81 | 81 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $response = $next($request, $response); |
| 92 | 92 | |
| 93 | - return $this->insertIntoPostForms($response, function ($match) use ($generator) { |
|
| 93 | + return $this->insertIntoPostForms($response, function($match) use ($generator) { |
|
| 94 | 94 | preg_match('/action=["\']?([^"\'\s]+)["\']?/i', $match[0], $matches); |
| 95 | 95 | |
| 96 | 96 | return $match[0].$generator(isset($matches[1]) ? $matches[1] : null); |
@@ -91,7 +91,7 @@ |
||
| 91 | 91 | $path = $this->getPath($uri->getPath()); |
| 92 | 92 | $request = $request->withUri($uri->withPath($path)); |
| 93 | 93 | |
| 94 | - $generator = function ($path) { |
|
| 94 | + $generator = function($path) { |
|
| 95 | 95 | return Utils\Helpers::joinPath($this->basePath, $path); |
| 96 | 96 | }; |
| 97 | 97 | |
@@ -113,13 +113,13 @@ |
||
| 113 | 113 | |
| 114 | 114 | $value = $this->encrypt(time()); |
| 115 | 115 | |
| 116 | - $generator = function () use ($value) { |
|
| 116 | + $generator = function() use ($value) { |
|
| 117 | 117 | return '<input type="hidden" name="'.$this->inputName.'" value="'.$value.'">'; |
| 118 | 118 | }; |
| 119 | 119 | |
| 120 | 120 | $response = $next($request, $response); |
| 121 | 121 | |
| 122 | - return $this->insertIntoPostForms($response, function ($match) use ($generator) { |
|
| 122 | + return $this->insertIntoPostForms($response, function($match) use ($generator) { |
|
| 123 | 123 | return $match[0].$generator(); |
| 124 | 124 | }); |
| 125 | 125 | } |
@@ -90,13 +90,13 @@ |
||
| 90 | 90 | return $response->withStatus(403); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $generator = function () { |
|
| 93 | + $generator = function() { |
|
| 94 | 94 | return '<input type="text" name="'.$this->inputName.'" class="'.$this->inputClass.'">'; |
| 95 | 95 | }; |
| 96 | 96 | |
| 97 | 97 | $response = $next($request, $response); |
| 98 | 98 | |
| 99 | - return $this->insertIntoPostForms($response, function ($match) use ($generator) { |
|
| 99 | + return $this->insertIntoPostForms($response, function($match) use ($generator) { |
|
| 100 | 100 | return $match[0].$generator(); |
| 101 | 101 | }); |
| 102 | 102 | } |
@@ -148,7 +148,7 @@ |
||
| 148 | 148 | return $response; |
| 149 | 149 | |
| 150 | 150 | case 'html': |
| 151 | - $generator = function ($path, $transform) { |
|
| 151 | + $generator = function($path, $transform) { |
|
| 152 | 152 | $info = pathinfo($path); |
| 153 | 153 | |
| 154 | 154 | if (!isset($this->sizes[$transform])) { |
@@ -91,7 +91,7 @@ |
||
| 91 | 91 | |
| 92 | 92 | if ($ip !== null) { |
| 93 | 93 | if ($this->saveInSession) { |
| 94 | - $ips =& self::getStorage($request, self::KEY); |
|
| 94 | + $ips = & self::getStorage($request, self::KEY); |
|
| 95 | 95 | |
| 96 | 96 | if (isset($ips[$ip])) { |
| 97 | 97 | $address = new AddressCollection($ips[$ip]); |
@@ -92,7 +92,7 @@ |
||
| 92 | 92 | throw new InvalidArgumentException('Invalid callable provided'); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - return function (RequestInterface $request, ResponseInterface $response, callable $next) use ($basePath, $factory) { |
|
| 95 | + return function(RequestInterface $request, ResponseInterface $response, callable $next) use ($basePath, $factory) { |
|
| 96 | 96 | if (strlen($basePath) > 0 && strpos($request->getUri()->getPath(), $basePath) !== 0) { |
| 97 | 97 | $middleware = false; |
| 98 | 98 | } else { |
@@ -61,41 +61,41 @@ |
||
| 61 | 61 | * |
| 62 | 62 | * @return ResponseInterface |
| 63 | 63 | */ |
| 64 | - public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
|
| 65 | - { |
|
| 66 | - ob_start(); |
|
| 67 | - $level = ob_get_level(); |
|
| 64 | + public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
|
| 65 | + { |
|
| 66 | + ob_start(); |
|
| 67 | + $level = ob_get_level(); |
|
| 68 | 68 | |
| 69 | - $whoops = $this->getWhoopsInstance($request); |
|
| 69 | + $whoops = $this->getWhoopsInstance($request); |
|
| 70 | 70 | |
| 71 | - //Catch errors means register whoops globally |
|
| 72 | - if ($this->catchErrors) { |
|
| 73 | - $whoops->register(); |
|
| 74 | - } |
|
| 71 | + //Catch errors means register whoops globally |
|
| 72 | + if ($this->catchErrors) { |
|
| 73 | + $whoops->register(); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - try { |
|
| 77 | - $response = $next($request, $response); |
|
| 78 | - } catch (\Exception $exception) { |
|
| 79 | - $method = Run::EXCEPTION_HANDLER; |
|
| 76 | + try { |
|
| 77 | + $response = $next($request, $response); |
|
| 78 | + } catch (\Exception $exception) { |
|
| 79 | + $method = Run::EXCEPTION_HANDLER; |
|
| 80 | 80 | |
| 81 | - $whoops->allowQuit(false); |
|
| 82 | - $whoops->writeToOutput(false); |
|
| 83 | - $whoops->sendHttpCode(false); |
|
| 81 | + $whoops->allowQuit(false); |
|
| 82 | + $whoops->writeToOutput(false); |
|
| 83 | + $whoops->sendHttpCode(false); |
|
| 84 | 84 | |
| 85 | - $body = self::createStream(); |
|
| 86 | - $body->write($whoops->$method($exception)); |
|
| 85 | + $body = self::createStream(); |
|
| 86 | + $body->write($whoops->$method($exception)); |
|
| 87 | 87 | |
| 88 | - $response = $response->withStatus(500)->withBody($body); |
|
| 89 | - } finally { |
|
| 90 | - Utils\Helpers::getOutput($level); |
|
| 91 | - } |
|
| 88 | + $response = $response->withStatus(500)->withBody($body); |
|
| 89 | + } finally { |
|
| 90 | + Utils\Helpers::getOutput($level); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - if ($this->catchErrors) { |
|
| 94 | - $whoops->unregister(); |
|
| 95 | - } |
|
| 93 | + if ($this->catchErrors) { |
|
| 94 | + $whoops->unregister(); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - return $response; |
|
| 98 | - } |
|
| 97 | + return $response; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Returns the whoops instance or create one. |