|
@@ -1,37 +1,64 @@
|
|
|
<?php require "../top.inc.php"; ?>
|
|
|
|
|
|
- <form method="post">
|
|
|
- <label for="username">Identifiant</label><br>
|
|
|
- <input id="username" pattern="[a-z]{4,32}" required="" name="username" type="text" placeholder="proudhon"><span></span><br>
|
|
|
+<?php
|
|
|
|
|
|
- <label for="password">Mot de passe</label><br>
|
|
|
- <input id="password" pattern=".{10,1024}" required="" name="password" type="password" placeholder="************"><span></span><br>
|
|
|
+if (isset($_POST['username']) AND isset($_POST['password'])) {
|
|
|
|
|
|
- <input type="submit">
|
|
|
- </form>
|
|
|
+ if (!checkPasswordFormat($_POST['password']))
|
|
|
+ exit("Le format du mot de passe n'est pas valide !");
|
|
|
|
|
|
- Déjà un compte ? <a class="authButton" href="login.php">Se connecter</a>
|
|
|
+ if (!checkUsernameFormat($_POST['username']))
|
|
|
+ exit("Le format du nom du compte n'est pas valide !");
|
|
|
|
|
|
- <?php
|
|
|
+ $username = $_POST['username'];
|
|
|
+ $userExist = userExist($username);
|
|
|
+ if (!$userExist) {
|
|
|
|
|
|
- if (isset($_POST['username']) AND isset($_POST['password'])) {
|
|
|
- $username = $_POST['username'];
|
|
|
- $password = password_hash($_POST['password'], PASSWORD_DEFAULT);
|
|
|
+ $password = password_hash($_POST['password'], PASSWORD_DEFAULT);
|
|
|
|
|
|
- $db = new PDO('sqlite:' . $dbPath);
|
|
|
+ $db = new PDO('sqlite:' . DB_PATH);
|
|
|
|
|
|
- $stmt = $db->prepare("INSERT INTO users(username, password) VALUES(:username, :password)");
|
|
|
+ $stmt = $db->prepare("INSERT INTO users(username, password, sftp_enabled, registration_date) VALUES(:username, :password, 0, :registration_date)");
|
|
|
|
|
|
- $stmt->bindParam(':username', $username);
|
|
|
- $stmt->bindParam(':password', $password);
|
|
|
+ $time = time();
|
|
|
|
|
|
- $stmt->execute();
|
|
|
+ $stmt->bindParam(':username', $username);
|
|
|
+ $stmt->bindParam(':password', $password);
|
|
|
+ $stmt->bindParam(':registration_date', $time);
|
|
|
|
|
|
- // Setup SFTP access for Hypertext
|
|
|
- exec("sudo /root/maniver/target/debug/maniver setup-user " . $_POST['username'] . " " . $_POST['password']);
|
|
|
+ $stmt->execute();
|
|
|
|
|
|
- }
|
|
|
+ $_SESSION['username'] = $username;
|
|
|
+ $_SESSION['sftp_enabled'] = false;
|
|
|
+ header('Location: ' . $prefixURL . '/');
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
?>
|
|
|
|
|
|
+<form method="post">
|
|
|
+ <label for="username">Identifiant</label><br>
|
|
|
+ <input id="username" minlength="4" maxlength="32" pattern="<?= USERNAME_REGEX ?>" required="" name="username" type="text" placeholder="proudhon"><span></span><br>
|
|
|
+ <?php
|
|
|
+ if (isset($userExist) AND $userExist == true) {
|
|
|
+ echo "Cet identifiant est déjà utilisé. Choisissez-en un autre.";
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+ <label for="password">
|
|
|
+ <details>
|
|
|
+ <summary>Mot de passe</summary>
|
|
|
+ Minimum 10 caractères ou minimum 8 caractères s'il contient minuscule, majuscule et chiffre
|
|
|
+ </details>
|
|
|
+
|
|
|
+ <input id="password" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" required="" name="password" type="password" placeholder="************"><span title="Le format nest pas valide"></span><br>
|
|
|
+
|
|
|
+ </label>
|
|
|
+
|
|
|
+ <input type="submit">
|
|
|
+</form>
|
|
|
+
|
|
|
+Déjà un compte ? <a class="authButton" href="login">Se connecter</a>
|
|
|
+
|
|
|
<?php require "../bottom.inc.php"; ?>
|