1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* sysPass |
4
|
|
|
* |
5
|
|
|
* @author nuxsmin |
6
|
|
|
* @link https://syspass.org |
7
|
|
|
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org |
8
|
|
|
* |
9
|
|
|
* This file is part of sysPass. |
10
|
|
|
* |
11
|
|
|
* sysPass is free software: you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU General Public License as published by |
13
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
14
|
|
|
* (at your option) any later version. |
15
|
|
|
* |
16
|
|
|
* sysPass is distributed in the hope that it will be useful, |
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19
|
|
|
* GNU General Public License for more details. |
20
|
|
|
* |
21
|
|
|
* You should have received a copy of the GNU General Public License |
22
|
|
|
* along with sysPass. If not, see <http://www.gnu.org/licenses/>. |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace SP\Modules\Web\Controllers; |
26
|
|
|
|
27
|
|
|
use DI\Container; |
28
|
|
|
use Klein\Klein; |
29
|
|
|
use SP\Core\Exceptions\FileNotFoundException; |
30
|
|
|
use SP\Core\Exceptions\SPException; |
31
|
|
|
use SP\Modules\Web\Controllers\Helpers\LayoutHelper; |
32
|
|
|
use SP\Mvc\View\Template; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Class ErrorController |
36
|
|
|
* |
37
|
|
|
* @package SP\Modules\Web\Controllers |
38
|
|
|
*/ |
39
|
|
|
final class ErrorController |
40
|
|
|
{ |
41
|
|
|
/** |
42
|
|
|
* @var Template |
43
|
|
|
*/ |
44
|
|
|
protected $view; |
45
|
|
|
/** |
46
|
|
|
* @var Klein |
47
|
|
|
*/ |
48
|
|
|
protected $router; |
49
|
|
|
/** |
50
|
|
|
* @var LayoutHelper |
51
|
|
|
*/ |
52
|
|
|
protected $layoutHelper; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* ErrorController constructor. |
56
|
|
|
* |
57
|
|
|
* @param Container $container |
58
|
|
|
* @param string $actionName |
59
|
|
|
* |
60
|
|
|
* @throws \DI\DependencyException |
61
|
|
|
* @throws \DI\NotFoundException |
62
|
|
|
*/ |
63
|
|
|
public function __construct(Container $container, $actionName) |
|
|
|
|
64
|
|
|
{ |
65
|
|
|
$this->router = $container->get(Klein::class); |
66
|
|
|
|
67
|
|
|
$this->view = $container->get(Template::class); |
68
|
|
|
$this->view->setBase('error'); |
69
|
|
|
|
70
|
|
|
$this->layoutHelper = $container->get(LayoutHelper::class); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* indexAction |
75
|
|
|
*/ |
76
|
|
|
public function indexAction() |
77
|
|
|
{ |
78
|
|
|
$this->layoutHelper->getPublicLayout('error'); |
79
|
|
|
$this->view(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Mostrar los datos de la plantilla |
84
|
|
|
*/ |
85
|
|
|
protected function view() |
86
|
|
|
{ |
87
|
|
|
try { |
88
|
|
|
echo $this->view->render(); |
89
|
|
|
} catch (FileNotFoundException $e) { |
90
|
|
|
processException($e); |
91
|
|
|
|
92
|
|
|
echo __($e->getMessage()); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
die(); |
|
|
|
|
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* databaseErrorAction |
100
|
|
|
*/ |
101
|
|
|
public function maintenanceErrorAction() |
102
|
|
|
{ |
103
|
|
|
$this->layoutHelper->getPublicLayout('error-maintenance'); |
104
|
|
|
|
105
|
|
|
$this->view->append('errors', [ |
106
|
|
|
'type' => SPException::WARNING, |
107
|
|
|
'description' => __('Aplicación en mantenimiento'), |
108
|
|
|
'hint' => __('En breve estará operativa') |
109
|
|
|
]); |
110
|
|
|
|
111
|
|
|
$this->view(); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* databaseErrorAction |
116
|
|
|
*/ |
117
|
|
|
public function databaseErrorAction() |
118
|
|
|
{ |
119
|
|
|
$this->layoutHelper->getPublicLayout('error-database'); |
120
|
|
|
|
121
|
|
|
$this->view->append('errors', [ |
122
|
|
|
'type' => SPException::CRITICAL, |
123
|
|
|
'description' => __('Error en la verificación de la base de datos'), |
124
|
|
|
'hint' => __('Consulte con el administrador') |
125
|
|
|
]); |
126
|
|
|
|
127
|
|
|
$this->view(); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* databaseErrorAction |
132
|
|
|
*/ |
133
|
|
|
public function databaseConnectionAction() |
134
|
|
|
{ |
135
|
|
|
$this->layoutHelper->getPublicLayout('error-database'); |
136
|
|
|
|
137
|
|
|
$this->view->append('errors', [ |
138
|
|
|
'type' => SPException::CRITICAL, |
139
|
|
|
'description' => __('No es posible conectar con la BD'), |
140
|
|
|
'hint' => __('Consulte con el administrador') |
141
|
|
|
]); |
142
|
|
|
|
143
|
|
|
$this->view(); |
144
|
|
|
} |
145
|
|
|
} |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.