public function sign() { $errors = array(); $VLog = new VLog(); $data = $VLog->getSignData(); if ($data) { $bool = true; foreach ($data as $elem) { if ($elem == "" && $bool) { $errors[] = 1; $bool = false; } } if ($data['password'] != $data['r_password']) { $errors[] = 2; $bool = false; } if ($bool) { $n = ucfirst($data['name']); $s = ucfirst($data['surname']); $SSN = strtoupper($data['ssn']); $p = $data['phone']; $m = strtolower($data['mail']); $pass = $data['password']; try { $b = new DateTime($data['birth']); $now = new DateTime(); $diff = $now->diff($b); if (intval($diff->format('%Y')) < 18) { $errors[] = 6; $bool = false; } else { $new_user = new DUser($n, $s, $SSN, $p, $m, $b, $pass); } } catch (Exception $e) { $errors[] = 3; $bool = false; } } } else { $errors[] = 1; } $n_errors = count($errors); if ($n_errors == 0) { $FUser = new FUser(); $hypS = $FUser->is_a_user($SSN); //controlla se c'è già un utente con quel codice fiscale if ($hypS) { $errors[] = 4; $bool = false; } $hypM = $FUser->mail_in($m); if ($hypM) { $errors[] = 7; $bool = false; } if (!$hypS && !$hypM) { try { global $config; $Mailer = new UEmail(); $VMail = new VMail(); $VMail->setLayout("confirmation"); $VMail->setDest("{$n} {$s}"); $VMail->setCode($new_user->getCode()); $message = $VMail->processTemplate(); if ($Mailer->send_mail($m, $n, $config['name'] . " confirmation mail", $message, true)) { $FUser->saveUser($new_user); //salva il nuovo utente (o aggiorna i campi nelle tabella person per un cliente ancora non utente) } else { $errors[] = 5; $bool = false; } } catch (Exception $e) { $errors[] = 5; $bool = false; } } } if ($bool) { return $this->show('sign_outcome', false); } else { return $this->show('sign_outcome', $errors); } }
public function smista($paramEmail) { $vutente = USingleton::getInstances('VUtente'); switch ($vutente->getTask()) { case 'login': return $vutente->processaTemplateUtente('login'); break; case 'autentica': $flag = $this->richiestaLogin(); return $this->esitoLogin($flag); break; case 'registrazione': return $vutente->processaTemplateUtente('registrazione'); break; case 'registra': $flag = $this->richiestaRegistrazione(); return $this->esitoRegistrazione($flag); case 'attivazione': $flag = $this->richiestaAttivazione($paramEmail); return $this->esitoAttivazione($flag); case 'attiva': $flag = $this->attiva($vutente->getEmailGET(), $vutente->getRequestCode()); return $this->esitoAttiva($flag); case 'attiva_admin_interface': $flag = $this->attivaUtente($vutente->getEmail()); return $this->esitoAttivaUtente($flag); case 'recuperapsw': return $vutente->processaTemplateUtente('recuperapsw'); break; case 'redirectpsw': // devo controllare se è nel db: $flag = $this->richiestaRecupero(); return $this->esitoRecupero($flag); break; case 'changepsw': // controllo se il codice corrisponde a quello inviato via email $flag = $this->richiestaCambioPsw($vutente->getEmailGET(), $vutente->getRequestCode()); return $this->esitoRichiestaCambioPsw($flag); break; case 'submit_new_psw': // inserisco la nuova psw nel DB e nel caso faccio la redirect $flag = $this->updateUserPsw($vutente->getEmailGET(), $vutente->getNewPassword()); return $this->esitoUpdatePsw($flag); break; case 'area_utente': return $this->riempiTemplateUtente(); break; case 'area_amministratore': return $vutente->processaTemplateUtente('area_amministratore'); break; case 'lista_utenti': return $vutente->impostaTemplateLista(); break; case 'logout': $this->proceduraLogout(); return $vutente->setRedirectText('Logout effettuato, stai per essere reindirizzato alla home...'); break; case 'invia_mail_di_prova': UEmail::sendMail('*****@*****.**', 'mattia', 'beta test subject', 'testo della email di prova'); return $vutente->processaTemplateUtente('redirect'); case 'modifica_utente': // devo tornare al pannello d'amministrazione break; case 'cancella': $flag = $this->richiestaRimuovi($vutente->getEmail()); return $this->esitoRimuovi($flag); // devo tornare al pannello d'amministrazione break; } }