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:
parent
a4c2e48ef5
commit
eec3643f19
150
arbre.php
150
arbre.php
@ -3,76 +3,77 @@ require_once 'fonctions.php';
|
|||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
if (!isset($_SESSION['admin_id'])) {
|
if (!isset($_SESSION['admin_id'])) {
|
||||||
header('Location: admin.php?action=login');
|
header('Location: admin.php?action=login');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
$action = $_POST['action'] ?? '';
|
$action = $_POST['action'] ?? '';
|
||||||
$path = $_POST['path'] ?? '';
|
$path = $_POST['path'] ?? '';
|
||||||
$newName = $_POST['new_name'] ?? '';
|
$newName = $_POST['new_name'] ?? '';
|
||||||
$description = $_POST['description'] ?? '';
|
$description = $_POST['description'] ?? '';
|
||||||
|
$matureContent = isset($_POST['mature_content']) ? '18+' : '18-';
|
||||||
switch ($action) {
|
|
||||||
case 'create_folder':
|
switch ($action) {
|
||||||
if ($path && $newName) {
|
case 'create_folder':
|
||||||
$newPath = $path . '/' . sanitizeFilename($newName);
|
if ($path && $newName) {
|
||||||
if (!file_exists($newPath)) {
|
$newPath = $path . '/' . sanitizeFilename($newName);
|
||||||
mkdir($newPath, 0755, true);
|
if (!file_exists($newPath)) {
|
||||||
$infoContent = $newName . "\n" . $description;
|
mkdir($newPath, 0755, true);
|
||||||
file_put_contents($newPath . '/infos.txt', $infoContent);
|
$infoContent = $newName . "\n" . $description . "\n" . $matureContent;
|
||||||
$_SESSION['success_message'] = "Dossier créé avec succès.";
|
file_put_contents($newPath . '/infos.txt', $infoContent);
|
||||||
} else {
|
$_SESSION['success_message'] = "Dossier créé avec succès.";
|
||||||
$_SESSION['error_message'] = "Ce dossier existe déjà.";
|
} else {
|
||||||
}
|
$_SESSION['error_message'] = "Ce dossier existe déjà.";
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case 'edit_folder':
|
|
||||||
if ($path && isSecurePath($path)) {
|
case 'edit_folder':
|
||||||
$infoContent = $newName . "\n" . $description;
|
if ($path && isSecurePath($path)) {
|
||||||
$infoPath = $path . '/infos.txt';
|
$infoContent = $newName . "\n" . $description . "\n" . $matureContent;
|
||||||
if (file_put_contents($infoPath, $infoContent) !== false) {
|
$infoPath = $path . '/infos.txt';
|
||||||
$_SESSION['success_message'] = "Dossier modifié avec succès.";
|
if (file_put_contents($infoPath, $infoContent) !== false) {
|
||||||
} else {
|
$_SESSION['success_message'] = "Dossier modifié avec succès.";
|
||||||
$_SESSION['error_message'] = "Erreur lors de la modification du dossier.";
|
} else {
|
||||||
}
|
$_SESSION['error_message'] = "Erreur lors de la modification du dossier.";
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case 'delete_folder':
|
|
||||||
if ($path && isSecurePath($path) && $path !== './liste_albums') { // Empêcher la suppression du dossier racine
|
case 'delete_folder':
|
||||||
function rrmdir($dir) {
|
if ($path && isSecurePath($path) && $path !== './liste_albums') {
|
||||||
if (is_dir($dir)) {
|
function rrmdir($dir) {
|
||||||
$objects = scandir($dir);
|
if (is_dir($dir)) {
|
||||||
foreach ($objects as $object) {
|
$objects = scandir($dir);
|
||||||
if ($object != "." && $object != "..") {
|
foreach ($objects as $object) {
|
||||||
if (is_dir($dir . "/" . $object)) {
|
if ($object != "." && $object != "..") {
|
||||||
rrmdir($dir . "/" . $object);
|
if (is_dir($dir . "/" . $object)) {
|
||||||
} else {
|
rrmdir($dir . "/" . $object);
|
||||||
unlink($dir . "/" . $object);
|
} else {
|
||||||
}
|
unlink($dir . "/" . $object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rmdir($dir);
|
}
|
||||||
}
|
rmdir($dir);
|
||||||
}
|
}
|
||||||
rrmdir($path);
|
}
|
||||||
$_SESSION['success_message'] = "Dossier supprimé avec succès.";
|
rrmdir($path);
|
||||||
}
|
$_SESSION['success_message'] = "Dossier supprimé avec succès.";
|
||||||
break;
|
}
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
header('Location: arbre.php');
|
|
||||||
exit;
|
header('Location: arbre.php');
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentPath = isset($_GET['path']) ? $_GET['path'] : './liste_albums';
|
$currentPath = isset($_GET['path']) ? $_GET['path'] : './liste_albums';
|
||||||
$currentPath = realpath($currentPath);
|
$currentPath = realpath($currentPath);
|
||||||
|
|
||||||
if (!isSecurePath($currentPath)) {
|
if (!isSecurePath($currentPath)) {
|
||||||
header('Location: arbre.php');
|
header('Location: arbre.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateTree($path, $currentPath) {
|
function generateTree($path, $currentPath) {
|
||||||
@ -87,9 +88,12 @@ function generateTree($path, $currentPath) {
|
|||||||
$output .= '<div class="tree-item-content">';
|
$output .= '<div class="tree-item-content">';
|
||||||
$output .= '<span class="tree-link">';
|
$output .= '<span class="tree-link">';
|
||||||
$output .= '<span class="folder-icon">📁</span> ' . htmlspecialchars($info['title']);
|
$output .= '<span class="folder-icon">📁</span> ' . htmlspecialchars($info['title']);
|
||||||
|
if ($info['mature_content']) {
|
||||||
|
$output .= ' <span class="mature-warning">🔞</span>';
|
||||||
|
}
|
||||||
$output .= '</span>';
|
$output .= '</span>';
|
||||||
$output .= '<div class="tree-actions">';
|
$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 .= '<button onclick="createSubfolder(\'' . htmlspecialchars($path) . '\')" class="tree-button">➕</button>';
|
||||||
$output .= '</div></div>';
|
$output .= '</div></div>';
|
||||||
}
|
}
|
||||||
@ -107,12 +111,15 @@ function generateTree($path, $currentPath) {
|
|||||||
$output .= '<div class="tree-item-content">';
|
$output .= '<div class="tree-item-content">';
|
||||||
$output .= '<span class="tree-link">';
|
$output .= '<span class="tree-link">';
|
||||||
$output .= '<span class="folder-icon">📁</span> ' . htmlspecialchars($info['title']);
|
$output .= '<span class="folder-icon">📁</span> ' . htmlspecialchars($info['title']);
|
||||||
|
if ($info['mature_content']) {
|
||||||
|
$output .= ' <span class="mature-warning">🔞</span>';
|
||||||
|
}
|
||||||
$output .= '</span>';
|
$output .= '</span>';
|
||||||
$output .= '<div class="tree-actions">';
|
$output .= '<div class="tree-actions">';
|
||||||
if (!$hasSubfolders) {
|
if (!$hasSubfolders) {
|
||||||
$output .= '<a href="arbre-img.php?path=' . urlencode($fullPath) . '" class="tree-button" style="text-decoration: none">🖼️</a>';
|
$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>';
|
$output .= '<button onclick="createSubfolder(\'' . htmlspecialchars($fullPath) . '\')" class="tree-button">➕</button>';
|
||||||
if ($fullPath !== './liste_albums') {
|
if ($fullPath !== './liste_albums') {
|
||||||
$output .= '<button onclick="deleteFolder(\'' . htmlspecialchars($fullPath) . '\')" class="tree-button tree-button-danger">🗑️</button>';
|
$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>
|
<label for="description">Description :</label>
|
||||||
<textarea id="description" name="description" rows="4" class="form-textarea"></textarea>
|
<textarea id="description" name="description" rows="4" class="form-textarea"></textarea>
|
||||||
</div>
|
</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">
|
<div class="form-actions">
|
||||||
<button type="button" onclick="closeModal()" class="action-button action-button-secondary">Annuler</button>
|
<button type="button" onclick="closeModal()" class="action-button action-button-secondary">Annuler</button>
|
||||||
<button type="submit" class="action-button">Créer</button>
|
<button type="submit" class="action-button">Créer</button>
|
||||||
@ -202,6 +216,13 @@ function generateTree($path, $currentPath) {
|
|||||||
<label for="edit_description">Description :</label>
|
<label for="edit_description">Description :</label>
|
||||||
<textarea id="edit_description" name="description" rows="4" class="form-textarea"></textarea>
|
<textarea id="edit_description" name="description" rows="4" class="form-textarea"></textarea>
|
||||||
</div>
|
</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">
|
<div class="form-actions">
|
||||||
<button type="button" onclick="closeModal()" class="action-button action-button-secondary">Annuler</button>
|
<button type="button" onclick="closeModal()" class="action-button action-button-secondary">Annuler</button>
|
||||||
<button type="submit" class="action-button">Enregistrer</button>
|
<button type="submit" class="action-button">Enregistrer</button>
|
||||||
@ -232,10 +253,11 @@ function generateTree($path, $currentPath) {
|
|||||||
document.getElementById('createFolderModal').style.display = 'block';
|
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('editPath').value = path;
|
||||||
document.getElementById('edit_name').value = title;
|
document.getElementById('edit_name').value = title;
|
||||||
document.getElementById('edit_description').value = description;
|
document.getElementById('edit_description').value = description;
|
||||||
|
document.getElementById('edit_mature_content').checked = matureContent;
|
||||||
document.getElementById('editFolderModal').style.display = 'block';
|
document.getElementById('editFolderModal').style.display = 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@ function getAlbumInfo($albumPath) {
|
|||||||
$infoFile = $albumPath . '/infos.txt';
|
$infoFile = $albumPath . '/infos.txt';
|
||||||
$info = [
|
$info = [
|
||||||
'title' => basename($albumPath),
|
'title' => basename($albumPath),
|
||||||
'description' => ''
|
'description' => '',
|
||||||
|
'mature_content' => false
|
||||||
];
|
];
|
||||||
|
|
||||||
if (file_exists($infoFile)) {
|
if (file_exists($infoFile)) {
|
||||||
@ -29,6 +30,7 @@ function getAlbumInfo($albumPath) {
|
|||||||
$lines = explode("\n", $content);
|
$lines = explode("\n", $content);
|
||||||
if (isset($lines[0])) $info['title'] = trim($lines[0]);
|
if (isset($lines[0])) $info['title'] = trim($lines[0]);
|
||||||
if (isset($lines[1])) $info['description'] = trim($lines[1]);
|
if (isset($lines[1])) $info['description'] = trim($lines[1]);
|
||||||
|
if (isset($lines[2])) $info['mature_content'] = trim($lines[2]) === '18+';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $info;
|
return $info;
|
||||||
|
@ -251,6 +251,55 @@ body {
|
|||||||
margin-bottom: 1.5rem;
|
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 {
|
.form-group label {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user