1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* StartFireflySession.php |
4
|
|
|
* Copyright (c) 2017 [email protected] |
5
|
|
|
* |
6
|
|
|
* This file is part of Firefly III. |
7
|
|
|
* |
8
|
|
|
* Firefly III is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU General Public License as published by |
10
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
11
|
|
|
* (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* Firefly III is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU General Public License |
19
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
declare(strict_types=1); |
23
|
|
|
|
24
|
|
|
namespace FireflyIII\Http\Middleware; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
use Closure; |
28
|
|
|
use Illuminate\Http\Request; |
29
|
|
|
use Illuminate\Session\Middleware\StartSession; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Class StartFireflySession |
33
|
|
|
* |
34
|
|
|
* @package FireflyIII\Http\Middleware |
35
|
|
|
*/ |
36
|
|
|
class StartFireflySession extends StartSession |
37
|
|
|
{ |
38
|
|
|
/** |
39
|
|
|
* Handle an incoming request. |
40
|
|
|
* |
41
|
|
|
* @param \Illuminate\Http\Request $request |
42
|
|
|
* @param Closure $next |
43
|
|
|
* |
44
|
|
|
* @return mixed |
45
|
|
|
*/ |
46
|
|
|
// public function handle($request, Closure $next) |
|
|
|
|
47
|
|
|
// { |
48
|
|
|
// return parent::handle($request, $next); // defer to the right stuff |
49
|
|
|
// } |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Store the current URL for the request if necessary. |
53
|
|
|
* |
54
|
|
|
* @param \Illuminate\Http\Request $request |
55
|
|
|
* @param \Illuminate\Contracts\Session\Session $session |
56
|
|
|
* |
57
|
|
|
* @return void |
58
|
|
|
*/ |
59
|
|
|
protected function storeCurrentUrl(Request $request, $session) |
60
|
|
|
{ |
61
|
|
|
$uri = $request->fullUrl(); |
62
|
|
|
$strpos = strpos($uri, 'jscript'); |
63
|
|
|
if ($request->method() === 'GET' && $request->route() && !$request->ajax() && $strpos === false) { |
64
|
|
|
$session->setPreviousUrl($uri); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
} |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.