Installation + création user

This commit is contained in:
Fred Tempez 2020-09-09 17:21:02 +02:00
parent f84613561e
commit 9c5642b9b0
2 changed files with 38 additions and 34 deletions

76
core/module/install/install.php Normal file → Executable file
View File

@ -41,17 +41,51 @@ class install extends common {
else {
// Soumission du formulaire
if($this->isPost()) {
//$sent = $success = false;
$success = true;
// Double vérification pour le mot de passe
if($this->getInput('installPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('installConfirmPassword', helper::FILTER_STRING_SHORT, true)) {
self::$inputNotices['installConfirmPassword'] = 'Incorrect';
$success = false;
}
// Crée l'utilisateur
// Utilisateur
$userFirstname = $this->getInput('installFirstname', helper::FILTER_STRING_SHORT, true);
$userLastname = $this->getInput('installLastname', helper::FILTER_STRING_SHORT, true);
$userMail = $this->getInput('installMail', helper::FILTER_MAIL, true);
$userId = $this->getInput('installId', helper::FILTER_ID, true);
// Bannière par défaut
// Création de l'utilisateur si les données sont complétées.
if ( $userFirstname
AND $userLastname
AND $userMail
AND $this->getInput('installPassword', helper::FILTER_PASSWORD, true)
AND $this->getInput('installConfirmPassword', helper::FILTER_STRING_SHORT, true)
AND $success
){
// success retour de l'enregistrement des données
$success = $this->setData([
'user',
$userId,
[
'firstname' => $userFirstname,
'forgot' => 0,
'group' => self::GROUP_ADMIN,
'lastname' => $userLastname,
'mail' => $userMail,
'password' => $this->getInput('installPassword', helper::FILTER_PASSWORD, true)
]
]);
// Compte créé, envoi du mail et création des données du site
if ($success) { // Formulaire complété envoi du mail
// Envoie le mail
// Sent contient true si réussite sinon code erreur d'envoi en clair
$sent = $this->sendMail(
$userMail,
'Installation de votre site',
'Bonjour' . ' <strong>' . $userFirstname . ' ' . $userLastname . '</strong>,<br><br>' .
'Voici les détails de votre installation.<br><br>' .
'<strong>URL du site :</strong> <a href="' . helper::baseUrl(false) . '" target="_blank">' . helper::baseUrl(false) . '</a><br>' .
'<strong>Identifiant du compte :</strong> ' . $this->getInput('installId') . '<br>',
null
);
// Créer les dossiers
if (!is_dir(self::FILE_DIR.'source/banniere/')) {
mkdir(self::FILE_DIR.'source/banniere/');}
@ -72,46 +106,16 @@ class install extends common {
$this->setData(['module', 'blog', 'mon-deuxieme-article', 'userId', $userId]);
$this->setData(['module', 'blog', 'mon-troisieme-article', 'userId', $userId]);
}
// Création de l'utilisateur si les données sont complétées.
$success = false;
if ( $userFirstname
AND $userLastname
AND $userMail
AND $this->getInput('installPassword', helper::FILTER_PASSWORD, true)
AND $this->getInput('installConfirmPassword', helper::FILTER_STRING_SHORT, true)
){
$success = $this->setData([
'user',
$userId,
[
'firstname' => $userFirstname,
'forgot' => 0,
'group' => self::GROUP_ADMIN,
'lastname' => $userLastname,
'mail' => $userMail,
'password' => $this->getInput('installPassword', helper::FILTER_PASSWORD, true)
]
]);
}
if ($success === true) { // Formulaire complété envoi du mail
// Envoie le mail
$sent = $this->sendMail(
$userMail,
'Installation de votre site',
'Bonjour' . ' <strong>' . $userFirstname . ' ' . $userLastname . '</strong>,<br><br>' .
'Voici les détails de votre installation.<br><br>' .
'<strong>URL du site :</strong> <a href="' . helper::baseUrl(false) . '" target="_blank">' . helper::baseUrl(false) . '</a><br>' .
'<strong>Identifiant du compte :</strong> ' . $this->getInput('installId') . '<br>',
null
);
// Stocker le dossier d'installation
$this->setData(['core', 'baseUrl', helper::baseUrl(false,false) ]);
// Générer un fichier robots.txt
$this->createRobots();
// Créer sitemap
$this->createSitemap();
} else {
die ('Erreur fatale : impossible de stockage les données de l\utilisateur.');
}
// Valeurs en sortie
echo helper::baseUrl(false);
$this->addOutput([
'redirect' => helper::baseUrl(false),
'notification' => ($sent === true ? 'Installation terminée' : $sent),

2
core/module/user/user.php Normal file → Executable file
View File

@ -58,7 +58,7 @@ class user extends common {
AND empty($userLastname)
AND empty($this->getInput('userAddPassword', helper::FILTER_STRING_SHORT, true))
AND empty($this->getInput('userAddConfirmPassword', helper::FILTER_STRING_SHORT, true))) {
$check=false;
$check = false;
}
// Si tout est ok création effective
if ($check === true) {