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