diff --git a/config/global.ini b/config/global.ini index 743c2efe..6f072131 100644 --- a/config/global.ini +++ b/config/global.ini @@ -1,41 +1,39 @@ -[main] -root = "https://e59.fr" -wwwroot = "/var/www/e59" -title = "Club Réseaux" -header-title = "E59" -header-subtitle = "Club Réseaux" -copyright = "© Jan BELLON - E59" +[root] +pageURL = "https://e59.fr/" +filePath = "/var/www/e59/" [sql] -dbname = "" -dbuser = "" -dbpass = "" -dbhost = "127.0.0.1" +databaseName = "E59" +databaseUser = "" +databasePass = "" +databaseHost = "127.0.0.1" -[nav] -News = "news.php" -A propos = "about.php" +[main] +pageTitle = "E59" +headerTitle = "E59" +headerSubtitle = "Club Réseaux" +footerText = "© Jan BELLON - E59 v1.2" -[classifications] +[confidentialLevels] 0 = "E59i-P (Public)" 1 = "E59i-M (Membres)" 2 = "E59i-R (Responsables)" 3 = "E59i-D (Direction)" -[roles] +[userLevels] 0 = "Invité" 1 = "Membre" 2 = "Responsable" 3 = "Directeur" -[themes_dark] -0 = '--text: hsl(0, 0%, 80%);--background: hsl(0, 0%, 15%);--banner-background: hsl(0, 0%, 10%);--buttons: hsl(0, 0%, 5%)' -1 = '--text: hsl(208, 100%, 96%); --background: hsl(215, 21%, 11%); --banner-background: hsl(216, 28%, 7%); --buttons: hsl(216, 28%, 7%)' - -[themes_light] -0 = '--text: hsl(0, 0%, 20%);--background: hsl(0, 0%, 100%);--banner-background: hsl(0, 0%, 100%);--buttons: hsl(0, 0%, 100%)' -1 = '--text: hsl(208, 100%, 0%); --background: hsl(215, 21%, 100%); --banner-background: hsl(216, 28%, 95%); --buttons: hsl(216, 28%, 95%)' - -[certifcolors] +[certificationColors] 2 = "#1d9bf0" -3 = "#e3ba1f" \ No newline at end of file +3 = "#e3ba1f" + +[darkThemes] +0 = '--text: hsl(0, 0%, 80%);--background: hsl(0, 0%, 15%);--panel-background: hsl(0, 0%, 10%);--buttons: hsl(0, 0%, 5%)' +1 = '--text: hsl(208, 100%, 96%); --background: hsl(215, 21%, 11%); --panel-background: hsl(216, 28%, 7%); --buttons: hsl(216, 28%, 7%)' + +[lightThemes] +0 = '--text: hsl(0, 0%, 20%);--background: hsl(0, 0%, 100%);--panel-background: hsl(0, 0%, 100%);--buttons: hsl(0, 0%, 100%)' +1 = '--text: hsl(208, 100%, 0%); --background: hsl(215, 21%, 100%); --panel-background: hsl(216, 28%, 95%); --buttons: hsl(216, 28%, 95%)' diff --git a/content/journal/0.md b/content/articles/0.md similarity index 100% rename from content/journal/0.md rename to content/articles/0.md diff --git a/content/journal/198183.md b/content/articles/198183.md similarity index 100% rename from content/journal/198183.md rename to content/articles/198183.md diff --git a/content/about.md b/content/pages/about.md similarity index 100% rename from content/about.md rename to content/pages/about.md diff --git a/content/admin.md b/content/pages/admin.md similarity index 100% rename from content/admin.md rename to content/pages/admin.md diff --git a/content/index.md b/content/pages/index.md similarity index 100% rename from content/index.md rename to content/pages/index.md diff --git a/html/about.php b/html-old/about.php similarity index 100% rename from html/about.php rename to html-old/about.php diff --git a/html/admin.php b/html-old/admin.php similarity index 100% rename from html/admin.php rename to html-old/admin.php diff --git a/html/compte.php b/html-old/compte.php similarity index 100% rename from html/compte.php rename to html-old/compte.php diff --git a/html/editpage.php b/html-old/editpage.php similarity index 100% rename from html/editpage.php rename to html-old/editpage.php diff --git a/html-old/index.php b/html-old/index.php new file mode 100644 index 00000000..af4d0fec --- /dev/null +++ b/html-old/index.php @@ -0,0 +1,98 @@ + + + + + + + + + + <?=$title?> + + +
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ text($markdownContent); + ?> +
+
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 '
'; + echo '
'; + echo ''; + echo '
'; + echo '
'; + echo '
n° ' . $row['ID'] . ' | ' . date('d/m/Y', $date) . ' | '. '' . $row['display_name'] . '
'; + echo ''; + echo '
' . $row['titre'] . '
'; + echo '
'; + echo '
' . $row['resume'] . '
'; + echo '
'; + echo '
'; + } + ?> +
+
+
+
+ + + \ No newline at end of file diff --git a/html/login.php b/html-old/login.php similarity index 100% rename from html/login.php rename to html-old/login.php diff --git a/html/logout.php b/html-old/logout.php similarity index 100% rename from html/logout.php rename to html-old/logout.php diff --git a/html/news.php b/html-old/news.php similarity index 100% rename from html/news.php rename to html-old/news.php diff --git a/html/register.php b/html-old/register.php similarity index 100% rename from html/register.php rename to html-old/register.php diff --git a/html-old/robots.txt b/html-old/robots.txt new file mode 100644 index 00000000..a896c212 --- /dev/null +++ b/html-old/robots.txt @@ -0,0 +1,5 @@ +User-agent: Googlebot +Disallow: /src/ + +User-agent: * +Allow: / \ No newline at end of file diff --git a/html/src/banner/index.php b/html-old/src/banner/index.php similarity index 100% rename from html/src/banner/index.php rename to html-old/src/banner/index.php diff --git a/html/src/miniature/index.php b/html-old/src/css/index.php similarity index 100% rename from html/src/miniature/index.php rename to html-old/src/css/index.php diff --git a/html-old/src/css/style.css b/html-old/src/css/style.css new file mode 100644 index 00000000..50cf84ad --- /dev/null +++ b/html-old/src/css/style.css @@ -0,0 +1,312 @@ +@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%; + } +} \ No newline at end of file diff --git a/html-old/src/fonts/bahnschrift.ttf b/html-old/src/fonts/bahnschrift.ttf new file mode 100644 index 00000000..8332c6ca Binary files /dev/null and b/html-old/src/fonts/bahnschrift.ttf differ diff --git a/html/src/pp/index.php b/html-old/src/fonts/index.php similarity index 100% rename from html/src/pp/index.php rename to html-old/src/fonts/index.php diff --git a/html-old/src/img/athena-mono.png b/html-old/src/img/athena-mono.png new file mode 100644 index 00000000..ef727bd1 Binary files /dev/null and b/html-old/src/img/athena-mono.png differ diff --git a/html/src/img/empty.jpg b/html-old/src/img/empty.jpg similarity index 100% rename from html/src/img/empty.jpg rename to html-old/src/img/empty.jpg diff --git a/html/src/img/favicon.ico b/html-old/src/img/favicon.ico similarity index 100% rename from html/src/img/favicon.ico rename to html-old/src/img/favicon.ico diff --git a/html-old/src/img/index.php b/html-old/src/img/index.php new file mode 100644 index 00000000..793e46d7 --- /dev/null +++ b/html-old/src/img/index.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/html-old/src/index.php b/html-old/src/index.php new file mode 100644 index 00000000..793e46d7 --- /dev/null +++ b/html-old/src/index.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/html-old/src/miniature/index.php b/html-old/src/miniature/index.php new file mode 100644 index 00000000..793e46d7 --- /dev/null +++ b/html-old/src/miniature/index.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/html-old/src/pp/index.php b/html-old/src/pp/index.php new file mode 100644 index 00000000..793e46d7 --- /dev/null +++ b/html-old/src/pp/index.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/html/upload.php b/html-old/upload.php similarity index 100% rename from html/upload.php rename to html-old/upload.php diff --git a/html/user.php b/html-old/user.php similarity index 100% rename from html/user.php rename to html-old/user.php diff --git a/html/users.php b/html-old/users.php similarity index 100% rename from html/users.php rename to html-old/users.php diff --git a/html/about/index.php b/html/about/index.php new file mode 100644 index 00000000..cc579115 --- /dev/null +++ b/html/about/index.php @@ -0,0 +1,46 @@ + + + + + + + + + + + + +
+
+ +
+
+ + + +
+
+ +
+ +
+
+
+ + + \ No newline at end of file diff --git a/html/account/index.php b/html/account/index.php new file mode 100644 index 00000000..ed76a92f --- /dev/null +++ b/html/account/index.php @@ -0,0 +1,254 @@ +prepare($sqlRequest); + $request->bindParam(":userPP", $imageURL); + $request->bindParam(":userID", $_SESSION['userID']); + if($request->execute()) { + $status = "Photo de profil mise à jour"; + } else { + $status = "Erreur SQL"; + } + } else { + $status = "Le fichier doit être au format PNG ou JPG"; + } +} + +if (isset($_FILES['newBanner']) && $_FILES['newBanner']['error'] == 0) { + $tempImagePath = $_FILES['newBanner']['tmp_name']; + $ImagePath = 'assets/banners/' . $_SESSION['userID'] . '.png'; + $rootImagePath = $rootFilePath . 'html/' . $ImagePath; + $imageURL = $rootPageURL . $ImagePath; + + list($width, $height) = getimagesize($tempImagePath); + + $imageInfo = getimagesize($tempImagePath); + + if ($imageInfo[2] === IMAGETYPE_PNG || $imageInfo[2] === IMAGETYPE_JPEG) { + $imageWidth = 800; + $imageHeight = ($height / $width) * $imageWidth; + $imageResized = imagecreatetruecolor($imageWidth, $imageHeight); + $imageOriginal = imagecreatefromstring(file_get_contents($tempImagePath)); + + imagecopyresampled($imageResized, $imageOriginal, 0, 0, 0, 0, $imageWidth, $imageHeight, $width, $height); + imagealphablending($imageResized, false); + imagesavealpha($imageResized, $rootPath); + + imagepng($imageResized, $rootImagePath); + + imagedestroy($imageOriginal); + imagedestroy($imageResized); + + $sqlRequest = "UPDATE users SET banner = :userBanner WHERE ID = :userID"; + $request = $pdo->prepare($sqlRequest); + $request->bindParam(":userBanner", $imageURL); + $request->bindParam(":userID", $_SESSION['userID']); + if($request->execute()) { + $status = "Banière mise à jour"; + } else { + $status = "Erreur SQL"; + } + } else { + $status = "Le fichier doit être au format PNG ou JPG"; + } +} + +if (isset($_POST['userDisplayName']) && isset($_POST['userBio'])) { + if(preg_match('!\S!u', $_POST['userDisplayName']) && preg_match('!\S!u', $_POST['userBio'])) { + $sqlRequest = "UPDATE users SET display_name = :userDisplayName, bio = :userBio WHERE ID = :userID"; + $request = $pdo->prepare($sqlRequest); + $request->bindParam(":userDisplayName", htmlspecialchars($_POST['userDisplayName'])); + $request->bindParam(":userBio", htmlspecialchars($_POST['userBio'])); + $request->bindParam(":userID", $_SESSION['userID']); + if($request->execute()) { + $status = "Informations mises à jour"; + $_SESSION['userDisplayName'] = htmlspecialchars($_POST['userDisplayName']); + } + } +} + +$request = $pdo->prepare("SELECT ID, username, display_name, profile_picture, banner, bio FROM users WHERE ID = :userID"); +$request->bindParam(":userID", $_SESSION['userID']); +$request->execute(); +$result = $request->fetchAll(PDO::FETCH_ASSOC); + +if($result) { + $userID = $result[0]['ID']; + $userName = $result[0]['username']; + $userDisplayName = $result[0]['display_name']; + $userPPURL = $result[0]['profile_picture'] == NULL ? "https://abs.twimg.com/sticky/default_profile_images/default_profile_400x400.png" : $result[0]['profile_picture']; + $userBanner = $result[0]['banner'] = NULL ? "" : $result[0]['banner']; + $userBio = $result[0]['bio']; +} else { + header("Location: /login?p=account"); + die("Erreur, utilisateur introuvable"); +} + +?> + + + + + + + + + + + +
+
+ +
+
+ + + +
+
+ +
+
+ + + \ No newline at end of file diff --git a/html/admin/index.php b/html/admin/index.php new file mode 100644 index 00000000..9d857ac8 --- /dev/null +++ b/html/admin/index.php @@ -0,0 +1,40 @@ + + + + + + + + + + + + +
+
+ +
+
+ + + +
+
+
+ + + \ No newline at end of file diff --git a/html/assets/banners/index.php b/html/assets/banners/index.php new file mode 100644 index 00000000..793e46d7 --- /dev/null +++ b/html/assets/banners/index.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/html/assets/index.php b/html/assets/index.php new file mode 100644 index 00000000..793e46d7 --- /dev/null +++ b/html/assets/index.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/html/assets/miniatures/index.php b/html/assets/miniatures/index.php new file mode 100644 index 00000000..793e46d7 --- /dev/null +++ b/html/assets/miniatures/index.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/html/assets/pp/index.php b/html/assets/pp/index.php new file mode 100644 index 00000000..793e46d7 --- /dev/null +++ b/html/assets/pp/index.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/html/editor/index.php b/html/editor/index.php new file mode 100644 index 00000000..11fc23c7 --- /dev/null +++ b/html/editor/index.php @@ -0,0 +1,200 @@ +prepare($sqlRequest); + $request->bindParam(":articleID", $_GET['article']); + $request->bindParam(":authorID", $_SESSION['userID']); + $request->execute(); + $result = $request->fetchAll(PDO::FETCH_ASSOC); + if ($result) { + $articleID = $result[0]['ID']; + $articleTitle = $result[0]['title']; + $articleResume = $result[0]['resume']; + $articleClassification = $result[0]['classification']; + $miniatureURL = $result[0]['miniature']; + $articleContent = file_get_contents($rootFilePath . 'content/articles/' . $articleID . '.md'); + } else { + $status = "Article introuvable"; + } +} else { + $status = "Veuillez choisir un article"; +} + + +// Article deletion + +if (isset($_POST['delete-article']) && $_POST['delete-article'] == "delete") { + $sqlRequest = "DELETE FROM articles WHERE ID = :articleID"; + $request = $pdo->prepare($sqlRequest); + $request->bindParam(":articleID", $articleID); + if($request->execute()) { + $status = "Article supprimé"; + $articleTitle = ""; + $articleResume = ""; + $articleContent = ""; + $miniatureURL = ""; + } +} + + +// Updating the article after upload + +if (isset($_POST['article-content']) && isset($_POST['classification']) && isset($articleID)) { + + file_put_contents($rootFilePath . "content/articles/" . $articleID . ".md", nl2br($_POST['article-content'])); + + $sqlRequest = "UPDATE articles SET title = :title, resume = :resume, classification = :classification WHERE ID = :articleID AND author = :authorID"; + $request = $pdo->prepare($sqlRequest); + $request->bindParam(":title", htmlspecialchars($_POST['article-title'])); + $request->bindParam(":resume", htmlspecialchars($_POST['article-resume'])); + $request->bindParam(":classification", $_POST['classification'], PDO::PARAM_INT); + $request->bindParam(":articleID", $_GET['article'], PDO::PARAM_INT); + $request->bindParam(":authorID", $_SESSION['userID'], PDO::PARAM_INT); + $request->execute(); + $result = $request->fetchAll(PDO::FETCH_ASSOC); + if($request->execute()) { + header("Location: /editor?article=" . $articleID); + } else { + $status = "Une erreur s'est produite"; + } +} + + +// Updating the miniature + +if (isset($_FILES['miniature']) && $_FILES['miniature']['error'] == 0 && isset($articleID)) { + $tempImagePath = $_FILES['miniature']['tmp_name']; + $ImagePath = 'assets/miniatures/' . $articleID . '.png'; + $rootImagePath = $rootFilePath . 'html/' . $ImagePath; + $imageURL = $rootPageURL . $ImagePath; + + list($width, $height) = getimagesize($tempImagePath); + + $imageInfo = getimagesize($tempImagePath); + + if ($imageInfo[2] === IMAGETYPE_PNG || $imageInfo[2] === IMAGETYPE_JPEG) { + $imageWidth = 500; + $imageHeight = ($height / $width) * $imageWidth; + $imageResized = imagecreatetruecolor($imageWidth, $imageHeight); + $imageOriginal = imagecreatefromstring(file_get_contents($tempImagePath)); + + imagecopyresampled($imageResized, $imageOriginal, 0, 0, 0, 0, $imageWidth, $imageHeight, $width, $height); + imagealphablending($imageResized, false); + imagesavealpha($imageResized, $rootPath); + + imagepng($imageResized, $rootImagePath); + + imagedestroy($imageOriginal); + imagedestroy($imageResized); + + $sqlRequest = "UPDATE articles SET miniature = :miniature WHERE ID = :articleID"; + $request = $pdo->prepare($sqlRequest); + $request->bindParam(":miniature", $imageURL); + $request->bindParam(":articleID", $articleID); + if($request->execute()) { + $status = "Miniature changée"; + $miniatureURL = $imageURL; + } else { + $status = "Erreur SQL"; + } + } else { + $status = "Le fichier doit être au format PNG ou JPG"; + } +} + +?> + + + + + + + + + + + +
+
+ +
+
+ + + +
+
+
+
+
+

