From 42a261dd2d6b7abf440e3b21d2f2357043bcaece Mon Sep 17 00:00:00 2001 From: cbo Date: Sat, 9 Mar 2024 17:38:09 +0100 Subject: [PATCH] =?UTF-8?q?Derni=C3=A8re=20correction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/global.ini | 4 +- content/about.md | 11 +++++ content/admin.md | 2 + content/index.md | 5 ++- content/journal/198183.md | 9 ++++ database/E59.sql | 88 ++++++++++++++++++++++++++++++++++++ html/about.php | 4 +- html/admin.php | 4 +- html/compte.php | 4 +- html/editpage.php | 93 +++++++++++++++++++-------------------- html/index.php | 4 +- html/login.php | 4 +- html/news.php | 10 ++--- html/register.php | 4 +- html/upload.php | 19 ++++---- html/users.php | 4 +- include/functions.php | 10 ++++- include/variables.php | 3 ++ 18 files changed, 203 insertions(+), 79 deletions(-) create mode 100644 content/journal/198183.md create mode 100644 database/E59.sql diff --git a/config/global.ini b/config/global.ini index 8690bc28..2224e667 100644 --- a/config/global.ini +++ b/config/global.ini @@ -1,4 +1,6 @@ [main] +root = "http://127.0.0.1/e59.fr/e59-website/html" +wwwroot = "C:\\xampp\\htdocs\\e59.fr\\e59-website" title = "Club Réseaux" header-title = "E59" header-subtitle = "Club Réseaux" @@ -7,7 +9,7 @@ copyright = "© Jan BELLON - E59" [sql] dbname = "E59" dbuser = "root" -dbpass = "vcwfDitW9tQBsRJX" +dbpass = "" ; vcwfDitW9tQBsRJX dbhost = "127.0.0.1" [nav] diff --git a/content/about.md b/content/about.md index e69de29b..05eb8cc0 100644 --- a/content/about.md +++ b/content/about.md @@ -0,0 +1,11 @@ +# Utilisation des données
+
+Seuls les cookies nécessaires au bon fonctionnement du site sont stockés sur la machine de l'utilisateur.
+
+Il est possible de supprimer votre compte et toutes les données associées dans [compte.php](compte.php)
+
+###Liste des données personnelles stockées :
+- Nom d'utilisateur
+- E-mail
+- Mot de passe chiffré
+- Adresse IP \ No newline at end of file diff --git a/content/admin.md b/content/admin.md index e69de29b..c38c5a85 100644 --- a/content/admin.md +++ b/content/admin.md @@ -0,0 +1,2 @@ +# Panneau d'administration +
Publier un article
Editer une page
Utilisateurs
\ No newline at end of file diff --git a/content/index.md b/content/index.md index b6b57969..991d51c2 100644 --- a/content/index.md +++ b/content/index.md @@ -1 +1,4 @@ -# Bienvenue cher visiteur ! \ No newline at end of file +#Bienvenue sur le site e59.fr
+##Ce site est la presse du Club Réseaux - E59.
+###Consulter les dernières infos :
+Pour nous contacter, envoyez un mail à [bod@intra.e59.fr](mailto:bod@intra.e59.fr) \ No newline at end of file diff --git a/content/journal/198183.md b/content/journal/198183.md new file mode 100644 index 00000000..8a4dee2b --- /dev/null +++ b/content/journal/198183.md @@ -0,0 +1,9 @@ +# Changelog update 1.0 + +- Creation de compte dans register.php +- Classification confidentielle des articles +- Publication d'articles en langage MarkDown +- Mise à jour des informations de compte +- Suppression de compte +- Préférences de thème couleur +- Adaptation du mode clair/sombre en fonction du navigateur \ No newline at end of file diff --git a/database/E59.sql b/database/E59.sql new file mode 100644 index 00000000..c9e61d28 --- /dev/null +++ b/database/E59.sql @@ -0,0 +1,88 @@ +-- phpMyAdmin SQL Dump +-- version 5.2.1 +-- https://www.phpmyadmin.net/ +-- +-- Host: localhost +-- Generation Time: Mar 09, 2024 at 03:55 PM +-- Server version: 10.5.23-MariaDB-0+deb11u1 +-- PHP Version: 7.4.33 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + +-- +-- Database: `E59` +-- + +-- -------------------------------------------------------- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `articles` +-- + +CREATE TABLE `articles` ( + `ID` int(12) NOT NULL, + `titre` varchar(255) NOT NULL, + `date` datetime NOT NULL DEFAULT current_timestamp(), + `auteur` varchar(255) NOT NULL, + `classification` int(12) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `ID` int(11) NOT NULL, + `username` varchar(255) NOT NULL, + `password` varchar(255) NOT NULL, + `email` varchar(255) DEFAULT NULL, + `creation_date` datetime NOT NULL DEFAULT current_timestamp(), + `display_name` varchar(255) DEFAULT 'Unnamed', + `role` int(12) NOT NULL, + `accreditation` int(12) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `admins` +-- +ALTER TABLE `admins` + ADD PRIMARY KEY (`ID`); + +-- +-- Indexes for table `articles` +-- +ALTER TABLE `articles` + ADD PRIMARY KEY (`ID`); + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`ID`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `admins` +-- +ALTER TABLE `admins` + MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT; +COMMIT; diff --git a/html/about.php b/html/about.php index 08e90347..e839e4ef 100644 --- a/html/about.php +++ b/html/about.php @@ -21,14 +21,14 @@ require "../include/functions.php"; } } - + <?=$title?>
diff --git a/html/admin.php b/html/admin.php index bfca2f0e..15fe175a 100644 --- a/html/admin.php +++ b/html/admin.php @@ -27,14 +27,14 @@ if($_SESSION['role'] < 3) { } } - + <?=$title?>
diff --git a/html/compte.php b/html/compte.php index 66949771..cb843795 100644 --- a/html/compte.php +++ b/html/compte.php @@ -79,14 +79,14 @@ if(isset($_POST['delete_account'])) { } - + <?=$title?>
diff --git a/html/editpage.php b/html/editpage.php index f355ca26..5d182afd 100644 --- a/html/editpage.php +++ b/html/editpage.php @@ -13,24 +13,24 @@ $filetypes = [ 1 => "page" ]; -$repertoire = "/var/www/e59/"; - if(isset($_GET['article']) && filter_var($_GET['article'], FILTER_VALIDATE_INT)) { - if(file_exists($repertoire . "content/journal/" . $_GET['article'] . ".md")){ - $fichier = $repertoire . "content/journal/" . $_GET['article'] . ".md"; + 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) { - if(file_exists($repertoire . "content/" . $_GET['page'] . ".md")){ - $fichier = $repertoire . "content/" . $_GET['page'] . ".md"; + if(file_exists($wwwroot . "/content/" . $_GET['page'] . ".md")){ + $fichier = $wwwroot . "/content/" . $_GET['page'] . ".md"; $filename = $_GET['page']; $filetype = 1; } } +$filename = isset($filename) ? $filename : ""; + if(isset($fichier)) { if(isset($_GET['article']) && isset($_POST['deletefile']) && $_POST['deletefile'] == "Supprimer") { if(unlink($fichier)) { @@ -73,7 +73,7 @@ if(isset($fichier)) { } } - + <?=$title?> - + <?=$title?>
diff --git a/html/login.php b/html/login.php index 18852d94..bef1831e 100644 --- a/html/login.php +++ b/html/login.php @@ -52,14 +52,14 @@ if(isset($_POST['username']) && isset($_POST['password'])) { } } - + <?=$title?>
diff --git a/html/news.php b/html/news.php index 3a7ac545..217a9107 100644 --- a/html/news.php +++ b/html/news.php @@ -2,7 +2,7 @@ require "../include/variables.php"; require "../include/functions.php"; -if (filter_var($_GET['article'], FILTER_VALIDATE_INT)) { +if (isset($_GET['article']) && filter_var($_GET['article'], FILTER_VALIDATE_INT)) { $article = $_GET['article']; } else { $article = ""; @@ -26,14 +26,14 @@ if (filter_var($_GET['article'], FILTER_VALIDATE_INT)) { } } - + <?=$title?>
@@ -80,8 +80,8 @@ if (filter_var($_GET['article'], FILTER_VALIDATE_INT)) { } else { echo "Aucun article trouvé"; } - } else if (!isset($_GET['search']) && $article != "" && file_exists('/var/www/e59/content/journal/' . $article . '.md')) { - $markdownContent = file_get_contents('/var/www/e59/content/journal/' . $article . '.md'); + } 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(); diff --git a/html/register.php b/html/register.php index 58f506de..c86291c9 100644 --- a/html/register.php +++ b/html/register.php @@ -52,14 +52,14 @@ if(isset($_POST['username']) && isset($_POST['password']) && isset($_POST['passw } } - + <?=$title?>
diff --git a/html/upload.php b/html/upload.php index 54c98efd..1e4fcdbe 100644 --- a/html/upload.php +++ b/html/upload.php @@ -2,20 +2,20 @@ require "../include/variables.php"; require "../include/functions.php"; -$repertoire = "/var/www/e59/"; - if($_SESSION['role'] < 3) { header("Location: login.php"); http_response_code(404); die(); } -if(isset($_POST['page-content'])) { +$filename = rand(100000, 999999); + +while(file_exists($wwwroot . "/content/journal/" . $filename . ".md")) { $filename = rand(100000, 999999); - while(file_exists($repertoire . "content/journal/" . $filename . ".md")) { - $filename = rand(100000, 999999); - } - file_put_contents($repertoire . "content/journal/" . $filename . ".md", nl2br($_POST['page-content'])); +} + +if(isset($_POST['page-content'])) { + file_put_contents($wwwroot . "/content/journal/" . $filename . ".md", nl2br($_POST['page-content'])); $bdd = connect($dbhost, $dbname, $dbuser, $dbpass); $upload = $bdd->prepare("INSERT INTO articles (ID, titre, auteur, classification) VALUES (:filename, :titre, :auteur, :classification)"); @@ -31,6 +31,7 @@ if(isset($_POST['page-content'])) { header("Location: editpage.php?article=" . $filename); exit(); } + ?> @@ -50,7 +51,7 @@ if(isset($_POST['page-content'])) { } } - + <?=$title?> - + <?=$title?>
diff --git a/include/functions.php b/include/functions.php index 2b2a5a95..f2087282 100644 --- a/include/functions.php +++ b/include/functions.php @@ -9,11 +9,17 @@ if(!isset($_SESSION['role'])) { $_SESSION['role'] = 0; } +if(!isset($_COOKIE['theme'])) { + setcookie('theme', 0, time()+10*60*60); + $theme_dark = $themes_dark[0]; + $theme_light = $themes_light[0]; +} + if(isset($_GET['theme'])) { - setcookie('theme', (int)$_GET['theme'] % 2, time()+10*60*60); + setcookie('theme', (int)$_GET['theme'] % 2); $theme_dark = $themes_dark[$_GET['theme']]; $theme_light = $themes_light[$_GET['theme']]; -} else { +} else if(isset($_COOKIE['theme'])){ $theme_dark = $themes_dark[$_COOKIE['theme']]; $theme_light = $themes_light[$_COOKIE['theme']]; } diff --git a/include/variables.php b/include/variables.php index e3b2b11b..e1352ef4 100644 --- a/include/variables.php +++ b/include/variables.php @@ -6,6 +6,9 @@ $dbpass = $config['sql']['dbpass']; $dbname = $config['sql']['dbname']; $dbhost = $config['sql']['dbhost']; +$root = $config['main']['root']; +$wwwroot = $config['main']['wwwroot']; + $title = $config['main']['title']; $header_title = $config['main']['header-title']; $header_subtitle = $config['main']['header-subtitle'];