@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | final class Router implements IRouter { |
24 | 24 | |
25 | 25 | /** |
26 | - * @var array CONSTANTE con las reglas permitidas |
|
27 | - */ |
|
26 | + * @var array CONSTANTE con las reglas permitidas |
|
27 | + */ |
|
28 | 28 | const RULES = [ |
29 | 29 | 'none', # Sin ninguna regla |
30 | 30 | 'letters', # Sólamente letras |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | ]; |
38 | 38 | |
39 | 39 | /** |
40 | - * Colección de rutas existentes |
|
41 | - * |
|
42 | - * @var array |
|
43 | - */ |
|
40 | + * Colección de rutas existentes |
|
41 | + * |
|
42 | + * @var array |
|
43 | + */ |
|
44 | 44 | private $routerCollection = array( |
45 | 45 | '/controller' => 'home', # controlador por defecto |
46 | 46 | '/method' => null, # método por defecto |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | ); |
49 | 49 | |
50 | 50 | /** |
51 | - * Colección de reglas para cada ruta existente |
|
52 | - * |
|
53 | - * @var array |
|
54 | - */ |
|
51 | + * Colección de reglas para cada ruta existente |
|
52 | + * |
|
53 | + * @var array |
|
54 | + */ |
|
55 | 55 | private $routerCollectionRules = array( |
56 | 56 | '/controller' => 'letters', |
57 | 57 | '/method' => 'none', |
@@ -59,18 +59,18 @@ discard block |
||
59 | 59 | ); |
60 | 60 | |
61 | 61 | /** |
62 | - * @var array |
|
63 | - */ |
|
62 | + * @var array |
|
63 | + */ |
|
64 | 64 | private $real_request = array(); |
65 | 65 | |
66 | 66 | /** |
67 | - * @var string |
|
68 | - */ |
|
67 | + * @var string |
|
68 | + */ |
|
69 | 69 | private $requestUri; |
70 | 70 | |
71 | 71 | /** |
72 | - * __construct() |
|
73 | - */ |
|
72 | + * __construct() |
|
73 | + */ |
|
74 | 74 | public function __construct() { |
75 | 75 | global $http; |
76 | 76 | |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | - * Coloca una regla destinada a una ruta, siempre y cuando esta regla exista. |
|
86 | - * |
|
87 | - * @param string $index : Índice de la ruta |
|
88 | - * @param string $rule : Nombre de la regla |
|
89 | - * |
|
90 | - * @throws \RuntimeException si la regla no existe |
|
91 | - */ |
|
85 | + * Coloca una regla destinada a una ruta, siempre y cuando esta regla exista. |
|
86 | + * |
|
87 | + * @param string $index : Índice de la ruta |
|
88 | + * @param string $rule : Nombre de la regla |
|
89 | + * |
|
90 | + * @throws \RuntimeException si la regla no existe |
|
91 | + */ |
|
92 | 92 | final private function setCollectionRule(string $index, string $rule) { |
93 | 93 | # Verificar si la regla existe |
94 | 94 | if(!in_array($rule,self::RULES)) { |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
102 | - * Verifica las peticiones por defecto |
|
103 | - */ |
|
102 | + * Verifica las peticiones por defecto |
|
103 | + */ |
|
104 | 104 | final private function checkRequests() { |
105 | 105 | # Verificar si existe peticiones |
106 | 106 | if(null !== $this->requestUri) { |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | - * Crea una nueva ruta. |
|
118 | - * |
|
119 | - * @param string $index : Índice de la ruta |
|
120 | - * @param string $rule : Nombre de la regla, por defecto es ninguna "none" |
|
121 | - * |
|
122 | - * @throws \RuntimeException si no puede definirse la ruta |
|
123 | - */ |
|
117 | + * Crea una nueva ruta. |
|
118 | + * |
|
119 | + * @param string $index : Índice de la ruta |
|
120 | + * @param string $rule : Nombre de la regla, por defecto es ninguna "none" |
|
121 | + * |
|
122 | + * @throws \RuntimeException si no puede definirse la ruta |
|
123 | + */ |
|
124 | 124 | final public function setRoute(string $index, string $rule = 'none') { |
125 | 125 | # Nombres de rutas no permitidos |
126 | 126 | if(in_array($index,['/controller','/method','/id'])) { |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
143 | - * Obtiene el valor de una ruta según la regla que ha sido definida y si ésta existe. |
|
144 | - * |
|
145 | - * @param string $index : Índice de la ruta |
|
146 | - * |
|
147 | - * @throws \RuntimeException si la ruta no existe o si no está implementada la regla |
|
148 | - * @return mixed : Valor de la ruta solicitada |
|
149 | - */ |
|
143 | + * Obtiene el valor de una ruta según la regla que ha sido definida y si ésta existe. |
|
144 | + * |
|
145 | + * @param string $index : Índice de la ruta |
|
146 | + * |
|
147 | + * @throws \RuntimeException si la ruta no existe o si no está implementada la regla |
|
148 | + * @return mixed : Valor de la ruta solicitada |
|
149 | + */ |
|
150 | 150 | final public function getRoute(string $index) { |
151 | 151 | # Verificar existencia de ruta |
152 | 152 | if(!array_key_exists($index,$this->routerCollection)) { |
@@ -189,34 +189,34 @@ discard block |
||
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
192 | - * Obtiene el nombre del controlador. |
|
193 | - * |
|
194 | - * @return string controlador. |
|
195 | - */ |
|
192 | + * Obtiene el nombre del controlador. |
|
193 | + * |
|
194 | + * @return string controlador. |
|
195 | + */ |
|
196 | 196 | final public function getController() { |
197 | 197 | return $this->routerCollection['/controller']; |
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
201 | - * Obtiene el método |
|
202 | - * |
|
203 | - * @return string con el método. |
|
204 | - * null si no está definido. |
|
205 | - */ |
|
201 | + * Obtiene el método |
|
202 | + * |
|
203 | + * @return string con el método. |
|
204 | + * null si no está definido. |
|
205 | + */ |
|
206 | 206 | final public function getMethod() { |
207 | 207 | return $this->routerCollection['/method']; |
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
211 | - * Obtiene el id |
|
212 | - * |
|
213 | - * @param bool $with_rules : true para obtener el id con reglas definidas para números mayores a 0 |
|
214 | - * false para obtener el id sin reglas definidas |
|
215 | - * |
|
216 | - * @return int|null con el id |
|
217 | - * int con el id si usa reglas. |
|
218 | - * null si no está definido. |
|
219 | - */ |
|
211 | + * Obtiene el id |
|
212 | + * |
|
213 | + * @param bool $with_rules : true para obtener el id con reglas definidas para números mayores a 0 |
|
214 | + * false para obtener el id sin reglas definidas |
|
215 | + * |
|
216 | + * @return int|null con el id |
|
217 | + * int con el id si usa reglas. |
|
218 | + * null si no está definido. |
|
219 | + */ |
|
220 | 220 | final public function getId(bool $with_rules = false) { |
221 | 221 | $id = $this->routerCollection['/id']; |
222 | 222 | if($with_rules) { |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | return $id; |
227 | 227 | } |
228 | 228 | |
229 | - /** |
|
230 | - * Ejecuta el controlador solicitado por la URL. |
|
231 | - * Si este no existe, ejecutará errorController. |
|
232 | - * Si no se solicita ningún controlador, ejecutará homeController. |
|
233 | - */ |
|
229 | + /** |
|
230 | + * Ejecuta el controlador solicitado por la URL. |
|
231 | + * Si este no existe, ejecutará errorController. |
|
232 | + * Si no se solicita ningún controlador, ejecutará homeController. |
|
233 | + */ |
|
234 | 234 | final public function executeController() { |
235 | 235 | # Definir controlador |
236 | 236 | if(null != ($controller = $this->getController())) { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | final private function setCollectionRule(string $index, string $rule) { |
93 | 93 | # Verificar si la regla existe |
94 | - if(!in_array($rule,self::RULES)) { |
|
94 | + if (!in_array($rule, self::RULES)) { |
|
95 | 95 | throw new \RuntimeException('La regla ' . $rule . ' no existe.'); |
96 | 96 | } |
97 | 97 | # Definir la regla para la ruta |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | */ |
104 | 104 | final private function checkRequests() { |
105 | 105 | # Verificar si existe peticiones |
106 | - if(null !== $this->requestUri) { |
|
107 | - $this->real_request = explode('/',$this->requestUri); |
|
106 | + if (null !== $this->requestUri) { |
|
107 | + $this->real_request = explode('/', $this->requestUri); |
|
108 | 108 | $this->routerCollection['/controller'] = $this->real_request[0]; |
109 | 109 | } |
110 | 110 | |
111 | 111 | # Setear las siguientes rutas |
112 | - $this->routerCollection['/method'] = array_key_exists(1,$this->real_request) ? $this->real_request[1] : null; |
|
113 | - $this->routerCollection['/id'] = array_key_exists(2,$this->real_request) ? $this->real_request[2] : null; |
|
112 | + $this->routerCollection['/method'] = array_key_exists(1, $this->real_request) ? $this->real_request[1] : null; |
|
113 | + $this->routerCollection['/id'] = array_key_exists(2, $this->real_request) ? $this->real_request[2] : null; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | final public function setRoute(string $index, string $rule = 'none') { |
125 | 125 | # Nombres de rutas no permitidos |
126 | - if(in_array($index,['/controller','/method','/id'])) { |
|
126 | + if (in_array($index, ['/controller', '/method', '/id'])) { |
|
127 | 127 | throw new \RuntimeException('No puede definirse ' . $index . ' como índice en la ruta.'); |
128 | 128 | } |
129 | 129 | |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | |
136 | 136 | # Definir la ruta y regla |
137 | 137 | $lastRoute = sizeof($this->routerCollection); |
138 | - $this->routerCollection[$index] = array_key_exists($lastRoute,$this->real_request) ? $this->real_request[$lastRoute] : null; |
|
139 | - $this->setCollectionRule($index,$rule); |
|
138 | + $this->routerCollection[$index] = array_key_exists($lastRoute, $this->real_request) ? $this->real_request[$lastRoute] : null; |
|
139 | + $this->setCollectionRule($index, $rule); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | final public function getRoute(string $index) { |
151 | 151 | # Verificar existencia de ruta |
152 | - if(!array_key_exists($index,$this->routerCollection)) { |
|
152 | + if (!array_key_exists($index, $this->routerCollection)) { |
|
153 | 153 | throw new \RuntimeException('La ruta ' . $index . ' no está definida en el controlador.'); |
154 | 154 | } |
155 | 155 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $ruta = $this->routerCollection[$index]; |
158 | 158 | |
159 | 159 | # Retornar ruta con la regla definida aplicada |
160 | - switch($this->routerCollectionRules[$index]) { |
|
160 | + switch ($this->routerCollectionRules[$index]) { |
|
161 | 161 | case 'none': |
162 | 162 | return $ruta; |
163 | 163 | case 'letters': |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | */ |
212 | 212 | final public function getId(bool $with_rules = false) { |
213 | 213 | $id = $this->routerCollection['/id']; |
214 | - if($with_rules) { |
|
214 | + if ($with_rules) { |
|
215 | 215 | return (null !== $id && is_numeric($id) && $id > 0) ? (int) $id : null; |
216 | 216 | } |
217 | 217 | |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | */ |
226 | 226 | final public function executeController() { |
227 | 227 | # Definir controlador |
228 | - if(null != ($controller = $this->getController())) { |
|
228 | + if (null != ($controller = $this->getController())) { |
|
229 | 229 | $controller = $controller . 'Controller'; |
230 | 230 | |
231 | - if(!is_readable('app/controllers/' . $controller . '.php')) { |
|
231 | + if (!is_readable('app/controllers/' . $controller . '.php')) { |
|
232 | 232 | $controller = 'errorController'; |
233 | 233 | } |
234 | 234 |
@@ -23,17 +23,17 @@ |
||
23 | 23 | final class Config { |
24 | 24 | |
25 | 25 | /** |
26 | - * Ruta con parámetros de configuración |
|
27 | - * |
|
28 | - * @var string |
|
29 | - */ |
|
26 | + * Ruta con parámetros de configuración |
|
27 | + * |
|
28 | + * @var string |
|
29 | + */ |
|
30 | 30 | const FILE_CONFIG_ROUTE = API_INTERFACE . 'Ocrend/Kernel/Config/Ocrend.ini.yml'; |
31 | 31 | |
32 | 32 | /** |
33 | - * Lee la configuración del archivo self::FILE_CONFIG_ROUTE |
|
34 | - * |
|
35 | - * @return array : Arreglo con la configuración en el archivo .yml |
|
36 | - */ |
|
33 | + * Lee la configuración del archivo self::FILE_CONFIG_ROUTE |
|
34 | + * |
|
35 | + * @return array : Arreglo con la configuración en el archivo .yml |
|
36 | + */ |
|
37 | 37 | final public function readConfig() : array { |
38 | 38 | return Yaml::parse(file_get_contents(self::FILE_CONFIG_ROUTE)); |
39 | 39 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | //--------------------------------------------------------------------------------------------- |
28 | 28 | |
29 | 29 | /** |
30 | - * Manejador de excepciones y errores |
|
30 | + * Manejador de excepciones y errores |
|
31 | 31 | */ |
32 | 32 | ErrorHandler::register(); |
33 | 33 | ExceptionHandler::register(); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | //--------------------------------------------------------------------------------------------- |
36 | 36 | |
37 | 37 | /** |
38 | - * Versión mínima de PHP |
|
38 | + * Versión mínima de PHP |
|
39 | 39 | */ |
40 | 40 | if (version_compare(phpversion(), '7.0.0', '<')) { |
41 | 41 | throw new \RuntimeException('La versión actual de PHP es ' . phpversion() . ' y como mínimo se require la versión 7.0.0'); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | //--------------------------------------------------------------------------------------------- |
45 | 45 | |
46 | 46 | /** |
47 | - * Lectura y escritura de caché para Twig |
|
47 | + * Lectura y escritura de caché para Twig |
|
48 | 48 | */ |
49 | 49 | if(!is_writable(API_INTERFACE . 'app/templates/.cache/') || !is_readable(API_INTERFACE . 'app/templates/.cache/')) { |
50 | 50 | throw new \RuntimeException('Debe conceder permisos de escritura y lectura a la ruta ' . API_INTERFACE . 'app/templates/.cache/ ó crearla si no existe.'); |
@@ -53,15 +53,15 @@ discard block |
||
53 | 53 | //--------------------------------------------------------------------------------------------- |
54 | 54 | |
55 | 55 | /** |
56 | - * Obtiene la configuración inicial del sistema, conexión a la base de datos, |
|
57 | - * constantes de phpmailer, credenciales de la api de paypal, etc. |
|
56 | + * Obtiene la configuración inicial del sistema, conexión a la base de datos, |
|
57 | + * constantes de phpmailer, credenciales de la api de paypal, etc. |
|
58 | 58 | */ |
59 | 59 | $config = (new Config)->readConfig(); |
60 | 60 | |
61 | 61 | //--------------------------------------------------------------------------------------------- |
62 | 62 | |
63 | 63 | /** |
64 | - * Capa orientada a objetos para el uso de sesiones más seguras en PHP |
|
64 | + * Capa orientada a objetos para el uso de sesiones más seguras en PHP |
|
65 | 65 | */ |
66 | 66 | $session = new Session(new NativeSessionStorage( |
67 | 67 | array( |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | //--------------------------------------------------------------------------------------------- |
74 | 74 | |
75 | 75 | /** |
76 | - * Capa orientada a objetos de HTTPFoundation |
|
76 | + * Capa orientada a objetos de HTTPFoundation |
|
77 | 77 | */ |
78 | 78 | $http = Request::createFromGlobals(); |
79 | 79 | |
80 | 80 | //--------------------------------------------------------------------------------------------- |
81 | 81 | |
82 | 82 | /** |
83 | - * Estatus del DEBUG |
|
83 | + * Estatus del DEBUG |
|
84 | 84 | */ |
85 | 85 | if($config['framework']['debug']) { |
86 | 86 | Debug::enable(); |
@@ -89,6 +89,6 @@ discard block |
||
89 | 89 | //--------------------------------------------------------------------------------------------- |
90 | 90 | |
91 | 91 | /** |
92 | - * Define el timezone actual |
|
92 | + * Define el timezone actual |
|
93 | 93 | */ |
94 | 94 | date_default_timezone_set($config['site']['timezone']); |
95 | 95 | \ No newline at end of file |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * Lectura y escritura de caché para Twig |
48 | 48 | */ |
49 | -if(!is_writable(API_INTERFACE . 'app/templates/.cache/') || !is_readable(API_INTERFACE . 'app/templates/.cache/')) { |
|
49 | +if (!is_writable(API_INTERFACE . 'app/templates/.cache/') || !is_readable(API_INTERFACE . 'app/templates/.cache/')) { |
|
50 | 50 | throw new \RuntimeException('Debe conceder permisos de escritura y lectura a la ruta ' . API_INTERFACE . 'app/templates/.cache/ ó crearla si no existe.'); |
51 | 51 | } |
52 | 52 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * Estatus del DEBUG |
84 | 84 | */ |
85 | -if($config['framework']['debug']) { |
|
85 | +if ($config['framework']['debug']) { |
|
86 | 86 | Debug::enable(); |
87 | 87 | } |
88 | 88 |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $this->template->addGlobal('is_logged', $this->is_logged); |
115 | 115 | |
116 | 116 | # Datos del usuario actual |
117 | - if($this->is_logged) { |
|
117 | + if ($this->is_logged) { |
|
118 | 118 | $this->user = (new Model\Users)->getOwnerUser(); |
119 | 119 | $this->template->addGlobal('owner_user', $this->user); |
120 | 120 | } |
@@ -145,17 +145,17 @@ discard block |
||
145 | 145 | $this->controllerConfig['users_not_logged'] = false; |
146 | 146 | |
147 | 147 | # Establecer las configuraciones pasadas |
148 | - if(null != $config) { |
|
148 | + if (null != $config) { |
|
149 | 149 | # Configura el autoreload del caché de twig |
150 | - if(array_key_exists('twig_cache_reload',$config)) { |
|
150 | + if (array_key_exists('twig_cache_reload', $config)) { |
|
151 | 151 | $this->controllerConfig['twig_cache_reload'] = (bool) $config['twig_cache_reload']; |
152 | 152 | } |
153 | 153 | # Configura el controlador para solo ser visto por usuarios logeados |
154 | - if(array_key_exists('users_logged',$config)) { |
|
154 | + if (array_key_exists('users_logged', $config)) { |
|
155 | 155 | $this->controllerConfig['users_logged'] = (bool) $config['users_logged']; |
156 | 156 | } |
157 | 157 | # Configura el controlador para solo ser visto por usuario no logeados |
158 | - if(array_key_exists('users_not_logged',$config)) { |
|
158 | + if (array_key_exists('users_not_logged', $config)) { |
|
159 | 159 | $this->controllerConfig['users_not_logged'] = (bool) $config['users_not_logged']; |
160 | 160 | } |
161 | 161 | } |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | */ |
169 | 169 | private function knowVisitorPermissions() { |
170 | 170 | # Sólamente usuarios logeados |
171 | - if($this->controllerConfig['users_logged'] && !$this->is_logged) { |
|
171 | + if ($this->controllerConfig['users_logged'] && !$this->is_logged) { |
|
172 | 172 | $this->functions->redir(); |
173 | 173 | } |
174 | 174 | |
175 | 175 | # Sólamente usuarios no logeados |
176 | - if($this->controllerConfig['users_not_logged'] && $this->is_logged) { |
|
176 | + if ($this->controllerConfig['users_not_logged'] && $this->is_logged) { |
|
177 | 177 | $this->functions->redir(); |
178 | 178 | } |
179 | 179 | } |
@@ -25,65 +25,65 @@ discard block |
||
25 | 25 | abstract class Controllers { |
26 | 26 | |
27 | 27 | /** |
28 | - * Obtiene el objeto del template |
|
29 | - * |
|
30 | - * @var \Twig_Environment |
|
31 | - */ |
|
28 | + * Obtiene el objeto del template |
|
29 | + * |
|
30 | + * @var \Twig_Environment |
|
31 | + */ |
|
32 | 32 | protected $template; |
33 | 33 | |
34 | 34 | /** |
35 | - * Verifica si está definida la ruta /id como un integer >= 1 |
|
36 | - * |
|
37 | - * @var bool |
|
38 | - */ |
|
35 | + * Verifica si está definida la ruta /id como un integer >= 1 |
|
36 | + * |
|
37 | + * @var bool |
|
38 | + */ |
|
39 | 39 | protected $isset_id = false; |
40 | 40 | |
41 | 41 | /** |
42 | - * Tiene el valor de la ruta /método |
|
43 | - * |
|
44 | - * @var string|null |
|
45 | - */ |
|
42 | + * Tiene el valor de la ruta /método |
|
43 | + * |
|
44 | + * @var string|null |
|
45 | + */ |
|
46 | 46 | protected $method; |
47 | 47 | |
48 | 48 | /** |
49 | - * Contiene una instancia del helper para funciones |
|
50 | - * |
|
51 | - * @var \Ocrend\Kernel\Helpers\Functions |
|
52 | - */ |
|
49 | + * Contiene una instancia del helper para funciones |
|
50 | + * |
|
51 | + * @var \Ocrend\Kernel\Helpers\Functions |
|
52 | + */ |
|
53 | 53 | protected $functions; |
54 | 54 | |
55 | 55 | /** |
56 | - * Arreglo con la información del usuario conectado actualmente. |
|
57 | - * |
|
58 | - * @var array |
|
59 | - */ |
|
56 | + * Arreglo con la información del usuario conectado actualmente. |
|
57 | + * |
|
58 | + * @var array |
|
59 | + */ |
|
60 | 60 | protected $user = array(); |
61 | 61 | |
62 | 62 | /** |
63 | - * Contiene información sobre el estado del usuario, si está o no conectado. |
|
64 | - * |
|
65 | - * @var bool |
|
66 | - */ |
|
63 | + * Contiene información sobre el estado del usuario, si está o no conectado. |
|
64 | + * |
|
65 | + * @var bool |
|
66 | + */ |
|
67 | 67 | private $is_logged = false; |
68 | 68 | |
69 | 69 | /** |
70 | - * Parámetros de configuración para el controlador con la forma: |
|
71 | - * 'parmáetro' => (bool) valor |
|
72 | - * |
|
73 | - * @var array |
|
74 | - */ |
|
70 | + * Parámetros de configuración para el controlador con la forma: |
|
71 | + * 'parmáetro' => (bool) valor |
|
72 | + * |
|
73 | + * @var array |
|
74 | + */ |
|
75 | 75 | private $controllerConfig; |
76 | 76 | |
77 | 77 | /** |
78 | - * Configuración inicial de cualquier controlador |
|
79 | - * |
|
80 | - * @param IRouter $router: Instancia de un Router |
|
81 | - * @param array|null $configController: Arreglo de configuración con la forma |
|
82 | - * 'twig_cache_reload' => bool, # Configura el autoreload del caché de twig |
|
83 | - * 'users_logged' => bool, # Configura el controlador para solo ser visto por usuarios logeados |
|
84 | - * 'users_not_logged' => bool, # Configura el controlador para solo ser visto por !(usuarios logeados) |
|
85 | - * |
|
86 | - */ |
|
78 | + * Configuración inicial de cualquier controlador |
|
79 | + * |
|
80 | + * @param IRouter $router: Instancia de un Router |
|
81 | + * @param array|null $configController: Arreglo de configuración con la forma |
|
82 | + * 'twig_cache_reload' => bool, # Configura el autoreload del caché de twig |
|
83 | + * 'users_logged' => bool, # Configura el controlador para solo ser visto por usuarios logeados |
|
84 | + * 'users_not_logged' => bool, # Configura el controlador para solo ser visto por !(usuarios logeados) |
|
85 | + * |
|
86 | + */ |
|
87 | 87 | protected function __construct(IRouter $router, $configController = null) { |
88 | 88 | global $config, $http, $session; |
89 | 89 | |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
134 | - * Establece los parámetros de configuración de un controlador |
|
135 | - * |
|
136 | - * @param IRouter $router: Instancia de un Router |
|
137 | - * @param array|null $config: Arreglo de configuración |
|
138 | - * |
|
139 | - * @return void |
|
140 | - */ |
|
134 | + * Establece los parámetros de configuración de un controlador |
|
135 | + * |
|
136 | + * @param IRouter $router: Instancia de un Router |
|
137 | + * @param array|null $config: Arreglo de configuración |
|
138 | + * |
|
139 | + * @return void |
|
140 | + */ |
|
141 | 141 | private function setControllerConfig($config) { |
142 | 142 | # Configuración por defecto |
143 | 143 | $this->controllerConfig['twig_cache_reload'] = true; |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | - * Acción que regula quién entra o no al controlador según la configuración |
|
166 | - * |
|
167 | - * @return void |
|
168 | - */ |
|
165 | + * Acción que regula quién entra o no al controlador según la configuración |
|
166 | + * |
|
167 | + * @return void |
|
168 | + */ |
|
169 | 169 | private function knowVisitorPermissions() { |
170 | 170 | # Sólamente usuarios logeados |
171 | 171 | if($this->controllerConfig['users_logged'] && !$this->is_logged) { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $mail->CharSet = "UTF-8"; |
36 | 36 | $mail->Encoding = "quoted-printable"; |
37 | 37 | |
38 | - if($is_smtp) { |
|
38 | + if ($is_smtp) { |
|
39 | 39 | $mail->isSMTP(); |
40 | 40 | $mail->SMTPAuth = true; |
41 | 41 | $mail->Host = $config['phpmailer']['host']; |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | $mail->Subject = $titulo; |
89 | 89 | $mail->Body = $HTML; |
90 | 90 | |
91 | - if(sizeof($adj)) { |
|
91 | + if (sizeof($adj)) { |
|
92 | 92 | foreach ($adj as $ruta) { |
93 | 93 | $mail->AddAttachment($ruta); |
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | - if(!$mail->send()) { |
|
97 | + if (!$mail->send()) { |
|
98 | 98 | return $mail->ErrorInfo; |
99 | 99 | } |
100 | 100 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | </head> |
119 | 119 | <body style="font-family: Verdana;"> |
120 | 120 | <section> |
121 | - '.$content.' |
|
121 | + '.$content . ' |
|
122 | 122 | </section> |
123 | 123 | </body> |
124 | 124 | </html>'; |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | final class Emails { |
21 | 21 | |
22 | 22 | /** |
23 | - * FUNCIÓN NO ACCESIBLE, USO ESTRICTO PARA UNA FUNCIÓN INTERNA DEL HELPER |
|
24 | - * Inicializa la clase PHPMailer y las configuraciones necesarias |
|
25 | - * Método privado utilizado en todo el Helper |
|
26 | - * |
|
27 | - * @param bool $is_smtp: Define si se hará la conexión a través de SMTP o no |
|
28 | - * |
|
29 | - * @return \PHPMailer un objeto de la clase PHPMailer |
|
30 | - */ |
|
23 | + * FUNCIÓN NO ACCESIBLE, USO ESTRICTO PARA UNA FUNCIÓN INTERNA DEL HELPER |
|
24 | + * Inicializa la clase PHPMailer y las configuraciones necesarias |
|
25 | + * Método privado utilizado en todo el Helper |
|
26 | + * |
|
27 | + * @param bool $is_smtp: Define si se hará la conexión a través de SMTP o no |
|
28 | + * |
|
29 | + * @return \PHPMailer un objeto de la clase PHPMailer |
|
30 | + */ |
|
31 | 31 | final private static function init(bool $is_smtp = true) : \PHPMailer { |
32 | 32 | global $config; |
33 | 33 | |
@@ -60,22 +60,22 @@ discard block |
||
60 | 60 | //------------------------------------------------ |
61 | 61 | |
62 | 62 | /** |
63 | - * Envía un correo electrónico utilizando PHPMailer |
|
64 | - * |
|
65 | - * @param array $dest: Arreglo con la forma array( |
|
66 | - * 'email destinatario 1' => 'nombre destinatario 1', |
|
67 | - * 'email destinatario 2' => 'nombre destinatario 2' |
|
68 | - * ) |
|
69 | - * @param string $HTML: Contenido en HTML del email |
|
70 | - * @param string $titulo: Asunto del email |
|
71 | - * @param bool $is_smtp: Define si se hará la conexión a través de SMTP o no |
|
72 | - * @param array $adj: Arreglo con direccion local de los adjuntos a enviar, con la forma array( |
|
73 | - * 'ruta archivo 1', |
|
74 | - * 'ruta archivo 2' |
|
75 | - * ) |
|
76 | - * |
|
77 | - * @return string|bool true si fue enviado correctamente, string con el Error descrito por PHPMailer |
|
78 | - */ |
|
63 | + * Envía un correo electrónico utilizando PHPMailer |
|
64 | + * |
|
65 | + * @param array $dest: Arreglo con la forma array( |
|
66 | + * 'email destinatario 1' => 'nombre destinatario 1', |
|
67 | + * 'email destinatario 2' => 'nombre destinatario 2' |
|
68 | + * ) |
|
69 | + * @param string $HTML: Contenido en HTML del email |
|
70 | + * @param string $titulo: Asunto del email |
|
71 | + * @param bool $is_smtp: Define si se hará la conexión a través de SMTP o no |
|
72 | + * @param array $adj: Arreglo con direccion local de los adjuntos a enviar, con la forma array( |
|
73 | + * 'ruta archivo 1', |
|
74 | + * 'ruta archivo 2' |
|
75 | + * ) |
|
76 | + * |
|
77 | + * @return string|bool true si fue enviado correctamente, string con el Error descrito por PHPMailer |
|
78 | + */ |
|
79 | 79 | final public static function send_mail(array $dest, string $HTML, string $titulo, bool $is_smtp = true, array $adj = []) { |
80 | 80 | global $config; |
81 | 81 | |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | //------------------------------------------------ |
105 | 105 | |
106 | 106 | /** |
107 | - * Plantilla estándar que muestra de forma amigable el texto, utiliza bootstrap |
|
108 | - * |
|
109 | - * @param string $content: Cadena de texto en HTML, puede ser en bootstrap |
|
110 | - * |
|
111 | - * @return string con el HTML para enviar |
|
112 | - */ |
|
107 | + * Plantilla estándar que muestra de forma amigable el texto, utiliza bootstrap |
|
108 | + * |
|
109 | + * @param string $content: Cadena de texto en HTML, puede ser en bootstrap |
|
110 | + * |
|
111 | + * @return string con el HTML para enviar |
|
112 | + */ |
|
113 | 113 | final public static function plantilla(string $content) : string { |
114 | 114 | return ' |
115 | 115 | <html> |
@@ -20,15 +20,15 @@ |
||
20 | 20 | class ModelsException extends \Exception { |
21 | 21 | |
22 | 22 | /** |
23 | - * __construct() |
|
24 | - */ |
|
23 | + * __construct() |
|
24 | + */ |
|
25 | 25 | public function __construct($message = null, $code = 1, \Exception $previous = null) { |
26 | 26 | parent::__construct($message, $code, $previous); |
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
30 | - * Muestra el error con un formato u otro dependiendo desde donde se hace la petición. |
|
31 | - */ |
|
30 | + * Muestra el error con un formato u otro dependiendo desde donde se hace la petición. |
|
31 | + */ |
|
32 | 32 | public function errorResponse() { |
33 | 33 | throw new \RuntimeException($this->getMessage()); |
34 | 34 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | * @author Brayan Narváez <[email protected]> |
20 | 20 | */ |
21 | 21 | |
22 | - interface IModels { |
|
23 | - public function __construct(IRouter $router = null); |
|
24 | - public function __destruct(); |
|
25 | - } |
|
26 | 22 | \ No newline at end of file |
23 | + interface IModels { |
|
24 | + public function __construct(IRouter $router = null); |
|
25 | + public function __destruct(); |
|
26 | + } |
|
27 | 27 | \ No newline at end of file |
@@ -9,43 +9,43 @@ discard block |
||
9 | 9 | * file that was distributed with this source code. |
10 | 10 | */ |
11 | 11 | |
12 | - namespace Ocrend\Kernel\Models\Traits; |
|
12 | + namespace Ocrend\Kernel\Models\Traits; |
|
13 | 13 | |
14 | - use Ocrend\Kernel\Database\Database; |
|
14 | + use Ocrend\Kernel\Database\Database; |
|
15 | 15 | |
16 | 16 | /** |
17 | - * Añade características a un modelo para que pueda conectarse a una base de datos. |
|
18 | - * |
|
19 | - * @author Brayan Narváez <[email protected]> |
|
17 | + * Añade características a un modelo para que pueda conectarse a una base de datos. |
|
18 | + * |
|
19 | + * @author Brayan Narváez <[email protected]> |
|
20 | 20 | */ |
21 | 21 | |
22 | 22 | trait DBModel { |
23 | 23 | |
24 | 24 | /** |
25 | - * Tiene la instancia de la base de datos actual |
|
26 | - * |
|
27 | - * @var null|Database |
|
28 | - */ |
|
25 | + * Tiene la instancia de la base de datos actual |
|
26 | + * |
|
27 | + * @var null|Database |
|
28 | + */ |
|
29 | 29 | protected $db = null; |
30 | 30 | |
31 | 31 | /** |
32 | - * Contiene la información que se pasa al manejador de la base de datos. |
|
33 | - * - Nombre de base de datos |
|
34 | - * - Motor de base de datos |
|
35 | - * - Valor de nueva instancia |
|
36 | - * |
|
37 | - * @var array |
|
38 | - */ |
|
32 | + * Contiene la información que se pasa al manejador de la base de datos. |
|
33 | + * - Nombre de base de datos |
|
34 | + * - Motor de base de datos |
|
35 | + * - Valor de nueva instancia |
|
36 | + * |
|
37 | + * @var array |
|
38 | + */ |
|
39 | 39 | private $databaseConfig = array(); |
40 | 40 | |
41 | 41 | /** |
42 | - * Establece la configuración de la base de datos |
|
43 | - * |
|
44 | - * @param array|null $databaseConfig: Configuración de conexión con base de datos con la forma |
|
45 | - * 'name' => string, # Nombre de la base de datos |
|
46 | - * 'motor' => string, # Motor de la base de datos |
|
47 | - * 'new_instance' => bool, # Establecer nueva instancia distinta a alguna ya existente |
|
48 | - */ |
|
42 | + * Establece la configuración de la base de datos |
|
43 | + * |
|
44 | + * @param array|null $databaseConfig: Configuración de conexión con base de datos con la forma |
|
45 | + * 'name' => string, # Nombre de la base de datos |
|
46 | + * 'motor' => string, # Motor de la base de datos |
|
47 | + * 'new_instance' => bool, # Establecer nueva instancia distinta a alguna ya existente |
|
48 | + */ |
|
49 | 49 | private function setDatabaseConfig($databaseConfig) { |
50 | 50 | global $config; |
51 | 51 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | # Añadir según lo pasado por $databaseConfig |
58 | 58 | if(is_array($databaseConfig)) { |
59 | 59 | if(array_key_exists('name',$databaseConfig)) { |
60 | - $this->databaseConfig['name'] = $databaseConfig['name']; |
|
60 | + $this->databaseConfig['name'] = $databaseConfig['name']; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | if(array_key_exists('motor',$databaseConfig)) { |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
74 | - * Constructor inicial del modelo. |
|
75 | - * |
|
76 | - * @param array|null $databaseConfig: Configuración de conexión con base de datos con la forma |
|
77 | - * 'name' => string, # Nombre de la base de datos |
|
78 | - * 'motor' => string, # Motor de la base de datos |
|
79 | - * 'new_instance' => bool, # Establecer nueva instancia distinta a alguna ya existente |
|
80 | - */ |
|
74 | + * Constructor inicial del modelo. |
|
75 | + * |
|
76 | + * @param array|null $databaseConfig: Configuración de conexión con base de datos con la forma |
|
77 | + * 'name' => string, # Nombre de la base de datos |
|
78 | + * 'motor' => string, # Motor de la base de datos |
|
79 | + * 'new_instance' => bool, # Establecer nueva instancia distinta a alguna ya existente |
|
80 | + */ |
|
81 | 81 | protected function startDBConexion($databaseConfig = null) { |
82 | 82 | # Llenar la configuración a la base de datos |
83 | 83 | $this->setDatabaseConfig($databaseConfig); |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | - * Finaliza la conexión con la base de datos. |
|
95 | - */ |
|
94 | + * Finaliza la conexión con la base de datos. |
|
95 | + */ |
|
96 | 96 | protected function endDBConexion() { |
97 | 97 | $this->db = null; |
98 | 98 | } |
@@ -55,16 +55,16 @@ |
||
55 | 55 | $this->databaseConfig['new_instance'] = false; |
56 | 56 | |
57 | 57 | # Añadir según lo pasado por $databaseConfig |
58 | - if(is_array($databaseConfig)) { |
|
59 | - if(array_key_exists('name',$databaseConfig)) { |
|
60 | - $this->databaseConfig['name'] = $databaseConfig['name']; |
|
58 | + if (is_array($databaseConfig)) { |
|
59 | + if (array_key_exists('name', $databaseConfig)) { |
|
60 | + $this->databaseConfig['name'] = $databaseConfig['name']; |
|
61 | 61 | } |
62 | 62 | |
63 | - if(array_key_exists('motor',$databaseConfig)) { |
|
64 | - $this->databaseConfig['motor'] = $databaseConfig['motor']; |
|
63 | + if (array_key_exists('motor', $databaseConfig)) { |
|
64 | + $this->databaseConfig['motor'] = $databaseConfig['motor']; |
|
65 | 65 | } |
66 | 66 | |
67 | - if(array_key_exists('new_instance',$databaseConfig)) { |
|
67 | + if (array_key_exists('new_instance', $databaseConfig)) { |
|
68 | 68 | $this->databaseConfig['new_instance'] = (bool) $databaseConfig['new_instance']; |
69 | 69 | } |
70 | 70 | } |
@@ -28,36 +28,36 @@ discard block |
||
28 | 28 | |
29 | 29 | class Users extends Models implements IModels { |
30 | 30 | /** |
31 | - * Característica para establecer conexión con base de datos. |
|
32 | - */ |
|
31 | + * Característica para establecer conexión con base de datos. |
|
32 | + */ |
|
33 | 33 | use DBModel; |
34 | 34 | |
35 | 35 | /** |
36 | - * Máximos intentos de inincio de sesión de un usuario |
|
37 | - * |
|
38 | - * @var int |
|
39 | - */ |
|
36 | + * Máximos intentos de inincio de sesión de un usuario |
|
37 | + * |
|
38 | + * @var int |
|
39 | + */ |
|
40 | 40 | const MAX_ATTEMPTS = 5; |
41 | 41 | |
42 | 42 | /** |
43 | - * Tiempo entre máximos intentos en segundos |
|
44 | - * |
|
45 | - * @var int |
|
46 | - */ |
|
43 | + * Tiempo entre máximos intentos en segundos |
|
44 | + * |
|
45 | + * @var int |
|
46 | + */ |
|
47 | 47 | const MAX_ATTEMPTS_TIME = 120; # (dos minutos) |
48 | 48 | |
49 | 49 | /** |
50 | - * Log de intentos recientes con la forma 'email' => (int) intentos |
|
51 | - * |
|
52 | - * @var array |
|
53 | - */ |
|
50 | + * Log de intentos recientes con la forma 'email' => (int) intentos |
|
51 | + * |
|
52 | + * @var array |
|
53 | + */ |
|
54 | 54 | private $recentAttempts = array(); |
55 | 55 | |
56 | - /** |
|
57 | - * Hace un set() a la sesión login_user_recentAttempts con el valor actualizado. |
|
58 | - * |
|
59 | - * @return void |
|
60 | - */ |
|
56 | + /** |
|
57 | + * Hace un set() a la sesión login_user_recentAttempts con el valor actualizado. |
|
58 | + * |
|
59 | + * @return void |
|
60 | + */ |
|
61 | 61 | private function updateSessionAttempts() { |
62 | 62 | global $session; |
63 | 63 | |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
68 | - * Genera la sesión con el id del usuario que ha iniciado |
|
69 | - * |
|
70 | - * @param string $pass : Contraseña sin encriptar |
|
71 | - * @param string $pass_repeat : Contraseña repetida sin encriptar |
|
72 | - * |
|
73 | - * @throws ModelsException cuando las contraseñas no coinciden |
|
74 | - */ |
|
68 | + * Genera la sesión con el id del usuario que ha iniciado |
|
69 | + * |
|
70 | + * @param string $pass : Contraseña sin encriptar |
|
71 | + * @param string $pass_repeat : Contraseña repetida sin encriptar |
|
72 | + * |
|
73 | + * @throws ModelsException cuando las contraseñas no coinciden |
|
74 | + */ |
|
75 | 75 | private function checkPassMatch(string $pass, string $pass_repeat) { |
76 | 76 | if($pass != $pass_repeat) { |
77 | 77 | throw new ModelsException('Las contraseñas no coinciden.'); |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | - * Verifica el email introducido, tanto el formato como su existencia en el sistema |
|
83 | - * |
|
84 | - * @param string $email: Email del usuario |
|
85 | - * |
|
86 | - * @throws ModelsException en caso de que no tenga formato válido o ya exista |
|
87 | - */ |
|
82 | + * Verifica el email introducido, tanto el formato como su existencia en el sistema |
|
83 | + * |
|
84 | + * @param string $email: Email del usuario |
|
85 | + * |
|
86 | + * @throws ModelsException en caso de que no tenga formato válido o ya exista |
|
87 | + */ |
|
88 | 88 | private function checkEmail(string $email) { |
89 | 89 | # Formato de email |
90 | 90 | if(!Strings::is_email($email)) { |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
102 | - * Restaura los intentos de un usuario al iniciar sesión |
|
103 | - * |
|
104 | - * @param string $email: Email del usuario a restaurar |
|
105 | - * |
|
106 | - * @throws ModelsException cuando hay un error de lógica utilizando este método |
|
107 | - * @return void |
|
108 | - */ |
|
102 | + * Restaura los intentos de un usuario al iniciar sesión |
|
103 | + * |
|
104 | + * @param string $email: Email del usuario a restaurar |
|
105 | + * |
|
106 | + * @throws ModelsException cuando hay un error de lógica utilizando este método |
|
107 | + * @return void |
|
108 | + */ |
|
109 | 109 | private function restoreAttempts(string $email) { |
110 | 110 | if(array_key_exists($email,$this->recentAttempts)) { |
111 | 111 | $this->recentAttempts[$email]['attempts'] = 0; |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
121 | - * Genera la sesión con el id del usuario que ha iniciado |
|
122 | - * |
|
123 | - * @param array $user_data: Arreglo con información de la base de datos, del usuario |
|
124 | - * |
|
125 | - * @return void |
|
126 | - */ |
|
121 | + * Genera la sesión con el id del usuario que ha iniciado |
|
122 | + * |
|
123 | + * @param array $user_data: Arreglo con información de la base de datos, del usuario |
|
124 | + * |
|
125 | + * @return void |
|
126 | + */ |
|
127 | 127 | private function generateSession(array $user_data) { |
128 | 128 | global $session, $config; |
129 | 129 | |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Verifica en la base de datos, el email y contraseña ingresados por el usuario |
|
136 | - * |
|
137 | - * @param string $email: Email del usuario que intenta el login |
|
138 | - * @param string $pass: Contraseña sin encriptar del usuario que intenta el login |
|
139 | - * |
|
140 | - * @return bool true: Cuando el inicio de sesión es correcto |
|
141 | - * false: Cuando el inicio de sesión no es correcto |
|
142 | - */ |
|
135 | + * Verifica en la base de datos, el email y contraseña ingresados por el usuario |
|
136 | + * |
|
137 | + * @param string $email: Email del usuario que intenta el login |
|
138 | + * @param string $pass: Contraseña sin encriptar del usuario que intenta el login |
|
139 | + * |
|
140 | + * @return bool true: Cuando el inicio de sesión es correcto |
|
141 | + * false: Cuando el inicio de sesión no es correcto |
|
142 | + */ |
|
143 | 143 | private function authentication(string $email,string $pass) : bool { |
144 | 144 | $email = $this->db->scape($email); |
145 | 145 | $query = $this->db->select('id_user,pass','users',"email='$email'",'LIMIT 1'); |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
162 | - * Establece los intentos recientes desde la variable de sesión acumulativa |
|
163 | - * |
|
164 | - * @return void |
|
165 | - */ |
|
162 | + * Establece los intentos recientes desde la variable de sesión acumulativa |
|
163 | + * |
|
164 | + * @return void |
|
165 | + */ |
|
166 | 166 | private function setDefaultAttempts() { |
167 | 167 | global $session; |
168 | 168 | |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
175 | - * Establece el intento del usuario actual o incrementa su cantidad si ya existe |
|
176 | - * |
|
177 | - * @param string $email: Email del usuario |
|
178 | - * |
|
179 | - * @return void |
|
180 | - */ |
|
175 | + * Establece el intento del usuario actual o incrementa su cantidad si ya existe |
|
176 | + * |
|
177 | + * @param string $email: Email del usuario |
|
178 | + * |
|
179 | + * @return void |
|
180 | + */ |
|
181 | 181 | private function setNewAttempt(string $email) { |
182 | 182 | if(!array_key_exists($email,$this->recentAttempts)) { |
183 | 183 | $this->recentAttempts[$email] = array( |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
194 | - * Controla la cantidad de intentos permitidos máximos por usuario, si llega al límite, |
|
195 | - * el usuario podrá seguir intentando en self::MAX_ATTEMPTS_TIME segundos. |
|
196 | - * |
|
197 | - * @param string $email: Email del usuario |
|
198 | - * |
|
199 | - * @throws ModelsException cuando ya ha excedido self::MAX_ATTEMPTS |
|
200 | - * @return void |
|
201 | - */ |
|
194 | + * Controla la cantidad de intentos permitidos máximos por usuario, si llega al límite, |
|
195 | + * el usuario podrá seguir intentando en self::MAX_ATTEMPTS_TIME segundos. |
|
196 | + * |
|
197 | + * @param string $email: Email del usuario |
|
198 | + * |
|
199 | + * @throws ModelsException cuando ya ha excedido self::MAX_ATTEMPTS |
|
200 | + * @return void |
|
201 | + */ |
|
202 | 202 | private function maximumAttempts(string $email) { |
203 | 203 | if($this->recentAttempts[$email]['attempts'] >= self::MAX_ATTEMPTS) { |
204 | 204 | |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
222 | - * Realiza la acción de login dentro del sistema |
|
223 | - * |
|
224 | - * @return array : Con información de éxito/falla al inicio de sesión. |
|
225 | - */ |
|
222 | + * Realiza la acción de login dentro del sistema |
|
223 | + * |
|
224 | + * @return array : Con información de éxito/falla al inicio de sesión. |
|
225 | + */ |
|
226 | 226 | public function login() : array { |
227 | 227 | try { |
228 | 228 | global $http; |
@@ -258,10 +258,10 @@ discard block |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
261 | - * Realiza la acción de registro dentro del sistema |
|
262 | - * |
|
263 | - * @return array : Con información de éxito/falla al registrar el usuario nuevo. |
|
264 | - */ |
|
261 | + * Realiza la acción de registro dentro del sistema |
|
262 | + * |
|
263 | + * @return array : Con información de éxito/falla al registrar el usuario nuevo. |
|
264 | + */ |
|
265 | 265 | public function register() : array { |
266 | 266 | try { |
267 | 267 | global $http; |
@@ -302,11 +302,11 @@ discard block |
||
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
305 | - * Envía un correo electrónico al usuario que quiere recuperar la contraseña, con un token y una nueva contraseña. |
|
306 | - * Si el usuario no visita el enlace, el sistema no cambiará la contraseña. |
|
307 | - * |
|
308 | - * @return array<string,integer|string> |
|
309 | - */ |
|
305 | + * Envía un correo electrónico al usuario que quiere recuperar la contraseña, con un token y una nueva contraseña. |
|
306 | + * Si el usuario no visita el enlace, el sistema no cambiará la contraseña. |
|
307 | + * |
|
308 | + * @return array<string,integer|string> |
|
309 | + */ |
|
310 | 310 | public function lostpass() { |
311 | 311 | try { |
312 | 312 | global $http, $config; |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | |
343 | 343 | # Enviar el correo electrónico |
344 | 344 | $dest = array(); |
345 | - $dest[$email] = $user_data[0]['name']; |
|
346 | - $email = Emails::send_mail($dest,Emails::plantilla($HTML),'Recuperar contraseña perdida'); |
|
345 | + $dest[$email] = $user_data[0]['name']; |
|
346 | + $email = Emails::send_mail($dest,Emails::plantilla($HTML),'Recuperar contraseña perdida'); |
|
347 | 347 | |
348 | 348 | # Verificar si hubo algún problema con el envío del correo |
349 | 349 | if(false === $email) { |
@@ -364,13 +364,13 @@ discard block |
||
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
367 | - * Cambia la contraseña de un usuario en el sistema, luego de que éste haya solicitado cambiarla. |
|
368 | - * Luego retorna al sitio de inicio con la variable GET success=(bool) |
|
369 | - * |
|
370 | - * La URL debe tener la forma URL/lostpass/cambiar/&token=TOKEN&user=ID |
|
371 | - * |
|
372 | - * @return void |
|
373 | - */ |
|
367 | + * Cambia la contraseña de un usuario en el sistema, luego de que éste haya solicitado cambiarla. |
|
368 | + * Luego retorna al sitio de inicio con la variable GET success=(bool) |
|
369 | + * |
|
370 | + * La URL debe tener la forma URL/lostpass/cambiar/&token=TOKEN&user=ID |
|
371 | + * |
|
372 | + * @return void |
|
373 | + */ |
|
374 | 374 | public function changeTemporalPass() { |
375 | 375 | global $config, $http; |
376 | 376 | |
@@ -394,10 +394,10 @@ discard block |
||
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
397 | - * Desconecta a un usuario si éste está conectado, y lo devuelve al inicio |
|
398 | - * |
|
399 | - * @return void |
|
400 | - */ |
|
397 | + * Desconecta a un usuario si éste está conectado, y lo devuelve al inicio |
|
398 | + * |
|
399 | + * @return void |
|
400 | + */ |
|
401 | 401 | public function logout() { |
402 | 402 | global $session; |
403 | 403 | |
@@ -409,36 +409,36 @@ discard block |
||
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
412 | - * Obtiene datos de un usuario según su id en la base de datos |
|
413 | - * |
|
414 | - * @param int $id: Id del usuario a obtener |
|
415 | - * @param string $select : Por defecto es *, se usa para obtener sólo los parámetros necesarios |
|
416 | - * |
|
417 | - * @return false|array con información del usuario |
|
418 | - */ |
|
412 | + * Obtiene datos de un usuario según su id en la base de datos |
|
413 | + * |
|
414 | + * @param int $id: Id del usuario a obtener |
|
415 | + * @param string $select : Por defecto es *, se usa para obtener sólo los parámetros necesarios |
|
416 | + * |
|
417 | + * @return false|array con información del usuario |
|
418 | + */ |
|
419 | 419 | public function getUserById(int $id, string $select = '*') { |
420 | - return $this->db->select($select,'users',"id_user='$id'",'LIMIT 1'); |
|
420 | + return $this->db->select($select,'users',"id_user='$id'",'LIMIT 1'); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
424 | - * Obtiene a todos los usuarios |
|
425 | - * |
|
426 | - * @param string $select : Por defecto es *, se usa para obtener sólo los parámetros necesarios |
|
427 | - * |
|
428 | - * @return false|array con información de los usuarios |
|
429 | - */ |
|
424 | + * Obtiene a todos los usuarios |
|
425 | + * |
|
426 | + * @param string $select : Por defecto es *, se usa para obtener sólo los parámetros necesarios |
|
427 | + * |
|
428 | + * @return false|array con información de los usuarios |
|
429 | + */ |
|
430 | 430 | public function getUsers(string $select = '*') { |
431 | - return $this->db->select($select,'users'); |
|
431 | + return $this->db->select($select,'users'); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
435 | - * Obtiene datos del usuario conectado actualmente |
|
436 | - * |
|
437 | - * @param string $select : Por defecto es *, se usa para obtener sólo los parámetros necesarios |
|
438 | - * |
|
439 | - * @throws ModelsException si el usuario no está logeado |
|
440 | - * @return array con datos del usuario conectado |
|
441 | - */ |
|
435 | + * Obtiene datos del usuario conectado actualmente |
|
436 | + * |
|
437 | + * @param string $select : Por defecto es *, se usa para obtener sólo los parámetros necesarios |
|
438 | + * |
|
439 | + * @throws ModelsException si el usuario no está logeado |
|
440 | + * @return array con datos del usuario conectado |
|
441 | + */ |
|
442 | 442 | public function getOwnerUser(string $select = '*') : array { |
443 | 443 | if(null !== $this->id_user) { |
444 | 444 | |
@@ -456,10 +456,10 @@ discard block |
||
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
459 | - * Instala el módulo de usuarios en la base de datos para que pueda funcionar correctamete. |
|
460 | - * |
|
461 | - * @throws \RuntimeException si no se puede realizar la query |
|
462 | - */ |
|
459 | + * Instala el módulo de usuarios en la base de datos para que pueda funcionar correctamete. |
|
460 | + * |
|
461 | + * @throws \RuntimeException si no se puede realizar la query |
|
462 | + */ |
|
463 | 463 | public function install() { |
464 | 464 | if(!$this->db->query(" |
465 | 465 | CREATE TABLE IF NOT EXISTS `users` ( |
@@ -480,16 +480,16 @@ discard block |
||
480 | 480 | } |
481 | 481 | |
482 | 482 | /** |
483 | - * __construct() |
|
484 | - */ |
|
483 | + * __construct() |
|
484 | + */ |
|
485 | 485 | public function __construct(IRouter $router = null) { |
486 | 486 | parent::__construct($router); |
487 | 487 | $this->startDBConexion(); |
488 | 488 | } |
489 | 489 | |
490 | 490 | /** |
491 | - * __destruct() |
|
492 | - */ |
|
491 | + * __destruct() |
|
492 | + */ |
|
493 | 493 | public function __destruct() { |
494 | 494 | parent::__destruct(); |
495 | 495 | $this->endDBConexion(); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @throws ModelsException cuando las contraseñas no coinciden |
74 | 74 | */ |
75 | 75 | private function checkPassMatch(string $pass, string $pass_repeat) { |
76 | - if($pass != $pass_repeat) { |
|
76 | + if ($pass != $pass_repeat) { |
|
77 | 77 | throw new ModelsException('Las contraseñas no coinciden.'); |
78 | 78 | } |
79 | 79 | } |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | */ |
88 | 88 | private function checkEmail(string $email) { |
89 | 89 | # Formato de email |
90 | - if(!Strings::is_email($email)) { |
|
90 | + if (!Strings::is_email($email)) { |
|
91 | 91 | throw new ModelsException('El email no tiene un formato válido.'); |
92 | 92 | } |
93 | 93 | # Existencia de email |
94 | 94 | $email = $this->db->scape($email); |
95 | - $query = $this->db->select('id_user','users',"email='$email'",'LIMIT 1'); |
|
96 | - if(false !== $query) { |
|
95 | + $query = $this->db->select('id_user', 'users', "email='$email'", 'LIMIT 1'); |
|
96 | + if (false !== $query) { |
|
97 | 97 | throw new ModelsException('El email introducido ya existe.'); |
98 | 98 | } |
99 | 99 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @return void |
108 | 108 | */ |
109 | 109 | private function restoreAttempts(string $email) { |
110 | - if(array_key_exists($email,$this->recentAttempts)) { |
|
110 | + if (array_key_exists($email, $this->recentAttempts)) { |
|
111 | 111 | $this->recentAttempts[$email]['attempts'] = 0; |
112 | 112 | $this->recentAttempts[$email]['time'] = null; |
113 | 113 | $this->updateSessionAttempts(); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | private function generateSession(array $user_data) { |
128 | 128 | global $session, $config; |
129 | 129 | |
130 | - $session->set('user_id',(int) $user_data['id_user']); |
|
130 | + $session->set('user_id', (int) $user_data['id_user']); |
|
131 | 131 | $session->set('unique_session', $config['sessions']['unique']); |
132 | 132 | } |
133 | 133 | |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | * @return bool true: Cuando el inicio de sesión es correcto |
141 | 141 | * false: Cuando el inicio de sesión no es correcto |
142 | 142 | */ |
143 | - private function authentication(string $email,string $pass) : bool { |
|
143 | + private function authentication(string $email, string $pass) : bool { |
|
144 | 144 | $email = $this->db->scape($email); |
145 | - $query = $this->db->select('id_user,pass','users',"email='$email'",'LIMIT 1'); |
|
145 | + $query = $this->db->select('id_user,pass', 'users', "email='$email'", 'LIMIT 1'); |
|
146 | 146 | |
147 | 147 | # Incio de sesión con éxito |
148 | - if(false !== $query && Strings::chash($query[0]['pass'],$pass)) { |
|
148 | + if (false !== $query && Strings::chash($query[0]['pass'], $pass)) { |
|
149 | 149 | |
150 | 150 | # Restaurar intentos |
151 | 151 | $this->restoreAttempts($email); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | private function setDefaultAttempts() { |
167 | 167 | global $session; |
168 | 168 | |
169 | - if(null != $session->get('login_user_recentAttempts')) { |
|
169 | + if (null != $session->get('login_user_recentAttempts')) { |
|
170 | 170 | $this->recentAttempts = $session->get('login_user_recentAttempts'); |
171 | 171 | } |
172 | 172 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @return void |
180 | 180 | */ |
181 | 181 | private function setNewAttempt(string $email) { |
182 | - if(!array_key_exists($email,$this->recentAttempts)) { |
|
182 | + if (!array_key_exists($email, $this->recentAttempts)) { |
|
183 | 183 | $this->recentAttempts[$email] = array( |
184 | 184 | 'attempts' => 0, # Intentos |
185 | 185 | 'time' => null # Tiempo |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | * @return void |
201 | 201 | */ |
202 | 202 | private function maximumAttempts(string $email) { |
203 | - if($this->recentAttempts[$email]['attempts'] >= self::MAX_ATTEMPTS) { |
|
203 | + if ($this->recentAttempts[$email]['attempts'] >= self::MAX_ATTEMPTS) { |
|
204 | 204 | |
205 | 205 | # Colocar timestamp para recuperar más adelante la posibilidad de acceso |
206 | - if(null == $this->recentAttempts[$email]['time']) { |
|
206 | + if (null == $this->recentAttempts[$email]['time']) { |
|
207 | 207 | $this->recentAttempts[$email]['time'] = time() + self::MAX_ATTEMPTS_TIME; |
208 | 208 | } |
209 | 209 | |
210 | - if(time() < $this->recentAttempts[$email]['time']) { |
|
210 | + if (time() < $this->recentAttempts[$email]['time']) { |
|
211 | 211 | # Setear sesión |
212 | 212 | $this->updateSessionAttempts(); |
213 | 213 | # Lanzar excepción |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $pass = $http->request->get('pass'); |
236 | 236 | |
237 | 237 | # Verificar que no están vacíos |
238 | - if($this->functions->e($email,$pass)) { |
|
238 | + if ($this->functions->e($email, $pass)) { |
|
239 | 239 | throw new ModelsException('Credenciales incompletas.'); |
240 | 240 | } |
241 | 241 | |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | $this->maximumAttempts($email); |
247 | 247 | |
248 | 248 | # Autentificar |
249 | - if($this->authentication($email,$pass)) { |
|
249 | + if ($this->authentication($email, $pass)) { |
|
250 | 250 | return array('success' => 1, 'message' => 'Conectado con éxito.'); |
251 | 251 | } |
252 | 252 | |
253 | 253 | throw new ModelsException('Credenciales incorrectas.'); |
254 | 254 | |
255 | - } catch(ModelsException $e) { |
|
255 | + } catch (ModelsException $e) { |
|
256 | 256 | return array('success' => 0, 'message' => $e->getMessage()); |
257 | 257 | } |
258 | 258 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $pass_repeat = $http->request->get('pass_repeat'); |
274 | 274 | |
275 | 275 | # Verificar que no están vacíos |
276 | - if($this->functions->e($name,$email,$pass,$pass_repeat)) { |
|
276 | + if ($this->functions->e($name, $email, $pass, $pass_repeat)) { |
|
277 | 277 | throw new ModelsException('Todos los datos son necesarios'); |
278 | 278 | } |
279 | 279 | |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | $this->checkEmail($email); |
282 | 282 | |
283 | 283 | # Veriricar contraseñas |
284 | - $this->checkPassMatch($pass,$pass_repeat); |
|
284 | + $this->checkPassMatch($pass, $pass_repeat); |
|
285 | 285 | |
286 | 286 | # Registrar al usuario |
287 | - $this->db->insert('users',array( |
|
287 | + $this->db->insert('users', array( |
|
288 | 288 | 'name' => $name, |
289 | 289 | 'email' => $email, |
290 | 290 | 'pass' => Strings::hash($pass) |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | )); |
297 | 297 | |
298 | 298 | return array('success' => 1, 'message' => 'Registrado con éxito.'); |
299 | - } catch(ModelsException $e) { |
|
299 | + } catch (ModelsException $e) { |
|
300 | 300 | return array('success' => 0, 'message' => $e->getMessage()); |
301 | 301 | } |
302 | 302 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $email = $http->request->get('email'); |
316 | 316 | |
317 | 317 | # Campo lleno |
318 | - if($this->functions->emp($email)) { |
|
318 | + if ($this->functions->emp($email)) { |
|
319 | 319 | throw new ModelsException('El campo email debe estar lleno.'); |
320 | 320 | } |
321 | 321 | |
@@ -323,10 +323,10 @@ discard block |
||
323 | 323 | $email = $this->db->scape($email); |
324 | 324 | |
325 | 325 | # Obtener información del usuario |
326 | - $user_data = $this->db->select('id_user,name','users',"email='$email'",'LIMIT 1'); |
|
326 | + $user_data = $this->db->select('id_user,name', 'users', "email='$email'", 'LIMIT 1'); |
|
327 | 327 | |
328 | 328 | # Verificar correo en base de datos |
329 | - if(false === $user_data) { |
|
329 | + if (false === $user_data) { |
|
330 | 330 | throw new ModelsException('El email no está registrado en el sistema.'); |
331 | 331 | } |
332 | 332 | |
@@ -335,30 +335,30 @@ discard block |
||
335 | 335 | $pass = uniqid(); |
336 | 336 | |
337 | 337 | # Construir mensaje y enviar mensaje |
338 | - $HTML = 'Hola <b>'. $user_data[0]['name'] .'</b>, ha solicitado recuperar su contraseña perdida, si no ha realizado esta acción no necesita hacer nada. |
|
338 | + $HTML = 'Hola <b>' . $user_data[0]['name'] . '</b>, ha solicitado recuperar su contraseña perdida, si no ha realizado esta acción no necesita hacer nada. |
|
339 | 339 | <br /> |
340 | 340 | <br /> |
341 | - Para cambiar su contraseña por <b>'. $pass .'</b> haga <a href="'. $config['site']['url'] . 'lostpass/cambiar/&token='.$token.'&user='.$user_data[0]['id_user'].'" target="_blank">clic aquí</a>.'; |
|
341 | + Para cambiar su contraseña por <b>'. $pass . '</b> haga <a href="' . $config['site']['url'] . 'lostpass/cambiar/&token=' . $token . '&user=' . $user_data[0]['id_user'] . '" target="_blank">clic aquí</a>.'; |
|
342 | 342 | |
343 | 343 | # Enviar el correo electrónico |
344 | 344 | $dest = array(); |
345 | 345 | $dest[$email] = $user_data[0]['name']; |
346 | - $email = Emails::send_mail($dest,Emails::plantilla($HTML),'Recuperar contraseña perdida'); |
|
346 | + $email = Emails::send_mail($dest, Emails::plantilla($HTML), 'Recuperar contraseña perdida'); |
|
347 | 347 | |
348 | 348 | # Verificar si hubo algún problema con el envío del correo |
349 | - if(false === $email) { |
|
349 | + if (false === $email) { |
|
350 | 350 | throw new ModelsException('No se ha podido enviar el correo electrónico.'); |
351 | 351 | } |
352 | 352 | |
353 | 353 | # Actualizar datos |
354 | 354 | $id_user = $user_data[0]['id_user']; |
355 | - $this->db->update('users',array( |
|
355 | + $this->db->update('users', array( |
|
356 | 356 | 'tmp_pass' => Strings::hash($pass), |
357 | 357 | 'token' => $token |
358 | - ),"id_user='$id_user'",'LIMIT 1'); |
|
358 | + ), "id_user='$id_user'", 'LIMIT 1'); |
|
359 | 359 | |
360 | 360 | return array('success' => 1, 'message' => 'Se ha enviado un enlace a su correo electrónico.'); |
361 | - } catch(ModelsException $e) { |
|
361 | + } catch (ModelsException $e) { |
|
362 | 362 | return array('success' => 0, 'message' => $e->getMessage()); |
363 | 363 | } |
364 | 364 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | $id_user = $http->query->get('user'); |
379 | 379 | $token = $http->query->get('token'); |
380 | 380 | |
381 | - if(!$this->functions->emp($token) && is_numeric($id_user) && $id_user >= 1) { |
|
381 | + if (!$this->functions->emp($token) && is_numeric($id_user) && $id_user >= 1) { |
|
382 | 382 | # Filtros a los datos |
383 | 383 | $id_user = $this->db->scape($id_user); |
384 | 384 | $token = $this->db->scape($token); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | public function logout() { |
402 | 402 | global $session; |
403 | 403 | |
404 | - if(null != $session->get('user_id')) { |
|
404 | + if (null != $session->get('user_id')) { |
|
405 | 405 | $session->remove('user_id'); |
406 | 406 | } |
407 | 407 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @return false|array con información del usuario |
418 | 418 | */ |
419 | 419 | public function getUserById(int $id, string $select = '*') { |
420 | - return $this->db->select($select,'users',"id_user='$id'",'LIMIT 1'); |
|
420 | + return $this->db->select($select, 'users', "id_user='$id'", 'LIMIT 1'); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @return false|array con información de los usuarios |
429 | 429 | */ |
430 | 430 | public function getUsers(string $select = '*') { |
431 | - return $this->db->select($select,'users'); |
|
431 | + return $this->db->select($select, 'users'); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -440,12 +440,12 @@ discard block |
||
440 | 440 | * @return array con datos del usuario conectado |
441 | 441 | */ |
442 | 442 | public function getOwnerUser(string $select = '*') : array { |
443 | - if(null !== $this->id_user) { |
|
443 | + if (null !== $this->id_user) { |
|
444 | 444 | |
445 | - $user = $this->db->select($select,'users',"id_user='$this->id_user'",'LIMIT 1'); |
|
445 | + $user = $this->db->select($select, 'users', "id_user='$this->id_user'", 'LIMIT 1'); |
|
446 | 446 | |
447 | 447 | # Si se borra al usuario desde la base de datos y sigue con la sesión activa |
448 | - if(false === $user) { |
|
448 | + if (false === $user) { |
|
449 | 449 | $this->logout(); |
450 | 450 | } |
451 | 451 | |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | * @throws \RuntimeException si no se puede realizar la query |
462 | 462 | */ |
463 | 463 | public function install() { |
464 | - if(!$this->db->query(" |
|
464 | + if (!$this->db->query(" |
|
465 | 465 | CREATE TABLE IF NOT EXISTS `users` ( |
466 | 466 | `id_user` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, |
467 | 467 | `name` varchar(100) NOT NULL, |