55 lines
1.6 KiB
PHP
Executable File
55 lines
1.6 KiB
PHP
Executable File
<?php require "../top.inc.php"; ?>
|
|
|
|
<form method="post">
|
|
<label for="username">Identifiant</label><br>
|
|
<input required="" minlength="4" maxlength="32" pattern="<?= USERNAME_REGEX ?>" id="username" name="username" type="text" placeholder="lain">
|
|
<br>
|
|
|
|
<label for="password">Clé de passe</label><br>
|
|
<input required="" autocomplete="current-password" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" id="password" name="password" type="password" placeholder="************************">
|
|
<br>
|
|
|
|
<input type="submit">
|
|
</form>
|
|
|
|
Pas de compte ? <a class="authButton" href="register">En créer un</a>
|
|
|
|
<?php
|
|
|
|
if (isset($_POST['username']) AND isset($_POST['password'])) {
|
|
|
|
antiCSRF();
|
|
|
|
if (!checkPasswordFormat($_POST['password']))
|
|
exit("Le format du mot de passe n'est pas valide !");
|
|
|
|
if (!checkUsernameFormat($_POST['username']))
|
|
exit("Le format du nom du compte n'est pas valide !");
|
|
|
|
if (checkPassword($_POST['username'], $_POST['password'])) {
|
|
|
|
$_SESSION['username'] = htmlspecialchars($_POST['username']);
|
|
$_SESSION['sftp_enabled'] = sftpStatus($_SESSION['username']);
|
|
|
|
if (outdatedPasswordHash($_SESSION['username']))
|
|
changePassword($_SESSION['username'], $_POST['password']);
|
|
|
|
if (isset($_GET['redir'])) {
|
|
if (preg_match("/^[0-9a-z\/-]+$/", $_GET['redir']))
|
|
header('Location: ' . PREFIX . "/" . $_GET['redir']);
|
|
else
|
|
exit("ERROR : Wrong character in redir argument");
|
|
} else {
|
|
header('Location: ' . PREFIX);
|
|
}
|
|
exit;
|
|
} else {
|
|
echo "<br>Connexion impossible : mot de passe invalide";
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<?php require "../bottom.inc.php"; ?>
|