servnest/auth/login.php

46 lines
1.6 KiB
PHP
Raw Normal View History

2021-01-22 21:58:46 +01:00
<?php require "../top.inc.php"; ?>
2021-01-23 17:26:46 +01:00
<form method="post">
2021-01-22 21:58:46 +01:00
<label for="username">Identifiant</label><br>
<input required="" minlength="4" maxlength="32" pattern="<?= USERNAME_REGEX ?>" id="username" name="username" type="text" placeholder="proudhon"><br>
2021-01-22 21:58:46 +01:00
<label for="password">Mot de passe</label><br>
<input required="" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" id="password" name="password" type="password" placeholder="************"><br>
2021-01-22 21:58:46 +01:00
2021-01-23 17:26:46 +01:00
<input type="submit">
2021-01-22 21:58:46 +01:00
</form>
Pas de compte ? <a class="authButton" href="register">En créer un</a>
2021-01-25 13:39:31 +01:00
2021-01-22 21:58:46 +01:00
<?php
if (isset($_POST['username']) AND isset($_POST['password'])) {
if (!checkPasswordFormat($_POST['password']))
exit("Le format du mot de passe n'est pas valide !");
2021-01-22 21:58:46 +01:00
if (!checkUsernameFormat($_POST['username']))
exit("Le format du nom du compte n'est pas valide !");
2021-01-22 21:58:46 +01:00
if (checkPassword($_POST['username'], $_POST['password'])) {
$_SESSION['username'] = htmlspecialchars($_POST['username']);
$_SESSION['sftp_enabled'] = sftpStatus($_SESSION['username']);
2021-02-16 19:20:19 +01:00
if (isset($_GET['redir'])) {
if (preg_match("/^[0-9a-z\/-]+$/", $_GET['redir']))
header('Location: ' . PREFIX . "/" . $_GET['redir']);
else
exit("ERROR : Wrong caracter in redir argument");
} else {
header('Location: ' . PREFIX);
}
exit;
2021-01-22 21:58:46 +01:00
} else {
echo "<br>Connexion impossible : mot de passe invalide";
2021-01-22 21:58:46 +01:00
}
}
?>
<?php require "../bottom.inc.php"; ?>