implémentation des albums matures P1

première partie, permet de noter un album comme possédant du contenu explicite ou non
This commit is contained in:
Esenjin 2024-12-30 23:41:42 +01:00
parent a4c2e48ef5
commit eec3643f19
3 changed files with 138 additions and 65 deletions

View File

@ -12,6 +12,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$path = $_POST['path'] ?? '';
$newName = $_POST['new_name'] ?? '';
$description = $_POST['description'] ?? '';
$matureContent = isset($_POST['mature_content']) ? '18+' : '18-';
switch ($action) {
case 'create_folder':
@ -19,7 +20,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$newPath = $path . '/' . sanitizeFilename($newName);
if (!file_exists($newPath)) {
mkdir($newPath, 0755, true);
$infoContent = $newName . "\n" . $description;
$infoContent = $newName . "\n" . $description . "\n" . $matureContent;
file_put_contents($newPath . '/infos.txt', $infoContent);
$_SESSION['success_message'] = "Dossier créé avec succès.";
} else {
@ -30,7 +31,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
case 'edit_folder':
if ($path && isSecurePath($path)) {
$infoContent = $newName . "\n" . $description;
$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.";
@ -41,7 +42,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
break;
case 'delete_folder':
if ($path && isSecurePath($path) && $path !== './liste_albums') { // Empêcher la suppression du dossier racine
if ($path && isSecurePath($path) && $path !== './liste_albums') {
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
@ -87,9 +88,12 @@ function generateTree($path, $currentPath) {
$output .= '<div class="tree-item-content">';
$output .= '<span class="tree-link">';
$output .= '<span class="folder-icon">📁</span> ' . htmlspecialchars($info['title']);
if ($info['mature_content']) {
$output .= ' <span class="mature-warning">🔞</span>';
}
$output .= '</span>';
$output .= '<div class="tree-actions">';
$output .= '<button onclick="editFolder(\'' . htmlspecialchars($path) . '\', \'' . htmlspecialchars($info['title']) . '\', \'' . htmlspecialchars($info['description']) . '\')" class="tree-button">✏️</button>';
$output .= '<button onclick="editFolder(\'' . htmlspecialchars($path) . '\', \'' . htmlspecialchars($info['title']) . '\', \'' . htmlspecialchars($info['description']) . '\', ' . ($info['mature_content'] ? 'true' : 'false') . ')" class="tree-button">✏️</button>';
$output .= '<button onclick="createSubfolder(\'' . htmlspecialchars($path) . '\')" class="tree-button"></button>';
$output .= '</div></div>';
}
@ -107,12 +111,15 @@ function generateTree($path, $currentPath) {
$output .= '<div class="tree-item-content">';
$output .= '<span class="tree-link">';
$output .= '<span class="folder-icon">📁</span> ' . htmlspecialchars($info['title']);
if ($info['mature_content']) {
$output .= ' <span class="mature-warning">🔞</span>';
}
$output .= '</span>';
$output .= '<div class="tree-actions">';
if (!$hasSubfolders) {
$output .= '<a href="arbre-img.php?path=' . urlencode($fullPath) . '" class="tree-button" style="text-decoration: none">🖼️</a>';
}
$output .= '<button onclick="editFolder(\'' . htmlspecialchars($fullPath) . '\', \'' . htmlspecialchars($info['title']) . '\', \'' . htmlspecialchars($info['description']) . '\')" class="tree-button">✏️</button>';
$output .= '<button onclick="editFolder(\'' . htmlspecialchars($fullPath) . '\', \'' . htmlspecialchars($info['title']) . '\', \'' . htmlspecialchars($info['description']) . '\', ' . ($info['mature_content'] ? 'true' : 'false') . ')" class="tree-button">✏️</button>';
$output .= '<button onclick="createSubfolder(\'' . htmlspecialchars($fullPath) . '\')" class="tree-button"></button>';
if ($fullPath !== './liste_albums') {
$output .= '<button onclick="deleteFolder(\'' . htmlspecialchars($fullPath) . '\')" class="tree-button tree-button-danger">🗑️</button>';
@ -179,6 +186,13 @@ function generateTree($path, $currentPath) {
<label for="description">Description :</label>
<textarea id="description" name="description" rows="4" class="form-textarea"></textarea>
</div>
<div class="form-group">
<label class="toggle-label">
<input type="checkbox" name="mature_content" id="mature_content">
<span class="toggle-text">Contenu réservé aux plus de 18 ans</span>
<span class="toggle-warning">⚠️</span>
</label>
</div>
<div class="form-actions">
<button type="button" onclick="closeModal()" class="action-button action-button-secondary">Annuler</button>
<button type="submit" class="action-button">Créer</button>
@ -202,6 +216,13 @@ function generateTree($path, $currentPath) {
<label for="edit_description">Description :</label>
<textarea id="edit_description" name="description" rows="4" class="form-textarea"></textarea>
</div>
<div class="form-group">
<label class="toggle-label">
<input type="checkbox" name="mature_content" id="edit_mature_content">
<span class="toggle-text">Contenu réservé aux plus de 18 ans</span>
<span class="toggle-warning">⚠️</span>
</label>
</div>
<div class="form-actions">
<button type="button" onclick="closeModal()" class="action-button action-button-secondary">Annuler</button>
<button type="submit" class="action-button">Enregistrer</button>
@ -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';
}

View File

@ -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;

View File

@ -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;