public function procede() { try { if ($this->oRequest->existParam('login')) { //Connection à la base de donnée $oMysqli = new mysqli($_SESSION['hostname'], $_SESSION['username'], $_SESSION['password'], $_SESSION['name']); if ($oMysqli->connect_error) { throw new Error('Impossible de se connecter à la base de donnée.', 4033); } $oMysqli->set_charset("utf8"); //Création de l'utilisateur if (!$this->oRequest->existParam('password')) { throw new Error('Vous devez renseigner un password.', 4033); } if (!$this->oRequest->existParam('email')) { throw new Error('Vous devez renseigner une adresse email.', 4033); } $sPassword = $this->oRequest->getParam('password', 'string'); $sConfirmation = $this->oRequest->getParam('confirmation', 'string'); if ($sPassword != $sConfirmation) { throw new Error("Le password et la confirmation ne correspondent pas.", 4033); } $sPassword = User::cryptPassword($sPassword); $oResult = $oMysqli->query("INSERT INTO `tks_users` (`id` ,`login` ,`pass` ,`mail` ,`passkey` ,`id_rank`)\r\n VALUES ('',\r\n '" . $this->oRequest->getParam('login', 'string') . "',\r\n '{$sPassword}',\r\n '" . $this->oRequest->getParam('email', 'string') . "', \r\n '" . md5($sPassword * rand()) . "',\r\n '1'); "); if ($oResult == false) { throw new Error('Impossible de créer l\'utilisateur.', 4034); } $this->oView->addAlert('Utilisateur créé. <b><a href="install.php?step=4">Poursuivre</a></b>', 'success'); } } catch (Exception $ex) { $this->oView->addAlert($ex, 'danger'); } finally { $this->oView->addData('titre', 'Etape 3 : Création du premier utilisateur'); //Création du formulaire $oForm = new FormGenerator(); $oForm->setAction('install.php?step=3'); $oForm->addInput('Identifiant', 'login', true, false, 'text', 'Username'); $oForm->addInput('Password', 'password', true, false, 'password', 'Password'); $oForm->addInput('Confirmation', 'confirmation', true, false, 'password', 'Password'); $oForm->addInput('Email', 'email', true, false, 'mail', '*****@*****.**'); $oForm->create(); $this->oView->addData('content', $oForm->getCode()); $this->oView->create(); } }
public function procede() { try { if ($this->oRequest->existParam('code')) { if (!$this->oRequest->existParam('password')) { throw new Error('Vous devez renseigner un password.', 1043); } if (!$this->oRequest->existParam('email')) { throw new Error('Vous devez renseigner une adresse email.', 1043); } if (!$this->oRequest->existParam('login')) { throw new Error('Vous devez renseigner un nom d\'utilisateur.', 1043); } $oInvite = new Invites(0, $this->oRequest->getParam('code', 'string')); if (!$oInvite->checkInvite()) { throw new Error('Votre code d\'invitation n\'est pas valide.', 1043); } $sPassword = $this->oRequest->getParam('password', 'string'); $sConfirmation = $this->oRequest->getParam('confirmation', 'string'); if ($sPassword != $sConfirmation) { throw new Error("Le password et la confirmation ne correspondent pas.", 1043); } $sPassword = User::cryptPassword($sPassword); $oUser = new User(0, $this->oRequest->getParam('login', 'string'), $sPassword, $this->oRequest->getParam('email', 'string'), md5(time() * rand())); $oUser->store(); //On demande au modèle de vérifier l'identification $this->oCurrentUser->loadFromFormular($this->oRequest->getParam('login', 'string'), $this->oRequest->getParam('password', 'string'), false); $oInvite->usedBy($this->oCurrentUser->getId()); Logger::log('admin', $this->oCurrentUser->getLogin() . ' a rejoint le site avec le code : ' . $this->oRequest->getParam('code', 'string')); $this->oView->addAlert("Redirection en cours ...", 'success'); header("Location: http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/index.php"); } } catch (Error $e) { $this->oView->addAlert($e, 'danger'); } finally { $this->oView->Create(); } }
/** * Vérifie et crypte le password au besoin * @return string Password Crypté * @throws Error */ private function checkPassword() { if ($this->oRequest->existParam('password')) { $sPassword = $this->oRequest->getParam('password', 'string'); $sConfirmation = $this->oRequest->getParam('confirmation', 'string'); if ($sPassword != $sConfirmation) { throw new Error("Le password et la confirmation ne correspondent pas.", 1053); } $sPassword = User::cryptPassword($sPassword); } else { $sPassword = ''; } return $sPassword; }
private function resetPassword() { $oMysqli = Database::getInstance(); $oResults = $oMysqli->query("SELECT * FROM tks_users WHERE id = '" . $this->oRequest->getParam('userid', 'int') . "'"); if ($oResults->num_rows == 0) { throw new Error("Aucun compte ne correspond.", 1083); } $aResult = $oResults->fetch_assoc(); if (crypt($aResult['mail'], $this->oRequest->getParam('key', 'string')) != $this->oRequest->getParam('key', 'string')) { throw new Error("Clé incorrecte.", 1083); } $sPassword = User::createPassword(12); $sCrypted = User::cryptPassword($sPassword); $oResults = $oMysqli->query("UPDATE tks_users SET pass = '******' WHERE id = '" . $aResult['id'] . "'"); $sMsg = "Bonjour " . $aResult['login'] . ",\n\nVoici votre nouveau mot de passe sur " . Config::get('sitetitle') . "\n\nMot de passe : \n{$sPassword}\n\n A bientôt,\nLe staff"; mail($aResult['mail'], "[" . Config::get('sitetitle') . "] Nouveau mot de passe", $sMsg); $this->oView->addAlert("Le nouveau mot de passe a été envoyé par email ...", 'success'); }
function profil_plugin_actions() { global $myUser, $_, $conf; switch ($_['action']) { case 'dash_profi_plugin_edit': echo 'L\'edition de ce bloc est disponible depuis <a href="setting.php?section=profil">la page d\'edition du profil</a>'; break; case 'dash_profil_plugin_load': header('content-type:application/json'); $response['title'] = 'Connecté'; $url_link = Functions::getBaseUrl('action.php') . '/action.php'; $response['content'] = '<div id="dash_application">' . $myUser->getGravatarImg() . ' <ul class="user-infos"> <li><h1 onclick="window.location=\'setting.php?section=profil\';"><i class="fa fa-pencil"></i>' . $myUser->getFullName() . '</h1></li> <li><a href="mailto:' . $myUser->getMail() . '">' . $myUser->getMail() . '</a></li> <li><div class="tokenbox" title="' . $myUser->getToken() . '">Token : <input type="text" onclick="$(this).select();" value="' . $myUser->getToken() . '"></div></li> </ul> <a href="#yanaWindowsModal" role="button" data-toggle="modal" class="btn btn-primary"><i class="fa fa-download-alt fa fa-white"></i> Installer YANA Windows</a></div> <!-- Modal --> <div id="yanaWindowsModal" class="modal hide fade" style="width:750px;margin-left:-375px;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3 id="myModalLabel">Installer/Lier à yana windows</h3> </div> <div class="modal-body" > <p>Pour avoir accès à la partie vocale, vous devez installer yana-windows. Pour cela suivez les inscructions ci dessous.</p> <ul> <li>Si ce n\'est pas déja fait <a href="https://github.com/ldleman/yana-windows/archive/master.zip">téléchargez Yana Windows</a> et décompressez le.</li> <li>Exécutez le programme <b>"ScanSoft Virginie_Dri40_16kHz.exe"</b> pour installez la voix de yana</li> <li>Lancez le programme <b>"yana.exe"</b>, puis faites un clic droit sur l\'îcone de yana situé dans la barre de tâche et cliquez sur \'Configuration\' <li>Configurez \'Adresse du serveur\' avec la valeur suivante : <code>' . $url_link . '</code></li> <li>Dans le champs suivant, entrez le \'Token\' d\'identification suivant : <code>' . $myUser->getToken() . '</code></li> <li>Cliquez sur enregistrer, le programme se relance et l\'installation est terminée !!</li> </ul> </div> <div class="modal-footer"> <button class="btn" data-dismiss="modal" aria-hidden="true">Fermer</button> </div> </div> '; echo json_encode($response); break; case 'profile_set_profile': $myUser->setFirstName($_['firstname']); $myUser->setName($_['name']); $myUser->setLogin($_['login']); $myUser->setMail($_['mail']); $fields = array('mail' => $myUser->getMail(), 'login' => $myUser->getLogin(), 'firstname' => $myUser->getFirstName(), 'name' => $myUser->getName()); if (trim($_['password']) != '') { $fields['password'] = User::cryptPassword($_['password']); } $userManager = new User(); $userManager->change($fields, array('id' => $myUser->getId())); $_SESSION['currentUser'] = serialize($myUser); header('location: setting.php?section=profil'); break; } }
function setPassword($password) { $this->password = User::cryptPassword($password); }