Updated includes.php
This commit is contained in:
parent
6f3a25be7e
commit
65db4d0b30
@ -1,73 +0,0 @@
|
||||
<?php
|
||||
require "../include/variables.php";
|
||||
require "../include/functions.php";
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./src/css/style.css">
|
||||
<style>
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.body {
|
||||
<?=$theme_dark?>
|
||||
}
|
||||
}
|
||||
@media (prefers-color-scheme: light) {
|
||||
.body {
|
||||
<?=$theme_light?>
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<link rel="icon" href="./src/img/favicon.ico">
|
||||
<title><?=$title?></title>
|
||||
</head>
|
||||
<body class="body">
|
||||
<header>
|
||||
<div class="pancontent">
|
||||
<div class="athena-container">
|
||||
<a href="<?=$root?>" class="athena-link">
|
||||
<img src="./src/img/athena-mono.png" class="athena">
|
||||
</a>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="main-title">
|
||||
<div class="title"><?=$header_title?></div>
|
||||
<div class="subtitle"><?=$header_subtitle?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<nav>
|
||||
<div class="pancontent">
|
||||
<?php nav($nav);?>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div>
|
||||
<?php
|
||||
$markdownContent = file_get_contents('../content/about.md');
|
||||
|
||||
require_once '../include/parsedown.php';
|
||||
$parsedown = new Parsedown();
|
||||
echo $parsedown->text($markdownContent);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div><?=$copyright?></div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -1,80 +0,0 @@
|
||||
<?php
|
||||
require "../include/variables.php";
|
||||
require "../include/functions.php";
|
||||
|
||||
if($_SESSION['role'] < 3) {
|
||||
header("Location: index.php");
|
||||
http_response_code(404);
|
||||
die();
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta name="robots" content="noindex">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./src/css/style.css">
|
||||
<style>
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.body {
|
||||
<?=$theme_dark?>
|
||||
}
|
||||
}
|
||||
@media (prefers-color-scheme: light) {
|
||||
.body {
|
||||
<?=$theme_light?>
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<link rel="icon" href="./src/img/favicon.ico">
|
||||
<title><?=$title?></title>
|
||||
</head>
|
||||
<body class="body">
|
||||
<header>
|
||||
<div class="pancontent">
|
||||
<div class="athena-container">
|
||||
<a href="<?=$root?>">
|
||||
<img src="./src/img/athena-mono.png" class="athena">
|
||||
</a>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="main-title">
|
||||
<div class="title"><?=$header_title?></div>
|
||||
<div class="subtitle"><?=$header_subtitle?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<nav>
|
||||
<div class="pancontent">
|
||||
<?php nav($nav);?>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div>
|
||||
<?php
|
||||
$markdownContent = file_get_contents('../content/admin.md');
|
||||
|
||||
require_once '../include/parsedown.php';
|
||||
$parsedown = new Parsedown();
|
||||
echo $parsedown->text($markdownContent);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div><?=$copyright?></div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -1,296 +0,0 @@
|
||||
<?php
|
||||
require "../include/variables.php";
|
||||
require "../include/functions.php";
|
||||
|
||||
if (isset($_FILES['profile_picture']) && $_FILES['profile_picture']['error'] == 0) {
|
||||
// Chemins et noms de fichiers
|
||||
$tempPath = $_FILES['profile_picture']['tmp_name'];
|
||||
$path = '/src/pp/'. $_SESSION['userid'] .'.png';
|
||||
$rootPath = $wwwroot . "/html" . $path;
|
||||
$webPath = $root . $path;
|
||||
|
||||
// Redimensionnement de l'image
|
||||
list($width, $height) = getimagesize($tempPath);
|
||||
|
||||
$imageInfo = getimagesize($tempPath);
|
||||
|
||||
if ($imageInfo[2] === IMAGETYPE_PNG || $imageInfo[2] === IMAGETYPE_JPEG) {
|
||||
$newWidth = 128;
|
||||
$newHeight = 128;
|
||||
$imageResized = imagecreatetruecolor($newWidth, $newHeight);
|
||||
$imageOriginal = imagecreatefromstring(file_get_contents($tempPath));
|
||||
imagecopyresampled($imageResized, $imageOriginal, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
|
||||
imagealphablending($imageResized, false);
|
||||
imagesavealpha($imageResized, true);
|
||||
|
||||
// Enregistrement de l'image redimensionnée
|
||||
imagepng($imageResized, $rootPath);
|
||||
|
||||
// Nettoyage
|
||||
imagedestroy($imageOriginal);
|
||||
imagedestroy($imageResized);
|
||||
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$req = $bdd->prepare("UPDATE users SET profile_picture = :user_pp WHERE ID = :user_id");
|
||||
$req->bindParam(":user_pp", $webPath);
|
||||
$req->bindParam(":user_id", $_SESSION['userid']);
|
||||
if($req->execute()) {
|
||||
$status = "PP mise à jour";
|
||||
} else {
|
||||
$status = "Erreur SQL";
|
||||
}
|
||||
} else {
|
||||
$status = "Le fichier doit être au format PNG ou JPG";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_FILES['banner']) && $_FILES['banner']['error'] == 0) {
|
||||
// Chemins et noms de fichiers
|
||||
$tempPath = $_FILES['banner']['tmp_name'];
|
||||
$path = '/src/banner/'. $_SESSION['userid'] .'.png';
|
||||
$rootPath = $wwwroot . "/html" . $path;
|
||||
$webPath = $root . $path;
|
||||
|
||||
// Redimensionnement de l'image
|
||||
list($width, $height) = getimagesize($tempPath);
|
||||
$imageInfo = getimagesize($tempPath);
|
||||
|
||||
if ($imageInfo[2] === IMAGETYPE_PNG || $imageInfo[2] === IMAGETYPE_JPEG) {
|
||||
$newWidth = 800;
|
||||
$newHeight = ($height / $width) * $newWidth;
|
||||
$imageResized = imagecreatetruecolor($newWidth, $newHeight);
|
||||
imagealphablending($imageResized, false);
|
||||
imagesavealpha($imageResized, true);
|
||||
$imageOriginal = imagecreatefromstring(file_get_contents($tempPath));
|
||||
imagecopyresampled($imageResized, $imageOriginal, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
|
||||
|
||||
// Enregistrement de l'image redimensionnée
|
||||
imagepng($imageResized, $rootPath);
|
||||
|
||||
// Nettoyage
|
||||
imagedestroy($imageOriginal);
|
||||
imagedestroy($imageResized);
|
||||
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$req = $bdd->prepare("UPDATE users SET banner = :user_banner WHERE ID = :user_id");
|
||||
$req->bindParam(":user_banner", $webPath);
|
||||
$req->bindParam(":user_id", $_SESSION['userid']);
|
||||
if($req->execute()) {
|
||||
$status = "Banière mise à jour";
|
||||
} else {
|
||||
$status = "Erreur SQL";
|
||||
}
|
||||
} else {
|
||||
$status = "Le fichier doit être un PNG ou JPG";
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['user_display_name']) && isset($_POST['user_name']) && isset($_POST['user_bio'])) {
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$req = $bdd->prepare("SELECT ID FROM users WHERE username = :user_name AND NOT ID = :user_id");
|
||||
$req->bindParam(":user_name", htmlspecialchars($_POST['user_name']));
|
||||
$req->bindParam(":user_id", $_SESSION['userid'], PDO::PARAM_INT);
|
||||
$req->execute();
|
||||
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||
if($resultat) {
|
||||
$status = "Erreur, le nom d'utilisateur existe déjà.";
|
||||
} else {
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$req = $bdd->prepare("UPDATE users SET username = :user_name, display_name = :user_display_name, bio = :user_bio WHERE ID = :user_id");
|
||||
$req->bindParam(":user_name", htmlspecialchars($_POST['user_name']));
|
||||
$req->bindParam(":user_display_name", htmlspecialchars($_POST['user_display_name']));
|
||||
$req->bindParam(":user_bio", htmlspecialchars($_POST['user_bio']));
|
||||
$req->bindParam(":user_id", $_SESSION['userid']);
|
||||
if($req->execute()) {
|
||||
$status = "Informations mises à jour";
|
||||
$_SESSION['username'] = htmlspecialchars($_POST['user_name']);
|
||||
$_SESSION['display_name'] = htmlspecialchars($_POST['user_display_name']);
|
||||
} else {
|
||||
$status = "Erreur, les informations n'ont pas pu être mises à jour.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$req = $bdd->prepare("SELECT ID, username, creation_date, display_name, role, profile_picture, banner, bio FROM users WHERE ID = :user_id");
|
||||
$req->bindParam(":user_id", $_SESSION['userid']);
|
||||
$req->execute();
|
||||
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if($resultat) {
|
||||
$user_id = $resultat[0]['ID'];
|
||||
$user_name = $resultat[0]['username'];
|
||||
$user_creation_date = $resultat[0]['creation_date'];
|
||||
$user_display_name = $resultat[0]['display_name'];
|
||||
$user_role = $resultat[0]['role'];
|
||||
$user_pp = $resultat[0]['profile_picture'] == NULL ? "https://abs.twimg.com/sticky/default_profile_images/default_profile_400x400.png" : $resultat[0]['profile_picture'];
|
||||
$user_pp_url = $resultat[0]['profile_picture'];
|
||||
$user_banner = $resultat[0]['banner'] = NULL ? "./src/img/empty.jpg" : $resultat[0]['banner'];
|
||||
$user_bio = $resultat[0]['bio'];
|
||||
} else {
|
||||
die("Erreur, utilisateur introuvable");
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta name="robots" content="noindex">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./src/css/style.css">
|
||||
<style>
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.body {
|
||||
<?=$theme_dark?>
|
||||
}
|
||||
<?php
|
||||
for ($i = 0; $i < count($themes_dark); $i++) {
|
||||
echo "#palette" . $i . " { ";
|
||||
echo $themes_dark[$i];
|
||||
echo " } ";
|
||||
}
|
||||
?>
|
||||
}
|
||||
@media (prefers-color-scheme: light) {
|
||||
.body {
|
||||
<?=$theme_light?>
|
||||
}
|
||||
<?php
|
||||
for ($i = 0; $i < count($themes_light); $i++) {
|
||||
echo "#palette" . $i . " { ";
|
||||
echo $themes_light[$i];
|
||||
echo " } ";
|
||||
}
|
||||
?>
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.user-banner {
|
||||
<?php
|
||||
if (empty($user_banner)) {
|
||||
echo "background-color: black";
|
||||
} else {
|
||||
echo "background-image: url('" . $user_banner . "');";
|
||||
}
|
||||
?>
|
||||
}
|
||||
|
||||
.certification {
|
||||
fill: <?php echo $user_role > 0 ? $certif_colors[$user_role] : "#000000"?>;
|
||||
}
|
||||
</style>
|
||||
<link rel="icon" href="./src/img/favicon.ico">
|
||||
<title><?=$title?></title>
|
||||
</head>
|
||||
<body class="body">
|
||||
<header>
|
||||
<div class="pancontent">
|
||||
<div class="athena-container">
|
||||
<a href="<?=$root?>" class="athena-link">
|
||||
<img src="./src/img/athena-mono.png" class="athena">
|
||||
</a>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="main-title">
|
||||
<div class="title"><?=$header_title?></div>
|
||||
<div class="subtitle"><?=$header_subtitle?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<nav>
|
||||
<div class="pancontent">
|
||||
<?php nav($nav);?>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="user-main-profile">
|
||||
<form action="#" method="post">
|
||||
<div class="user-banner"></div>
|
||||
<div class="user-header">
|
||||
<div class="user-content">
|
||||
<div class="user-pp"><img src="<?=$user_pp?>" class="user-pp-image"></div>
|
||||
<div><a href="user.php?user=<?=$user_name?>" class="button">Voir le profil publique</a></div>
|
||||
<div class="status"><?=$status?></div>
|
||||
<div class="user-info">
|
||||
<div class="names">
|
||||
<div class="display-name"><input type="text" name="user_display_name" value="<?=$user_display_name?>" required/></div>
|
||||
<div class="username"><input type="text" name="user_name" value="<?=$user_name?>" required/></div>
|
||||
</div>
|
||||
<div><textarea class="bio-input" name="user_bio" placeholder="Bio..." maxlength="100"><?=$user_bio?></textarea></div>
|
||||
<div><input type="submit" value="Mettre à jour les informations"></div>
|
||||
</form>
|
||||
<div>
|
||||
<form action="#" method="post" enctype="multipart/form-data">
|
||||
<input type="file" name="profile_picture">
|
||||
<input type="submit" value="Mettre à jour la PP">
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<form action="#" method="post" enctype="multipart/form-data">
|
||||
<input type="file" name="banner">
|
||||
<input type="submit" value="Mettre à jour la banière">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="user-articles">
|
||||
<div class="user-content">
|
||||
<div><a href="upload.php" class="button">Publier un article</a></div>
|
||||
<?php
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$search = isset($_GET['search']) ? "%" . htmlspecialchars($_GET['search']) . "%" : "%%";
|
||||
$req = $bdd->prepare("SELECT ID, titre, date, image, resume FROM articles WHERE (titre LIKE :search OR ID LIKE :search OR auteur LIKE :search) AND classification <= :accreditation AND auteur = :user_id ORDER BY date DESC");
|
||||
$req->bindParam(":search", $search);
|
||||
$req->bindParam(":accreditation", $_SESSION['accreditation']);
|
||||
$req->bindParam(":user_id", $user_id);
|
||||
$req->execute();
|
||||
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||
echo "<h1>Editer un article</h1>";
|
||||
echo "<form action='' method='get'><input type='text' placeholder='Article' name='search'><input type='submit' value='Rechercher'></form>";
|
||||
|
||||
if ($resultat) {
|
||||
foreach($resultat as $row) {
|
||||
$date = strtotime($row['date']);
|
||||
echo '<div class="article-preview">';
|
||||
echo '<div class="article-illustration">';
|
||||
echo '<a href="editpage.php?article=' . $row['ID'] . '" class="article-link"><img src="' . $row['image'] . '" class="article-miniature"></a>';
|
||||
echo '</div>';
|
||||
echo '<div class="article-details">';
|
||||
echo '<div class="article-data">n° ' . $row['ID'] . ' | ' . date('d/m/Y', $date) . '</div>';
|
||||
echo '<a href="editpage.php?article=' . $row['ID'] . '" class="article-link">';
|
||||
echo '<div class="article-titre">' . $row['titre'] . '</div>';
|
||||
echo '</a>';
|
||||
echo '<div class="article-resume">' . $row['resume'] . '</div>';
|
||||
echo '</div>';
|
||||
echo '</div> ';
|
||||
}
|
||||
} else {
|
||||
echo "Vous n'avez publié aucun article...";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div><?=$copyright?></div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -1,276 +0,0 @@
|
||||
<?php
|
||||
require "../include/variables.php";
|
||||
require "../include/functions.php";
|
||||
|
||||
if($_SESSION['role'] < 1) {
|
||||
header("Location: index.php");
|
||||
http_response_code(404);
|
||||
die();
|
||||
}
|
||||
|
||||
$filetypes = [
|
||||
0 => "article",
|
||||
1 => "page"
|
||||
];
|
||||
|
||||
if(isset($_GET['article']) && filter_var($_GET['article'], FILTER_VALIDATE_INT)) {
|
||||
if(file_exists($wwwroot . "/content/journal/" . $_GET['article'] . ".md")){
|
||||
$fichier = $wwwroot . "/content/journal/" . $_GET['article'] . ".md";
|
||||
$filename = $_GET['article'];
|
||||
$filetype = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_GET['page']) && strpos($_GET['page'], "..") == false && $_SESSION['role'] >= 3) {
|
||||
if(file_exists($wwwroot . "/content/" . $_GET['page'] . ".md")){
|
||||
$fichier = $wwwroot . "/content/" . $_GET['page'] . ".md";
|
||||
$filename = $_GET['page'];
|
||||
$filetype = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_FILES['miniature']) && $_FILES['miniature']['error'] == 0 && isset($_GET['article'])) {
|
||||
// Chemins et noms de fichiers
|
||||
$tempPath = $_FILES['miniature']['tmp_name'];
|
||||
$path = '/src/miniature/'. $_GET['article'] .'.png';
|
||||
$rootPath = $wwwroot . "/html" . $path;
|
||||
$webPath = $root . $path;
|
||||
|
||||
// Redimensionnement de l'image
|
||||
list($width, $height) = getimagesize($tempPath);
|
||||
$imageInfo = getimagesize($tempPath);
|
||||
|
||||
if ($imageInfo[2] === IMAGETYPE_PNG || $imageInfo[2] === IMAGETYPE_JPEG) {
|
||||
$newWidth = 600;
|
||||
$newHeight = ($height / $width) * $newWidth;
|
||||
$imageResized = imagecreatetruecolor($newWidth, $newHeight);
|
||||
imagealphablending($imageResized, false);
|
||||
imagesavealpha($imageResized, true);
|
||||
$imageOriginal = imagecreatefromstring(file_get_contents($tempPath));
|
||||
imagecopyresampled($imageResized, $imageOriginal, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
|
||||
|
||||
// Enregistrement de l'image redimensionnée
|
||||
imagepng($imageResized, $rootPath);
|
||||
|
||||
// Nettoyage
|
||||
imagedestroy($imageOriginal);
|
||||
imagedestroy($imageResized);
|
||||
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$req = $bdd->prepare("UPDATE articles SET image = :image WHERE ID = :article AND auteur = :user_id");
|
||||
$req->bindParam(":image", $webPath);
|
||||
$req->bindParam(":article", $_GET['article']);
|
||||
$req->bindParam(":user_id", $_SESSION['userid']);
|
||||
if($req->execute()) {
|
||||
$status = "Miniature mise à jour";
|
||||
} else {
|
||||
$status = "Erreur SQL";
|
||||
}
|
||||
} else {
|
||||
$status = "Le fichier doit être un PNG ou JPG";
|
||||
}
|
||||
}
|
||||
|
||||
$filename = isset($filename) ? $filename : "";
|
||||
|
||||
if(isset($fichier)) {
|
||||
if(isset($_GET['article']) && isset($_POST['deletefile']) && $_POST['deletefile'] == "Supprimer") {
|
||||
if(unlink($fichier)) {
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$upload = $bdd->prepare("DELETE FROM articles WHERE ID = :filename AND auteur = :user_id");
|
||||
$upload->bindParam(':filename', $filename);
|
||||
$upload->bindParam(':auteur', $_SESSION['userid']);
|
||||
if($upload->execute()) {
|
||||
header("Location: editpage.php");
|
||||
echo "Fichier supprimé";
|
||||
exit();
|
||||
} else {
|
||||
die("Erreur SQL");
|
||||
}
|
||||
} else {
|
||||
die("Erreur : Le fichier n'a pas pu être supprimé");
|
||||
}
|
||||
}
|
||||
if(isset($_POST['page-content'])) {
|
||||
file_put_contents($fichier, nl2br($_POST['page-content']));
|
||||
}
|
||||
if(isset($_POST['article-classification']) && isset($_POST['article-resume']) && isset($_GET['article'])) {
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
|
||||
$req = $bdd->prepare("UPDATE articles SET classification = :classification, titre = :titre, resume = :resume WHERE ID = :article AND auteur = :user_id");
|
||||
$req->bindParam(':classification', $_POST['article-classification']);
|
||||
$req->bindParam(':titre', htmlspecialchars($_POST['article-titre']));
|
||||
$req->bindParam(':resume', nl2br($_POST['article-resume']));
|
||||
$req->bindParam(':article', $_GET['article']);
|
||||
$req->bindParam(':user_id', $_SESSION['userid']);
|
||||
if($req->execute()) {
|
||||
$status = "Informations mises à jour";
|
||||
} else {
|
||||
$status = "Erreur SQL";
|
||||
}
|
||||
}
|
||||
$contenu = file_get_contents($fichier);
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta name="robots" content="noindex">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./src/css/style.css">
|
||||
<style>
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.body {
|
||||
<?=$theme_dark?>
|
||||
}
|
||||
}
|
||||
@media (prefers-color-scheme: light) {
|
||||
.body {
|
||||
<?=$theme_light?>
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<link rel="icon" href="./src/img/favicon.ico">
|
||||
<title><?=$title?></title>
|
||||
<style>
|
||||
textarea {
|
||||
width: 100%;
|
||||
min-height: 50em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="body">
|
||||
<header>
|
||||
<div class="pancontent">
|
||||
<div class="athena-container">
|
||||
<a href="<?=$root?>">
|
||||
<img src="./src/img/athena-mono.png" class="athena">
|
||||
</a>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="main-title">
|
||||
<div class="title"><?=$header_title?></div>
|
||||
<div class="subtitle"><?=$header_subtitle?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<nav>
|
||||
<div class="pancontent">
|
||||
<?php nav($nav);?>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div><div class="status"><?=$status?></div>
|
||||
<?php
|
||||
if(isset($contenu)) {
|
||||
echo '<form action="?' . $filetypes[$filetype] . '=' . $filename . '" method="post">';
|
||||
echo "<div><div class='button'><a href='editpage.php'>Retour</a></div>";
|
||||
echo "<div><div class='button'><a href='news.php?article=" . $filename . "'>Voir l'article</a></div>";
|
||||
if(isset($_GET['article'])) {
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$req = $bdd->prepare("SELECT classification, titre, image, resume FROM articles WHERE ID = :article AND auteur = :user_id");
|
||||
$req->bindParam(":article", $_GET['article']);
|
||||
$req->bindParam(":user_id", $_SESSION['userid']);
|
||||
$req->execute();
|
||||
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if($resultat) {
|
||||
echo '<div><label for="article-classification">Classification : </label><select name="article-classification" required>';
|
||||
foreach($classifications as $id => $nom) {
|
||||
if((int)$resultat[0]['classification'] == $id) {
|
||||
echo '<option value="' . $id .'" selected>' . $nom . '</option>';
|
||||
} else {
|
||||
echo '<option value="' . $id .'">' . $nom . '</option>';
|
||||
}
|
||||
|
||||
}
|
||||
echo '</select></div>';
|
||||
$filetitle = $resultat[0]['titre'];
|
||||
|
||||
echo '<div><input type="text" name="article-titre" value="' . $resultat[0]['titre'] . '"></div>';
|
||||
echo '<div><textarea name="article-resume" placeholder="Résumé de l\'article (200 cacactères) ..." class="article-resume-input" maxlength="200">' . str_replace("<br />", "", $resultat[0]['resume']) . '</textarea></div>';
|
||||
}
|
||||
}
|
||||
echo "<div><h1>" . $filetitle . "</h1></div>";
|
||||
echo '<div><textarea name="page-content" placeholder="Contenu de l\'article (MarkDown) ...">' . str_replace("<br />", "", $contenu) . '</textarea></div>';
|
||||
echo '<div><input type="submit" value="Publier"></div></form>';
|
||||
if($resultat) {
|
||||
echo '<form action="?article=' . $_GET['article'] . '" method="post" enctype="multipart/form-data">';
|
||||
echo '<input type="file" name="miniature">';
|
||||
echo '<input type="submit" value="Mettre à jour la Miniature">';
|
||||
echo '</form></div>';
|
||||
}
|
||||
} else {
|
||||
if($_SESSION['role'] >= 3) {
|
||||
echo "<div><div><h2>Pages</h2></div>";
|
||||
echo "<div>";
|
||||
$pages = scandir($wwwroot . "/content/");
|
||||
foreach($pages as $page) {
|
||||
if($page != "." && $page != "..") {
|
||||
if (is_file($wwwroot . "/content/" . $page)) {
|
||||
echo "<a href='?page=" . pathinfo($page, PATHINFO_FILENAME) . "'><div class='button'>" . pathinfo($page, PATHINFO_FILENAME) . "</div></a>";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "</div></div><div>";
|
||||
}
|
||||
echo "<div><h2>Articles</h2></div>";
|
||||
echo "<form action='' method='get'><input type='text' placeholder='Article' name='search'><input type='submit' value='Rechercher'></form>";
|
||||
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$condition = "";
|
||||
if(isset($_GET['search'])) {
|
||||
$search = "%" . htmlspecialchars($_GET['search']) . "%";
|
||||
$condition = "AND (titre LIKE '" . $search . "' OR ID LIKE '" . $search . "' OR auteur LIKE '" . $search . "') ";
|
||||
}
|
||||
$req = $bdd->prepare("SELECT ID, titre, date, image, resume FROM articles WHERE auteur = :user_id ORDER BY date DESC LIMIT 10");
|
||||
$req->bindParam(":user_id", $_SESSION['userid']);
|
||||
$req->execute();
|
||||
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($resultat) {
|
||||
foreach($resultat as $row) {
|
||||
$date = strtotime($row['date']);
|
||||
echo '<div class="article-preview">';
|
||||
echo '<div class="article-illustration">';
|
||||
echo '<a href="?article=' . $row['ID'] . '" class="article-link"><img src="' . $row['image'] . '" class="article-miniature"></a>';
|
||||
echo '</div>';
|
||||
echo '<div class="article-details">';
|
||||
echo '<div class="article-data">n° ' . $row['ID'] . ' | ' . date('d/m/Y', $date) . '</div>';
|
||||
echo '<a href="?article=' . $row['ID'] . '" class="article-link">';
|
||||
echo '<div class="article-titre">' . $row['titre'] . '</div>';
|
||||
echo '</a>';
|
||||
echo '<div class="article-resume">' . $row['resume'] . '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
if(isset($contenu)) {
|
||||
echo '<form action=?article=' . $filename . ' method="post"><div><input type="submit" name="deletefile" value="Supprimer"></div></form>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div><?=$copyright?></div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -1,98 +0,0 @@
|
||||
<?php
|
||||
require "../include/variables.php";
|
||||
require "../include/functions.php";
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./src/css/style.css">
|
||||
<style>
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.body {
|
||||
<?=$theme_dark?>
|
||||
}
|
||||
}
|
||||
@media (prefers-color-scheme: light) {
|
||||
.body {
|
||||
<?=$theme_light?>
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<link rel="icon" href="./src/img/favicon.ico">
|
||||
<title><?=$title?></title>
|
||||
</head>
|
||||
<body class="body">
|
||||
<header>
|
||||
<div class="pancontent">
|
||||
<div class="athena-container">
|
||||
<a href="<?=$root?>" class="athena-link">
|
||||
<img src="./src/img/athena-mono.png" class="athena">
|
||||
</a>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="main-title">
|
||||
<div class="title"><?=$header_title?></div>
|
||||
<div class="subtitle"><?=$header_subtitle?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<nav>
|
||||
<div class="pancontent">
|
||||
<?php nav($nav);?>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div>
|
||||
<?php
|
||||
$markdownContent = file_get_contents('../content/index.md');
|
||||
|
||||
require_once '../include/parsedown.php';
|
||||
$parsedown = new Parsedown();
|
||||
echo $parsedown->text($markdownContent);
|
||||
?>
|
||||
</div>
|
||||
<div class="articles"><?php
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$search = isset($_GET['search']) ? "%" . htmlspecialchars($_GET['search']) . "%" : "%%";
|
||||
$req = $bdd->prepare("SELECT articles.ID, articles.titre, articles.date, articles.image, articles.resume, users.username, users.display_name FROM articles JOIN users ON articles.auteur = users.ID WHERE articles.classification <= :accreditation ORDER BY date DESC LIMIT 3");
|
||||
$req->bindParam(":accreditation", $_SESSION['accreditation']);
|
||||
$req->execute();
|
||||
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach($resultat as $row) {
|
||||
$date = strtotime($row['date']);
|
||||
echo '<div class="article-preview">';
|
||||
echo '<div class="article-illustration">';
|
||||
echo '<a href="news.php?article=' . $row['ID'] . '" class="article-link"><img src="' . $row['image'] . '" class="article-miniature"></a>';
|
||||
echo '</div>';
|
||||
echo '<div class="article-details">';
|
||||
echo '<div class="article-data">n° ' . $row['ID'] . ' | ' . date('d/m/Y', $date) . ' | '. '<a href="user.php?user=' . $row['username'] . '">' . $row['display_name'] . '</a></div>';
|
||||
echo '<a href="news.php?article=' . $row['ID'] . '" class="article-link">';
|
||||
echo '<div class="article-titre">' . $row['titre'] . '</div>';
|
||||
echo '</a>';
|
||||
echo '<div class="article-resume">' . $row['resume'] . '</div>';
|
||||
echo '</div>';
|
||||
echo '</div> ';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div><?=$copyright?></div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -1,101 +0,0 @@
|
||||
<?php
|
||||
require "../include/variables.php";
|
||||
require "../include/functions.php";
|
||||
|
||||
if(isset($_SESSION['userid'])) {
|
||||
header("Location: index.php");
|
||||
die("Vous êtes déjà connecté");
|
||||
}
|
||||
|
||||
if(isset($_POST['username']) && isset($_POST['password'])) {
|
||||
if(empty($_POST['username']) == false && empty($_POST['password']) === false) {
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
|
||||
$req = $bdd->prepare("SELECT ID, username, email, display_name, role, accreditation FROM users WHERE (username = :username OR email = :username) AND password = :password");
|
||||
$req->bindParam(':username', htmlspecialchars($_POST['username']));
|
||||
$req->bindParam(':password', md5($_POST['password']));
|
||||
$req->execute();
|
||||
|
||||
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($resultat) {
|
||||
$_SESSION['username'] = $resultat[0]['username'];
|
||||
$_SESSION['email'] = $resultat[0]['email'];
|
||||
$_SESSION['display_name'] = $resultat[0]['display_name'];
|
||||
$_SESSION['userid'] = $resultat[0]['ID'];
|
||||
$_SESSION['role'] = $resultat[0]['role'];
|
||||
$_SESSION['accreditation'] = $resultat[0]['accreditation'];
|
||||
header("Location: index.php");
|
||||
exit();
|
||||
} else {
|
||||
$status = "Nom d'utilisateur / mot de passe incorrect";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./src/css/style.css">
|
||||
<style>
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.body {
|
||||
<?=$theme_dark?>
|
||||
}
|
||||
}
|
||||
@media (prefers-color-scheme: light) {
|
||||
.body {
|
||||
<?=$theme_light?>
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<link rel="icon" href="./src/img/favicon.ico">
|
||||
<title><?=$title?></title>
|
||||
</head>
|
||||
<body class="body">
|
||||
<header>
|
||||
<div class="pancontent">
|
||||
<div class="athena-container">
|
||||
<a href="<?=$root?>" class="athena-link">
|
||||
<img src="./src/img/athena-mono.png" class="athena">
|
||||
</a>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="main-title">
|
||||
<div class="title"><?=$header_title?></div>
|
||||
<div class="subtitle"><?=$header_subtitle?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<nav>
|
||||
<div class="pancontent">
|
||||
<?php nav($nav);?>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
<div class="content">
|
||||
<div><form action="#" method="post">
|
||||
<div>
|
||||
<div><input type="text" name="username" placeholder="Nom d'utilisateur" required></div>
|
||||
<div><input type="password" name="password" placeholder="Mot de Passe" required></div>
|
||||
<div><input type="submit" value="Connexion"><a href="register.php"><div class="button">Créer un compte</div></a></div>
|
||||
<div class="status"><?=$status?></div>
|
||||
</div>
|
||||
</div></form>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div><?=$copyright?></div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_destroy();
|
||||
header("Location: index.php");
|
||||
exit();
|
||||
?>
|
@ -1,144 +0,0 @@
|
||||
<?php
|
||||
require "../include/variables.php";
|
||||
require "../include/functions.php";
|
||||
|
||||
if (isset($_GET['article']) && filter_var($_GET['article'], FILTER_VALIDATE_INT)) {
|
||||
$article = $_GET['article'];
|
||||
} else {
|
||||
$article = "";
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./src/css/style.css">
|
||||
<style>
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.body {
|
||||
<?=$theme_dark?>
|
||||
}
|
||||
}
|
||||
@media (prefers-color-scheme: light) {
|
||||
.body {
|
||||
<?=$theme_light?>
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<link rel="icon" href="./src/img/favicon.ico">
|
||||
<title><?=$title?></title>
|
||||
</head>
|
||||
<body class="body">
|
||||
<header>
|
||||
<div class="pancontent">
|
||||
<div class="athena-container">
|
||||
<a href="<?=$root?>" class="athena-link">
|
||||
<img src="./src/img/athena-mono.png" class="athena">
|
||||
</a>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="main-title">
|
||||
<div class="title"><?=$header_title?></div>
|
||||
<div class="subtitle"><?=$header_subtitle?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<nav>
|
||||
<div class="pancontent">
|
||||
<?php nav($nav);?>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div>
|
||||
<?php
|
||||
if ($article == "") {
|
||||
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$search = isset($_GET['search']) ? "%" . htmlspecialchars($_GET['search']) . "%" : "%%";
|
||||
$req = $bdd->prepare("SELECT articles.ID, articles.titre, articles.date, articles.image, articles.resume, users.username, users.display_name FROM articles JOIN users ON articles.auteur = users.ID WHERE (articles.titre LIKE :search OR articles.ID LIKE :search OR users.username LIKE :search) AND articles.classification <= :accreditation ORDER BY date DESC");
|
||||
$req->bindParam(":search", $search);
|
||||
$req->bindParam(":accreditation", $_SESSION['accreditation']);
|
||||
$req->execute();
|
||||
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
echo "<h1>Actualités du club</h1>";
|
||||
echo "<form action='' method='get'><input type='text' placeholder='Article' name='search'><input type='submit' value='Rechercher'></form>";
|
||||
|
||||
if ($resultat) {
|
||||
foreach($resultat as $row) {
|
||||
$date = strtotime($row['date']);
|
||||
echo '<div class="article-preview">';
|
||||
echo '<div class="article-illustration">';
|
||||
echo '<a href="?article=' . $row['ID'] . '" class="article-link"><img src="' . $row['image'] . '" class="article-miniature"></a>';
|
||||
echo '</div>';
|
||||
echo '<div class="article-details">';
|
||||
echo '<div class="article-data">n° ' . $row['ID'] . ' | ' . date('d/m/Y', $date) . ' | '. '<a href="user.php?user=' . $row['username'] . '">' . $row['display_name'] . '</a></div>';
|
||||
echo '<a href="?article=' . $row['ID'] . '" class="article-link">';
|
||||
echo '<div class="article-titre">' . $row['titre'] . '</div>';
|
||||
echo '</a>';
|
||||
echo '<div class="article-resume">' . $row['resume'] . '</div>';
|
||||
echo '</div>';
|
||||
echo '</div> ';
|
||||
}
|
||||
} else {
|
||||
echo "Aucun article trouvé";
|
||||
}
|
||||
|
||||
} else if (!isset($_GET['search']) && $article != "" && file_exists($wwwroot . '/content/journal/' . $article . '.md')) {
|
||||
|
||||
$markdownContent = file_get_contents($wwwroot . '/content/journal/' . $article . '.md');
|
||||
|
||||
require_once '../include/parsedown.php';
|
||||
$parsedown = new Parsedown();
|
||||
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$req = $bdd->prepare("SELECT articles.ID, articles.titre, articles.date, articles.classification, articles.image, users.username, users.display_name, users.role, users.profile_picture FROM articles JOIN users ON users.ID = articles.auteur WHERE articles.ID = :article AND articles.classification <= :accreditation");
|
||||
$req->bindParam(":article", $article);
|
||||
$req->bindParam(":accreditation", $_SESSION['accreditation']);
|
||||
$req->execute();
|
||||
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);;
|
||||
|
||||
if ($resultat) {
|
||||
$date = strtotime($resultat[0]['date']);
|
||||
$auteur_pp = $resultat[0]['profile_picture'] == NULL ? "https://abs.twimg.com/sticky/default_profile_images/default_profile_400x400.png" : $resultat[0]['profile_picture'];
|
||||
echo "<div class='article'><div class='article-info'>";
|
||||
echo "<div class='article-titre'>" . $resultat[0]['titre'] . "</div>";
|
||||
echo "<div class='article-date'>" . date('d/m/Y', $date) . "</div>";
|
||||
echo "<a href='user.php?user=" . $resultat[0]['username'] . "'>";
|
||||
echo "<div class='article-auteur'>";
|
||||
echo "<div class='auteur-pp'><img src='" . $auteur_pp . "' class='auteur-pp-image'/></div>";
|
||||
echo "<div class='auteur-names'>";
|
||||
echo "<div class='auteur-display-name'>" . $resultat[0]['display_name'];
|
||||
if($resultat[0]['role'] > 1) {
|
||||
echo '<svg class="certification" fill="' . $certif_colors[$resultat[0]['role']] . '" viewBox="0 0 22 22" aria-label="Compte certifié" role="img"><g><path d="M20.396 11c-.018-.646-.215-1.275-.57-1.816-.354-.54-.852-.972-1.438-1.246.223-.607.27-1.264.14-1.897-.131-.634-.437-1.218-.882-1.687-.47-.445-1.053-.75-1.687-.882-.633-.13-1.29-.083-1.897.14-.273-.587-.704-1.086-1.245-1.44S11.647 1.62 11 1.604c-.646.017-1.273.213-1.813.568s-.969.854-1.24 1.44c-.608-.223-1.267-.272-1.902-.14-.635.13-1.22.436-1.69.882-.445.47-.749 1.055-.878 1.688-.13.633-.08 1.29.144 1.896-.587.274-1.087.705-1.443 1.245-.356.54-.555 1.17-.574 1.817.02.647.218 1.276.574 1.817.356.54.856.972 1.443 1.245-.224.606-.274 1.263-.144 1.896.13.634.433 1.218.877 1.688.47.443 1.054.747 1.687.878.633.132 1.29.084 1.897-.136.274.586.705 1.084 1.246 1.439.54.354 1.17.551 1.816.569.647-.016 1.276-.213 1.817-.567s.972-.854 1.245-1.44c.604.239 1.266.296 1.903.164.636-.132 1.22-.447 1.68-.907.46-.46.776-1.044.908-1.681s.075-1.299-.165-1.903c.586-.274 1.084-.705 1.439-1.246.354-.54.551-1.17.569-1.816zM9.662 14.85l-3.429-3.428 1.293-1.302 2.072 2.072 4.4-4.794 1.347 1.246z"></path></g></svg>';
|
||||
}
|
||||
echo "</div>";
|
||||
echo "<div class='auteur-username'>@" . $resultat[0]['username'] . "</div>";
|
||||
echo "</div></div></a>";
|
||||
echo "<div class='article-classification'>" . $classifications[$resultat[0]['classification']] . "</div></div>";
|
||||
echo "<div class='article-illustration'><img src='" . $resultat[0]['image'] . "' class='article-miniature'/></div>";
|
||||
echo "<div class='article-content'>";
|
||||
echo $parsedown->text($markdownContent);
|
||||
echo "</div></div></div>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div><?=$copyright?></div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -1,111 +0,0 @@
|
||||
<?php
|
||||
require "../include/variables.php";
|
||||
require "../include/functions.php";
|
||||
|
||||
if(isset($_SESSION['userid'])) {
|
||||
header("Location: index.php");
|
||||
die("Vous êtes déjà connecté");
|
||||
}
|
||||
|
||||
if(isset($_POST['username']) && isset($_POST['password']) && isset($_POST['password2'])) {
|
||||
if(empty($_POST['username']) == false && empty($_POST['password']) === false && empty($_POST['password2']) === false) {
|
||||
if($_POST['password'] == $_POST['password2']) {
|
||||
|
||||
$display_name = isset($_POST['display_name']) ? $_POST['display_name'] : $_POST['username'];
|
||||
$email = isset($_POST['email']) ? $_POST['email'] : "";
|
||||
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$req = $bdd->prepare("SELECT ID FROM users WHERE username = :username");
|
||||
$req->bindParam(":username", htmlspecialchars($_POST['username']));
|
||||
$req->execute();
|
||||
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||
if($resultat) {
|
||||
$status = "Erreur, le nom d'utilisateur existe déjà.";
|
||||
} else {
|
||||
$req = $bdd->prepare("INSERT INTO users (username, password, email, display_name, role, accreditation) VALUES (:username, :password, :email, :display_name, 0, 0)");
|
||||
$req->bindParam(':username', htmlspecialchars($_POST['username']));
|
||||
$req->bindParam(':password', md5($_POST['password']));
|
||||
$req->bindParam(':email', htmlspecialchars($_POST['email']));
|
||||
$req->bindParam(':display_name', htmlspecialchars($_POST['display_name']));
|
||||
if ($req->execute()) {
|
||||
header("Location: login.php");
|
||||
exit();
|
||||
} else {
|
||||
$status = "Erreur SQL";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$status = "Les mots de passe ne correspondent pas.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./src/css/style.css">
|
||||
<style>
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.body {
|
||||
<?=$theme_dark?>
|
||||
}
|
||||
}
|
||||
@media (prefers-color-scheme: light) {
|
||||
.body {
|
||||
<?=$theme_light?>
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<link rel="icon" href="./src/img/favicon.ico">
|
||||
<title><?=$title?></title>
|
||||
</head>
|
||||
<body class="body">
|
||||
<header>
|
||||
<div class="pancontent">
|
||||
<div class="athena-container">
|
||||
<a href="<?=$root?>" class="athena-link">
|
||||
<img src="./src/img/athena-mono.png" class="athena">
|
||||
</a>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="main-title">
|
||||
<div class="title"><?=$header_title?></div>
|
||||
<div class="subtitle"><?=$header_subtitle?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<nav>
|
||||
<div class="pancontent">
|
||||
<?php nav($nav);?>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
<div class="content">
|
||||
<div><form action="#" method="post">
|
||||
<div>
|
||||
<div><input type="text" name="display_name" placeholder="Nom d'affichage"></div>
|
||||
<div><input type="email" name="email" placeholder="Adresse email"></div>
|
||||
<div><input type="text" name="username" placeholder="Nom d'utilisateur" required></div>
|
||||
<div><input type="password" name="password" placeholder="Mot de Passe" required></div>
|
||||
<div><input type="password" name="password2" placeholder="Confirmez votre mot de passe" required></div>
|
||||
<div><input type="submit" value="Connexion"></div>
|
||||
<div class="status"><?=$status?></div>
|
||||
</div>
|
||||
</div></form>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div><?=$copyright?></div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -1,5 +0,0 @@
|
||||
User-agent: Googlebot
|
||||
Disallow: /src/
|
||||
|
||||
User-agent: *
|
||||
Allow: /
|
@ -1 +0,0 @@
|
||||
<?php http_response_code(403);?>
|
@ -1 +0,0 @@
|
||||
<?php http_response_code(403);?>
|
@ -1,312 +0,0 @@
|
||||
@font-face {
|
||||
font-family: crfont; /* Nom de la police */
|
||||
src: url('/src/fonts/bahnschrift.ttf') format('truetype'); /* Chemin vers votre fichier TTF */
|
||||
/* Autres attributs de la police (facultatif) */
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: crfont, sans-serif;
|
||||
color: var(--text);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
main {
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
background: var(--background);
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
min-height: 100em;
|
||||
}
|
||||
|
||||
header, footer, nav {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
background: var(--banner-background);
|
||||
display: flex;
|
||||
}
|
||||
|
||||
header, footer {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
input, textarea {
|
||||
background-color: var(--buttons);
|
||||
color: var(--text);
|
||||
padding: 0.4em 1em;
|
||||
margin: 15px 0;
|
||||
font-size: 1.2em;
|
||||
border: 0;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
input[type='submit'], button {
|
||||
color: var(--text);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
input[type='submit']:hover, button:hover {
|
||||
box-shadow: 0 0 15px var(--banner-background);
|
||||
}
|
||||
|
||||
img {
|
||||
border-radius: 1em;
|
||||
}
|
||||
|
||||
.navitem {
|
||||
padding: 0.5em;
|
||||
background-color: var(--buttons);
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.status {
|
||||
color: rgb(199 181 147);
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 80%;
|
||||
margin: 0 auto;
|
||||
padding: 2em 0;
|
||||
}
|
||||
|
||||
.pancontent {
|
||||
width: 90%;
|
||||
display: flex;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.athena-container {
|
||||
padding: 1em 0;
|
||||
}
|
||||
|
||||
.athena {
|
||||
height: 7em;
|
||||
border-radius: 3.5em;
|
||||
}
|
||||
|
||||
.athena:hover {
|
||||
box-shadow: 0 0 15px rgba(255, 255, 255, 0.322);
|
||||
}
|
||||
|
||||
.main-title {
|
||||
text-align: right;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.main-title .title {
|
||||
font-size: 3em;
|
||||
}
|
||||
|
||||
.article-preview {
|
||||
padding: 2em 0.5em;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.article-preview .article-illustration {
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
.article-preview .article-details {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.article-preview .article-link {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.article-preview .article-miniature {
|
||||
max-width: 15em;
|
||||
}
|
||||
|
||||
.article-preview .article-data {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.article-preview .article-titre {
|
||||
font: 1.5em crfont, Arial;
|
||||
padding: 0.5em 0 0.5em 0;
|
||||
}
|
||||
|
||||
.article-resume-input {
|
||||
min-height: 5em;
|
||||
}
|
||||
|
||||
.article-info .article-auteur {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.article-info .article-classification {
|
||||
padding: 1em 0;
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.article-info .article-titre {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
.article .article-illustration {
|
||||
padding: 2em 0;
|
||||
}
|
||||
|
||||
.article .article-miniature {
|
||||
margin: 0 auto;
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.article-content img {
|
||||
max-height: 10em;
|
||||
}
|
||||
|
||||
.user-main-profile .user-content {
|
||||
width: 80%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.user-main-profile .user-header {
|
||||
background-color: var(--banner-background);
|
||||
padding-bottom: 2em;
|
||||
}
|
||||
|
||||
.user-main-profile .user-banner {
|
||||
width: 100%;
|
||||
height: 12em;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.user-main-profile .user-pp-image {
|
||||
width: 10em;
|
||||
height: 10em;
|
||||
border-radius: 10em;
|
||||
transform: translate(0, -60%);
|
||||
border: 5px solid var(--banner-background);
|
||||
background-color: var(--banner-background);
|
||||
}
|
||||
|
||||
.user-main-profile .user-pp {
|
||||
height: 6em;
|
||||
}
|
||||
|
||||
.user-main-profile .display-name {
|
||||
font-weight: bold;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.user-main-profile .user-role {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.user-main-profile .certification {
|
||||
transform: translate(0, +22%);
|
||||
width: 1.5em;
|
||||
}
|
||||
|
||||
.user-main-profile .bio {
|
||||
padding: 1em 0;
|
||||
}
|
||||
|
||||
.user-main-profile .user-articles {
|
||||
margin-top: 5em;
|
||||
}
|
||||
|
||||
.user-main-profile .bio-input {
|
||||
max-height: 3em;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.article-auteur {
|
||||
background-color: var(--banner-background);
|
||||
display: flex;
|
||||
padding: 0.5em 1em 0.5em 0.5em;
|
||||
border-radius: 10em;
|
||||
width: 15em;
|
||||
}
|
||||
|
||||
.article-auteur .auteur-display-name {
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.article-auteur .auteur-display-name .certification {
|
||||
transform: translate(0, -15%);
|
||||
width: 1.5em;
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
.article-auteur .auteur-names {
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.article-auteur .auteur-pp {
|
||||
height: 4em;
|
||||
}
|
||||
|
||||
.article-auteur .auteur-pp-image {
|
||||
width: 4em;
|
||||
height: 4em;
|
||||
border-radius: 4em;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: inline-block;
|
||||
background-color: var(--banner-background);
|
||||
border-radius: 10px;
|
||||
padding: 2em;
|
||||
margin: 2em;
|
||||
}
|
||||
|
||||
.row input {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.button {
|
||||
background-color: var(--buttons);
|
||||
color: var(--text);
|
||||
border-radius: 10px;
|
||||
color: var(--text);
|
||||
padding: 0.4em 1em;
|
||||
margin: 15px;
|
||||
font-size: 1.2em;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
@media(max-width: 750px) {
|
||||
body {
|
||||
font-size: 0.8em
|
||||
}
|
||||
.article-preview {
|
||||
display: block;
|
||||
}
|
||||
.article-preview .article-illustration {
|
||||
margin: 0 auto;
|
||||
padding: 2em 0;
|
||||
}
|
||||
.article-preview .article-miniature {
|
||||
max-width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.article-preview .article-details {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.article-preview .article-data {
|
||||
font-size: 1em;
|
||||
}
|
||||
.article-preview .article-titre {
|
||||
font-size: 2em;
|
||||
}
|
||||
.article-preview .article-resume {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
.article .article-miniature {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
Binary file not shown.
@ -1 +0,0 @@
|
||||
<?php http_response_code(403);?>
|
Binary file not shown.
Before Width: | Height: | Size: 408 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB |
@ -1 +0,0 @@
|
||||
<?php http_response_code(403);?>
|
@ -1 +0,0 @@
|
||||
<?php http_response_code(403);?>
|
@ -1 +0,0 @@
|
||||
<?php http_response_code(403);?>
|
@ -1 +0,0 @@
|
||||
<?php http_response_code(403);?>
|
@ -1,118 +0,0 @@
|
||||
<?php
|
||||
require "../include/variables.php";
|
||||
require "../include/functions.php";
|
||||
|
||||
if($_SESSION['role'] < 1) {
|
||||
header("Location: login.php");
|
||||
http_response_code(404);
|
||||
die();
|
||||
}
|
||||
|
||||
$filename = rand(100000, 999999);
|
||||
|
||||
while(file_exists($wwwroot . "/content/journal/" . $filename . ".md")) {
|
||||
$filename = rand(100000, 999999);
|
||||
}
|
||||
|
||||
if(isset($_POST['article-content'])) {
|
||||
file_put_contents($wwwroot . "/content/journal/" . $filename . ".md", nl2br($_POST['article-content']));
|
||||
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$upload = $bdd->prepare("INSERT INTO articles (ID, titre, auteur, resume, classification) VALUES (:filename, :titre, :auteur, :resume, :classification)");
|
||||
$upload->bindParam(':filename', $filename);
|
||||
$upload->bindParam(':titre', htmlspecialchars($_POST['article-titre']));
|
||||
$upload->bindParam(':auteur', $_SESSION['userid']);
|
||||
$upload->bindParam(':resume', htmlspecialchars($_POST['article-resume']));
|
||||
$upload->bindParam(':classification', $_POST['classification']);
|
||||
if($upload->execute()) {
|
||||
$status = "Article Publié";
|
||||
} else {
|
||||
$status = "Erreur SQL";
|
||||
}
|
||||
header("Location: editpage.php?article=" . $filename);
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta name="robots" content="noindex">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./src/css/style.css">
|
||||
<style>
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.body {
|
||||
<?=$theme_dark?>
|
||||
}
|
||||
}
|
||||
@media (prefers-color-scheme: light) {
|
||||
.body {
|
||||
<?=$theme_light?>
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<link rel="icon" href="./src/img/favicon.ico">
|
||||
<title><?=$title?></title>
|
||||
<style>
|
||||
textarea {
|
||||
width: 100%;
|
||||
min-height: 50em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="body">
|
||||
<header>
|
||||
<div class="pancontent">
|
||||
<div class="athena-container">
|
||||
<a href="<?=$root?>">
|
||||
<img src="./src/img/athena-mono.png" class="athena">
|
||||
</a>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="main-title">
|
||||
<div class="title"><?=$header_title?></div>
|
||||
<div class="subtitle"><?=$header_subtitle?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<nav>
|
||||
<div class="pancontent">
|
||||
<?php nav($nav);?>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="status"><?=$status?></div>
|
||||
<form action="?article=<?=$filename?>" method="post">
|
||||
<div>
|
||||
<div><div><h1>Publier un article</h1></div>
|
||||
<div><input type="text" name="article-titre" placeholder="Titre"></div>
|
||||
<div><textarea name="article-resume" placeholder="Résumé de l'article (200 cacactères) ..." class="article-resume-input" maxlength="200"></textarea></div>
|
||||
<div><textarea name="article-content" placeholder="Contenu de l'article (MarkDown) ..."></textarea></div>
|
||||
<div>
|
||||
<label for="classification">Classification : </label>
|
||||
<select name="classification" required>
|
||||
<?php foreach($classifications as $id => $nom) { echo '<option value="' . $id .'">' . $nom . '</option>'; }?>
|
||||
</select>
|
||||
</div>
|
||||
<div><input type="submit" value="Publier"></div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div><?=$copyright?></div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -1,186 +0,0 @@
|
||||
<?php
|
||||
require "../include/variables.php";
|
||||
require "../include/functions.php";
|
||||
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$username = isset($_GET['user']) ? htmlspecialchars($_GET['user']) : "";
|
||||
$req = $bdd->prepare("SELECT ID, username, creation_date, display_name, role, profile_picture, banner, bio FROM users WHERE username = :username");
|
||||
$req->bindParam(":username", $username);
|
||||
$req->execute();
|
||||
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if($resultat) {
|
||||
$user_id = $resultat[0]['ID'];
|
||||
$user_name = $resultat[0]['username'];
|
||||
$user_creation_date = $resultat[0]['creation_date'];
|
||||
$user_display_name = $resultat[0]['display_name'];
|
||||
$user_role = $resultat[0]['role'];
|
||||
$user_pp = $resultat[0]['profile_picture'] == NULL ? "https://abs.twimg.com/sticky/default_profile_images/default_profile_400x400.png" : $resultat[0]['profile_picture'];
|
||||
$user_banner = $resultat[0]['banner'] = NULL ? "./src/img/empty.jpg" : $resultat[0]['banner'];
|
||||
$user_bio = $resultat[0]['bio'];
|
||||
} else {
|
||||
$user_id = 0;
|
||||
$user_name = $username;
|
||||
$user_creation_date = "01/01/2024";
|
||||
$user_display_name = "User not found";
|
||||
$user_role = 0;
|
||||
$user_pp = "https://abs.twimg.com/sticky/default_profile_images/default_profile_400x400.png";
|
||||
$user_banner = "";
|
||||
$user_bio = "";
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta name="robots" content="noindex">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./src/css/style.css">
|
||||
<style>
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.body {
|
||||
<?=$theme_dark?>
|
||||
}
|
||||
<?php
|
||||
for ($i = 0; $i < count($themes_dark); $i++) {
|
||||
echo "#palette" . $i . " { ";
|
||||
echo $themes_dark[$i];
|
||||
echo " } ";
|
||||
}
|
||||
?>
|
||||
}
|
||||
@media (prefers-color-scheme: light) {
|
||||
.body {
|
||||
<?=$theme_light?>
|
||||
}
|
||||
<?php
|
||||
for ($i = 0; $i < count($themes_light); $i++) {
|
||||
echo "#palette" . $i . " { ";
|
||||
echo $themes_light[$i];
|
||||
echo " } ";
|
||||
}
|
||||
?>
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.user-banner {
|
||||
<?php
|
||||
if (empty($user_banner)) {
|
||||
echo "background-color: black";
|
||||
} else {
|
||||
echo "background-image: url('" . $user_banner . "');";
|
||||
}
|
||||
?>
|
||||
}
|
||||
|
||||
.certification {
|
||||
fill: <?php echo $user_role > 0 ? $certif_colors[$user_role] : "#000000"?>;
|
||||
}
|
||||
</style>
|
||||
<link rel="icon" href="./src/img/favicon.ico">
|
||||
<title><?=$title?></title>
|
||||
</head>
|
||||
<body class="body">
|
||||
<header>
|
||||
<div class="pancontent">
|
||||
<div class="athena-container">
|
||||
<a href="<?=$root?>" class="athena-link">
|
||||
<img src="./src/img/athena-mono.png" class="athena">
|
||||
</a>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="main-title">
|
||||
<div class="title"><?=$header_title?></div>
|
||||
<div class="subtitle"><?=$header_subtitle?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<nav>
|
||||
<div class="pancontent">
|
||||
<?php nav($nav);?>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="user-main-profile">
|
||||
<div class="user-banner"></div>
|
||||
<div class="user-header">
|
||||
<div class="user-content">
|
||||
<div class="user-pp"><img src="<?=$user_pp?>" class="user-pp-image"></div>
|
||||
<div class="user-info">
|
||||
<div class="names">
|
||||
<div class="display-name"><?=$user_display_name?></div>
|
||||
<div class="user-role">
|
||||
|
||||
<?php
|
||||
if($user_role > 1) {
|
||||
echo '<svg class="certification" viewBox="0 0 22 22" aria-label="Compte certifié" role="img"><g><path d="M20.396 11c-.018-.646-.215-1.275-.57-1.816-.354-.54-.852-.972-1.438-1.246.223-.607.27-1.264.14-1.897-.131-.634-.437-1.218-.882-1.687-.47-.445-1.053-.75-1.687-.882-.633-.13-1.29-.083-1.897.14-.273-.587-.704-1.086-1.245-1.44S11.647 1.62 11 1.604c-.646.017-1.273.213-1.813.568s-.969.854-1.24 1.44c-.608-.223-1.267-.272-1.902-.14-.635.13-1.22.436-1.69.882-.445.47-.749 1.055-.878 1.688-.13.633-.08 1.29.144 1.896-.587.274-1.087.705-1.443 1.245-.356.54-.555 1.17-.574 1.817.02.647.218 1.276.574 1.817.356.54.856.972 1.443 1.245-.224.606-.274 1.263-.144 1.896.13.634.433 1.218.877 1.688.47.443 1.054.747 1.687.878.633.132 1.29.084 1.897-.136.274.586.705 1.084 1.246 1.439.54.354 1.17.551 1.816.569.647-.016 1.276-.213 1.817-.567s.972-.854 1.245-1.44c.604.239 1.266.296 1.903.164.636-.132 1.22-.447 1.68-.907.46-.46.776-1.044.908-1.681s.075-1.299-.165-1.903c.586-.274 1.084-.705 1.439-1.246.354-.54.551-1.17.569-1.816zM9.662 14.85l-3.429-3.428 1.293-1.302 2.072 2.072 4.4-4.794 1.347 1.246z"></path></g></svg>';
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
<div class="username">@<?=$user_name?></div>
|
||||
</div>
|
||||
<div class="bio"><?=$user_bio?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="status"><?=$status?></div>
|
||||
<div class="user-articles">
|
||||
<div class="user-content">
|
||||
<?php
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$search = isset($_GET['search']) ? "%" . htmlspecialchars($_GET['search']) . "%" : "%%";
|
||||
$req = $bdd->prepare("SELECT ID, titre, date, auteur, image, resume FROM articles WHERE (titre LIKE :search OR ID LIKE :search OR auteur LIKE :search) AND classification <= :accreditation AND auteur = :user_id ORDER BY date DESC");
|
||||
$req->bindParam(":search", $search);
|
||||
$req->bindParam(":accreditation", $_SESSION['accreditation']);
|
||||
$req->bindParam(":user_id", $user_id);
|
||||
$req->execute();
|
||||
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||
echo "<h1>Articles de " . $user_display_name . "</h1>";
|
||||
echo "<form action='' method='get'><input type='text' placeholder='Article' name='search'><input type='submit' value='Rechercher'></form>";
|
||||
|
||||
if ($resultat) {
|
||||
foreach($resultat as $row) {
|
||||
$date = strtotime($row['date']);
|
||||
echo '<div class="article-preview">';
|
||||
echo '<div class="article-illustration">';
|
||||
echo '<a href="news.php?article=' . $row['ID'] . '" class="article-link"><img src="' . $row['image'] . '" class="article-miniature"></a>';
|
||||
echo '</div>';
|
||||
echo '<div class="article-details">';
|
||||
echo '<div class="article-data">n° ' . $row['ID'] . ' | ' . date('d/m/Y', $date) . '</div>';
|
||||
echo '<a href="news.php?article=' . $row['ID'] . '" class="article-link">';
|
||||
echo '<div class="article-titre">' . $row['titre'] . '</div>';
|
||||
echo '</a>';
|
||||
echo '<div class="article-resume">' . $row['resume'] . '</div>';
|
||||
echo '</div>';
|
||||
echo '</div> ';
|
||||
}
|
||||
} else {
|
||||
echo "L'utilisateur n'a pas publié d'articles";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div><?=$copyright?></div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -1,184 +0,0 @@
|
||||
<?php
|
||||
require "../include/variables.php";
|
||||
require "../include/functions.php";
|
||||
|
||||
if($_SESSION['role'] < 3) {
|
||||
header("Location: index.php");
|
||||
http_response_code(404);
|
||||
die();
|
||||
}
|
||||
|
||||
if(isset($_POST['userid']) && isset($_POST['role']) && isset($_POST['accreditation']) && $_POST['userid'] != $_SESSION['userid']) {
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
|
||||
$req = $bdd->prepare("UPDATE users SET role = :role, accreditation = :accreditation WHERE ID = :userid");
|
||||
$req->bindParam(':role',$_POST['role'], PDO::PARAM_INT);
|
||||
$req->bindParam(':accreditation',$_POST['accreditation'], PDO::PARAM_INT);
|
||||
$req->bindParam(':userid', $_POST['userid'], PDO::PARAM_INT);
|
||||
if ($req->execute()) {
|
||||
$status = "Utilisateur mis à jour";
|
||||
} else {
|
||||
$status = "Erreur SQL";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta name="robots" content="noindex">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./src/css/style.css">
|
||||
<style>
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.body {
|
||||
<?=$theme_dark?>
|
||||
}
|
||||
}
|
||||
@media (prefers-color-scheme: light) {
|
||||
.body {
|
||||
<?=$theme_light?>
|
||||
}
|
||||
}
|
||||
|
||||
.user {
|
||||
background-color: var(--banner-background);
|
||||
display: flex;
|
||||
padding: 0.5em 1em 0.5em 0.5em;
|
||||
border-radius: 10em;
|
||||
width: 30em;
|
||||
height: 10em;
|
||||
margin: 2em auto;
|
||||
}
|
||||
|
||||
.user-username {
|
||||
|
||||
}
|
||||
|
||||
.user-display-name {
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.user-display-name .certification {
|
||||
transform: translate(0, -15%);
|
||||
width: 1.5em;
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
.perm-div {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.user-names {
|
||||
margin: 1em 1em 1em 0;
|
||||
}
|
||||
|
||||
.user-pp {
|
||||
height: 6em;
|
||||
height: 100%;
|
||||
padding-right: 2em;
|
||||
}
|
||||
|
||||
.user-pp-image {
|
||||
height: 10em;
|
||||
width: 10em;
|
||||
border-radius: 10em;
|
||||
}
|
||||
|
||||
.certification {
|
||||
transform: translate(0, -15%);
|
||||
width: 1.5em;
|
||||
}
|
||||
</style>
|
||||
<link rel="icon" href="./src/img/favicon.ico">
|
||||
<title><?=$title?></title>
|
||||
</head>
|
||||
<body class="body">
|
||||
<header>
|
||||
<div class="pancontent">
|
||||
<div class="athena-container">
|
||||
<a href="<?=$root?>">
|
||||
<img src="./src/img/athena-mono.png" class="athena">
|
||||
</a>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="main-title">
|
||||
<div class="title"><?=$header_title?></div>
|
||||
<div class="subtitle"><?=$header_subtitle?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<nav>
|
||||
<div class="pancontent">
|
||||
<?php nav($nav);?>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div class="status"><?=$status?></div>
|
||||
<?php
|
||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||
$req = $bdd->prepare("SELECT ID, display_name, username, email, role, accreditation, profile_picture FROM users ORDER BY creation_date DESC");
|
||||
$req->execute();
|
||||
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($resultat) {
|
||||
foreach($resultat as $row) {
|
||||
$user_pp = $row['profile_picture'] == NULL ? "https://abs.twimg.com/sticky/default_profile_images/default_profile_400x400.png" : $row['profile_picture'];
|
||||
echo "<div class='user'>";
|
||||
echo "<div class='user-pp'><a href='user.php?user=" . $row['username'] . "'>";
|
||||
echo "<img src='" . $user_pp . "' class='user-pp-image'>";
|
||||
echo "</a></div>";
|
||||
echo "<div class='user-data'>";
|
||||
echo "<div class='user-names'>";
|
||||
echo "<div class='user-display-name'>" . $row['display_name'];
|
||||
if($row['role'] > 1) {
|
||||
echo '<svg class="certification" fill="' . $certif_colors[$row['role']] . '" viewBox="0 0 22 22" aria-label="Compte certifié" role="img"><g><path d="M20.396 11c-.018-.646-.215-1.275-.57-1.816-.354-.54-.852-.972-1.438-1.246.223-.607.27-1.264.14-1.897-.131-.634-.437-1.218-.882-1.687-.47-.445-1.053-.75-1.687-.882-.633-.13-1.29-.083-1.897.14-.273-.587-.704-1.086-1.245-1.44S11.647 1.62 11 1.604c-.646.017-1.273.213-1.813.568s-.969.854-1.24 1.44c-.608-.223-1.267-.272-1.902-.14-.635.13-1.22.436-1.69.882-.445.47-.749 1.055-.878 1.688-.13.633-.08 1.29.144 1.896-.587.274-1.087.705-1.443 1.245-.356.54-.555 1.17-.574 1.817.02.647.218 1.276.574 1.817.356.54.856.972 1.443 1.245-.224.606-.274 1.263-.144 1.896.13.634.433 1.218.877 1.688.47.443 1.054.747 1.687.878.633.132 1.29.084 1.897-.136.274.586.705 1.084 1.246 1.439.54.354 1.17.551 1.816.569.647-.016 1.276-.213 1.817-.567s.972-.854 1.245-1.44c.604.239 1.266.296 1.903.164.636-.132 1.22-.447 1.68-.907.46-.46.776-1.044.908-1.681s.075-1.299-.165-1.903c.586-.274 1.084-.705 1.439-1.246.354-.54.551-1.17.569-1.816zM9.662 14.85l-3.429-3.428 1.293-1.302 2.072 2.072 4.4-4.794 1.347 1.246z"></path></g></svg>';
|
||||
}
|
||||
echo "</div>";
|
||||
echo "<div class='user-username'>@" . $row['username'] . "</div>";
|
||||
echo "</div>";
|
||||
echo "<div class='user-perms'>";
|
||||
echo "<form action='' method='post'>";
|
||||
echo "<div class='perm-div'><select name='accreditation' required>";
|
||||
foreach($classifications as $id => $nom) {
|
||||
if($row['accreditation'] == $id) {
|
||||
echo '<option value="' . $id .'" selected>' . $nom . '</option>';
|
||||
} else {
|
||||
echo '<option value="' . $id .'">' . $nom . '</option>';
|
||||
}
|
||||
}
|
||||
echo "</select>";
|
||||
echo "<select name='role' required>";
|
||||
foreach($roles as $id => $nom) {
|
||||
if($row['role'] == $id) {
|
||||
echo '<option value="' . $id .'" selected>' . $nom . '</option>';
|
||||
} else {
|
||||
echo '<option value="' . $id .'">' . $nom . '</option>';
|
||||
}
|
||||
}
|
||||
echo "</select></div>";
|
||||
echo "<div class='perm-div'><input type='hidden' name='userid' value='" . $row['ID'] . "'><input type='submit' value='Mettre à jour'></div>";
|
||||
echo "</div></form></div></div>";
|
||||
echo "</div>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<div class="content">
|
||||
<div>
|
||||
<div><?=$copyright?></div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
require("../../include/variables.php");
|
||||
require("../../include/functions.php");
|
||||
require("../../include/init.php");
|
||||
require("../../include/main-functions.php");
|
||||
require("../../include/panels.php");
|
||||
|
||||
$pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlDatabasePass);
|
||||
?>
|
||||
|
||||
|
@ -1,6 +1,11 @@
|
||||
<?php
|
||||
require("../../include/variables.php");
|
||||
require("../../include/functions.php");
|
||||
require("../../include/init.php");
|
||||
require("../../include/main-functions.php");
|
||||
require("../../include/objects.php");
|
||||
require("../../include/inputs.php");
|
||||
require("../../include/panels.php");
|
||||
|
||||
$pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlDatabasePass);
|
||||
|
||||
if (isset($_FILES['newPP']) && $_FILES['newPP']['error'] == 0) {
|
||||
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
require("../../include/variables.php");
|
||||
require("../../include/functions.php");
|
||||
require("../../include/init.php");
|
||||
require("../../include/main-functions.php");
|
||||
require("../../include/inputs.php");
|
||||
require("../../include/panels.php");
|
||||
|
||||
if (!isset($_SESSION['userLevel']) || $_SESSION['userLevel'] < 3) {
|
||||
http_response_code(403);
|
||||
|
@ -1,6 +1,10 @@
|
||||
<?php
|
||||
require("../../include/variables.php");
|
||||
require("../../include/functions.php");
|
||||
require("../../include/init.php");
|
||||
require("../../include/main-functions.php");
|
||||
require("../../include/inputs.php");
|
||||
require("../../include/panels.php");
|
||||
|
||||
$pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlDatabasePass);
|
||||
|
||||
if ($_SESSION['level'] < 1) {
|
||||
|
@ -1,6 +1,10 @@
|
||||
<?php
|
||||
require("../include/variables.php");
|
||||
require("../include/functions.php");
|
||||
require("../include/init.php");
|
||||
require("../include/main-functions.php");
|
||||
require("../include/objects.php");
|
||||
require("../include/panels.php");
|
||||
|
||||
$pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlDatabasePass);
|
||||
?>
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
<?php
|
||||
require("../../include/variables.php");
|
||||
require("../../include/functions.php");
|
||||
require("../../include/init.php");
|
||||
require("../../include/main-functions.php");
|
||||
require("../../include/inputs.php");
|
||||
require("../../include/panels.php");
|
||||
|
||||
$pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlDatabasePass);
|
||||
|
||||
if (isset($_SESSION['userID'])) {
|
||||
|
@ -1,6 +1,10 @@
|
||||
<?php
|
||||
require("../../include/variables.php");
|
||||
require("../../include/functions.php");
|
||||
require("../../include/init.php");
|
||||
require("../../include/main-functions.php");
|
||||
require("../../include/inputs.php");
|
||||
require("../../include/panels.php");
|
||||
|
||||
$pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlDatabasePass);
|
||||
|
||||
if (isset($_SESSION['userID'])) {
|
||||
|
@ -1,6 +1,11 @@
|
||||
<?php
|
||||
require("../../include/variables.php");
|
||||
require("../../include/functions.php");
|
||||
require("../../include/init.php");
|
||||
require("../../include/main-functions.php");
|
||||
require("../../include/objects.php");
|
||||
require("../../include/inputs.php");
|
||||
require("../../include/panels.php");
|
||||
|
||||
$pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlDatabasePass);
|
||||
?>
|
||||
|
||||
@ -64,10 +69,6 @@ $pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlData
|
||||
<div class="content">
|
||||
<?php
|
||||
if (isset($_GET['article']) && filter_var($_GET['article'], FILTER_VALIDATE_INT) && file_exists($rootFilePath . 'content/articles/' . $_GET['article'] . '.md')) {
|
||||
$articleMarkdownContent = file_get_contents($rootFilePath . 'content/articles/' . $_GET['article'] . '.md');
|
||||
|
||||
require_once '../../include/parsedown.php';
|
||||
$parsedown = new Parsedown();
|
||||
|
||||
$sqlRequest = "SELECT articles.ID, articles.title, articles.date, articles.miniature, articles.resume, articles.author, users.username, users.display_name, users.certification, users.profile_picture FROM articles JOIN users ON articles.author = users.ID WHERE articles.ID = :articleID AND (articles.classification <= :userAccreditation OR articles.author = :userID)";
|
||||
$request = $pdo->prepare($sqlRequest);
|
||||
@ -105,7 +106,9 @@ $pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlData
|
||||
echo ('</div>');
|
||||
|
||||
echo ('<div class="article-content">');
|
||||
echo ($parsedown->text($articleMarkdownContent));
|
||||
$pageContent = markdownContent($rootFilePath . 'content/articles/' . $articleID . '.md', $rootFilePath);
|
||||
|
||||
echo($pageContent);
|
||||
echo ('</div>');
|
||||
|
||||
echo ('</div>');
|
||||
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
require("../../include/variables.php");
|
||||
require("../../include/functions.php");
|
||||
require("../../include/init.php");
|
||||
require("../../include/main-functions.php");
|
||||
require("../../include/panels.php");
|
||||
|
||||
$pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlDatabasePass);
|
||||
|
||||
if (!isset($_SESSION['userID'])) {
|
||||
|
@ -1,6 +1,10 @@
|
||||
<?php
|
||||
require("../../include/variables.php");
|
||||
require("../../include/functions.php");
|
||||
require("../../include/init.php");
|
||||
require("../../include/main-functions.php");
|
||||
require("../../include/inputs.php");
|
||||
require("../../include/panels.php");
|
||||
|
||||
$pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlDatabasePass);
|
||||
|
||||
if (!isset($_SESSION['userID'])) {
|
||||
|
@ -1,6 +1,10 @@
|
||||
<?php
|
||||
require("../../include/variables.php");
|
||||
require("../../include/functions.php");
|
||||
require("../../include/init.php");
|
||||
require("../../include/main-functions.php");
|
||||
require("../../include/inputs.php");
|
||||
require("../../include/panels.php");
|
||||
|
||||
$pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlDatabasePass);
|
||||
|
||||
if ($_SESSION['level'] < 1) {
|
||||
|
@ -1,6 +1,10 @@
|
||||
<?php
|
||||
require("../../include/variables.php");
|
||||
require("../../include/functions.php");
|
||||
require("../../include/init.php");
|
||||
require("../../include/main-functions.php");
|
||||
require("../../include/objects.php");
|
||||
require("../../include/panels.php");
|
||||
|
||||
$pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlDatabasePass);
|
||||
|
||||
if(isset($_GET['u']) && empty($_GET['u']) == false) {
|
||||
|
@ -1 +0,0 @@
|
||||
<div class="error-message"><span><?=$e->getMessage();?></span></div>
|
@ -1,217 +0,0 @@
|
||||
<?php // Functions
|
||||
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['userID'])) {
|
||||
$_SESSION['userAccreditation'] = 0;
|
||||
$_SESSION['userLevel'] = 0;
|
||||
}
|
||||
|
||||
if (!isset($_COOKIE['theme'])) {
|
||||
setcookie('theme', 0, time()+10*60*60);
|
||||
$darkTheme = $darkThemes[0];
|
||||
$lightTheme = $lightThemes[0];
|
||||
}
|
||||
|
||||
if (isset($_GET['theme'])) {
|
||||
$newTheme = (int)$_GET['theme'] % 2;
|
||||
setcookie('theme', $newTheme); // % 2 => Number of different themes
|
||||
$darkTheme = $darkThemes[$newTheme];
|
||||
$lightTHeme = $lightThemes[$newTheme];
|
||||
|
||||
} else if (isset($_COOKIE['theme'])) {
|
||||
$theme = (int)$_COOKIE['theme'] % 2;
|
||||
$darkTheme = $darkThemes[$theme];
|
||||
$lightTheme = $lightThemes[$theme];
|
||||
}
|
||||
|
||||
$status = "";
|
||||
|
||||
function markdownContent($filePath, $rootFilePath) {
|
||||
$markdownContent = file_get_contents($filePath);
|
||||
require_once $rootFilePath . 'include/parsedown.php';
|
||||
$parsedown = new Parsedown();
|
||||
return $parsedown->text($markdownContent);
|
||||
}
|
||||
|
||||
function fillHead($rootPageURL, $pageTitle, $darkTheme, $lightTheme) {
|
||||
|
||||
echo ('<meta charset="UTF-8">');
|
||||
echo ('<meta name="viewport" content="width=device-width, initial-scale=1.0">');
|
||||
echo ('<link rel="stylesheet" href="' . $rootPageURL . 'src/css/style.css">');
|
||||
echo ('<link rel="icon" href="' . $rootPageURL . 'src/img/favicon.ico">');
|
||||
|
||||
echo ('<style>');
|
||||
|
||||
echo ('@media (prefers-color-scheme: dark) {');
|
||||
echo ('.body {');
|
||||
echo ($darkTheme);
|
||||
echo ('}');
|
||||
echo ('}');
|
||||
|
||||
echo ('@media (prefers-color-scheme: light) {');
|
||||
echo ('.body {');
|
||||
echo ($lightTheme);
|
||||
echo ('}');
|
||||
echo ('}');
|
||||
|
||||
echo ('</style>');
|
||||
|
||||
echo ('<title>' . $pageTitle . '</title>');
|
||||
}
|
||||
|
||||
function fillHeader($rootPageURL, $headerTitle, $headerSubtitle) {
|
||||
|
||||
echo ('<div class="logo-container">');
|
||||
|
||||
echo ('<a href="' . $rootPageURL . '">');
|
||||
echo ('<img src="' . $rootPageURL . 'src/img/athena-mono.png" class="logo-img">');
|
||||
echo ('</a>');
|
||||
|
||||
echo ('</div>');
|
||||
|
||||
echo ('<div class="content">');
|
||||
|
||||
echo ('<div class="header-title-container">');
|
||||
echo ('<div class="header-title">' . $headerTitle . '</div>');
|
||||
echo ('<div class="header-subtitle">' . $headerSubtitle . '</div>');
|
||||
echo ('</div>');
|
||||
|
||||
echo ('</div>');
|
||||
}
|
||||
|
||||
function fillNav($rootPageURL) {
|
||||
|
||||
echo ('<a href="' . $rootPageURL . 'news"><div class="nav-link">News</div></a>');
|
||||
echo ('<a href="' . $rootPageURL . 'about"><div class="nav-link">A propos</div></a>');
|
||||
|
||||
if ($_SESSION['userLevel'] >= 3) {
|
||||
echo ('<a href="' . $rootPageURL . 'admin"><div class="nav-link">Admin</div></a>');
|
||||
}
|
||||
|
||||
if(isset($_SESSION['userID'])) {
|
||||
echo ('<a href="' . $rootPageURL . 'account"><div class="nav-link">Profil</div></a>');
|
||||
echo ('<a href="' . $rootPageURL . 'settings"><div class="nav-link">Options</div></a>');
|
||||
echo ('<a href="' . $rootPageURL . 'login/logout.php"><div class="nav-link">Déconnexion</div></a>');
|
||||
} else {
|
||||
echo ('<a href="' . $rootPageURL . 'login"><div class="nav-link">Se connecter</div></a>');
|
||||
}
|
||||
}
|
||||
|
||||
function fillFooter($footerText) {
|
||||
echo($footerText);
|
||||
}
|
||||
|
||||
function sqlConnect($dbHost, $dbName, $dbUser, $dbPass) {
|
||||
try {
|
||||
$pdo = new PDO('mysql:host=' . $dbHost . ';dbname=' . $dbName . ';charset=UTF8mb4', $dbUser, $dbPass);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
} catch(Exception $e) {
|
||||
require('error.php');
|
||||
die();
|
||||
}
|
||||
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
function userWidget($userPPURL, $userDisplayName, $userName, $userCertification, $badges, $rootPageURL) {
|
||||
|
||||
echo ('<a href="' . $rootPageURL . 'users?u=' . $userName . '" class="user-widget-link">');
|
||||
echo ('<div class="user-widget">');
|
||||
|
||||
echo ('<div class="user-pp">');
|
||||
echo ('<img src="' . $userPPURL . '">');
|
||||
echo ('</div>');
|
||||
|
||||
echo ('<div class="user-info">');
|
||||
|
||||
echo ('<div class="user-display-name">');
|
||||
echo ($userDisplayName);
|
||||
if ($userCertification > 0) {
|
||||
echo ('<svg class="certification" viewBox="0 0 22 22" aria-label="Compte certifié" role="img">');
|
||||
echo ('<g>' . $badges[$userCertification] . '</g>');
|
||||
echo ('</svg>');
|
||||
}
|
||||
echo ('</div>');
|
||||
|
||||
echo ('<div class="user-name">@' . $userName . '</div>');
|
||||
|
||||
echo ('</div>');
|
||||
|
||||
echo ('</div>');
|
||||
echo ('</a>');
|
||||
}
|
||||
|
||||
function listArticles($result, $rootPageURL) {
|
||||
|
||||
foreach($result as $article) {
|
||||
$pubDateTime = strtotime($article['date']);
|
||||
$pubDate = date('d/m/Y', $pubDateTime);
|
||||
$articleID = $article['ID'];
|
||||
$articleTitle = $article['title'];
|
||||
$articleResume = $article['resume'];
|
||||
$miniatureURL = empty($article['miniature']) ? $rootPageURL . "src/img/empty.jpg" : $article['miniature'];
|
||||
if(isset($article['username']) && isset($article['display_name'])) {
|
||||
$authorLink = ' | <a href="user.php?user=' . $article['username'] . '">' . $article['display_name'] . '</a>';
|
||||
} else {
|
||||
$authorLink = '';
|
||||
}
|
||||
|
||||
echo('<div class="article-preview">');
|
||||
|
||||
echo('<a href="'. $rootPageURL .'news?article=' . $articleID . '" class="article-link">');
|
||||
echo('<div class="article-illustration">');
|
||||
|
||||
echo('<img src="' . $miniatureURL . '" class="article-miniature">');
|
||||
|
||||
echo('</div>');
|
||||
echo('</a>');
|
||||
|
||||
echo('<div class="article-info">');
|
||||
echo('<div class="article-data">n° ' . $articleID . ' | ' . $pubDate . '</div>');
|
||||
|
||||
echo('<a href="'. $rootPageURL .'news?article=' . $articleID . '" class="article-link">');
|
||||
echo('<div class="article-title">' . $articleTitle . '</div>');
|
||||
echo('</a>');
|
||||
|
||||
echo('<div class="article-resume">' . $articleResume . '</div>');
|
||||
|
||||
echo('</div>');
|
||||
echo('</div> ');
|
||||
}
|
||||
}
|
||||
|
||||
function textInput($type, $shapePath, $name, $placeholder, $value) {
|
||||
|
||||
echo ('<div class="text-input">');
|
||||
echo ('<label for="' . $name . '">');
|
||||
echo ('<svg viewBox="0 0 24 24" aria-hidden="true" class="input-icon">');
|
||||
echo ('<g>' . $shapePath . '</g>');
|
||||
echo ('</svg>');
|
||||
echo ('</label>');
|
||||
echo ('<input type="' . $type . '" placeholder="' . $placeholder . '" name="' . $name . '" value="' . $value . '">');
|
||||
echo ('</div>');
|
||||
}
|
||||
|
||||
function fileInput($name) {
|
||||
echo ('<div class="file-input">');
|
||||
echo ('<input type="file" name="' . $name . '">');
|
||||
echo ('</div>');
|
||||
}
|
||||
|
||||
function selectInput($name, $label, $options, $defaultValue) {
|
||||
echo('<div class="select-input">');
|
||||
echo('<label for="' . $name . '">' . $label . '</label>');
|
||||
echo('<select name="' . $name .'" required>');
|
||||
|
||||
foreach($options as $value => $name) {
|
||||
$selectStatus = $value == $defaultValue ? "selected" : "";
|
||||
echo ('<option value="' . $value .'" ' . $selectStatus . '>' . $name . '</option>');
|
||||
}
|
||||
|
||||
echo('</select>');
|
||||
echo('</div>');
|
||||
}
|
||||
|
||||
?>
|
30
include/init.php
Normal file
30
include/init.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['userID'])) {
|
||||
$_SESSION['userAccreditation'] = 0;
|
||||
$_SESSION['userLevel'] = 0;
|
||||
}
|
||||
|
||||
if (!isset($_COOKIE['theme'])) {
|
||||
setcookie('theme', 0, time()+10*60*60);
|
||||
$darkTheme = $darkThemes[0];
|
||||
$lightTheme = $lightThemes[0];
|
||||
}
|
||||
|
||||
if (isset($_GET['theme'])) {
|
||||
$newTheme = (int)$_GET['theme'] % 2;
|
||||
setcookie('theme', $newTheme); // % 2 => Number of different themes
|
||||
$darkTheme = $darkThemes[$newTheme];
|
||||
$lightTHeme = $lightThemes[$newTheme];
|
||||
|
||||
} else if (isset($_COOKIE['theme'])) {
|
||||
$theme = (int)$_COOKIE['theme'] % 2;
|
||||
$darkTheme = $darkThemes[$theme];
|
||||
$lightTheme = $lightThemes[$theme];
|
||||
}
|
||||
|
||||
$status = "";
|
||||
|
||||
?>
|
33
include/inputs.php
Normal file
33
include/inputs.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
function textInput($type, $shapePath, $name, $placeholder, $value) {
|
||||
|
||||
echo ('<div class="text-input">');
|
||||
echo ('<label for="' . $name . '">');
|
||||
echo ('<svg viewBox="0 0 24 24" aria-hidden="true" class="input-icon">');
|
||||
echo ('<g>' . $shapePath . '</g>');
|
||||
echo ('</svg>');
|
||||
echo ('</label>');
|
||||
echo ('<input type="' . $type . '" placeholder="' . $placeholder . '" name="' . $name . '" value="' . $value . '">');
|
||||
echo ('</div>');
|
||||
}
|
||||
|
||||
function fileInput($name) {
|
||||
echo ('<div class="file-input">');
|
||||
echo ('<input type="file" name="' . $name . '">');
|
||||
echo ('</div>');
|
||||
}
|
||||
|
||||
function selectInput($name, $label, $options, $defaultValue) {
|
||||
echo('<div class="select-input">');
|
||||
echo('<label for="' . $name . '">' . $label . '</label>');
|
||||
echo('<select name="' . $name .'" required>');
|
||||
|
||||
foreach($options as $value => $name) {
|
||||
$selectStatus = $value == $defaultValue ? "selected" : "";
|
||||
echo ('<option value="' . $value .'" ' . $selectStatus . '>' . $name . '</option>');
|
||||
}
|
||||
|
||||
echo('</select>');
|
||||
echo('</div>');
|
||||
}
|
||||
?>
|
21
include/main-functions.php
Executable file
21
include/main-functions.php
Executable file
@ -0,0 +1,21 @@
|
||||
<?php // Functions
|
||||
|
||||
function markdownContent($filePath, $rootFilePath) {
|
||||
$markdownContent = file_get_contents($filePath);
|
||||
require_once $rootFilePath . 'include/parsedown.php';
|
||||
$parsedown = new Parsedown();
|
||||
return $parsedown->text($markdownContent);
|
||||
}
|
||||
|
||||
function sqlConnect($dbHost, $dbName, $dbUser, $dbPass) {
|
||||
try {
|
||||
$pdo = new PDO('mysql:host=' . $dbHost . ';dbname=' . $dbName . ';charset=UTF8mb4', $dbUser, $dbPass);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
} catch(Exception $e) {
|
||||
die('<div class="error-message"><span><?=$e->getMessage();?></span></div>');
|
||||
}
|
||||
|
||||
return $pdo;
|
||||
}
|
||||
?>
|
72
include/objects.php
Normal file
72
include/objects.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
function userWidget($userPPURL, $userDisplayName, $userName, $userCertification, $badges, $rootPageURL) {
|
||||
|
||||
echo ('<a href="' . $rootPageURL . 'users?u=' . $userName . '" class="user-widget-link">');
|
||||
echo ('<div class="user-widget">');
|
||||
|
||||
echo ('<div class="user-pp">');
|
||||
echo ('<img src="' . $userPPURL . '">');
|
||||
echo ('</div>');
|
||||
|
||||
echo ('<div class="user-info">');
|
||||
|
||||
echo ('<div class="user-display-name">');
|
||||
echo ($userDisplayName);
|
||||
if ($userCertification > 0) {
|
||||
echo ('<svg class="certification" viewBox="0 0 22 22" aria-label="Compte certifié" role="img">');
|
||||
echo ('<g>' . $badges[$userCertification] . '</g>');
|
||||
echo ('</svg>');
|
||||
}
|
||||
echo ('</div>');
|
||||
|
||||
echo ('<div class="user-name">@' . $userName . '</div>');
|
||||
|
||||
echo ('</div>');
|
||||
|
||||
echo ('</div>');
|
||||
echo ('</a>');
|
||||
}
|
||||
|
||||
|
||||
function listArticles($result, $rootPageURL) {
|
||||
|
||||
foreach($result as $article) {
|
||||
|
||||
$pubDateTime = strtotime($article['date']);
|
||||
$pubDate = date('d/m/Y', $pubDateTime);
|
||||
$articleID = $article['ID'];
|
||||
$articleTitle = $article['title'];
|
||||
$articleResume = $article['resume'];
|
||||
$miniatureURL = empty($article['miniature']) ? $rootPageURL . "src/img/empty.jpg" : $article['miniature'];
|
||||
if(isset($article['username']) && isset($article['display_name'])) {
|
||||
$authorLink = ' | <a href="user.php?user=' . $article['username'] . '">' . $article['display_name'] . '</a>';
|
||||
} else {
|
||||
$authorLink = '';
|
||||
}
|
||||
|
||||
echo('<div class="article-preview">');
|
||||
|
||||
echo('<a href="'. $rootPageURL .'news?article=' . $articleID . '" class="article-link">');
|
||||
echo('<div class="article-illustration">');
|
||||
|
||||
echo('<img src="' . $miniatureURL . '" class="article-miniature">');
|
||||
|
||||
echo('</div>');
|
||||
echo('</a>');
|
||||
|
||||
echo('<div class="article-info">');
|
||||
echo('<div class="article-data">n° ' . $articleID . ' | ' . $pubDate . '</div>');
|
||||
|
||||
echo('<a href="'. $rootPageURL .'news?article=' . $articleID . '" class="article-link">');
|
||||
echo('<div class="article-title">' . $articleTitle . '</div>');
|
||||
echo('</a>');
|
||||
|
||||
echo('<div class="article-resume">' . $articleResume . '</div>');
|
||||
|
||||
echo('</div>');
|
||||
echo('</div> ');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
74
include/panels.php
Normal file
74
include/panels.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?
|
||||
|
||||
function fillHead($rootPageURL, $pageTitle, $darkTheme, $lightTheme) {
|
||||
|
||||
echo ('<meta charset="UTF-8">');
|
||||
echo ('<meta name="viewport" content="width=device-width, initial-scale=1.0">');
|
||||
echo ('<link rel="stylesheet" href="' . $rootPageURL . 'src/css/style.css">');
|
||||
echo ('<link rel="icon" href="' . $rootPageURL . 'src/img/favicon.ico">');
|
||||
|
||||
echo ('<style>');
|
||||
|
||||
echo ('@media (prefers-color-scheme: dark) {');
|
||||
echo ('.body {');
|
||||
echo ($darkTheme);
|
||||
echo ('}');
|
||||
echo ('}');
|
||||
|
||||
echo ('@media (prefers-color-scheme: light) {');
|
||||
echo ('.body {');
|
||||
echo ($lightTheme);
|
||||
echo ('}');
|
||||
echo ('}');
|
||||
|
||||
echo ('</style>');
|
||||
|
||||
echo ('<title>' . $pageTitle . '</title>');
|
||||
}
|
||||
|
||||
|
||||
function fillHeader($rootPageURL, $headerTitle, $headerSubtitle) {
|
||||
|
||||
echo ('<div class="logo-container">');
|
||||
|
||||
echo ('<a href="' . $rootPageURL . '">');
|
||||
echo ('<img src="' . $rootPageURL . 'src/img/athena-mono.png" class="logo-img">');
|
||||
echo ('</a>');
|
||||
|
||||
echo ('</div>');
|
||||
|
||||
echo ('<div class="content">');
|
||||
|
||||
echo ('<div class="header-title-container">');
|
||||
echo ('<div class="header-title">' . $headerTitle . '</div>');
|
||||
echo ('<div class="header-subtitle">' . $headerSubtitle . '</div>');
|
||||
echo ('</div>');
|
||||
|
||||
echo ('</div>');
|
||||
}
|
||||
|
||||
|
||||
function fillNav($rootPageURL) {
|
||||
|
||||
echo ('<a href="' . $rootPageURL . 'news"><div class="nav-link">News</div></a>');
|
||||
echo ('<a href="' . $rootPageURL . 'about"><div class="nav-link">A propos</div></a>');
|
||||
|
||||
if ($_SESSION['userLevel'] >= 3) {
|
||||
echo ('<a href="' . $rootPageURL . 'admin"><div class="nav-link">Admin</div></a>');
|
||||
}
|
||||
|
||||
if(isset($_SESSION['userID'])) {
|
||||
echo ('<a href="' . $rootPageURL . 'account"><div class="nav-link">Profil</div></a>');
|
||||
echo ('<a href="' . $rootPageURL . 'settings"><div class="nav-link">Options</div></a>');
|
||||
echo ('<a href="' . $rootPageURL . 'login/logout.php"><div class="nav-link">Déconnexion</div></a>');
|
||||
} else {
|
||||
echo ('<a href="' . $rootPageURL . 'login"><div class="nav-link">Se connecter</div></a>');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function fillFooter($footerText) {
|
||||
echo($footerText);
|
||||
}
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user