1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
class usuarioControlador extends \Sistema\Nucleo\CFControlador |
5
|
|
|
{ |
6
|
|
|
private $_ayuda; |
7
|
|
|
private $_seg; |
8
|
|
|
private $_sesion; |
9
|
|
View Code Duplication |
public function __construct() { |
10
|
|
|
parent::__construct(); |
11
|
|
|
|
12
|
|
|
// cargamos la clase ayudantes para usar sus metodos de ayuda |
13
|
|
|
$this->_ayuda= new Sistema\Ayudantes\CFPHPAyuda; |
14
|
|
|
$this->_seg= new Sistema\Ayudantes\CFPHPSeguridad; |
15
|
|
|
$this->_sesion=new Sistema\Nucleo\CFSesion(); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
public function index(){ |
19
|
|
|
$this->_sesion->iniciarSesion('_s', Cf_SESION_PARAMETRO_SEGURO); |
20
|
|
|
session_destroy(); |
21
|
|
|
$this->_vista->titulo = 'CalimaFramework Login'; |
|
|
|
|
22
|
|
|
$this->_vista->error = 'CalimaFramework Login'; |
|
|
|
|
23
|
|
|
$this->_vista->imprimirVista('index', 'usuario'); |
|
|
|
|
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function registro(){ |
27
|
|
|
$this->_vista->titulo = 'CalimaFramework registro'; |
|
|
|
|
28
|
|
|
$this->_vista->imprimirVista('registro', 'usuario'); |
|
|
|
|
29
|
|
|
|
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function crearRegistro(){ |
|
|
|
|
33
|
|
|
$datas = $this->cargaModelo('usuario'); |
34
|
|
|
if(isset($_POST['nombre'])){ |
35
|
|
|
$nombre=$_POST['nombre']; |
36
|
|
|
$email=$_POST['email']; |
37
|
|
|
$usuario=$_POST['nombre']; |
38
|
|
|
$clave=$this->_seg->cifrado($this->_seg->filtrarTexto($_POST['clave'])); |
39
|
|
|
|
40
|
|
|
$datas->insertarRegistro( |
41
|
|
|
$this->_seg->filtrarTexto($_POST['nombre']), |
42
|
|
|
$this->_seg->filtrarTexto($_POST['email']), |
43
|
|
|
'1', |
44
|
|
|
$clave |
45
|
|
|
); |
46
|
|
|
$this->_ayuda->redireccionUrl('usuario'); |
47
|
|
|
} |
48
|
|
|
else{ |
49
|
|
|
$this->_ayuda->redireccionUrl('usuario/registro'); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function valida(){ |
|
|
|
|
54
|
|
|
if(isset($_POST['usuario'])){ |
55
|
|
|
$usuario=$_POST['usuario']; |
56
|
|
|
$clave=$this->_seg->cifrado($this->_seg->filtrarTexto($_POST['clave'])); |
57
|
|
|
|
58
|
|
|
$datosUser = $this->cargaModelo('usuario'); |
59
|
|
|
$valida=$datosUser->seleccionUsuario($usuario, $clave); |
60
|
|
|
|
61
|
|
|
if(isset($valida)){ |
62
|
|
|
$this->_sesion->iniciarSesion('_s', Cf_SESION_PARAMETRO_SEGURO); |
63
|
|
|
$_SESSION['usuario']=$usuario; |
64
|
|
|
$_SESSION['id_usuario']=$valida['id_usuario']; |
65
|
|
|
$_SESSION['nivel']=$valida['nivel']; |
66
|
|
|
$this->_ayuda->redireccionUrl('data/index'); |
67
|
|
|
} |
68
|
|
|
$this->_ayuda->redireccionUrl('usuario'); |
69
|
|
|
|
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function cerrarSesion(){ |
74
|
|
|
$this->_sesion->iniciarSesion('_s', false); |
75
|
|
|
session_destroy(); |
76
|
|
|
$this->_sesion->destruir('usuario'); |
77
|
|
|
$this->_ayuda->redireccionUrl('usuario'); |
78
|
|
|
|
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.