diff --git a/arbre.php b/arbre.php index 92346bc..8937cbc 100644 --- a/arbre.php +++ b/arbre.php @@ -3,76 +3,77 @@ require_once 'fonctions.php'; session_start(); if (!isset($_SESSION['admin_id'])) { - header('Location: admin.php?action=login'); - exit; + header('Location: admin.php?action=login'); + exit; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { - $action = $_POST['action'] ?? ''; - $path = $_POST['path'] ?? ''; - $newName = $_POST['new_name'] ?? ''; - $description = $_POST['description'] ?? ''; - - switch ($action) { - case 'create_folder': - if ($path && $newName) { - $newPath = $path . '/' . sanitizeFilename($newName); - if (!file_exists($newPath)) { - mkdir($newPath, 0755, true); - $infoContent = $newName . "\n" . $description; - file_put_contents($newPath . '/infos.txt', $infoContent); - $_SESSION['success_message'] = "Dossier créé avec succès."; - } else { - $_SESSION['error_message'] = "Ce dossier existe déjà."; - } - } - break; - - case 'edit_folder': - if ($path && isSecurePath($path)) { - $infoContent = $newName . "\n" . $description; - $infoPath = $path . '/infos.txt'; - if (file_put_contents($infoPath, $infoContent) !== false) { - $_SESSION['success_message'] = "Dossier modifié avec succès."; - } else { - $_SESSION['error_message'] = "Erreur lors de la modification du dossier."; - } - } - break; - - case 'delete_folder': - if ($path && isSecurePath($path) && $path !== './liste_albums') { // Empêcher la suppression du dossier racine - function rrmdir($dir) { - if (is_dir($dir)) { - $objects = scandir($dir); - foreach ($objects as $object) { - if ($object != "." && $object != "..") { - if (is_dir($dir . "/" . $object)) { - rrmdir($dir . "/" . $object); - } else { - unlink($dir . "/" . $object); - } - } - } - rmdir($dir); - } - } - rrmdir($path); - $_SESSION['success_message'] = "Dossier supprimé avec succès."; - } - break; - } - - header('Location: arbre.php'); - exit; + $action = $_POST['action'] ?? ''; + $path = $_POST['path'] ?? ''; + $newName = $_POST['new_name'] ?? ''; + $description = $_POST['description'] ?? ''; + $matureContent = isset($_POST['mature_content']) ? '18+' : '18-'; + + switch ($action) { + case 'create_folder': + if ($path && $newName) { + $newPath = $path . '/' . sanitizeFilename($newName); + if (!file_exists($newPath)) { + mkdir($newPath, 0755, true); + $infoContent = $newName . "\n" . $description . "\n" . $matureContent; + file_put_contents($newPath . '/infos.txt', $infoContent); + $_SESSION['success_message'] = "Dossier créé avec succès."; + } else { + $_SESSION['error_message'] = "Ce dossier existe déjà."; + } + } + break; + + case 'edit_folder': + if ($path && isSecurePath($path)) { + $infoContent = $newName . "\n" . $description . "\n" . $matureContent; + $infoPath = $path . '/infos.txt'; + if (file_put_contents($infoPath, $infoContent) !== false) { + $_SESSION['success_message'] = "Dossier modifié avec succès."; + } else { + $_SESSION['error_message'] = "Erreur lors de la modification du dossier."; + } + } + break; + + case 'delete_folder': + if ($path && isSecurePath($path) && $path !== './liste_albums') { + function rrmdir($dir) { + if (is_dir($dir)) { + $objects = scandir($dir); + foreach ($objects as $object) { + if ($object != "." && $object != "..") { + if (is_dir($dir . "/" . $object)) { + rrmdir($dir . "/" . $object); + } else { + unlink($dir . "/" . $object); + } + } + } + rmdir($dir); + } + } + rrmdir($path); + $_SESSION['success_message'] = "Dossier supprimé avec succès."; + } + break; + } + + header('Location: arbre.php'); + exit; } $currentPath = isset($_GET['path']) ? $_GET['path'] : './liste_albums'; $currentPath = realpath($currentPath); if (!isSecurePath($currentPath)) { - header('Location: arbre.php'); - exit; + header('Location: arbre.php'); + exit; } function generateTree($path, $currentPath) { @@ -87,9 +88,12 @@ function generateTree($path, $currentPath) { $output .= '
'; $output .= ''; $output .= '📁 ' . htmlspecialchars($info['title']); + if ($info['mature_content']) { + $output .= ' 🔞'; + } $output .= ''; $output .= '
'; - $output .= ''; + $output .= ''; $output .= ''; $output .= '
'; } @@ -107,12 +111,15 @@ function generateTree($path, $currentPath) { $output .= '
'; $output .= ''; $output .= '📁 ' . htmlspecialchars($info['title']); + if ($info['mature_content']) { + $output .= ' 🔞'; + } $output .= ''; $output .= '
'; if (!$hasSubfolders) { $output .= '🖼️'; } - $output .= ''; + $output .= ''; $output .= ''; if ($fullPath !== './liste_albums') { $output .= ''; @@ -179,6 +186,13 @@ function generateTree($path, $currentPath) {
+
+ +
@@ -202,6 +216,13 @@ function generateTree($path, $currentPath) {
+
+ +
@@ -232,10 +253,11 @@ function generateTree($path, $currentPath) { document.getElementById('createFolderModal').style.display = 'block'; } - function editFolder(path, title, description) { + function editFolder(path, title, description, matureContent = false) { document.getElementById('editPath').value = path; document.getElementById('edit_name').value = title; document.getElementById('edit_description').value = description; + document.getElementById('edit_mature_content').checked = matureContent; document.getElementById('editFolderModal').style.display = 'block'; } diff --git a/fonctions.php b/fonctions.php index 0d4704c..b9e8305 100644 --- a/fonctions.php +++ b/fonctions.php @@ -21,7 +21,8 @@ function getAlbumInfo($albumPath) { $infoFile = $albumPath . '/infos.txt'; $info = [ 'title' => basename($albumPath), - 'description' => '' + 'description' => '', + 'mature_content' => false ]; if (file_exists($infoFile)) { @@ -29,6 +30,7 @@ function getAlbumInfo($albumPath) { $lines = explode("\n", $content); if (isset($lines[0])) $info['title'] = trim($lines[0]); if (isset($lines[1])) $info['description'] = trim($lines[1]); + if (isset($lines[2])) $info['mature_content'] = trim($lines[2]) === '18+'; } return $info; diff --git a/styles-admin.css b/styles-admin.css index 42527f1..e2096ee 100644 --- a/styles-admin.css +++ b/styles-admin.css @@ -251,6 +251,55 @@ body { margin-bottom: 1.5rem; } +/* Toggle pour contenu mature */ +.toggle-label { + display: flex; + align-items: center; + gap: 0.5rem; + cursor: pointer; + user-select: none; +} + +.toggle-label input[type="checkbox"] { + position: relative; + width: 3rem; + height: 1.5rem; + appearance: none; + background-color: #2a2a2a; + border-radius: 1.5rem; + cursor: pointer; + transition: all 0.3s ease; +} + +.toggle-label input[type="checkbox"]::before { + content: ""; + position: absolute; + top: 0.2rem; + left: 0.2rem; + width: 1.1rem; + height: 1.1rem; + background-color: white; + border-radius: 50%; + transition: all 0.3s ease; +} + +.toggle-label input[type="checkbox"]:checked { + background-color: #dc3545; +} + +.toggle-label input[type="checkbox"]:checked::before { + left: 1.7rem; +} + +.toggle-text { + color: #e0e0e0; +} + +.toggle-warning { + font-size: 1.2rem; + opacity: 0.7; +} + .form-group label { display: block; margin-bottom: 0.5rem;