These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Single entrypoint of the app |
||
5 | */ |
||
6 | require_once './src/lib.inc.php'; |
||
7 | |||
8 | $app->post('/redirect[/{subject}]', function ($request, $response, $args) { |
||
0 ignored issues
–
show
|
|||
9 | $body = $response->getBody(); |
||
10 | $query_string = $request->getUri()->getQuery(); |
||
0 ignored issues
–
show
$query_string is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
11 | $misc = $this->misc; |
||
0 ignored issues
–
show
|
|||
12 | |||
13 | $loginShared = $request->getParsedBodyParam('loginShared'); |
||
14 | $loginServer = $request->getParsedBodyParam('loginServer'); |
||
15 | $loginUsername = $request->getParsedBodyParam('loginUsername'); |
||
16 | $loginPassword = $request->getParsedBodyParam('loginPassword_' . md5($loginServer)); |
||
17 | |||
18 | // If login action is set, then set session variables |
||
19 | if (boolval($loginServer) && boolval($loginUsername) && $loginPassword !== null) { |
||
20 | $_server_info = $this->misc->getServerInfo($loginServer); |
||
21 | |||
22 | $_server_info['username'] = $loginUsername; |
||
23 | $_server_info['password'] = $loginPassword; |
||
24 | |||
25 | $this->misc->setServerInfo(null, $_server_info, $loginServer); |
||
26 | |||
27 | $data = $misc->getDatabaseAccessor(); |
||
28 | |||
29 | if ($data === null) { |
||
30 | $login_controller = new \PHPPgAdmin\Controller\LoginController($this, true); |
||
31 | $body->write($login_controller->doLoginForm($misc->getErrorMsg())); |
||
32 | return $response; |
||
33 | } |
||
34 | // Check for shared credentials |
||
35 | if ($loginShared !== null) { |
||
36 | $_SESSION['sharedUsername'] = $loginUsername; |
||
37 | $_SESSION['sharedPassword'] = $loginPassword; |
||
38 | } |
||
39 | |||
40 | $misc->setReloadBrowser(true); |
||
41 | $all_db_controller = new \PHPPgAdmin\Controller\AlldbController($this); |
||
42 | return $all_db_controller->render(); |
||
43 | } else { |
||
44 | $_server_info = $this->misc->getServerInfo(); |
||
45 | |||
46 | if (!isset($_server_info['username'])) { |
||
47 | $destinationurl = $this->utils->getDestinationWithLastTab($subject); |
||
0 ignored issues
–
show
|
|||
48 | return $response->withStatus(302)->withHeader('Location', $destinationurl); |
||
49 | } |
||
50 | } |
||
51 | }); |
||
52 | |||
53 | $app->get('/redirect[/{subject}]', function ($request, $response, $args) { |
||
54 | $subject = (isset($args['subject'])) ? $args['subject'] : 'root'; |
||
55 | $destinationurl = $this->utils->getDestinationWithLastTab($subject); |
||
0 ignored issues
–
show
|
|||
56 | return $response->withStatus(302)->withHeader('Location', $destinationurl); |
||
57 | }); |
||
58 | |||
59 | $app->get('/src/views/browser', function ($request, $response, $args) { |
||
0 ignored issues
–
show
|
|||
60 | $controller = new \PHPPgAdmin\Controller\BrowserController($this, true); |
||
0 ignored issues
–
show
|
|||
61 | return $controller->render(); |
||
62 | }); |
||
63 | |||
64 | $app->get('/src/views/login', function ($request, $response, $args) { |
||
0 ignored issues
–
show
|
|||
65 | $controller = new \PHPPgAdmin\Controller\LoginController($this, true); |
||
0 ignored issues
–
show
|
|||
66 | return $controller->render(); |
||
67 | }); |
||
68 | |||
69 | $app->get('/src/views/servers', function ($request, $response, $args) { |
||
0 ignored issues
–
show
|
|||
70 | $controller = new \PHPPgAdmin\Controller\ServersController($this, true); |
||
0 ignored issues
–
show
|
|||
71 | return $controller->render(); |
||
72 | }); |
||
73 | |||
74 | $app->get('/src/views/intro', function ($request, $response, $args) { |
||
0 ignored issues
–
show
|
|||
75 | $controller = new \PHPPgAdmin\Controller\IntroController($this, true); |
||
0 ignored issues
–
show
|
|||
76 | return $controller->render(); |
||
77 | }); |
||
78 | |||
79 | $app->map(['GET', 'POST'], '/src/views/{subject}', function ($request, $response, $args) { |
||
80 | if ($this->misc->getServerId() === null) { |
||
0 ignored issues
–
show
|
|||
81 | return $response->withStatus(302)->withHeader('Location', SUBFOLDER . '/src/views/servers'); |
||
82 | } |
||
83 | $_server_info = $this->misc->getServerInfo(); |
||
84 | |||
85 | if (!isset($_server_info['username'])) { |
||
86 | $destinationurl = SUBFOLDER . '/src/views/login?server=' . $this->misc->getServerId(); |
||
87 | return $response->withStatus(302)->withHeader('Location', $destinationurl); |
||
88 | } |
||
89 | |||
90 | $subject = $args['subject']; |
||
91 | |||
92 | $className = '\PHPPgAdmin\Controller\\' . ucfirst($subject) . 'Controller'; |
||
93 | $controller = new $className($this); |
||
94 | return $controller->render(); |
||
95 | }); |
||
96 | |||
97 | $app->get('/[{subject}]', function ($request, $response, $args) { |
||
98 | $subject = (isset($args['subject'])) ? $args['subject'] : 'intro'; |
||
99 | $_server_info = $this->misc->getServerInfo(); |
||
0 ignored issues
–
show
|
|||
100 | $query_string = $request->getUri()->getQuery(); |
||
101 | $server_id = $request->getQueryParam('server'); |
||
102 | |||
103 | if (!isset($_server_info['username']) && ($subject === 'server' || $subject === 'root')) { |
||
104 | $subject = 'login'; |
||
105 | } |
||
106 | |||
107 | if ($subject === 'login' && $server_id === null) { |
||
108 | $subject = 'servers'; |
||
109 | } |
||
110 | |||
111 | $viewVars = [ |
||
112 | 'url' => '/src/views/' . $subject . ($query_string ? '?' . $query_string : ''), |
||
113 | 'headertemplate' => 'header.twig', |
||
114 | ]; |
||
115 | |||
116 | return $this->view->render($response, 'iframe_view.twig', $viewVars); |
||
117 | }); |
||
118 | |||
119 | // Run app |
||
120 | $app->run(); |
||
121 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.