forked from ZwiiCMS-Team/ZwiiCMS
Installation + création user
This commit is contained in:
parent
f84613561e
commit
9c5642b9b0
76
core/module/install/install.php
Normal file → Executable file
76
core/module/install/install.php
Normal file → Executable file
@ -41,17 +41,51 @@ class install extends common {
|
|||||||
else {
|
else {
|
||||||
// Soumission du formulaire
|
// Soumission du formulaire
|
||||||
if($this->isPost()) {
|
if($this->isPost()) {
|
||||||
//$sent = $success = false;
|
$success = true;
|
||||||
// Double vérification pour le mot de passe
|
// 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)) {
|
if($this->getInput('installPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('installConfirmPassword', helper::FILTER_STRING_SHORT, true)) {
|
||||||
self::$inputNotices['installConfirmPassword'] = 'Incorrect';
|
self::$inputNotices['installConfirmPassword'] = 'Incorrect';
|
||||||
|
$success = false;
|
||||||
}
|
}
|
||||||
// Crée l'utilisateur
|
// Utilisateur
|
||||||
$userFirstname = $this->getInput('installFirstname', helper::FILTER_STRING_SHORT, true);
|
$userFirstname = $this->getInput('installFirstname', helper::FILTER_STRING_SHORT, true);
|
||||||
$userLastname = $this->getInput('installLastname', helper::FILTER_STRING_SHORT, true);
|
$userLastname = $this->getInput('installLastname', helper::FILTER_STRING_SHORT, true);
|
||||||
$userMail = $this->getInput('installMail', helper::FILTER_MAIL, true);
|
$userMail = $this->getInput('installMail', helper::FILTER_MAIL, true);
|
||||||
$userId = $this->getInput('installId', helper::FILTER_ID, 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
|
// Créer les dossiers
|
||||||
if (!is_dir(self::FILE_DIR.'source/banniere/')) {
|
if (!is_dir(self::FILE_DIR.'source/banniere/')) {
|
||||||
mkdir(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-deuxieme-article', 'userId', $userId]);
|
||||||
$this->setData(['module', 'blog', 'mon-troisieme-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
|
// Stocker le dossier d'installation
|
||||||
$this->setData(['core', 'baseUrl', helper::baseUrl(false,false) ]);
|
$this->setData(['core', 'baseUrl', helper::baseUrl(false,false) ]);
|
||||||
// Générer un fichier robots.txt
|
// Générer un fichier robots.txt
|
||||||
$this->createRobots();
|
$this->createRobots();
|
||||||
// Créer sitemap
|
// Créer sitemap
|
||||||
$this->createSitemap();
|
$this->createSitemap();
|
||||||
|
} else {
|
||||||
|
die ('Erreur fatale : impossible de stockage les données de l\utilisateur.');
|
||||||
|
}
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
echo helper::baseUrl(false);
|
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl(false),
|
'redirect' => helper::baseUrl(false),
|
||||||
'notification' => ($sent === true ? 'Installation terminée' : $sent),
|
'notification' => ($sent === true ? 'Installation terminée' : $sent),
|
||||||
|
2
core/module/user/user.php
Normal file → Executable file
2
core/module/user/user.php
Normal file → Executable file
@ -58,7 +58,7 @@ class user extends common {
|
|||||||
AND empty($userLastname)
|
AND empty($userLastname)
|
||||||
AND empty($this->getInput('userAddPassword', helper::FILTER_STRING_SHORT, true))
|
AND empty($this->getInput('userAddPassword', helper::FILTER_STRING_SHORT, true))
|
||||||
AND empty($this->getInput('userAddConfirmPassword', 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
|
// Si tout est ok création effective
|
||||||
if ($check === true) {
|
if ($check === true) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user