Editer un article

+ +
+
+ +
+
+
+
+
+
+
+ + +
+
+
+ + +
+
+
+
+ + + \ No newline at end of file diff --git a/html/index.php b/html/index.php index af4d0fec..e69de29b 100644 --- a/html/index.php +++ b/html/index.php @@ -1,98 +0,0 @@ - - - - - - - - - - <?=$title?> - - -
-
-
- - - -
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
- text($markdownContent); - ?> -
-
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 '
'; - echo '
'; - echo ''; - echo '
'; - echo '
'; - echo '
n° ' . $row['ID'] . ' | ' . date('d/m/Y', $date) . ' | '. '' . $row['display_name'] . '
'; - echo ''; - echo '
' . $row['titre'] . '
'; - echo '
'; - echo '
' . $row['resume'] . '
'; - echo '
'; - echo '
'; - } - ?> -
-
-
-
- - - \ No newline at end of file diff --git a/html/login/index.php b/html/login/index.php new file mode 100644 index 00000000..6128271a --- /dev/null +++ b/html/login/index.php @@ -0,0 +1,94 @@ +prepare($sqlRequest); + $request->bindParam(":username", htmlspecialchars($_POST['username'])); + $request->bindParam(":password", md5($_POST['password'])); + $request->execute(); + $result = $request->fetchAll(PDO::FETCH_ASSOC); + + if ($result) { + + $_SESSION['userID'] = $result[0]['ID']; + $_SESSION['userName'] = $result[0]['username']; + $_SESSION['userDisplayName'] = $result[0]['display_name']; + $_SESSION['userLevel'] = $result[0]['level']; + $_SESSION['userAccreditation'] = $result[0]['accreditation']; + $redirectPage = isset($_GET['p']) ? $_GET['p'] : ""; + header('Location: /' . $redirectPage); + exit("Login success"); + + } else { + $status = 'Identifiants incorrects'; + } + } else { + $status = 'Caractères illégaux'; + } + } else { + $status = 'Les champs ne doivent pas être vides'; + } +} + +?> + + + + + + + + + + + +
+
+ +
+
+ + + +
+
+
+
+
Se Connecter
+
+ + +
ou
+ Créer un compte +
+
+
+
+ + + \ No newline at end of file diff --git a/html/login/logout.php b/html/login/logout.php new file mode 100644 index 00000000..4759225c --- /dev/null +++ b/html/login/logout.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/html/login/register.php b/html/login/register.php new file mode 100644 index 00000000..49cc1458 --- /dev/null +++ b/html/login/register.php @@ -0,0 +1,108 @@ +prepare($sqlRequest); + $request->bindParam(":username", htmlspecialchars($_POST['username'])); + $request->execute(); + $result = $request->fetchAll(PDO::FETCH_ASSOC); + + if($result) { + $status = "Le nom d'utilisateur existe déjà"; + } else { + + $request = $pdo->prepare("INSERT INTO users (username, password, email, display_name, level, accreditation) VALUES (:username, :password, :email, :display_name, 1, 1)"); + $request->bindParam(':username', $userName); + $request->bindParam(':password', md5($_POST['password1'])); + $request->bindParam(':email', $userEmail); + $request->bindParam(':display_name', $userDisplayName); + + if ($request->execute()) { + header("Location: index.php"); + exit(); + } else { + $status = "Erreur SQL"; + } + } + } + } else { + $status = "Les mots de passe ne correspondent pas"; + } + } else { + $status = "Caractères illégaux"; + } + } else { + $status = "Les champs ne doivent pas être vides"; + } +} +?> + + + + + + + + + + + +
+
+ +
+
+ + + +
+
+
+
+
Créer un compte
+
+ + +
ou
+ Se connecter +
+
+
+
+ + + \ No newline at end of file diff --git a/html/news/index.php b/html/news/index.php new file mode 100644 index 00000000..98d12854 --- /dev/null +++ b/html/news/index.php @@ -0,0 +1,143 @@ + + + + + + + + + + + + +
+
+ +
+
+ + + +
+
+ prepare($sqlRequest); + $request->bindParam(":articleID", $_GET['article']); + $request->bindParam(":userAccreditation", $_SESSION['userAccreditation']); + $request->execute(); + $result = $request->fetchAll(PDO::FETCH_ASSOC); + + if($result) { + $pubDateTime = strtotime($result[0]['date']); + $pubDate = date('d/m/Y', $pubDateTime); + $articleID = $result[0]['ID']; + $articleTitle = $result[0]['title']; + $articleResume = $result[0]['resume']; + $miniatureURL = $result[0]['miniature']; + $authorUsername = $result[0]['username']; + $authorDisplayName = $result[0]['display_name']; + $authorLevel = $result[0]['level']; + $authorPPURL = $result[0]['profile_picture'] == NULL ? "https://abs.twimg.com/sticky/default_profile_images/default_profile_400x400.png" : $result[0]['profile_picture']; + $authorID = $result[0]['author']; + + echo ('
'); + echo (''); + echo ('
'); + } + + } else { + $search = isset($_GET['search']) ? "%" . htmlspecialchars($_GET['search']) . "%" : "%%"; + $sqlRequest = "SELECT articles.ID, articles.title, articles.date, articles.miniature, articles.resume, users.username, users.display_name FROM articles JOIN users ON articles.author = users.ID WHERE (articles.title LIKE :search OR articles.ID LIKE :search OR users.username LIKE :search) AND articles.classification <= :userAccreditation"; + $request = $pdo->prepare($sqlRequest); + $request->bindParam(":search", $search); + $request->bindParam(":userAccreditation", $_SESSION['userAccreditation']); + $request->execute(); + $result = $request->fetchAll(PDO::FETCH_ASSOC); + + echo ('

News

'); + + echo ('
'); + $shapePath = ''; + textInput("text", $shapePath, "search", "Chercher", ""); + echo ('
'); + + if ($result) { + echo('
'); + listArticles($result, $rootPageURL); + echo('
'); + } else { + echo ('Aucun article trouvé'); + } + } + ?> +
+
+ + + \ No newline at end of file diff --git a/html/robots.txt b/html/robots.txt index a896c212..e69de29b 100644 --- a/html/robots.txt +++ b/html/robots.txt @@ -1,5 +0,0 @@ -User-agent: Googlebot -Disallow: /src/ - -User-agent: * -Allow: / \ No newline at end of file diff --git a/html/settings/deleteaccount.php b/html/settings/deleteaccount.php new file mode 100644 index 00000000..7b176126 --- /dev/null +++ b/html/settings/deleteaccount.php @@ -0,0 +1,90 @@ +prepare($sqlRequest); + $request->bindParam(":userID", $_SESSION['userID']); + if($request->execute()) { + $sqlRequest = "UPDATE articles SET author = 0 WHERE author = :userID"; + $request = $pdo->prepare($sqlRequest); + $request->bindParam(":userID", $_SESSION['userID']); + if($request->execute()) { + $status = "Votre compte a été supprimé, votre session reste active jusqu'à déconnexion"; + } else { + $status = "Erreur lors du passage de propriétés"; + } + } else { + $status = "Erreur lors de la suppression utilisateur"; + } +} + +?> + + + + + + + + + + + +
+
+ +
+
+ + + +
+
+
+
+
Etes vous sur de vouloir supprimer votre compte
+
+
+ Non + +
+
+ +
+
+ + + \ No newline at end of file diff --git a/html/settings/index.php b/html/settings/index.php new file mode 100644 index 00000000..16ba4470 --- /dev/null +++ b/html/settings/index.php @@ -0,0 +1,99 @@ +prepare($sqlRequest); + $request->bindParam(":username", htmlspecialchars($_POST['username'])); + $request->execute(); + $result = $request->fetchAll(PDO::FETCH_ASSOC); + if($result && $result[0]['ID'] != $_SESSION['userID']) { + $status = "Le nom d'utilisateur n'est pas disponible"; + } else { + $sqlRequest = "UPDATE users SET username = :username, email = :email WHERE ID = :userID"; + $request = $pdo->prepare($sqlRequest); + $request->bindParam(":username", htmlspecialchars($_POST['username'])); + $request->bindParam(":email", htmlspecialchars($_POST['email'])); + $request->bindParam(":userID", $_SESSION['userID']); + if($request->execute()) { + $status = "Informations mises à jour"; + } + } + } + } else { + $status = "Le nom d'utilisateur ne peut pas être vide"; + } +} + +?> + + + + + + + + + + + +
+
+ +
+
+ + + +
+
+
+
+
Options
+
+ prepare($sqlRequest); + $request->bindParam(":userID", $_SESSION['userID']); + $request->execute(); + $result = $request->fetchAll(PDO::FETCH_ASSOC); + + textInput("text", "", "username", "username", $result[0]['username']); + textInput("email", "", "email", "user@e59.fr", $result[0]['email']); + ?> +
+ + Supprimer le compte +
+
+
+
+
+ + + \ No newline at end of file diff --git a/html/src/css/style.css b/html/src/css/style.css index 50cf84ad..e69de29b 100644 --- a/html/src/css/style.css +++ b/html/src/css/style.css @@ -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%; - } -} \ No newline at end of file diff --git a/html/src/img/athena-mono.png b/html/src/img/athena-mono.png index ef727bd1..a2d9d9d5 100644 Binary files a/html/src/img/athena-mono.png and b/html/src/img/athena-mono.png differ diff --git a/include/functions.php b/include/functions.php index ccf86949..79d10fe7 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1,56 +1,217 @@ - $url) { - echo ""; + if (!isset($_SESSION['userID'])) { + $_SESSION['userAccreditation'] = 0; + $_SESSION['userLevel'] = 0; } - if($_SESSION['role'] >= 3) { - echo ""; - } - if (isset($_SESSION['userid'])) { - echo ""; - } else { - echo ""; - } -} -function connect($dbhost, $dbname, $dbuser, $dbpass) { - try - { - $bdd = new PDO('mysql:host=' . $dbhost . ';dbname=' . $dbname . ';charset=UTF8mb4',$dbuser,$dbpass); - $bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + 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 (''); + echo (''); + echo (''); + echo (''); + + echo (''); + + echo ('' . $pageTitle . ''); + } + + function fillHeader($rootPageURL, $headerTitle, $headerSubtitle) { + + echo ('
'); + + echo (''); + echo (''); + echo (''); + + echo ('
'); + + echo ('
'); + + echo ('
'); + echo ('
' . $headerTitle . '
'); + echo ('
' . $headerSubtitle . '
'); + echo ('
'); + + echo ('
'); + } + + function fillNav($rootPageURL) { + + echo (''); + echo (''); + + /*if ($_SESSION['userLevel'] >= 3) { + echo (''); + }*/ + + if(isset($_SESSION['userID'])) { + echo (''); + echo (''); + echo (''); + } else { + echo (''); } - catch(Exception $e) - { - die('Erreur : '.$e->getMessage()); + } + + 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 $bdd; -} + + return $pdo; + } + + function userWidget($userPPURL, $userDisplayName, $userName, $userLevel, $certificationColors, $rootPageURL) { + + echo (''); + echo ('
'); + + echo ('
'); + echo (''); + echo ('
'); + + echo (''); + + echo ('
'); + echo ('
'); + } + + 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 = ' | ' . $article['display_name'] . ''; + } else { + $authorLink = ''; + } + + echo('
'); + + echo(''); + echo('
'); + + echo(''); + + echo('
'); + echo('
'); + + echo('
'); + echo('
n° ' . $articleID . ' | ' . $pubDate . '
'); + + echo(''); + echo('
' . $articleTitle . '
'); + echo('
'); + + echo('
' . $articleResume . '
'); + + echo('
'); + echo('
'); + } + } + + function textInput($type, $shapePath, $name, $placeholder, $value) { + + echo ('
'); + echo (''); + echo (''); + echo ('
'); + } + + function fileInput($name) { + echo ('
'); + echo (''); + echo ('
'); + } + + function selectInput($name, $label, $options, $defaultValue) { + echo('
'); + echo(''); + echo(''); + echo('
'); + } + ?> \ No newline at end of file diff --git a/include/variables.php b/include/variables.php index f3d87015..8898d09d 100644 --- a/include/variables.php +++ b/include/variables.php @@ -1,24 +1,24 @@ - \ No newline at end of file