##// END OF EJS Templates
modificaciones del componente usuarios. Reduccion de codigo
arturo -
r4:5
parent child
Show More
@@ -1,718 +1,717
1 <?php No newline at end of file
1 <?php
2 class UsersController extends ControllerBase{ No newline at end of file
2 class UsersController extends ControllerBase{
3 No newline at end of file
3
4 public function ingresar(){ No newline at end of file
4 public function ingresar(){
5 No newline at end of file
5
6 if(isset($_SESSION['usersession']['iduser'])){ No newline at end of file
6 if(isset($_SESSION['usersession']['iduser'])){
7 require 'models/UsersModel.php'; No newline at end of file
7 require 'models/UsersModel.php';
8 No newline at end of file
8
9 $user = new UsersModel(); No newline at end of file
9 $user = new UsersModel();
10 $session = new SessionsModel(); No newline at end of file
10 $session = new SessionsModel();
11 No newline at end of file
11
12 $datos_validados = $user->obtenerUsuarioxId($_SESSION['usersession']['iduser']); No newline at end of file
12 $datos_validados = $user->obtenerUsuarioxId($_SESSION['usersession']['iduser']);
13 $datos_session_validados = $session->validarSession($_SESSION['usersession']['iduser']); No newline at end of file
13 $datos_session_validados = $session->validarSession($_SESSION['usersession']['iduser']);
14 No newline at end of file
14
15 $datos_usuario = $datos_validados->fetch(); No newline at end of file
15 $datos_usuario = $datos_validados->fetch();
16 $datos_session = $datos_session_validados->fetch(); No newline at end of file
16 $datos_session = $datos_session_validados->fetch();
17 No newline at end of file
17
18 if(is_array($datos_usuario) && is_array($datos_session) && ($datos_usuario['usertype'] == 2) ){ No newline at end of file
18 if(is_array($datos_usuario) && is_array($datos_session) && ($datos_usuario['usertype'] == 2) ){
19 //$resultado_log = $items->registrarLogIngreso($datos_usuario["id_usu"]); ///??? No newline at end of file
19 //$resultado_log = $items->registrarLogIngreso($datos_usuario["id_usu"]); ///???
20 //require 'components'.DS.'com_messages'.DS.'models'.DS.'MailBoxesModel.php'; No newline at end of file
20 //require 'components'.DS.'com_messages'.DS.'models'.DS.'MailBoxesModel.php';
21 No newline at end of file
21
22 $date_last_activity = new DateTime(date("Y-m-d H:i:s")); No newline at end of file
22 $date_last_activity = new DateTime(date("Y-m-d H:i:s"));
23 No newline at end of file
23
24 //$mailbox = new MailBoxesModel(); No newline at end of file
24 //$mailbox = new MailBoxesModel();
25 No newline at end of file
25
26 //$rs_boxes = $mailbox->getMailBoxesSystem($datos_usuario['iduser']); No newline at end of file
26 //$rs_boxes = $mailbox->getMailBoxesSystem($datos_usuario['iduser']);
27 No newline at end of file
27
28 //$idtypemb = 1; No newline at end of file
28 //$idtypemb = 1;
29 //$rsMailBox = $mailbox->getMailBoxType($datos_usuario['iduser'], $idtypemb); No newline at end of file
29 //$rsMailBox = $mailbox->getMailBoxType($datos_usuario['iduser'], $idtypemb);
30 //$datosMailBox = $rsMailBox->fetch(); No newline at end of file
30 //$datosMailBox = $rsMailBox->fetch();
31 No newline at end of file
31
32 //$lista_mensajes = $mailbox->getMessagesNoRead($datosMailBox['idmailbox']); No newline at end of file
32 //$lista_mensajes = $mailbox->getMessagesNoRead($datosMailBox['idmailbox']);
33 //$idmailbox = $datosMailBox['idmailbox']; No newline at end of file
33 //$idmailbox = $datosMailBox['idmailbox'];
34 No newline at end of file
34
35 $_SESSION['usersession']['attempt'] = 0; No newline at end of file
35 $_SESSION['usersession']['attempt'] = 0;
36 $_SESSION['usersession']['iduser'] = $datos_usuario['iduser']; No newline at end of file
36 $_SESSION['usersession']['iduser'] = $datos_usuario['iduser'];
37 $_SESSION['usersession']['date_last_activity'] = $date_last_activity->format("Y-m-d H:i:s") ; No newline at end of file
37 $_SESSION['usersession']['date_last_activity'] = $date_last_activity->format("Y-m-d H:i:s") ;
38 $_SESSION['usersession']['idsession'] = $datos_session['idsession']; No newline at end of file
38 $_SESSION['usersession']['idsession'] = $datos_session['idsession'];
39 No newline at end of file
39
40 $datos['idsession'] = $datos_session['idsession']; No newline at end of file
40 $datos['idsession'] = $datos_session['idsession'];
41 $datos['date_last_activity'] = $date_last_activity->format("Y-m-d H:i:s") ; No newline at end of file
41 $datos['date_last_activity'] = $date_last_activity->format("Y-m-d H:i:s") ;
42 No newline at end of file
42
43 if($datos_usuario['state'] == 1){ No newline at end of file
43 if($datos_usuario['state'] == 1){
44 $data['datos_usuario'] = $datos_usuario; No newline at end of file
44 $data['datos_usuario'] = $datos_usuario;
45 $data['inicio'] = 0; No newline at end of file
45 $data['inicio'] = 0;
46 //$data['rs_boxes'] = $rs_boxes; No newline at end of file
46 //$data['rs_boxes'] = $rs_boxes;
47 //$data['lista_mensajes'] = $lista_mensajes; No newline at end of file
47 //$data['lista_mensajes'] = $lista_mensajes;
48 //$data['idmailbox'] = $idmailbox; No newline at end of file
48 //$data['idmailbox'] = $idmailbox;
49 $data['content'] = "components".DS."com_users".DS."views".DS."home.php"; No newline at end of file
49 $data['content'] = "components".DS."com_users".DS."views".DS."home.php";
50 $data['title'] = "WELCOME:::::::::::::"; No newline at end of file
50 $data['title'] = "WELCOME:::::::::::::";
51 No newline at end of file
51
52 $this->view->show("template.php", $data); No newline at end of file
52 $this->view->show("template.php", $data);
53 }else{ No newline at end of file
53 }else{
54 $data = array(); No newline at end of file
54 $data = array();
55 $data['xin'] = ''; No newline at end of file
55 $data['xin'] = '';
56 $data['forget'] = 'no'; No newline at end of file
56 $data['forget'] = 'no';
57 $data['force'] = 'yes'; No newline at end of file
57 $data['force'] = 'yes';
58 No newline at end of file
58
59 $this->view->show("usersNewPasswordForm.php", $data); No newline at end of file
59 $this->view->show("usersNewPasswordForm.php", $data);
60 } No newline at end of file
60 }
61 }else{ No newline at end of file
61 }else{
62 $data = array(); No newline at end of file
62 $data = array();
63 $this->view->show("login.php", $data); No newline at end of file
63 $this->view->show("login.php", $data);
64 } No newline at end of file
64 }
65 }else{ No newline at end of file
65 }else{
66 $data = array(); No newline at end of file
66 $data = array();
67 $this->view->show("login.php", $data); No newline at end of file
67 $this->view->show("login.php", $data);
68 } No newline at end of file
68 }
69 } No newline at end of file
69 }
70 No newline at end of file
70
71 public function validarUsuario(){ No newline at end of file
71 public function validarUsuario(){
72 No newline at end of file
72
73 $valor_intervalo = 30; No newline at end of file
73 $valor_intervalo = 30;
74 $intervalo = 'PT'.$valor_intervalo.'M'; No newline at end of file
74 $intervalo = 'PT'.$valor_intervalo.'M';
75 $tiempo_bloqueo = new DateInterval($intervalo); //minutos No newline at end of file
75 $tiempo_bloqueo = new DateInterval($intervalo); //minutos
76 No newline at end of file
76
77 if(isset($_SESSION['usersession']['timebadlogin'])){ No newline at end of file
77 if(isset($_SESSION['usersession']['timebadlogin'])){
78 $valor_timebadlogin = $_SESSION['usersession']['timebadlogin']; No newline at end of file
78 $valor_timebadlogin = $_SESSION['usersession']['timebadlogin'];
79 $timebadlogin = new DateTime($valor_timebadlogin); No newline at end of file
79 $timebadlogin = new DateTime($valor_timebadlogin);
80 date_add($timebadlogin, $tiempo_bloqueo); No newline at end of file
80 date_add($timebadlogin, $tiempo_bloqueo);
81 $timeactual = new DateTime(date("Y-m-d H:i:s")); No newline at end of file
81 $timeactual = new DateTime(date("Y-m-d H:i:s"));
82 No newline at end of file
82
83 if($timeactual > $timebadlogin){ No newline at end of file
83 if($timeactual > $timebadlogin){
84 $_SESSION['usersession']['disabled'] = false; No newline at end of file
84 $_SESSION['usersession']['disabled'] = false;
85 $_SESSION['usersession']['attempt'] = 0; No newline at end of file
85 $_SESSION['usersession']['attempt'] = 0;
86 unset($_SESSION['usersession']['timebadlogin']); No newline at end of file
86 unset($_SESSION['usersession']['timebadlogin']);
87 } No newline at end of file
87 }
88 } No newline at end of file
88 }
89 No newline at end of file
89
90 require 'components'.DS.'com_users'.DS.'models'.DS.'UsersModel.php'; No newline at end of file
90 require 'components'.DS.'com_users'.DS.'models'.DS.'UsersModel.php';
91 No newline at end of file
91
92 $user = new UsersModel(); No newline at end of file
92 $user = new UsersModel();
93 $session = new SessionsModel(); No newline at end of file
93 $session = new SessionsModel();
94 No newline at end of file
94
95 $username = $_REQUEST["username"]; No newline at end of file
95 $username = $_REQUEST["username"];
96 $password = $_REQUEST["passwd"]; No newline at end of file
96 $password = $_REQUEST["passwd"];
97 No newline at end of file
97
98 if( (@$_SESSION['usersession']['attempt'] < 3) && ( @!$_SESSION['usersession']['disabled'] ) ){ No newline at end of file
98 if( (@$_SESSION['usersession']['attempt'] < 3) && ( @!$_SESSION['usersession']['disabled'] ) ){
99 No newline at end of file
99
100 $datos_usuario = ""; No newline at end of file
100 $datos_usuario = "";
101 $rs_usuario = $user->validateUsers($username,$password); No newline at end of file
101 $rs_usuario = $user->validateUsers($username,$password);
102 $datos_usuario = $rs_usuario->fetch(); No newline at end of file
102 $datos_usuario = $rs_usuario->fetch();
103 No newline at end of file
103
104 if(@is_array($datos_usuario)){ No newline at end of file
104 if(@is_array($datos_usuario)){
105 $_SESSION["usersession"]["iduser"] = $datos_usuario['iduser']; No newline at end of file
105 $_SESSION["usersession"]["iduser"] = $datos_usuario['iduser'];
106 $_SESSION["usersession"]["username"] = $datos_usuario['username']; No newline at end of file
106 $_SESSION["usersession"]["username"] = $datos_usuario['username'];
107 $_SESSION["usersession"]["firstname"] = $datos_usuario['firstname']; No newline at end of file
107 $_SESSION["usersession"]["firstname"] = $datos_usuario['firstname'];
108 $_SESSION["usersession"]["lastname"] = $datos_usuario['lastname']; No newline at end of file
108 $_SESSION["usersession"]["lastname"] = $datos_usuario['lastname'];
109 $_SESSION["usersession"]["photo"] = $datos_usuario['photo']; No newline at end of file
109 $_SESSION["usersession"]["photo"] = $datos_usuario['photo'];
110 $_SESSION["usersession"]["type"] = $datos_usuario['usertype']; No newline at end of file
110 $_SESSION["usersession"]["type"] = $datos_usuario['usertype'];
111 No newline at end of file
111
112 $date_session = new DateTime(date('Y-m-d H:i:s')); No newline at end of file
112 $date_session = new DateTime(date('Y-m-d H:i:s'));
113 $date_last_activity = new DateTime(date("Y-m-d H:i:s")); No newline at end of file
113 $date_last_activity = new DateTime(date("Y-m-d H:i:s"));
114 No newline at end of file
114
115 $datos['idsession'] = ""; No newline at end of file
115 $datos['idsession'] = "";
116 $datos['iduser'] = $datos_usuario['iduser']; No newline at end of file
116 $datos['iduser'] = $datos_usuario['iduser'];
117 $datos['client_ip'] = $_SERVER['REMOTE_ADDR']; No newline at end of file
117 $datos['client_ip'] = $_SERVER['REMOTE_ADDR'];
118 $datos['date_session'] = $date_session->format('Y-m-d H:i:s'); No newline at end of file
118 $datos['date_session'] = $date_session->format('Y-m-d H:i:s');
119 $datos['date_last_activity'] = $date_last_activity->format("Y-m-d H:i:s") ; No newline at end of file
119 $datos['date_last_activity'] = $date_last_activity->format("Y-m-d H:i:s") ;
120 $datos['state'] = 1; No newline at end of file
120 $datos['state'] = 1;
121 No newline at end of file
121
122 list($rs_session, $idsession, $message) = $session->addItem($datos); No newline at end of file
122 list($rs_session, $idsession, $message) = $session->addItem($datos);
123 $_SESSION['usersession']['idsession'] = $idsession; No newline at end of file
123 $_SESSION['usersession']['idsession'] = $idsession;
124 No newline at end of file
124
125 $_SESSION['usersession']['attempt'] = 0; No newline at end of file
125 $_SESSION['usersession']['attempt'] = 0;
126 $_SESSION['usersession']['client_ip'] = $_SERVER['REMOTE_ADDR']; No newline at end of file
126 $_SESSION['usersession']['client_ip'] = $_SERVER['REMOTE_ADDR'];
127 $_SESSION['usersession']['date_session'] = $date_session->format('Y-m-d H:i:s'); No newline at end of file
127 $_SESSION['usersession']['date_session'] = $date_session->format('Y-m-d H:i:s');
128 $_SESSION['usersession']['date_last_activity'] = $date_last_activity->format("Y-m-d H:i:s"); No newline at end of file
128 $_SESSION['usersession']['date_last_activity'] = $date_last_activity->format("Y-m-d H:i:s");
129 $_SESSION['usersession']['state'] = 1; No newline at end of file
129 $_SESSION['usersession']['state'] = 1;
130 //coloca los idmailbox dentro de la variable de session No newline at end of file
130 //coloca los idmailbox dentro de la variable de session
131 //$_SESSION['usersession']['inbox'] = $mnuBoxes[0]['idmailbox'];//Inbox No newline at end of file
131 //$_SESSION['usersession']['inbox'] = $mnuBoxes[0]['idmailbox'];//Inbox
132 $_SESSION['usersession']['inbox'] = 1;//Inbox No newline at end of file
132 $_SESSION['usersession']['inbox'] = 1;//Inbox
133 //$_SESSION['usersession']['sent'] = $mnuBoxes[1]['idmailbox'];//Sent No newline at end of file
133 //$_SESSION['usersession']['sent'] = $mnuBoxes[1]['idmailbox'];//Sent
134 $_SESSION['usersession']['sent'] = 2;//Sent No newline at end of file
134 $_SESSION['usersession']['sent'] = 2;//Sent
135 //$_SESSION['usersession']['trash'] = $mnuBoxes[2]['idmailbox'];//Trash No newline at end of file
135 //$_SESSION['usersession']['trash'] = $mnuBoxes[2]['idmailbox'];//Trash
136 $_SESSION['usersession']['trash'] = 3;//Trash No newline at end of file
136 $_SESSION['usersession']['trash'] = 3;//Trash
137 No newline at end of file
137
138 if(($datos_usuario['state'] == 4) || ($datos_usuario['state'] == 5)){ No newline at end of file
138 if(($datos_usuario['state'] == 4) || ($datos_usuario['state'] == 5)){
139 $url = "index.php?option=com_users&controller=Users&action=getNewPasswordForm"; No newline at end of file
139 $url = "index.php?option=com_users&controller=Users&action=getNewPasswordForm";
140 header("location: ".$url); No newline at end of file
140 header("location: ".$url);
141 exit(0); No newline at end of file
141 exit(0);
142 } No newline at end of file
142 }
143 if($datos_usuario['state'] == 2){ No newline at end of file
143 if($datos_usuario['state'] == 2){
144 $data['titulo'] = "Error:: User Locked"; No newline at end of file
144 $data['titulo'] = "Error:: User Locked";
145 $data['mensaje'] = "Login is disabled by excesses of failed attempts. Contact your 'System Administrator' to solve the problem"; No newline at end of file
145 $data['mensaje'] = "Login is disabled by excesses of failed attempts. Contact your 'System Administrator' to solve the problem";
146 $this->view->show("errorLogin.php", $data); No newline at end of file
146 $this->view->show("errorLogin.php", $data);
147 exit(0); No newline at end of file
147 exit(0);
148 } No newline at end of file
148 }
149 No newline at end of file
149
150 $flag_activo = true; No newline at end of file
150 $flag_activo = true;
151 //require 'components'.DS.'com_messages'.DS.'models'.DS.'MailBoxesModel.php'; No newline at end of file
151 //require 'components'.DS.'com_messages'.DS.'models'.DS.'MailBoxesModel.php';
152 No newline at end of file
152
153 //$resultado_log = $items->registrarLogIngreso($datos_usuario["id_usu"]); No newline at end of file
153 //$resultado_log = $items->registrarLogIngreso($datos_usuario["id_usu"]);
154 /* No newline at end of file
154 /*
155 $mailbox = new MailBoxesModel(); No newline at end of file
155 $mailbox = new MailBoxesModel();
156 No newline at end of file
156
157 $rs_boxes = $mailbox->getMailBoxesSystem($datos_usuario['iduser']); No newline at end of file
157 $rs_boxes = $mailbox->getMailBoxesSystem($datos_usuario['iduser']);
158 //Coloca los idmailbox dentro de variables de session No newline at end of file
158 //Coloca los idmailbox dentro de variables de session
159 $rs_mnuboxes = $mailbox->getIDMailBoxesSystem($datos_usuario['iduser']); No newline at end of file
159 $rs_mnuboxes = $mailbox->getIDMailBoxesSystem($datos_usuario['iduser']);
160 $mnuBoxes = $rs_mnuboxes->fetchAll(); No newline at end of file
160 $mnuBoxes = $rs_mnuboxes->fetchAll();
161 No newline at end of file
161
162 $idtypemb = 1; No newline at end of file
162 $idtypemb = 1;
163 $rsMailBox = $mailbox->getMailBoxType($datos_usuario['iduser'], $idtypemb); No newline at end of file
163 $rsMailBox = $mailbox->getMailBoxType($datos_usuario['iduser'], $idtypemb);
164 $datosMailBox = $rsMailBox->fetch(); No newline at end of file
164 $datosMailBox = $rsMailBox->fetch();
165 No newline at end of file
165
166 $lista_mensajes = $mailbox->getMessagesNoRead($datosMailBox['idmailbox']); No newline at end of file
166 $lista_mensajes = $mailbox->getMessagesNoRead($datosMailBox['idmailbox']);
167 $idmailbox = $datosMailBox['idmailbox']; No newline at end of file
167 $idmailbox = $datosMailBox['idmailbox'];
168 */ No newline at end of file
168 */
169 No newline at end of file
169
170 $data['datos_usuario'] = $datos_usuario; No newline at end of file
170 $data['datos_usuario'] = $datos_usuario;
171 $data['inicio'] = 0; No newline at end of file
171 $data['inicio'] = 0;
172 //$data['rs_boxes'] = $rs_boxes; No newline at end of file
172 //$data['rs_boxes'] = $rs_boxes;
173 //$data['lista_mensajes'] = $lista_mensajes; No newline at end of file
173 //$data['lista_mensajes'] = $lista_mensajes;
174 //$data['idmailbox'] = $idmailbox; No newline at end of file
174 //$data['idmailbox'] = $idmailbox;
175 $data['content'] = "components".DS."com_users".DS."views".DS."home.php"; No newline at end of file
175 $data['content'] = "components".DS."com_users".DS."views".DS."home.php";
176 $data['title'] = "WELCOME:::::::::::"; No newline at end of file
176 $data['title'] = "WELCOME:::::::::::";
177 No newline at end of file
177
178 $this->view->show("template.php", $data); No newline at end of file
178 $this->view->show("template.php", $data);
179 }else{ No newline at end of file
179 }else{
180 $result = $user->obtenerUsuarioxUsername($username); No newline at end of file
180 $result = $user->obtenerUsuarioxUsername($username);
181 $data_user = $result->fetch(); No newline at end of file
181 $data_user = $result->fetch();
182 if(is_array($data_user)){ No newline at end of file
182 if(is_array($data_user)){
183 if (!isset($_SESSION['usersession'])) { No newline at end of file
183 if (!isset($_SESSION['usersession'])) {
184 $_SESSION['usersession'] = array(); No newline at end of file
184 $_SESSION['usersession'] = array();
185 $_SESSION['usersession']['attempt'] = 1; No newline at end of file
185 $_SESSION['usersession']['attempt'] = 1;
186 }else{ No newline at end of file
186 }else{
187 if (!isset($_SESSION['usersession']['attempt'])) { No newline at end of file
187 if (!isset($_SESSION['usersession']['attempt'])) {
188 $_SESSION['usersession']['attempt'] = 1; No newline at end of file
188 $_SESSION['usersession']['attempt'] = 1;
189 }else{ No newline at end of file
189 }else{
190 $_SESSION['usersession']['attempt']++; No newline at end of file
190 $_SESSION['usersession']['attempt']++;
191 } No newline at end of file
191 }
192 } No newline at end of file
192 }
193 if ($_SESSION['usersession']['attempt'] == 3){ No newline at end of file
193 if ($_SESSION['usersession']['attempt'] == 3){
194 $datos['state'] = 2; No newline at end of file
194 $datos['state'] = 2;
195 $user->setIdValue($data_user['iduser']); No newline at end of file
195 $user->setIdValue($data_user['iduser']);
196 list($result, $message) = $user->UpdateItem($datos); No newline at end of file
196 list($result, $message) = $user->UpdateItem($datos);
197 No newline at end of file
197
198 $data['titulo'] = "Failed attempts excess"; No newline at end of file
198 $data['titulo'] = "Failed attempts excess";
199 $data['mensaje'] = "You have exceeded the number of attempts. <br /> User blocked"; No newline at end of file
199 $data['mensaje'] = "You have exceeded the number of attempts. <br /> User blocked";
200 No newline at end of file
200
201 $this->view->show("errorLogin.php", $data); No newline at end of file
201 $this->view->show("errorLogin.php", $data);
202 exit(0); No newline at end of file
202 exit(0);
203 } No newline at end of file
203 }
204 }else{ No newline at end of file
204 }else{
205 if (!isset($_SESSION['usersession'])) { No newline at end of file
205 if (!isset($_SESSION['usersession'])) {
206 $_SESSION['usersession'] = array(); No newline at end of file
206 $_SESSION['usersession'] = array();
207 $_SESSION['usersession']['attempt'] = 1; No newline at end of file
207 $_SESSION['usersession']['attempt'] = 1;
208 }else{ No newline at end of file
208 }else{
209 if (!isset($_SESSION['usersession']['attempt'])) { No newline at end of file
209 if (!isset($_SESSION['usersession']['attempt'])) {
210 $_SESSION['usersession']['attempt'] = 1; No newline at end of file
210 $_SESSION['usersession']['attempt'] = 1;
211 }else{ No newline at end of file
211 }else{
212 $_SESSION['usersession']['attempt']++; No newline at end of file
212 $_SESSION['usersession']['attempt']++;
213 } No newline at end of file
213 }
214 } No newline at end of file
214 }
215 $data['titulo'] = "Error user login / password"; No newline at end of file
215 $data['titulo'] = "Error user login / password";
216 $data['mensaje'] = "Error user login / password"; No newline at end of file
216 $data['mensaje'] = "Error user login / password";
217 //Finalmente presentamos nuestra plantilla No newline at end of file
217 //Finalmente presentamos nuestra plantilla
218 $this->view->show("errorLogin.php", $data); No newline at end of file
218 $this->view->show("errorLogin.php", $data);
219 exit(0); No newline at end of file
219 exit(0);
220 } No newline at end of file
220 }
221 } No newline at end of file
221 }
222 }else{ No newline at end of file
222 }else{
223 //EXCESO DE INTENTOS No newline at end of file
223 //EXCESO DE INTENTOS
224 $timebadlogin = new DateTime(date('Y-m-d H:i:s')); No newline at end of file
224 $timebadlogin = new DateTime(date('Y-m-d H:i:s'));
225 //deshabilitar logueo por determinado tiempo No newline at end of file
225 //deshabilitar logueo por determinado tiempo
226 $data['titulo'] = "Failed attempts excess"; No newline at end of file
226 $data['titulo'] = "Failed attempts excess";
227 $data['mensaje'] = "You have exceeded the number of attempts.<br />Try again in".$valor_intervalo." minutes"; No newline at end of file
227 $data['mensaje'] = "You have exceeded the number of attempts.<br />Try again in".$valor_intervalo." minutes";
228 //establecemos la variable que maneje el tiempo de espera No newline at end of file
228 //establecemos la variable que maneje el tiempo de espera
229 $_SESSION['usersession']['disabled'] = true; No newline at end of file
229 $_SESSION['usersession']['disabled'] = true;
230 if(!isset($_SESSION['usersession']['timebadlogin'])){ No newline at end of file
230 if(!isset($_SESSION['usersession']['timebadlogin'])){
231 $_SESSION['usersession']['timebadlogin'] = $timebadlogin->format('Y-m-d H:i:s'); No newline at end of file
231 $_SESSION['usersession']['timebadlogin'] = $timebadlogin->format('Y-m-d H:i:s');
232 } No newline at end of file
232 }
233 No newline at end of file
233
234 $this->view->show("errorLogin.php", $data); No newline at end of file
234 $this->view->show("errorLogin.php", $data);
235 } No newline at end of file
235 }
236 } No newline at end of file
236 }
237 No newline at end of file
237
238 public function logout(){ No newline at end of file
238 public function logout(){
239 //@print_r($_SESSION['usersession']); No newline at end of file
239 //@print_r($_SESSION['usersession']);
240 $session = new SessionsModel(); No newline at end of file
240 $session = new SessionsModel();
241 No newline at end of file
241
242 $rs_datos_session = $session->validarSession(@$_SESSION['usersession']['iduser']); No newline at end of file
242 $rs_datos_session = $session->validarSession(@$_SESSION['usersession']['iduser']);
243 //print_r($rs_datos_session); No newline at end of file
243 //print_r($rs_datos_session);
244 $datos_session = $rs_datos_session->fetch(); No newline at end of file
244 $datos_session = $rs_datos_session->fetch();
245 $date_last_activity = new DateTime(date("Y-m-d H:i:s")); No newline at end of file
245 $date_last_activity = new DateTime(date("Y-m-d H:i:s"));
246 No newline at end of file
246
247 //establecemos el arreglo datos. No newline at end of file
247 //establecemos el arreglo datos.
248 $datos['date_last_activity'] = $date_last_activity->format('Y-m-d H:i:s'); No newline at end of file
248 $datos['date_last_activity'] = $date_last_activity->format('Y-m-d H:i:s');
249 $datos['idsession'] = $datos_session['idsession']; No newline at end of file
249 $datos['idsession'] = $datos_session['idsession'];
250 $rs = $session->setInactive($datos); No newline at end of file
250 $rs = $session->setInactive($datos);
251 No newline at end of file
251
252 unset($_SESSION['usersession']); No newline at end of file
252 unset($_SESSION['usersession']);
253 session_destroy(); No newline at end of file
253 session_destroy();
254 No newline at end of file
254
255 $data = array(); No newline at end of file
255 $data = array();
256 $this->view->show("logout.php", $data); No newline at end of file
256 $this->view->show("logout.php", $data);
257 } No newline at end of file
257 }
258 No newline at end of file
258
259 public function getRememberPasswordForm(){ No newline at end of file
259 public function getRememberPasswordForm(){
260 $data = array(); No newline at end of file
260 $data = array();
261 $this->view->show("password.php", $data); No newline at end of file
261 $this->view->show("password.php", $data);
262 } No newline at end of file
262 }
263 No newline at end of file
263
264 public function sendPasswordLink(){ No newline at end of file
264 public function sendPasswordLink(){
265 No newline at end of file
265
266 require 'models/UsersModel.php'; No newline at end of file
266 require 'models/UsersModel.php';
267 $user = new UsersModel(); No newline at end of file
267 $user = new UsersModel();
268 No newline at end of file
268
269 $username = $_REQUEST["usuario"]; No newline at end of file
269 $username = $_REQUEST["usuario"];
270 No newline at end of file
270
271 $rs_usuario = $user->obtenerUsuarioxUsername($username); No newline at end of file
271 $rs_usuario = $user->obtenerUsuarioxUsername($username);
272 $datos_usuario = $rs_usuario->fetch(); No newline at end of file
272 $datos_usuario = $rs_usuario->fetch();
273 No newline at end of file
273
274 if(is_array($datos_usuario)){ No newline at end of file
274 if(is_array($datos_usuario)){
275 $servername = $_SERVER['SERVER_NAME']; No newline at end of file
275 $servername = $_SERVER['SERVER_NAME'];
276 $usernamemd5 = md5($datos_usuario['username']); No newline at end of file
276 $usernamemd5 = md5($datos_usuario['username']);
277 $link = 'http://'.$servername.'/?controller=Users&action=getNewPasswordForm&xin='.$usernamemd5.'&forget=yes'; No newline at end of file
277 $link = 'http://'.$servername.'/?controller=Users&action=getNewPasswordForm&xin='.$usernamemd5.'&forget=yes';
278 No newline at end of file
278
279 $contenido = ''; No newline at end of file
279 $contenido = '';
280 No newline at end of file
280
281 $destinatario = "nmedina79@gmail.com"; No newline at end of file
281 $destinatario = "nmedina79@gmail.com";
282 $asunto = "Este mensaje es de prueba"; No newline at end of file
282 $asunto = "Este mensaje es de prueba";
283 $cuerpo = ' No newline at end of file
283 $cuerpo = '
284 <html> No newline at end of file
284 <html>
285 <head> No newline at end of file
285 <head>
286 <title>Prueba de correo</title> No newline at end of file
286 <title>Prueba de correo</title>
287 </head> No newline at end of file
287 </head>
288 <body> No newline at end of file
288 <body>
289 <h1>Hola amigos!</h1> No newline at end of file
289 <h1>Hola amigos!</h1>
290 <p> No newline at end of file
290 <p>
291 <b>Bienvenidos a mi correo electronico de prueba</b>. Estoy encantado de tener tantos lectores. Este cuerpo del mensaje es del articulo de envio de mails por PHP. Habria que cambiarlo para poner tu propio cuerpo. Por cierto, cambia tambien las cabeceras del mensaje.<br/> No newline at end of file
291 <b>Bienvenidos a mi correo electronico de prueba</b>. Estoy encantado de tener tantos lectores. Este cuerpo del mensaje es del articulo de envio de mails por PHP. Habria que cambiarlo para poner tu propio cuerpo. Por cierto, cambia tambien las cabeceras del mensaje.<br/>
292 enlace : <a href="'.$link.'" target="_parent">'.$link.'</a> No newline at end of file
292 enlace : <a href="'.$link.'" target="_parent">'.$link.'</a>
293 No newline at end of file
293
294 </p> No newline at end of file
294 </p>
295 </body> No newline at end of file
295 </body>
296 </html> No newline at end of file
296 </html>
297 '; No newline at end of file
297 ';
298 No newline at end of file
298
299 //para el envio en formato HTML No newline at end of file
299 //para el envio en formato HTML
300 $headers = "MIME-Version: 1.0\r\n"; No newline at end of file
300 $headers = "MIME-Version: 1.0\r\n";
301 $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; No newline at end of file
301 $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
302 No newline at end of file
302
303 //direccion del remitente No newline at end of file
303 //direccion del remitente
304 $headers .= "From: Administrador <admin@epimed.com>\r\n"; No newline at end of file
304 $headers .= "From: Administrador <admin@epimed.com>\r\n";
305 No newline at end of file
305
306 //direccion de respuesta, si queremos que sea distinta que la del remitente No newline at end of file
306 //direccion de respuesta, si queremos que sea distinta que la del remitente
307 $headers .= "Reply-To: deployment@epimed.com\r\n"; No newline at end of file
307 $headers .= "Reply-To: deployment@epimed.com\r\n";
308 No newline at end of file
308
309 //ruta del mensaje desde origen a destino No newline at end of file
309 //ruta del mensaje desde origen a destino
310 $headers .= "Return-path: nmedina79@gmail.com\r\n"; No newline at end of file
310 $headers .= "Return-path: nmedina79@gmail.com\r\n";
311 No newline at end of file
311
312 //direcciones que recibion copia No newline at end of file
312 //direcciones que recibion copia
313 $headers .= "Cc: deployment@epimed.com\r\n"; No newline at end of file
313 $headers .= "Cc: deployment@epimed.com\r\n";
314 No newline at end of file
314
315 //direcciones que recibiron copia oculta No newline at end of file
315 //direcciones que recibiron copia oculta
316 $headers .= "Bcc: jsalyrosas@poweruptechs.com,hleon@poweruptechs.com\r\n"; No newline at end of file
316 $headers .= "Bcc: jsalyrosas@poweruptechs.com,hleon@poweruptechs.com\r\n";
317 No newline at end of file
317
318 if(mail($destinatario,$asunto,$cuerpo,$headers)){ No newline at end of file
318 if(mail($destinatario,$asunto,$cuerpo,$headers)){
319 $mensaje = 'An email with a link to update has been sent to your email.'; No newline at end of file
319 $mensaje = 'An email with a link to update has been sent to your email.';
320 }else{ No newline at end of file
320 }else{
321 $mensaje = 'Failed to send link. Try again in a few minutes or contact your system administrator'; No newline at end of file
321 $mensaje = 'Failed to send link. Try again in a few minutes or contact your system administrator';
322 } No newline at end of file
322 }
323 No newline at end of file
323
324 try{ No newline at end of file
324 try{
325 mail($destinatario,$asunto,$cuerpo,$headers); No newline at end of file
325 mail($destinatario,$asunto,$cuerpo,$headers);
326 }catch (Exception $e){ No newline at end of file
326 }catch (Exception $e){
327 echo 'Caught exception: ', $e->getMessage(), "\n"; No newline at end of file
327 echo 'Caught exception: ', $e->getMessage(), "\n";
328 } No newline at end of file
328 }
329 No newline at end of file
329
330 /* No newline at end of file
330 /*
331 require("class.phpmailer.php"); No newline at end of file
331 require("class.phpmailer.php");
332 $mail = new PHPMailer(); No newline at end of file
332 $mail = new PHPMailer();
333 No newline at end of file
333
334 $mail->IsSMTP(); // set mailer to use SMTP No newline at end of file
334 $mail->IsSMTP(); // set mailer to use SMTP
335 $mail->Host = "smtp.innovaciencia.com;smtp.innovaciencia.com"; // specify main and backup server No newline at end of file
335 $mail->Host = "smtp.innovaciencia.com;smtp.innovaciencia.com"; // specify main and backup server
336 $mail->SMTPAuth = true; // turn on SMTP authentication No newline at end of file
336 $mail->SMTPAuth = true; // turn on SMTP authentication
337 $mail->Username = "jsalyrosas"; // SMTP username No newline at end of file
337 $mail->Username = "jsalyrosas"; // SMTP username
338 $mail->Password = "j05e4nt0n10"; // SMTP password No newline at end of file
338 $mail->Password = "j05e4nt0n10"; // SMTP password
339 No newline at end of file
339
340 $mail->From = "Admin@epimed.com"; No newline at end of file
340 $mail->From = "Admin@epimed.com";
341 $mail->FromName = "Admin"; No newline at end of file
341 $mail->FromName = "Admin";
342 $mail->AddAddress("nmedina79@gmail.com", "Josh Adams"); No newline at end of file
342 $mail->AddAddress("nmedina79@gmail.com", "Josh Adams");
343 $mail->AddAddress("nmedina79@gmail.com"); // name is optional No newline at end of file
343 $mail->AddAddress("nmedina79@gmail.com"); // name is optional
344 $mail->AddReplyTo("nmedina79@hotmail.com", "Information"); No newline at end of file
344 $mail->AddReplyTo("nmedina79@hotmail.com", "Information");
345 No newline at end of file
345
346 $mail->WordWrap = 50; // set word wrap to 50 characters No newline at end of file
346 $mail->WordWrap = 50; // set word wrap to 50 characters
347 //$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments No newline at end of file
347 //$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
348 //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name No newline at end of file
348 //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
349 $mail->IsHTML(true); // set email format to HTML No newline at end of file
349 $mail->IsHTML(true); // set email format to HTML
350 No newline at end of file
350
351 $mail->Subject = "Here is the subject"; No newline at end of file
351 $mail->Subject = "Here is the subject";
352 //$mail->Body = "This is the HTML message body <b>in bold!</b>".$cuerpo; No newline at end of file
352 //$mail->Body = "This is the HTML message body <b>in bold!</b>".$cuerpo;
353 $mail->Body = $cuerpo; No newline at end of file
353 $mail->Body = $cuerpo;
354 $mail->AltBody = "This is the body in plain text for non-HTML mail clients"; No newline at end of file
354 $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
355 No newline at end of file
355
356 if(!$mail->Send()){ No newline at end of file
356 if(!$mail->Send()){
357 echo "Message could not be sent. <p>"; No newline at end of file
357 echo "Message could not be sent. <p>";
358 echo "Mailer Error: " . $mail->ErrorInfo; No newline at end of file
358 echo "Mailer Error: " . $mail->ErrorInfo;
359 exit; No newline at end of file
359 exit;
360 } No newline at end of file
360 }
361 No newline at end of file
361
362 echo "Message has been sent"; No newline at end of file
362 echo "Message has been sent";
363 */ No newline at end of file
363 */
364 }else{ No newline at end of file
364 }else{
365 $mensaje = " User doesn't exist."; No newline at end of file
365 $mensaje = " User doesn't exist.";
366 } No newline at end of file
366 }
367 No newline at end of file
367
368 $data = array(); No newline at end of file
368 $data = array();
369 $data['mensaje'] = $mensaje; No newline at end of file
369 $data['mensaje'] = $mensaje;
370 $data['link'] = $link; No newline at end of file
370 $data['link'] = $link;
371 No newline at end of file
371
372 $this->view->show("password.php", $data); No newline at end of file
372 $this->view->show("password.php", $data);
373 } No newline at end of file
373 }
374 No newline at end of file
374
375 public function getNewPasswordForm(){ No newline at end of file
375 public function getNewPasswordForm(){
376 (!empty($_REQUEST['forget']))?$forget = $_REQUEST['forget']:$forget='no'; No newline at end of file
376 (!empty($_REQUEST['forget']))?$forget = $_REQUEST['forget']:$forget='no';
377 (!empty($_REQUEST['xin']))?$xin = $_REQUEST['xin']:$xin=''; No newline at end of file
377 (!empty($_REQUEST['xin']))?$xin = $_REQUEST['xin']:$xin='';
378 (!empty($_REQUEST['force']))?$force = $_REQUEST['force']:$force='yes'; No newline at end of file
378 (!empty($_REQUEST['force']))?$force = $_REQUEST['force']:$force='yes';
379 No newline at end of file
379
380 //@$forget = $_REQUEST['forget']; No newline at end of file
380 //@$forget = $_REQUEST['forget'];
381 //@$xin = $_REQUEST['xin']; No newline at end of file
381 //@$xin = $_REQUEST['xin'];
382 $data = array(); No newline at end of file
382 $data = array();
383 $data['forget'] = $forget; No newline at end of file
383 $data['forget'] = $forget;
384 $data['force'] = $force; No newline at end of file
384 $data['force'] = $force;
385 $data['xin'] = $xin; No newline at end of file
385 $data['xin'] = $xin;
386 No newline at end of file
386
387 $this->view->show("change_passwd.php", $data); No newline at end of file
387 $this->view->show("change_passwd.php", $data);
388 } No newline at end of file
388 }
389 No newline at end of file
389
390 public function passwordUpdate(){ No newline at end of file
390 public function passwordUpdate(){
391 No newline at end of file
391
392 $datos = $_REQUEST['datos']; No newline at end of file
392 $datos = $_REQUEST['datos'];
393 (!empty($_REQUEST['forget']))?$forget = $_REQUEST['forget']:$forget='no'; No newline at end of file
393 (!empty($_REQUEST['forget']))?$forget = $_REQUEST['forget']:$forget='no';
394 (!empty($_REQUEST['usernamemd5']))?$usernamemd5 = $_REQUEST['xin']:$usernamemd5=''; No newline at end of file
394 (!empty($_REQUEST['usernamemd5']))?$usernamemd5 = $_REQUEST['xin']:$usernamemd5='';
395 (!empty($_REQUEST['force']))?$force = $_REQUEST['force']:$force=''; No newline at end of file
395 (!empty($_REQUEST['force']))?$force = $_REQUEST['force']:$force='';
396 //@$forget = $_REQUEST['forget']; No newline at end of file
396 //@$forget = $_REQUEST['forget'];
397 //@$usernamemd5 = $_REQUEST['xin']; No newline at end of file
397 //@$usernamemd5 = $_REQUEST['xin'];
398 //@$force = $_REQUEST['force']; No newline at end of file
398 //@$force = $_REQUEST['force'];
399 No newline at end of file
399
400 //print_r($datos); No newline at end of file
400 //print_r($datos);
401 No newline at end of file
401
402 require 'models/UsersModel.php'; No newline at end of file
402 require 'models/UsersModel.php';
403 No newline at end of file
403
404 $user = new UsersModel(); No newline at end of file
404 $user = new UsersModel();
405 No newline at end of file
405
406 if( $datos['new_password'] == $datos['new_password_again']){ No newline at end of file
406 if( $datos['new_password'] == $datos['new_password_again']){
407 No newline at end of file
407
408 if($forget == 'yes'){ No newline at end of file
408 if($forget == 'yes'){
409 //echo $usernamemd5; No newline at end of file
409 //echo $usernamemd5;
410 $rs_usuario = $user->obtenerUsuarioxUsernameMD5($usernamemd5); No newline at end of file
410 $rs_usuario = $user->obtenerUsuarioxUsernameMD5($usernamemd5);
411 //print_r($rs_usuario); No newline at end of file
411 //print_r($rs_usuario);
412 $datos_usuario = $rs_usuario->fetch(); No newline at end of file
412 $datos_usuario = $rs_usuario->fetch();
413 $iduser = $datos_usuario['iduser']; No newline at end of file
413 $iduser = $datos_usuario['iduser'];
414 $password = $datos['new_password']; No newline at end of file
414 $password = $datos['new_password'];
415 $rs_updatePassword = $user->setNewPassword($iduser,$password); No newline at end of file
415 $rs_updatePassword = $user->setNewPassword($iduser,$password);
416 //print_r($rs_updatePassword); No newline at end of file
416 //print_r($rs_updatePassword);
417 $data['xin'] = $usernamemd5; No newline at end of file
417 $data['xin'] = $usernamemd5;
418 $data['forget'] = $forget; No newline at end of file
418 $data['forget'] = $forget;
419 $data['force'] = $force; No newline at end of file
419 $data['force'] = $force;
420 No newline at end of file
420
421 $data['mensaje'] = ' your password has been updated<br/><a href="?controller=Users&action=ingresar">next</a>'; No newline at end of file
421 $data['mensaje'] = ' your password has been updated<br/><a href="?controller=Users&action=ingresar">next</a>';
422 unset($_SESSION['sessionuser']); No newline at end of file
422 unset($_SESSION['sessionuser']);
423 $this->view->show("usersNewPasswordForm.php", $data); No newline at end of file
423 $this->view->show("usersNewPasswordForm.php", $data);
424 No newline at end of file
424
425 }else{ No newline at end of file
425 }else{
426 if(!empty($datos['current_password'])){ No newline at end of file
426 if(!empty($datos['current_password'])){
427 //validarAdministrador($username,$password) No newline at end of file
427 //validarAdministrador($username,$password)
428 if(!empty($_SESSION['usersession']['iduser'])){ No newline at end of file
428 if(!empty($_SESSION['usersession']['iduser'])){
429 $iduser = $_SESSION['usersession']['iduser']; No newline at end of file
429 $iduser = $_SESSION['usersession']['iduser'];
430 $password = $datos['new_password']; No newline at end of file
430 $password = $datos['new_password'];
431 $rs_usuario = $user->obtenerUsuarioxId($iduser); No newline at end of file
431 $rs_usuario = $user->obtenerUsuarioxId($iduser);
432 $datos_usuario = $rs_usuario->fetch(); No newline at end of file
432 $datos_usuario = $rs_usuario->fetch();
433 No newline at end of file
433
434 //validamos la existencia del usuario No newline at end of file
434 //validamos la existencia del usuario
435 $username = $datos_usuario['username']; No newline at end of file
435 $username = $datos_usuario['username'];
436 $current_password = $datos['current_password'];// No newline at end of file
436 $current_password = $datos['current_password'];//
437 $rs_validado = $user->validarAdministrador($username,$current_password); No newline at end of file
437 $rs_validado = $user->validarAdministrador($username,$current_password);
438 $datos_validado = $rs_validado->fetch(); No newline at end of file
438 $datos_validado = $rs_validado->fetch();
439 No newline at end of file
439
440 if(is_array($datos_validado)){ No newline at end of file
440 if(is_array($datos_validado)){
441 //actualizamos el nuevo password No newline at end of file
441 //actualizamos el nuevo password
442 $rs_updatePassword = $user->setNewPassword($iduser,$password); No newline at end of file
442 $rs_updatePassword = $user->setNewPassword($iduser,$password);
443 //cambiar el estado del usuario No newline at end of file
443 //cambiar el estado del usuario
444 $rs_updatePassword = $user->setActive($iduser); No newline at end of file
444 $rs_updatePassword = $user->setActive($iduser);
445 No newline at end of file
445
446 unset($_SESSION['usersession']); No newline at end of file
446 unset($_SESSION['usersession']);
447 $data = array(); No newline at end of file
447 $data = array();
448 $data['forget'] = $forget; No newline at end of file
448 $data['forget'] = $forget;
449 $data['mensaje'] = ' your password has been updated<br/><a href="send.php?controller=Users&action=logout" target="enviar">continuar</a>'; No newline at end of file
449 $data['mensaje'] = ' your password has been updated<br/><a href="send.php?controller=Users&action=logout" target="enviar">continuar</a>';
450 $this->view->show("usersNewPasswordForm.php", $data); No newline at end of file
450 $this->view->show("usersNewPasswordForm.php", $data);
451 No newline at end of file
451
452 No newline at end of file
452
453 }else{ No newline at end of file
453 }else{
454 $data['mensaje'] = ' your current password is invalid '; No newline at end of file
454 $data['mensaje'] = ' your current password is invalid ';
455 $this->view->show("usersNewPasswordForm.php", $data); No newline at end of file
455 $this->view->show("usersNewPasswordForm.php", $data);
456 } No newline at end of file
456 }
457 }else{ No newline at end of file
457 }else{
458 $data['mensaje'] = ' you have not started your user session.<br/> '; No newline at end of file
458 $data['mensaje'] = ' you have not started your user session.<br/> ';
459 $this->view->show("login.php", $data); No newline at end of file
459 $this->view->show("login.php", $data);
460 } No newline at end of file
460 }
461 }else{ No newline at end of file
461 }else{
462 //$data['xin'] = $usernamemd5; No newline at end of file
462 //$data['xin'] = $usernamemd5;
463 //$data['forget'] = $forget; No newline at end of file
463 //$data['forget'] = $forget;
464 $data['mensaje'] = ' did not enter the current password '; No newline at end of file
464 $data['mensaje'] = ' did not enter the current password ';
465 $this->view->show("usersNewPasswordForm.php", $data); No newline at end of file
465 $this->view->show("usersNewPasswordForm.php", $data);
466 } No newline at end of file
466 }
467 } No newline at end of file
467 }
468 No newline at end of file
468
469 }else{ No newline at end of file
469 }else{
470 $data['xin'] = $usernamemd5; No newline at end of file
470 $data['xin'] = $usernamemd5;
471 $data['forget'] = $forget; No newline at end of file
471 $data['forget'] = $forget;
472 $data['mensaje'] = 'the new password entered does not match'; No newline at end of file
472 $data['mensaje'] = 'the new password entered does not match';
473 $this->view->show("usersNewPasswordForm.php", $data); No newline at end of file
473 $this->view->show("usersNewPasswordForm.php", $data);
474 } No newline at end of file
474 }
475 No newline at end of file
475
476 } No newline at end of file
476 }
477 No newline at end of file
477
478 public function dolist(){ No newline at end of file
478 public function dolist(){
479 require 'components'.DS.'com_users'.DS.'models'.DS.'UsersModel.php'; No newline at end of file
479 require 'components'.DS.'com_users'.DS.'models'.DS.'UsersModel.php';
480 $users = new UsersModel(); No newline at end of file
480 $users = new UsersModel();
481 No newline at end of file
481
482 if(!empty($_REQUEST['inicio'])){ No newline at end of file
482 if(!empty($_REQUEST['inicio'])){
483 $inicio = $_REQUEST['inicio']; No newline at end of file
483 $inicio = $_REQUEST['inicio'];
484 }else{ No newline at end of file
484 }else{
485 $inicio = 0; No newline at end of file
485 $inicio = 0;
486 } No newline at end of file
486 }
487 No newline at end of file
487
488 $tamanio = 15; No newline at end of file
488 $tamanio = 15;
489 $parametros = array("inicio" => $inicio, "tamanio" => $tamanio); No newline at end of file
489 $parametros = array("inicio" => $inicio, "tamanio" => $tamanio);
490 list($list_users, $paginas, $navegador) = $users->dolist($parametros); No newline at end of file
490 list($list_users, $paginas, $navegador) = $users->dolist($parametros);
491 No newline at end of file
491
492 $data['listUsers'] = $list_users; No newline at end of file
492 $data['listUsers'] = $list_users;
493 $data['paginas'] = $paginas; No newline at end of file
493 $data['paginas'] = $paginas;
494 $data['navegador'] = $navegador; No newline at end of file
494 $data['navegador'] = $navegador;
495 $data['inicio'] = $inicio; No newline at end of file
495 $data['inicio'] = $inicio;
496 $data['content'] = "components".DS."com_users".DS."views".DS."dolist.php"; No newline at end of file
496 $data['content'] = "components".DS."com_users".DS."views".DS."dolist.php";
497 $data['title'] = "USUARIOS::::::::::::"; No newline at end of file
497 $data['title'] = "USUARIOS::::::::::::";
498 No newline at end of file
498
499 $this->view->show("template.php", $data); No newline at end of file
499 $this->view->show("template.php", $data);
500 } No newline at end of file
500 }
501 No newline at end of file
501
502 public function newUser(){ No newline at end of file
502 public function newUser(){
503 if(!empty($_REQUEST['message'])){ No newline at end of file
503 if(!empty($_REQUEST['message'])){
504 $message = $_REQUEST['message']; No newline at end of file
504 $message = $_REQUEST['message'];
505 }else{ No newline at end of file
505 }else{
506 $message = ""; No newline at end of file
506 $message = "";
507 } No newline at end of file
507 }
508 $data['message'] = $message; No newline at end of file
508 $data['message'] = $message;
509 $data['content'] = "components".DS."com_users".DS."views".DS."newUser.php"; No newline at end of file
509 $data['content'] = "components".DS."com_users".DS."views".DS."newUser.php";
510 $data['title'] = "NEW USER:::::"; No newline at end of file
510 $data['title'] = "NEW USER:::::";
511 No newline at end of file
511
512 $this->view->show("template.php", $data); No newline at end of file
512 $this->view->show("template.php", $data);
513 } No newline at end of file
513 }
514 No newline at end of file
514
515 public function addUser(){ No newline at end of file
515 public function addUser(){
516 require 'components'.DS.'com_users'.DS.'models'.DS.'UsersModel.php'; No newline at end of file
516 require 'components'.DS.'com_users'.DS.'models'.DS.'UsersModel.php';
517 $user = new UsersModel(); No newline at end of file
517 $user = new UsersModel();
518 No newline at end of file
518
519 $data_user = $_REQUEST["data_user"]; No newline at end of file
519 $data_user = $_REQUEST["data_user"];
520 $data_user['username'] = $_REQUEST["newusername"]; No newline at end of file
520 $data_user['username'] = $_REQUEST["newusername"];
521 $data_user['password'] = md5($_REQUEST["newpasswd"]); No newline at end of file
521 $data_user['password'] = md5($_REQUEST["newpasswd"]);
522 $data_user['email'] = $_REQUEST["txt_email"]; No newline at end of file
522 $data_user['email'] = $_REQUEST["txt_email"];
523 $data_user['usertype'] = 1; No newline at end of file
523 $data_user['usertype'] = 1;
524 $data_user['state'] = 4; No newline at end of file
524 $data_user['state'] = 4;
525 No newline at end of file
525
526 $urlphoto = "avatar.jpg"; No newline at end of file
526 $urlphoto = "avatar.jpg";
527 No newline at end of file
527
528 $url = explode(DS, trim(dirname(__DIR__))); No newline at end of file
528 $url = explode(DS, trim(dirname(__DIR__)));
529 array_pop($url); No newline at end of file
529 array_pop($url);
530 array_pop($url); No newline at end of file
530 array_pop($url);
531 array_pop($url); No newline at end of file
531 array_pop($url);
532 array_pop($url); No newline at end of file
532 array_pop($url);
533 $path = implode(DS, $url); No newline at end of file
533 $path = implode(DS, $url);
534 No newline at end of file
534
535 $flag = FALSE;
535 $flag = FALSE;
No newline at end of file
536 $data_list = $user->getAllUsers(); No newline at end of file
536 $result = $user->getAllUsers();
No newline at end of file
537 $data_list = $result->fetchAll(); No newline at end of file
538 foreach($data_list as $userdata){
537 foreach($data_list as $userdata){
No newline at end of file
538 if(strtolower($data_user['username']) == strtolower($userdata->username)){$flag = TRUE; break;} No newline at end of file
539 if(strtolower($data_user['username']) == strtolower($userdata['username'])){$flag = TRUE; break;} No newline at end of file
540 } No newline at end of file
539 }
541 No newline at end of file
540
542 if($flag === FALSE){ No newline at end of file
541 if($flag === FALSE){
543 if($_FILES['fphoto']['tmp_name'] != ""){ No newline at end of file
542 if($_FILES['fphoto']['tmp_name'] != ""){
544 if (is_uploaded_file($_FILES['fphoto']['tmp_name'])){ No newline at end of file
543 if (is_uploaded_file($_FILES['fphoto']['tmp_name'])){
545 $psize = $_FILES ['fphoto']['size']; No newline at end of file
544 $psize = $_FILES ['fphoto']['size'];
546 $pname = $_FILES ['fphoto']['name']; No newline at end of file
545 $pname = $_FILES ['fphoto']['name'];
547 $type = substr( $pname, strlen($pname)-4); No newline at end of file
546 $type = substr( $pname, strlen($pname)-4);
548 if($type==".jpg" || $type==".gif" || $type==".png" || $type==".JPG" || $type==".GIF" || $type==".PNG"){ No newline at end of file
547 if($type==".jpg" || $type==".gif" || $type==".png" || $type==".JPG" || $type==".GIF" || $type==".PNG"){
549 copy($_FILES['fphoto']['tmp_name'], $path.DS."files".DS."photos".DS.$username.$type); No newline at end of file
548 copy($_FILES['fphoto']['tmp_name'], $path.DS."files".DS."photos".DS.$username.$type);
550 $urlphoto = "photos".DS.$username.$type; No newline at end of file
549 $urlphoto = "photos".DS.$username.$type;
551 }else{ No newline at end of file
550 }else{
552 $mensaje_upload = ". Uploaded failed: No image file.";// error por tipo No newline at end of file
551 $mensaje_upload = ". Uploaded failed: No image file.";// error por tipo
553 } No newline at end of file
552 }
554 }else{ No newline at end of file
553 }else{
555 $mensaje_upload = ". Uploaded failed.";// error por tamanio No newline at end of file
554 $mensaje_upload = ". Uploaded failed.";// error por tamanio
556 } No newline at end of file
555 }
557 }else{ No newline at end of file
556 }else{
558 $mensaje_upload = "Error: Uploaded failed."; No newline at end of file
557 $mensaje_upload = "Error: Uploaded failed.";
559 } No newline at end of file
558 }
560 No newline at end of file
559
561 $data_user['photo'] = $urlphoto; No newline at end of file
560 $data_user['photo'] = $urlphoto;
562 list($result, $id, $message) = $user->addItem($data_user); No newline at end of file
561 list($result, $id, $message) = $user->addItem($data_user);
563 No newline at end of file
562
564 $url = 'index.php?option=com_users&controller=Users&action=dolist'; No newline at end of file
563 $url = 'index.php?option=com_users&controller=Users&action=dolist';
565 }else{ No newline at end of file
564 }else{
566 $message = "Error::: Username unavailable."; No newline at end of file
565 $message = "Error::: Username unavailable.";
567 $url = 'index.php?option=com_users&controller=Users&action=newUser&message='.$message; No newline at end of file
566 $url = 'index.php?option=com_users&controller=Users&action=newUser&message='.$message;
568 } No newline at end of file
567 }
569 header("location: ".$url); No newline at end of file
568 header("location: ".$url);
570 exit(); No newline at end of file
569 exit();
571 } No newline at end of file
570 }
572 No newline at end of file
571
573 public function editUser(){ No newline at end of file
572 public function editUser(){
574 require 'components'.DS.'com_users'.DS.'models'.DS.'UsersModel.php'; No newline at end of file
573 require 'components'.DS.'com_users'.DS.'models'.DS.'UsersModel.php';
575 No newline at end of file
574
576 $user = new UsersModel(); No newline at end of file
575 $user = new UsersModel();
577 No newline at end of file
576
578 $iduser = $_REQUEST['user']; No newline at end of file
577 $iduser = $_REQUEST['user'];
579 $newuser = $user->editUser($iduser); No newline at end of file
578 $newuser = $user->editUser($iduser);
580 $method = "edit"; No newline at end of file
579 $method = "edit";
581 No newline at end of file
580
582 $data['usuario'] = $newuser->fetch(); No newline at end of file
581 $data['usuario'] = $newuser->fetch();
583 $data['edit'] = true; No newline at end of file
582 $data['edit'] = true;
584 $data['method'] = $method; No newline at end of file
583 $data['method'] = $method;
585 $data['iduser'] = $iduser; No newline at end of file
584 $data['iduser'] = $iduser;
586 $data['content'] = "components".DS."com_users".DS."views".DS."editUser.php"; No newline at end of file
585 $data['content'] = "components".DS."com_users".DS."views".DS."editUser.php";
587 $data['title'] = "EDIT USER::::::::::::::::"; No newline at end of file
586 $data['title'] = "EDIT USER::::::::::::::::";
588 No newline at end of file
587
589 $this->view->show("template.php", $data); No newline at end of file
588 $this->view->show("template.php", $data);
590 } No newline at end of file
589 }
591 No newline at end of file
590
592 public function view(){ No newline at end of file
591 public function view(){
593 require 'models/UsersModel.php'; No newline at end of file
592 require 'models/UsersModel.php';
594 No newline at end of file
593
595 $user = new UsersModel(); No newline at end of file
594 $user = new UsersModel();
596 No newline at end of file
595
597 $iduser = $_REQUEST['user']; No newline at end of file
596 $iduser = $_REQUEST['user'];
598 $newuser = $user->editUser($iduser); No newline at end of file
597 $newuser = $user->editUser($iduser);
599 $method = "view"; No newline at end of file
598 $method = "view";
600 No newline at end of file
599
601 $data['usuario'] = $newuser->fetch(); No newline at end of file
600 $data['usuario'] = $newuser->fetch();
602 $data['edit'] = false; No newline at end of file
601 $data['edit'] = false;
603 $data['method'] = $method; No newline at end of file
602 $data['method'] = $method;
604 $data['iduser'] = $iduser; No newline at end of file
603 $data['iduser'] = $iduser;
605 $data['content'] = "components".DS."com_users".DS."views".DS."editUser.php"; No newline at end of file
604 $data['content'] = "components".DS."com_users".DS."views".DS."editUser.php";
606 No newline at end of file
605
607 $this->view->show("template.php", $data); No newline at end of file
606 $this->view->show("template.php", $data);
608 } No newline at end of file
607 }
609 No newline at end of file
608
610 public function updateUser(){ No newline at end of file
609 public function updateUser(){
611 require 'components'.DS.'com_users'.DS.'models'.DS.'UsersModel.php'; No newline at end of file
610 require 'components'.DS.'com_users'.DS.'models'.DS.'UsersModel.php';
612 No newline at end of file
611
613 $user = new UsersModel(); No newline at end of file
612 $user = new UsersModel();
614 $iduser = $_POST['iduser']; No newline at end of file
613 $iduser = $_POST['iduser'];
615 $datos['firstname'] = $_POST['firstname']; No newline at end of file
614 $datos['firstname'] = $_POST['firstname'];
616 $datos['lastname'] = $_POST['lastname']; No newline at end of file
615 $datos['lastname'] = $_POST['lastname'];
617 $datos['state'] = $_POST['state']; No newline at end of file
616 $datos['state'] = $_POST['state'];
618 No newline at end of file
617
619 $user->setIdValue($iduser); No newline at end of file
618 $user->setIdValue($iduser);
620 list($result, $message) = $user->UpdateItem($datos); No newline at end of file
619 list($result, $message) = $user->UpdateItem($datos);
621 No newline at end of file
620
622 $url = 'index.php?option=com_users&controller=Users&action=dolist'; No newline at end of file
621 $url = 'index.php?option=com_users&controller=Users&action=dolist';
623 header("location: ".$url); No newline at end of file
622 header("location: ".$url);
624 exit(); No newline at end of file
623 exit();
625 } No newline at end of file
624 }
626 No newline at end of file
625
627 public function remove(){ No newline at end of file
626 public function remove(){
628 require 'models/UsersModel.php'; No newline at end of file
627 require 'models/UsersModel.php';
629 $user = new UsersModel(); No newline at end of file
628 $user = new UsersModel();
630 $iduser = $_REQUEST['user']; No newline at end of file
629 $iduser = $_REQUEST['user'];
631 No newline at end of file
630
632 $data_user['state'] = 3; No newline at end of file
631 $data_user['state'] = 3;
633 No newline at end of file
632
634 $user->setIdValue($iduser); No newline at end of file
633 $user->setIdValue($iduser);
635 //list($result, $message) = $user->DeleteItem(); No newline at end of file
634 //list($result, $message) = $user->DeleteItem();
636 list($result, $message) = $user->UpdateItem($data_user); No newline at end of file
635 list($result, $message) = $user->UpdateItem($data_user);
637 No newline at end of file
636
638 $url = 'index.php?option=com_users&controller=Users&action=getUsers'; No newline at end of file
637 $url = 'index.php?option=com_users&controller=Users&action=getUsers';
639 No newline at end of file
638
640 header("location: ".$url); No newline at end of file
639 header("location: ".$url);
641 exit(); No newline at end of file
640 exit();
642 } No newline at end of file
641 }
643 No newline at end of file
642
644 public function searchUser(){ No newline at end of file
643 public function searchUser(){
645 require 'models/UsersModel.php'; No newline at end of file
644 require 'models/UsersModel.php';
646 No newline at end of file
645
647 $user = new UsersModel(); No newline at end of file
646 $user = new UsersModel();
648 $username = $_REQUEST['value']; No newline at end of file
647 $username = $_REQUEST['value'];
649 $newuser = $user->searchUserbyUName($username); No newline at end of file
648 $newuser = $user->searchUserbyUName($username);
650 $usuario = $newuser->fetch(); No newline at end of file
649 $usuario = $newuser->fetch();
651 No newline at end of file
650
652 if(!is_array($usuario)){ No newline at end of file
651 if(!is_array($usuario)){
653 $generatePassword = substr(md5($username.time('YmdHis')),0,5); No newline at end of file
652 $generatePassword = substr(md5($username.time('YmdHis')),0,5);
654 } No newline at end of file
653 }
655 No newline at end of file
654
656 $data['username'] = $username; No newline at end of file
655 $data['username'] = $username;
657 $data['usuario'] = $usuario; No newline at end of file
656 $data['usuario'] = $usuario;
658 @$data['key'] = $generatePassword; No newline at end of file
657 @$data['key'] = $generatePassword;
659 No newline at end of file
658
660 $this->view->show("searchUser.php", $data); No newline at end of file
659 $this->view->show("searchUser.php", $data);
661 } No newline at end of file
660 }
662 No newline at end of file
661
663 public function changePasswd(){ No newline at end of file
662 public function changePasswd(){
664 require 'components'.DS.'com_users'.DS.'models'.DS.'UsersModel.php'; No newline at end of file
663 require 'components'.DS.'com_users'.DS.'models'.DS.'UsersModel.php';
665 No newline at end of file
664
666 $iduser = $_POST['iduser']; No newline at end of file
665 $iduser = $_POST['iduser'];
667 try{ No newline at end of file
666 try{
668 if(isset ($_POST['chgPasswd'])){ No newline at end of file
667 if(isset ($_POST['chgPasswd'])){
669 $type_login = $_POST['chgPasswd']; No newline at end of file
668 $type_login = $_POST['chgPasswd'];
670 $user = new UsersModel(); No newline at end of file
669 $user = new UsersModel();
671 No newline at end of file
670
672 if($type_login == 4){ No newline at end of file
671 if($type_login == 4){
673 No newline at end of file
672
674 $datos['password'] = md5($_POST['passwd']); No newline at end of file
673 $datos['password'] = md5($_POST['passwd']);
675 $datos['state'] = 1; No newline at end of file
674 $datos['state'] = 1;
676 $user->setIdValue($iduser); No newline at end of file
675 $user->setIdValue($iduser);
677 list($result, $message) = $user->UpdateItem($datos); No newline at end of file
676 list($result, $message) = $user->UpdateItem($datos);
678 No newline at end of file
677
679 $url = 'index.php?option=com_users&controller=Users&action=home'; No newline at end of file
678 $url = 'index.php?option=com_users&controller=Users&action=home';
680 No newline at end of file
679
681 header("location: ".$url); No newline at end of file
680 header("location: ".$url);
682 exit(); No newline at end of file
681 exit();
683 }else{ No newline at end of file
682 }else{
684 No newline at end of file
683
685 $oldpasswd = $_POST['oldpasswd']; No newline at end of file
684 $oldpasswd = $_POST['oldpasswd'];
686 $datos['password'] = $_POST['newpasswd']; No newline at end of file
685 $datos['password'] = $_POST['newpasswd'];
687 $check_password = $_POST['retypepasswd']; No newline at end of file
686 $check_password = $_POST['retypepasswd'];
688 No newline at end of file
687
689 $result = $user->getPasswd($iduser); No newline at end of file
688 $result = $user->getPasswd($iduser);
690 $data_model = $result->fetch(); No newline at end of file
689 $data_model = $result->fetch();
691 $db_old_passwd = $data_model[0]; No newline at end of file
690 $db_old_passwd = $data_model[0];
692 No newline at end of file
691
693 if($db_old_passwd == md5($oldpasswd)){ No newline at end of file
692 if($db_old_passwd == md5($oldpasswd)){
694 $user->setIdValue($iduser); No newline at end of file
693 $user->setIdValue($iduser);
695 $datos['password'] = md5($datos['password']); No newline at end of file
694 $datos['password'] = md5($datos['password']);
696 list($result, $message) = $user->UpdateItem($datos); No newline at end of file
695 list($result, $message) = $user->UpdateItem($datos);
697 } No newline at end of file
696 }
698 No newline at end of file
697
699 $url = 'index.php?controller=Users&action=editUser&user='.$iduser; No newline at end of file
698 $url = 'index.php?controller=Users&action=editUser&user='.$iduser;
700 No newline at end of file
699
701 header("location: ".$url); No newline at end of file
700 header("location: ".$url);
702 exit(); No newline at end of file
701 exit();
703 } No newline at end of file
702 }
704 } No newline at end of file
703 }
705 } catch (Exception $e){ No newline at end of file
704 } catch (Exception $e){
706 var_dump($e->getMessage()); No newline at end of file
705 var_dump($e->getMessage());
707 } No newline at end of file
706 }
708 } No newline at end of file
707 }
709 No newline at end of file
708
710 public function home(){ No newline at end of file
709 public function home(){
711 $data['content'] = "components".DS."com_users".DS."views".DS."home.php"; No newline at end of file
710 $data['content'] = "components".DS."com_users".DS."views".DS."home.php";
712 $data['title'] = "WELCOME:::::::::::"; No newline at end of file
711 $data['title'] = "WELCOME:::::::::::";
713 No newline at end of file
712
714 $this->view->show("template.php", $data); No newline at end of file
713 $this->view->show("template.php", $data);
715 } No newline at end of file
714 }
716 } No newline at end of file
715 }
717 No newline at end of file
716
718 ?> No newline at end of file
717 ?>
@@ -1,296 +1,276
1 <?php No newline at end of file
1 <?php
2 class UsersModel extends ModelBase{ No newline at end of file
2 class UsersModel extends ModelBase{
3 No newline at end of file
3
4 public $tableName = 'sis_user'; No newline at end of file
4 public $tableName = 'sis_user';
5 public $id = array('key'=>'iduser','value'=>''); No newline at end of file
5 public $id = array('key'=>'iduser','value'=>'');
6 No newline at end of file
6
7 public function addItem($datos){ No newline at end of file
7 public function addItem($datos){
8 $this->setFieldArray($datos); No newline at end of file
8 $this->setFieldArray($datos);
9 list($resultado,$id,$mensaje) = $this->insert(); No newline at end of file
9 list($resultado,$id,$mensaje) = $this->insert();
10 return array ($resultado,$id,$mensaje); No newline at end of file
10 return array ($resultado,$id,$mensaje);
11 } No newline at end of file
11 }
12 No newline at end of file
12
13 public function DeleteItem(){ No newline at end of file
13 public function DeleteItem(){
14 list($resultado,$mensaje) = $this->delete(); No newline at end of file
14 list($resultado,$mensaje) = $this->delete();
15 return array ($resultado,$mensaje); No newline at end of file
15 return array ($resultado,$mensaje);
16 } No newline at end of file
16 }
17 No newline at end of file
17
18 public function UpdateItem($datos){ No newline at end of file
18 public function UpdateItem($datos){
19 $this->setFieldArray($datos); No newline at end of file
19 $this->setFieldArray($datos);
20 list($resultado,$mensaje) = $this->update(); No newline at end of file
20 list($resultado,$mensaje) = $this->update();
21 return array ($resultado,$mensaje); No newline at end of file
21 return array ($resultado,$mensaje);
22 } No newline at end of file
22 }
23 No newline at end of file
23
24 public function dolist($datos = array("inicio" => 0, "tamanio" => 5)){ No newline at end of file
24 public function dolist($datos = array("inicio" => 0, "tamanio" => 5)){
25 $query = "SELECT * FROM sis_user WHERE usertype = 1"; No newline at end of file
25 $query = "SELECT * FROM sis_user WHERE usertype = 1";
26 $consulta = $this->db->prepare($query); No newline at end of file
26 $consulta = $this->db->prepare($query);
27 $consulta->execute(); No newline at end of file
27 $consulta->execute();
28 $num_filas = $consulta->rowCount(); No newline at end of file
28 $num_filas = $consulta->rowCount();
29 //getPager($datos = array("total" => 0, "inicio" => 0, "pagina" => 5)//uso de la variable arreglo. No newline at end of file
29 //getPager($datos = array("total" => 0, "inicio" => 0, "pagina" => 5)//uso de la variable arreglo.
30 $parametros = array("total" => $num_filas, "inicio" => $datos['inicio'], "pagina" => $datos['tamanio']); No newline at end of file
30 $parametros = array("total" => $num_filas, "inicio" => $datos['inicio'], "pagina" => $datos['tamanio']);
31 list($paginas,$navegador) = $this->getPager($parametros); No newline at end of file
31 list($paginas,$navegador) = $this->getPager($parametros);
32 No newline at end of file
32
33 //realizamos una consulta paginada No newline at end of file
33 //realizamos una consulta paginada
34 $consulta = $this->db->prepare($query.' LIMIT '.$datos['inicio'].' , '.$datos['tamanio'].' '); No newline at end of file
34 $consulta = $this->db->prepare($query.' LIMIT '.$datos['inicio'].' , '.$datos['tamanio'].' ');
35 $consulta->execute(); No newline at end of file
35 $consulta->execute();
36 No newline at end of file
36
37 return array($consulta,$paginas,$navegador); No newline at end of file
37 return array($consulta,$paginas,$navegador);
38 } No newline at end of file
38 }
39 No newline at end of file
39
40 public function validarUsuario($username,$password){ No newline at end of file
40 public function validarUsuario($username,$password){
41 $str_query = ' SELECT sis_user.* FROM sis_user WHERE username = "'.$username.'"' No newline at end of file
41 $str_query = ' SELECT sis_user.* FROM sis_user WHERE username = "'.$username.'"'
42 .' AND password = "'.md5($password).'" AND (state = "1" OR state = "4" OR state = "5") AND usertype = 1 '; No newline at end of file
42 .' AND password = "'.md5($password).'" AND (state = "1" OR state = "4" OR state = "5") AND usertype = 1 ';
43 $consulta = $this->db->prepare($str_query); No newline at end of file
43 $consulta = $this->db->prepare($str_query);
44 $consulta->execute(); No newline at end of file
44 $consulta->execute();
45 No newline at end of file
45
46 return $consulta; No newline at end of file
46 return $consulta;
47 } No newline at end of file
47 }
48 No newline at end of file
48
49 public function validarAdmin($username,$password){ No newline at end of file
49 public function validarAdmin($username,$password){
50 $str_query = 'SELECT * FROM sis_user WHERE username = "'.$username No newline at end of file
50 $str_query = 'SELECT * FROM sis_user WHERE username = "'.$username
51 .'" AND password = "'.md5($password).'" AND state = "1" AND usertype = 2 '; No newline at end of file
51 .'" AND password = "'.md5($password).'" AND state = "1" AND usertype = 2 ';
52 $consulta = $this->db->prepare($str_query); No newline at end of file
52 $consulta = $this->db->prepare($str_query);
53 $consulta->execute(); No newline at end of file
53 $consulta->execute();
54 No newline at end of file
54
55 return $consulta; No newline at end of file
55 return $consulta;
56 } No newline at end of file
56 }
57 No newline at end of file
57
58 public function validateUsers($username,$password){ No newline at end of file
58 public function validateUsers($username,$password){
59 $str_query = 'SELECT * FROM '.$this->tableName.' WHERE username = "'.$username No newline at end of file
59 $str_query = 'SELECT * FROM '.$this->tableName.' WHERE username = "'.$username
60 .'" AND password = "'.md5($password).'" AND usertype >= 1 '; No newline at end of file
60 .'" AND password = "'.md5($password).'" AND usertype >= 1 ';
61 $consulta = $this->db->prepare($str_query); No newline at end of file
61 $consulta = $this->db->prepare($str_query);
62 $consulta->execute(); No newline at end of file
62 $consulta->execute();
63 No newline at end of file
63
64 return $consulta; No newline at end of file
64 return $consulta;
65 } No newline at end of file
65 }
66 No newline at end of file
66
67 public function obtenerUsuarioxId($id){ No newline at end of file
67 public function obtenerUsuarioxId($id){
68 //realizamos la consulta de usuario por id No newline at end of file
68 //realizamos la consulta de usuario por id
69 $consulta = $this->db->prepare('SELECT sis_user.* FROM sis_user WHERE iduser = "'.$id.'" '); No newline at end of file
69 $consulta = $this->db->prepare('SELECT sis_user.* FROM sis_user WHERE iduser = "'.$id.'" ');
70 $consulta->execute(); No newline at end of file
70 $consulta->execute();
71 //devolvemos la coleccion para que la vista la presente. No newline at end of file
71 //devolvemos la coleccion para que la vista la presente.
72 return $consulta; No newline at end of file
72 return $consulta;
73 No newline at end of file
73
74 } No newline at end of file
74 }
75 No newline at end of file
75
76 public function obtenerUsuarioxUsername($username){ No newline at end of file
76 public function obtenerUsuarioxUsername($username){
77 $str_query = 'SELECT * FROM '.$this->tableName.' WHERE username = "'.$username.'" '; No newline at end of file
77 $str_query = 'SELECT * FROM '.$this->tableName.' WHERE username = "'.$username.'" ';
78 $consulta = $this->db->prepare($str_query); No newline at end of file
78 $consulta = $this->db->prepare($str_query);
79 $consulta->execute(); No newline at end of file
79 $consulta->execute();
80 return $consulta; No newline at end of file
80 return $consulta;
81 } No newline at end of file
81 }
82 No newline at end of file
82
83 public function obtenerUsuarioxUsernameMD5($username){ No newline at end of file
83 public function obtenerUsuarioxUsernameMD5($username){
84 //realizamos la consulta de usuario por id No newline at end of file
84 //realizamos la consulta de usuario por id
85 $consulta = $this->db->prepare('SELECT sis_user.* FROM sis_user WHERE MD5(sis_user.username) = "'.$username.'" '); No newline at end of file
85 $consulta = $this->db->prepare('SELECT sis_user.* FROM sis_user WHERE MD5(sis_user.username) = "'.$username.'" ');
86 $consulta->execute(); No newline at end of file
86 $consulta->execute();
87 //devolvemos la coleccion para que la vista la presente. No newline at end of file
87 //devolvemos la coleccion para que la vista la presente.
88 return $consulta; No newline at end of file
88 return $consulta;
89 } No newline at end of file
89 }
90 No newline at end of file
90
91 public function bloquearUsuario($iduser){ No newline at end of file
91 public function bloquearUsuario($iduser){
92 //realizamos la consulta de usuario por id No newline at end of file
92 //realizamos la consulta de usuario por id
93 $consulta = $this->db->prepare('UPDATE sis_user SET state = "2" WHERE iduser = '.$iduser.' '); No newline at end of file
93 $consulta = $this->db->prepare('UPDATE sis_user SET state = "2" WHERE iduser = '.$iduser.' ');
94 $consulta->execute(); No newline at end of file
94 $consulta->execute();
95 //devolvemos la coleccion para que la vista la presente. No newline at end of file
95 //devolvemos la coleccion para que la vista la presente.
96 return $consulta; No newline at end of file
96 return $consulta;
97 } No newline at end of file
97 }
98 No newline at end of file
98
99 public function setUserSession($datos){ No newline at end of file
99 public function setUserSession($datos){
100 //realizamos la consulta de usuario por id No newline at end of file
100 //realizamos la consulta de usuario por id
101 $consulta = $this->db->prepare(' INSERT INTO sis_session ( idsession , iduser , client_ip , date_session, date_last_activity, state ) VALUES ( "" , "'.$datos['iduser'].'", "'.$datos['client_ip'].'", "'.$datos['date_session'].'" , "'.$datos['date_last_activity'].'" , "'.$datos['state'].'" ) '); No newline at end of file
101 $consulta = $this->db->prepare(' INSERT INTO sis_session ( idsession , iduser , client_ip , date_session, date_last_activity, state ) VALUES ( "" , "'.$datos['iduser'].'", "'.$datos['client_ip'].'", "'.$datos['date_session'].'" , "'.$datos['date_last_activity'].'" , "'.$datos['state'].'" ) ');
102 $consulta->execute(); No newline at end of file
102 $consulta->execute();
103 //devolvemos la coleccion para que la vista la presente. No newline at end of file
103 //devolvemos la coleccion para que la vista la presente.
104 return $consulta; No newline at end of file
104 return $consulta;
105 } No newline at end of file
105 }
106 No newline at end of file
106
107 public function obtenerEstadoUsuario($username){ No newline at end of file
107 public function obtenerEstadoUsuario($username){
108 $str_query = 'SELECT * FROM '.$this->tableName.' WHERE username = "'.$username.'"'; No newline at end of file
108 $str_query = 'SELECT * FROM '.$this->tableName.' WHERE username = "'.$username.'"';
109 $consulta = $this->db->prepare($str_query); No newline at end of file
109 $consulta = $this->db->prepare($str_query);
110 $consulta->execute(); No newline at end of file
110 $consulta->execute();
111 No newline at end of file
111
112 $datauser = $consulta->fetch(); No newline at end of file
112 $datauser = $consulta->fetch();
113 $estado = ""; No newline at end of file
113 $estado = "";
114 No newline at end of file
114
115 if(isset($datauser['state'])){ No newline at end of file
115 if(isset($datauser['state'])){
116 switch($datauser['state']){ No newline at end of file
116 switch($datauser['state']){
117 case 1: No newline at end of file
117 case 1:
118 $state = "ACTIVE"; No newline at end of file
118 $state = "ACTIVE";
119 break; No newline at end of file
119 break;
120 case 2: No newline at end of file
120 case 2:
121 $state = "LOCKED"; No newline at end of file
121 $state = "LOCKED";
122 break; No newline at end of file
122 break;
123 case 3: No newline at end of file
123 case 3:
124 $state = "DELETED"; No newline at end of file
124 $state = "DELETED";
125 break; No newline at end of file
125 break;
126 case 4: No newline at end of file
126 case 4:
127 $state = "FLOGIN"; No newline at end of file
127 $state = "FLOGIN";
128 break; No newline at end of file
128 break;
129 case 5: No newline at end of file
129 case 5:
130 $state = "RESET"; No newline at end of file
130 $state = "RESET";
131 break; No newline at end of file
131 break;
132 } No newline at end of file
132 }
133 return $state; No newline at end of file
133 return $state;
134 }else{ No newline at end of file
134 }else{
135 return ''; No newline at end of file
135 return '';
136 } No newline at end of file
136 }
137 } No newline at end of file
137 }
138 No newline at end of file
138
139 public function registrarLogIngreso($id_usu){ No newline at end of file
139 public function registrarLogIngreso($id_usu){
140 $consulta = $this->db->prepare(' INSERT INTO log_login ( id_log , id_usu , fec_log ) VALUES ( "" , "'.$id_usu.'", "'.date("Ymd H:i:s", time()).'") '); No newline at end of file
140 $consulta = $this->db->prepare(' INSERT INTO log_login ( id_log , id_usu , fec_log ) VALUES ( "" , "'.$id_usu.'", "'.date("Ymd H:i:s", time()).'") ');
141 $consulta->execute(); No newline at end of file
141 $consulta->execute();
142 //devolvemos .... No newline at end of file
142 //devolvemos ....
143 return $consulta; No newline at end of file
143 return $consulta;
144 } No newline at end of file
144 }
145 No newline at end of file
145
146 public function obtenerListaUsuariosIngresos($where=""){ No newline at end of file
146 public function obtenerListaUsuariosIngresos($where=""){
147 //realizamos la consulta de todos los items No newline at end of file
147 //realizamos la consulta de todos los items
148 $consulta = $this->db->prepare('SELECT tb_usuarios.* , tb_roles.des_rol AS "rol", count(log_login.id_usu) as "ingresos", No newline at end of file
148 $consulta = $this->db->prepare('SELECT tb_usuarios.* , tb_roles.des_rol AS "rol", count(log_login.id_usu) as "ingresos",
149 max(log_login.fec_log) as "ultimo_ingreso" FROM tb_usuarios LEFT JOIN tb_roles ON tb_usuarios.id_rol = tb_roles.id_rol LEFT JOIN log_login ON tb_usuarios.id_usu = log_login.id_usu '.$where.' GROUP BY tb_usuarios.id_usu'); No newline at end of file
149 max(log_login.fec_log) as "ultimo_ingreso" FROM tb_usuarios LEFT JOIN tb_roles ON tb_usuarios.id_rol = tb_roles.id_rol LEFT JOIN log_login ON tb_usuarios.id_usu = log_login.id_usu '.$where.' GROUP BY tb_usuarios.id_usu');
150 $consulta->execute(); No newline at end of file
150 $consulta->execute();
151 //devolvemos la coleccion para que la vista la presente. No newline at end of file
151 //devolvemos la coleccion para que la vista la presente.
152 return $consulta; No newline at end of file
152 return $consulta;
153 } No newline at end of file
153 }
154 No newline at end of file
154
155 public function setNewPassword($iduser,$password){ No newline at end of file
155 public function setNewPassword($iduser,$password){
156 //realizamos la consulta de usuario por id No newline at end of file
156 //realizamos la consulta de usuario por id
157 $consulta = $this->db->prepare('UPDATE sis_user SET password = "'.md5($password).'" WHERE iduser = '.$iduser.' '); No newline at end of file
157 $consulta = $this->db->prepare('UPDATE sis_user SET password = "'.md5($password).'" WHERE iduser = '.$iduser.' ');
158 $consulta->execute(); No newline at end of file
158 $consulta->execute();
159 //devolvemos la coleccion para que la vista la presente. No newline at end of file
159 //devolvemos la coleccion para que la vista la presente.
160 return $consulta; No newline at end of file
160 return $consulta;
161 No newline at end of file
161
162 } No newline at end of file
162 }
163 No newline at end of file
163
164 public function setInactive($iduser){ No newline at end of file
164 public function setInactive($iduser){
165 //realizamos la consulta de usuario por id No newline at end of file
165 //realizamos la consulta de usuario por id
166 $consulta = $this->db->prepare('UPDATE sis_user SET state = "2" WHERE iduser = '.$iduser.' '); No newline at end of file
166 $consulta = $this->db->prepare('UPDATE sis_user SET state = "2" WHERE iduser = '.$iduser.' ');
167 $consulta->execute(); No newline at end of file
167 $consulta->execute();
168 //devolvemos la coleccion para que la vista la presente. No newline at end of file
168 //devolvemos la coleccion para que la vista la presente.
169 return $consulta; No newline at end of file
169 return $consulta;
170 No newline at end of file
170
171 } No newline at end of file
171 }
172 No newline at end of file
172
173 public function setActive($iduser){ No newline at end of file
173 public function setActive($iduser){
174 //realizamos la consulta de usuario por id No newline at end of file
174 //realizamos la consulta de usuario por id
175 $consulta = $this->db->prepare('UPDATE sis_user SET state = "1" WHERE iduser = '.$iduser.' '); No newline at end of file
175 $consulta = $this->db->prepare('UPDATE sis_user SET state = "1" WHERE iduser = '.$iduser.' ');
176 $consulta->execute(); No newline at end of file
176 $consulta->execute();
177 //devolvemos la coleccion para que la vista la presente. No newline at end of file
177 //devolvemos la coleccion para que la vista la presente.
178 return $consulta; No newline at end of file
178 return $consulta;
179 No newline at end of file
179
180 } No newline at end of file
180 }
181 No newline at end of file
181
182 public function getStringUsers(){ No newline at end of file
182 public function getStringUsers(){
183 //realizamos la consulta de todos los items No newline at end of file
183 //realizamos la consulta de todos los items
184 $query = $this->db->prepare('SELECT u.* FROM sis_user AS u '); No newline at end of file
184 $query = $this->db->prepare('SELECT u.* FROM sis_user AS u ');
185 $query->execute(); No newline at end of file
185 $query->execute();
186 //Se recibe el arreglo completo de usuarios. No newline at end of file
186 //Se recibe el arreglo completo de usuarios.
187 $arregloUsuarios = $query->fetchAll(); No newline at end of file
187 $arregloUsuarios = $query->fetchAll();
188 $j = count($arregloUsuarios); No newline at end of file
188 $j = count($arregloUsuarios);
189 $cadena = ''; No newline at end of file
189 $cadena = '';
190 for($i=0; $j>$i;$i++){ No newline at end of file
190 for($i=0; $j>$i;$i++){
191 $arregloUsuario = $arregloUsuarios[$i]; No newline at end of file
191 $arregloUsuario = $arregloUsuarios[$i];
192 if(($j-1) == $i){ No newline at end of file
192 if(($j-1) == $i){
193 $cadena .= $arregloUsuario['firstname'].' '.$arregloUsuario['lastname'].' [ '.$arregloUsuario['username'].' ]'; No newline at end of file
193 $cadena .= $arregloUsuario['firstname'].' '.$arregloUsuario['lastname'].' [ '.$arregloUsuario['username'].' ]';
194 }else{ No newline at end of file
194 }else{
195 $cadena .= $arregloUsuario['firstname'].' '.$arregloUsuario['lastname'].' [ '.$arregloUsuario['username'].' ] , '; No newline at end of file
195 $cadena .= $arregloUsuario['firstname'].' '.$arregloUsuario['lastname'].' [ '.$arregloUsuario['username'].' ] , ';
196 } No newline at end of file
196 }
197 No newline at end of file
197
198 } No newline at end of file
198 }
199 No newline at end of file
199
200 return $cadena; No newline at end of file
200 return $cadena;
201 } No newline at end of file
201 }
202 No newline at end of file
202
203 No newline at end of file
203 public function getStringUser($iduser){
204 No newline at end of file
204 //realizamos la consulta de todos los items
205 public function getStringUser($iduser){ No newline at end of file
205 $query = $this->db->prepare('SELECT u.* FROM sis_user AS u WHERE u.iduser = "'.$iduser.'" ');
206 //realizamos la consulta de todos los items No newline at end of file
206 $query->execute();
207 $query = $this->db->prepare('SELECT u.* FROM sis_user AS u WHERE u.iduser = "'.$iduser.'" '); No newline at end of file
207 //Se recibe el arreglo completo de usuarios.
208 $query->execute(); No newline at end of file
208 $datosUsuarios = $query->fetch();
209 //Se recibe el arreglo completo de usuarios. No newline at end of file
209 $cadena = '';
210 $datosUsuarios = $query->fetch(); No newline at end of file
210 $cadena .= $datosUsuarios['firstname'].' '.$datosUsuarios['lastname'].' [ '.$datosUsuarios['username'].' ]';
211 $cadena = ''; No newline at end of file
211 return $cadena;
212 $cadena .= $datosUsuarios['firstname'].' '.$datosUsuarios['lastname'].' [ '.$datosUsuarios['username'].' ]'; No newline at end of file
212 }
213 return $cadena; No newline at end of file
213
214 } No newline at end of file
214 public function obtenerListaRoles(){
215 No newline at end of file
215 //realizamos la consulta de todos los items
216 public function obtenerListaRoles(){ No newline at end of file
216 $consulta = $this->db->prepare('SELECT tb_roles.* FROM tb_roles ');
217 //realizamos la consulta de todos los items No newline at end of file
217 $consulta->execute();
218 $consulta = $this->db->prepare('SELECT tb_roles.* FROM tb_roles '); No newline at end of file
218 //devolvemos la coleccion para que la vista la presente.
219 $consulta->execute(); No newline at end of file
219 return $consulta;
220 //devolvemos la coleccion para que la vista la presente. No newline at end of file
220 }
221 return $consulta; No newline at end of file
221
222 } No newline at end of file
222 public function getUsers($datos = array("inicio" => 0, "tamanio" => 5)){
223 No newline at end of file
223 //realizamos la consulta de todos los items
224 public function getUsers($datos = array("inicio" => 0, "tamanio" => 5)){ No newline at end of file
224 $query = "SELECT * FROM sis_user WHERE usertype = 1";
225 //realizamos la consulta de todos los items No newline at end of file
225 $consulta = $this->db->prepare($query);
226 $query = "SELECT * FROM sis_user WHERE usertype = 1"; No newline at end of file
226 $consulta->execute();
227 $consulta = $this->db->prepare($query); No newline at end of file
227 $num_filas = $consulta->rowCount();
228 $consulta->execute(); No newline at end of file
228 //getPager($datos = array("total" => 0, "inicio" => 0, "pagina" => 5)//uso de la variable arreglo.
229 $num_filas = $consulta->rowCount(); No newline at end of file
229 $parametros = array("total" => $num_filas, "inicio" => $datos['inicio'], "pagina" => $datos['tamanio']);
230 //getPager($datos = array("total" => 0, "inicio" => 0, "pagina" => 5)//uso de la variable arreglo. No newline at end of file
230 list($paginas,$navegador) = $this->getPager($parametros);
231 $parametros = array("total" => $num_filas, "inicio" => $datos['inicio'], "pagina" => $datos['tamanio']); No newline at end of file
231
232 list($paginas,$navegador) = $this->getPager($parametros); No newline at end of file
232
233 No newline at end of file
233 //realizamos una consulta paginada
234 No newline at end of file
234 $consulta = $this->db->prepare($query.' LIMIT '.$datos['inicio'].' , '.$datos['tamanio'].' ');
235 //realizamos una consulta paginada No newline at end of file
235 $consulta->execute();
236 $consulta = $this->db->prepare($query.' LIMIT '.$datos['inicio'].' , '.$datos['tamanio'].' '); No newline at end of file
236
237 $consulta->execute(); No newline at end of file
237 //devolvemos la coleccion para que la vista la presente.
238 No newline at end of file
238 return array($consulta,$paginas,$navegador);
239 //devolvemos la coleccion para que la vista la presente. No newline at end of file
239 }
240 return array($consulta,$paginas,$navegador); No newline at end of file
240
241 } No newline at end of file
241 function editUser($user){
242
242 $query = "SELECT * FROM sis_user WHERE iduser = '$user'";
No newline at end of file
243 function addUser($username, $password, $data_user){
No newline at end of file
244 $query = "INSERT INTO sis_user( username, password, date_create, firstname, lastname, email,"
No newline at end of file
245 ." photo, usertype, state ) VALUES ( '$username' , md5('$password'), '".date("Y-m-d H:i:s")."',"
No newline at end of file
246 ." '".$data_user['firstname']."', '".$data_user['lastname']."', '".$data_user['email']."',"
No newline at end of file
247 ." '".$data_user['urlphoto']."', 1, 4)";
No newline at end of file
248 $result = $this->db->prepare($query);
No newline at end of file
249 $result->execute();
No newline at end of file
250 return $result;
No newline at end of file
251 }
No newline at end of file
252 No newline at end of file
253 function editUser($user){ No newline at end of file
243 $result = $this->db->prepare($query);
254 $query = "SELECT * FROM sis_user WHERE iduser = '$user'"; No newline at end of file
244 $result->execute();
255 $result = $this->db->prepare($query); No newline at end of file
245 return $result;
256 $result->execute(); No newline at end of file
246 }
257 return $result; No newline at end of file
247
258 } No newline at end of file
248 function delUser($user){
259
249 $query = "UPDATE sis_user SET state = 3 WHERE iduser = $user";
No newline at end of file
260 function updateUser($user, $firstname, $lastname, $state){
No newline at end of file
261 $query = "UPDATE sis_user SET firstname = '$firstname', lastname = '$lastname'"
No newline at end of file
262 .", state = $state WHERE iduser = $user";
No newline at end of file
263 $result = $this->db->prepare($query);
No newline at end of file
264 $result->execute();
No newline at end of file
265 return $result;
No newline at end of file
266 }
No newline at end of file
267 No newline at end of file
268 function delUser($user){ No newline at end of file
250 $result = $this->db->prepare($query);
269 $query = "UPDATE sis_user SET state = 3 WHERE iduser = $user"; No newline at end of file
251 $result->execute();
270 $result = $this->db->prepare($query); No newline at end of file
252 return $result;
271 $result->execute(); No newline at end of file
253 }
272 return $result; No newline at end of file
254
273 } No newline at end of file
255 function searchUserbyUName($username){
274 No newline at end of file
256 $query = "SELECT * FROM sis_user WHERE username = '$username'";
275 function searchUserbyUName($username){ No newline at end of file
257 $result = $this->db->prepare($query);
276 $query = "SELECT * FROM sis_user WHERE username = '$username'"; No newline at end of file
258 $result->execute();
277 $result = $this->db->prepare($query); No newline at end of file
259 return $result;
278 $result->execute(); No newline at end of file
260 }
279 return $result; No newline at end of file
261
280 } No newline at end of file
262 public function getPasswd($iduser){
281 No newline at end of file
263 $query = "SELECT password FROM sis_user WHERE iduser = $iduser";
282 public function getPasswd($iduser){ No newline at end of file
264 $result = $this->db->prepare($query);
283 $query = "SELECT password FROM sis_user WHERE iduser = $iduser"; No newline at end of file
265 $result->execute();
284 $result = $this->db->prepare($query); No newline at end of file
266 return $result;
285 $result->execute(); No newline at end of file
267 }
286 return $result; No newline at end of file
268
287 } No newline at end of file
269 public function getAllUsers(){
288 No newline at end of file
270 $str_query = "SELECT * FROM ".$this->tableName." WHERE usertype = 1";
289 public function getAllUsers(){
271 $this->setQuery($str_query);
No newline at end of file
272 $query = $this->loadObjectList();
290 $query = "SELECT username FROM sis_user WHERE usertype = 1";
No newline at end of file
No newline at end of file
273 return $query;
291 $result = $this->db->prepare($query);
No newline at end of file
No newline at end of file
274 }
292 $result->execute();
No newline at end of file
No newline at end of file
275 } No newline at end of file
293 return $result; No newline at end of file
294 } No newline at end of file
276 ?>
295 } No newline at end of file
277
296 ?> No newline at end of file
278 L278: rhodecode diff rendering error
@@ -1,123 +1,123
1 <?php
1 <?php
No newline at end of file
2 $html_select_pag = '<select onchange="window.location='.chr(39).'index.php?option=com_users&controller=Users&action=dolist&inicio='.chr(39).'+this.value">'; No newline at end of file
2 $html_select_pag = '<select onchange="window.location='.chr(39).'index.php?option=com_users&controller=Users&action=getUsers&inicio='.chr(39).'+this.value">'; No newline at end of file
3 No newline at end of file
3
4 $j = count($paginas); No newline at end of file
4 $j = count($paginas);
5 for($i=0;$i<$j;$i++){ No newline at end of file
5 for($i=0;$i<$j;$i++){
6 $html_select_pag .= "<option value='".$paginas[$i]."'"; No newline at end of file
6 $html_select_pag .= "<option value='".$paginas[$i]."'";
7 if($inicio == $paginas[$i]){ No newline at end of file
7 if($inicio == $paginas[$i]){
8 $html_select_pag .= "selected='selected'"; No newline at end of file
8 $html_select_pag .= "selected='selected'";
9 } No newline at end of file
9 }
10 $html_select_pag .= ">"; No newline at end of file
10 $html_select_pag .= ">";
11 $html_select_pag .= "".($i+1)."/".$j."</option>"; No newline at end of file
11 $html_select_pag .= "".($i+1)."/".$j."</option>";
12 } No newline at end of file
12 }
13 $html_select_pag .= "</select>"; No newline at end of file
13 $html_select_pag .= "</select>";
14 No newline at end of file
14
15 $html_pagination = '<ul class="mnu_pagination">';
15 $html_pagination = '<ul class="mnu_pagination">';
No newline at end of file
16 $html_pagination .= '<li><a href="index.php?option=com_users&controller=Users&action=dolist&inicio='.$navegador["fin"].'">'; No newline at end of file
16 $html_pagination .= '<li><a href="index.php?option=com_users&controller=Users&action=getUsers&inicio='.$navegador["fin"].'">'; No newline at end of file
17 $html_pagination .= "Last</a></li>";
17 $html_pagination .= "Last</a></li>";
No newline at end of file
18 $html_pagination .= '<li><a href="index.php?option=com_users&controller=Users&action=dolist&inicio='.$navegador["siguiente"].'">'; No newline at end of file
18 $html_pagination .= '<li><a href="index.php?option=com_users&controller=Users&action=getUsers&inicio='.$navegador["siguiente"].'">'; No newline at end of file
19 $html_pagination .= "Next</a></li>"; No newline at end of file
19 $html_pagination .= "Next</a></li>";
20 $html_pagination .= '<li class="pages">Page'.$html_select_pag.'</li>';
20 $html_pagination .= '<li class="pages">Page'.$html_select_pag.'</li>';
No newline at end of file
21 $html_pagination .= '<li><a href="index.php?option=com_users&controller=Users&action=dolist&inicio='.$navegador["anterior"].'">'; No newline at end of file
21 $html_pagination .= '<li><a href="index.php?option=com_users&controller=Users&action=getUsers&inicio='.$navegador["anterior"].'">'; No newline at end of file
22 $html_pagination .= "Prev</a></li>";
22 $html_pagination .= "Prev</a></li>";
No newline at end of file
23 $html_pagination .= '<li><a href="index.php?option=com_users&controller=Users&action=dolist&inicio='.$navegador["inicio"].'">'; No newline at end of file
23 $html_pagination .= '<li><a href="index.php?option=com_users&controller=Users&action=getUsers&inicio='.$navegador["inicio"].'">'; No newline at end of file
24 $html_pagination .= "Start</a></li>"; No newline at end of file
24 $html_pagination .= "Start</a></li>";
25 $html_pagination .= '</ul><div style="clear:both"></div>'; No newline at end of file
25 $html_pagination .= '</ul><div style="clear:both"></div>';
26 ?> No newline at end of file
26 ?>
27 <script type="text/javascript"> No newline at end of file
27 <script type="text/javascript">
28 $().ready(function() { No newline at end of file
28 $().ready(function() {
29 $(".btn_delUser").click(function(){ No newline at end of file
29 $(".btn_delUser").click(function(){
30 var _id = $(this).attr("alt"); No newline at end of file
30 var _id = $(this).attr("alt");
31 if(confirm("Are you sure to delete this user?")){ No newline at end of file
31 if(confirm("Are you sure to delete this user?")){
32 window.location = "index.php?option=com_users&controller=Users&action=remove&user="+_id; No newline at end of file
32 window.location = "index.php?option=com_users&controller=Users&action=remove&user="+_id;
33 } No newline at end of file
33 }
34 }); No newline at end of file
34 });
35 }); No newline at end of file
35 });
36 </script> No newline at end of file
36 </script>
37 <span class="etiqueta">Users</span> No newline at end of file
37 <span class="etiqueta">Users</span>
38 <div id="div_info_user"> No newline at end of file
38 <div id="div_info_user">
39 <div class="toolbar_right"> No newline at end of file
39 <div class="toolbar_right">
40 <ul> No newline at end of file
40 <ul>
41 <li><a href="index.php?option=com_users&controller=Users&action=newUser">Delete</a></li> No newline at end of file
41 <li><a href="index.php?option=com_users&controller=Users&action=newUser">Delete</a></li>
42 <li><a href="index.php?option=com_users&controller=Users&action=newUser">Add</a></li> No newline at end of file
42 <li><a href="index.php?option=com_users&controller=Users&action=newUser">Add</a></li>
43 </ul> No newline at end of file
43 </ul>
44 </div> No newline at end of file
44 </div>
45 <div style="clear:both; overflow: hidden"></div> No newline at end of file
45 <div style="clear:both; overflow: hidden"></div>
46 <div class="div_pagination_right"> No newline at end of file
46 <div class="div_pagination_right">
47 <?php echo $html_pagination; ?> No newline at end of file
47 <?php echo $html_pagination; ?>
48 </div> No newline at end of file
48 </div>
49 <div style="clear:both; overflow: hidden"></div> No newline at end of file
49 <div style="clear:both; overflow: hidden"></div>
50 <div id="content_user" class="content_list"> No newline at end of file
50 <div id="content_user" class="content_list">
51 <table width="100%" cellpadding="0" cellspacing="0"> No newline at end of file
51 <table width="100%" cellpadding="0" cellspacing="0">
52 <thead> No newline at end of file
52 <thead>
53 <tr> No newline at end of file
53 <tr>
54 <th align="center" width="5%">N&deg;</th> No newline at end of file
54 <th align="center" width="5%">N&deg;</th>
55 <th align="center" width="10%" colspan="2"></th> No newline at end of file
55 <th align="center" width="10%" colspan="2"></th>
56 <th align="center">Username</th> No newline at end of file
56 <th align="center">Username</th>
57 <th align="center">Lastname</th> No newline at end of file
57 <th align="center">Lastname</th>
58 <th align="center">Firstname</th> No newline at end of file
58 <th align="center">Firstname</th>
59 <th align="center">State</th> No newline at end of file
59 <th align="center">State</th>
60 </tr> No newline at end of file
60 </tr>
61 </thead> No newline at end of file
61 </thead>
62 <tbody> No newline at end of file
62 <tbody>
63 <?php No newline at end of file
63 <?php
64 $numeracion = 1; No newline at end of file
64 $numeracion = 1;
65 No newline at end of file
65
66 $num_rows = $listUsers->rowCount(); No newline at end of file
66 $num_rows = $listUsers->rowCount();
67 //echo SYS_IMAGES.DS.'system'.DS.'b_edit.png'; No newline at end of file
67 //echo SYS_IMAGES.DS.'system'.DS.'b_edit.png';
68 if($num_rows > 0){ No newline at end of file
68 if($num_rows > 0){
69 while($datos_usuario = $listUsers->fetch()){ No newline at end of file
69 while($datos_usuario = $listUsers->fetch()){
70 ?> No newline at end of file
70 ?>
71 <tr> No newline at end of file
71 <tr>
72 <td align="center" width="5%"><?php echo ($numeracion+$inicio); ?></td> No newline at end of file
72 <td align="center" width="5%"><?php echo ($numeracion+$inicio); ?></td>
73 <td width="5%" align="center"> No newline at end of file
73 <td width="5%" align="center">
74 <a href="index.php?option=com_users&controller=Users&action=editUser&user=<?php echo $datos_usuario['iduser']; ?>"> No newline at end of file
74 <a href="index.php?option=com_users&controller=Users&action=editUser&user=<?php echo $datos_usuario['iduser']; ?>">
75 <img src="../images/system/b_edit.png" alt="Edit" style="border: 0" /> No newline at end of file
75 <img src="../images/system/b_edit.png" alt="Edit" style="border: 0" />
76 </a> No newline at end of file
76 </a>
77 </td> No newline at end of file
77 </td>
78 <td width="5%" align="center"> No newline at end of file
78 <td width="5%" align="center">
79 <a href="#" class="btn_delUser" alt="<?php echo $datos_usuario['iduser']; ?>"> No newline at end of file
79 <a href="#" class="btn_delUser" alt="<?php echo $datos_usuario['iduser']; ?>">
80 <img src="../images/system/b_drop.png" alt="Delete" style="border: 0" /> No newline at end of file
80 <img src="../images/system/b_drop.png" alt="Delete" style="border: 0" />
81 </a> No newline at end of file
81 </a>
82 </td> No newline at end of file
82 </td>
83 <td align="center"> No newline at end of file
83 <td align="center">
84 <a href="index.php?option=com_users&controller=Users&action=view&user=<?php echo $datos_usuario['iduser']; ?>"> No newline at end of file
84 <a href="index.php?option=com_users&controller=Users&action=view&user=<?php echo $datos_usuario['iduser']; ?>">
85 <?php echo $datos_usuario['username']; ?> No newline at end of file
85 <?php echo $datos_usuario['username']; ?>
86 </a> No newline at end of file
86 </a>
87 </td> No newline at end of file
87 </td>
88 <td align="center"><?php echo $datos_usuario['lastname']; ?></td> No newline at end of file
88 <td align="center"><?php echo $datos_usuario['lastname']; ?></td>
89 <td align="center"><?php echo $datos_usuario['firstname']; ?></td> No newline at end of file
89 <td align="center"><?php echo $datos_usuario['firstname']; ?></td>
90 <td align="center"> No newline at end of file
90 <td align="center">
91 <?php if($datos_usuario['state'] == 1){ ?>
91 <?php if($datos_usuario['state'] == 1){ ?>
No newline at end of file
92 <img src="images/system/tick.png" alt="Active" border="0" /> No newline at end of file
92 <img src="../imagenes/usractive.jpeg" alt="Active" border="0" /> No newline at end of file
93 <?php } ?> No newline at end of file
93 <?php } ?>
94 <?php if($datos_usuario['state'] == 2){ ?> No newline at end of file
94 <?php if($datos_usuario['state'] == 2){ ?>
95 <img src="../imagenes/b_locked.png" alt="Locked" border="0" /> No newline at end of file
95 <img src="../imagenes/b_locked.png" alt="Locked" border="0" />
96 <?php } ?> No newline at end of file
96 <?php } ?>
97 <?php No newline at end of file
97 <?php
98 switch($datos_usuario['state']){ No newline at end of file
98 switch($datos_usuario['state']){
99 case 3: echo 'Deleted'; No newline at end of file
99 case 3: echo 'Deleted';
100 break; No newline at end of file
100 break;
101 case 4: echo 'First Login'; No newline at end of file
101 case 4: echo 'First Login';
102 break; No newline at end of file
102 break;
103 case 5: echo 'Reset'; No newline at end of file
103 case 5: echo 'Reset';
104 break; No newline at end of file
104 break;
105 } No newline at end of file
105 }
106 ?> No newline at end of file
106 ?>
107 </td> No newline at end of file
107 </td>
108 </tr> No newline at end of file
108 </tr>
109 <?php No newline at end of file
109 <?php
110 $numeracion ++; No newline at end of file
110 $numeracion ++;
111 } No newline at end of file
111 }
112 } else { No newline at end of file
112 } else {
113 ?> No newline at end of file
113 ?>
114 <tr><td colspan="7" align="center">Users not found.</td></tr> No newline at end of file
114 <tr><td colspan="7" align="center">Users not found.</td></tr>
115 <?php } ?> No newline at end of file
115 <?php } ?>
116 </tbody> No newline at end of file
116 </tbody>
117 </table> No newline at end of file
117 </table>
118 </div> No newline at end of file
118 </div>
119 <div class="div_pagination_right"> No newline at end of file
119 <div class="div_pagination_right">
120 <?php echo $html_pagination; ?> No newline at end of file
120 <?php echo $html_pagination; ?>
121 </div> No newline at end of file
121 </div>
122 <div style="clear:both; overflow: hidden"></div> No newline at end of file
122 <div style="clear:both; overflow: hidden"></div>
123 </div> No newline at end of file
123 </div>
General Comments 0
You need to be logged in to leave comments. Login now