2022-09-01 04:21:17 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if (processForm(false)) {
|
|
|
|
checkPasswordFormat($_POST['password']);
|
|
|
|
|
|
|
|
checkUsernameFormat($_POST['username']);
|
|
|
|
|
|
|
|
if (userExist($_POST['username']) !== false)
|
2022-09-15 19:17:48 +02:00
|
|
|
output(403, 'Ce nom de compte est déjà utilisé.');
|
2022-09-01 04:21:17 +02:00
|
|
|
|
2022-09-17 00:49:07 +02:00
|
|
|
rateLimit();
|
|
|
|
|
|
|
|
insert('users', [
|
|
|
|
'username' => $_POST['username'],
|
|
|
|
'password' => hashPassword($_POST['password']),
|
|
|
|
'registration_date' => date("Y-m-d H:i:s"),
|
|
|
|
'bucket_tokens' => 0,
|
|
|
|
'bucket_last_update' => 0,
|
|
|
|
]);
|
|
|
|
|
2022-09-01 04:21:17 +02:00
|
|
|
// Setup SFTP directory
|
|
|
|
umask(0002);
|
|
|
|
if (mkdir(CONF['ht']['ht_path'] . "/" . $_POST['username'], 0775) !== true)
|
2022-09-15 19:17:48 +02:00
|
|
|
output(500, 'Can\'t create user directory.');
|
2022-09-01 04:21:17 +02:00
|
|
|
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['chgrp_path'] . " " . CONF['ht']['sftpgo_group'] . " " . CONF['ht']['ht_path'] . "/" . $_POST['username'] . " --no-dereference", result_code: $code);
|
|
|
|
if ($code !== 0)
|
2022-09-15 19:17:48 +02:00
|
|
|
output(500, 'Can\'t change user directory group.');
|
2022-09-01 04:21:17 +02:00
|
|
|
|
|
|
|
// Setup Tor config directory
|
|
|
|
if (mkdir(CONF['ht']['tor_config_path'] . "/" . $_POST['username'], 0755) !== true)
|
2022-09-15 19:17:48 +02:00
|
|
|
output(500, 'Can\'t create Tor config directory.');
|
2022-09-01 04:21:17 +02:00
|
|
|
|
|
|
|
// Setup Tor keys directory
|
|
|
|
exec(CONF['ht']['sudo_path'] . " -u " . CONF['ht']['tor_user'] . " " . CONF['ht']['mkdir_path'] . " --mode=0700 " . CONF['ht']['tor_keys_path'] . "/" . $_POST['username'], result_code: $code);
|
|
|
|
if ($code !== 0)
|
2022-09-15 19:17:48 +02:00
|
|
|
output(500, 'Can\'t create Tor keys directory.');
|
2022-09-01 04:21:17 +02:00
|
|
|
|
|
|
|
$_SESSION['username'] = $_POST['username'];
|
|
|
|
|
|
|
|
redir();
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
2021-01-22 21:58:46 +01:00
|
|
|
|
2022-06-06 23:14:50 +02:00
|
|
|
<p>Déjà un compte ? <a class="auth" href="login">Se connecter</a></p>
|
|
|
|
|
2022-06-10 21:14:47 +02:00
|
|
|
<form method="post">
|
2022-05-21 19:41:46 +02:00
|
|
|
|
2022-06-10 21:14:47 +02:00
|
|
|
<details>
|
|
|
|
<summary><label for="username">Identifiant</label></summary>
|
|
|
|
Uniquement composé de lettres minuscules.
|
|
|
|
</details>
|
2022-10-09 23:36:35 +02:00
|
|
|
<input id="username" minlength="1" maxlength="64" pattern="<?= USERNAME_REGEX ?>" required="" name="username" type="text" placeholder="<?= PLACEHOLDER_USERNAME ?>"><br>
|
2021-01-22 21:58:46 +01:00
|
|
|
|
2022-06-10 21:14:47 +02:00
|
|
|
<details>
|
|
|
|
<summary><label for="password">Clé de passe</label></summary>
|
|
|
|
<p>Une clé de passe sécurisée est trop compliquée à deviner pour une attaque qui testerais automatiquement plein de clés de passe tout en connaissant d'autres informations et secrets sur vous.</p>
|
|
|
|
<p>Minimum 8 caractères si elle contient minuscule, majuscule et chiffre, ou minimum 10 caractères sinon.</p>
|
|
|
|
</details>
|
2022-05-05 23:40:36 +02:00
|
|
|
|
2022-06-10 21:14:47 +02:00
|
|
|
<input autocomplete="new-password" id="password" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" required="" name="password" type="password" placeholder="<?= PLACEHOLDER_PASSWORD ?>"><br>
|
2021-01-22 21:58:46 +01:00
|
|
|
|
2022-06-10 21:14:47 +02:00
|
|
|
<input type="submit">
|
|
|
|
</form>
|