
- /html/about.php - /html/admin.php - /html/compte.php - /html/editpage.php - /html/login.php - /html/logout.php - /html/news.php - /html/register.php - /html/src/banner/index.php - /html/src/img/empty.jpg - /html/src/img/favicon.ico - /html/src/miniature/index.php - /html/src/pp/index.php - /html/upload.php - /html/user.php - /html/users.php - /content/journal/0.md - /content/journal/198183.md - /content/about.md - /content/admin.md - /content/index.md - /html-old/editpage.php - /html-old/src/banner/index.php - /html-old/src/css/index.php - /html-old/src/css/style.css - /html-old/src/fonts/index.php - /html-old/src/fonts/bahnschrift.ttf - /html-old/src/img/empty.jpg - /html-old/src/img/favicon.ico - /html-old/src/img/index.php - /html-old/src/img/athena-mono.png - /html-old/src/miniature/index.php - /html-old/src/pp/index.php - /html-old/src/index.php - /html-old/about.php - /html-old/robots.txt - /html-old/admin.php - /html-old/compte.php - /html-old/login.php - /html-old/logout.php - /html-old/index.php - /html-old/news.php - /html-old/register.php - /html-old/upload.php - /html-old/users.php - /html-old/user.php - /html/about/index.php - /html/account/index.php - /html/admin/index.php - /html/assets/banners/index.php - /html/assets/miniatures/index.php - /html/assets/pp/index.php - /html/assets/index.php - /html/editor/index.php - /html/login/index.php - /html/login/logout.php - /html/login/register.php - /html/news/index.php - /html/settings/index.php - /html/settings/deleteaccount.php - /html/src/css/style.css - /html/src/img/athena-mono.png - /html/index.php - /html/robots.txt - /content/articles/0.md - /content/articles/198183.md - /content/pages/about.md - /content/pages/admin.md - /content/pages/index.md - /include/variables.php - /include/functions.php - /config/global.ini
94 lines
3.2 KiB
PHP
94 lines
3.2 KiB
PHP
<?php
|
|
require("../../include/variables.php");
|
|
require("../../include/functions.php");
|
|
$pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlDatabasePass);
|
|
|
|
if (isset($_SESSION['userID'])) {
|
|
header("Location: /");
|
|
die("Vous êtes déjà connecté.");
|
|
}
|
|
|
|
if (isset($_POST['username']) && isset($_POST['password'])) {
|
|
|
|
if (empty($_POST['username']) == false && empty($_POST['password']) == false) {
|
|
|
|
if(preg_match('!\S!u', $_POST['username']) && preg_match('!\S!u', $_POST['password'])) {
|
|
|
|
$sqlRequest = "SELECT ID, username, display_name, level, accreditation FROM users WHERE (username = :username OR email = :username) AND password = :password";
|
|
$request = $pdo->prepare($sqlRequest);
|
|
$request->bindParam(":username", htmlspecialchars($_POST['username']));
|
|
$request->bindParam(":password", md5($_POST['password']));
|
|
$request->execute();
|
|
$result = $request->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if ($result) {
|
|
|
|
$_SESSION['userID'] = $result[0]['ID'];
|
|
$_SESSION['userName'] = $result[0]['username'];
|
|
$_SESSION['userDisplayName'] = $result[0]['display_name'];
|
|
$_SESSION['userLevel'] = $result[0]['level'];
|
|
$_SESSION['userAccreditation'] = $result[0]['accreditation'];
|
|
$redirectPage = isset($_GET['p']) ? $_GET['p'] : "";
|
|
header('Location: /' . $redirectPage);
|
|
exit("Login success");
|
|
|
|
} else {
|
|
$status = 'Identifiants incorrects';
|
|
}
|
|
} else {
|
|
$status = 'Caractères illégaux';
|
|
}
|
|
} else {
|
|
$status = 'Les champs ne doivent pas être vides';
|
|
}
|
|
}
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
|
|
<head>
|
|
<?php fillHead($rootPageURL, $pageTitle, $darkTheme, $lightTheme);?>
|
|
<style>
|
|
</style>
|
|
</head>
|
|
|
|
<body class="body">
|
|
|
|
<header>
|
|
<div class="panel-content">
|
|
<?php fillHeader($rootPageURL, $headerTitle, $headerSubtitle);?>
|
|
</div>
|
|
</header>
|
|
|
|
<nav>
|
|
<div class="panel-content">
|
|
<?php fillNav($rootPageURL);?>
|
|
</div>
|
|
</nav>
|
|
|
|
<main>
|
|
<div class="content">
|
|
<form action="#" method="post">
|
|
<div class="form">
|
|
<div class="form-title">Se Connecter</div>
|
|
<div class="status"><?=$status?></div>
|
|
<?php
|
|
textInput("text", "", "username", "Login / Email", "");
|
|
textInput("password", "", "password", "Mot de Passe", "");
|
|
?>
|
|
<button type="submit">Se connecter</button>
|
|
<div>ou</div>
|
|
<a href="register.php" class="button">Créer un compte</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</main>
|
|
<footer>
|
|
<div class="panel-content">
|
|
<?php fillFooter($footerText);?>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html>
|