first commit

This commit is contained in:
mrtoine 2025-09-12 10:57:48 +02:00
commit b216a187bd
34 changed files with 4829 additions and 0 deletions

34
admin/delete-project.php Normal file
View file

@ -0,0 +1,34 @@
<?php
require_once './includes/nav.php';
$id = isset($_GET['id']) ? sanitizeInput($_GET['id']) : null;
if (!$id) {
echo "<div class='alert alert-error'>ID de projet manquant.</div>";
exit;
}
$jsonFile = '../data/projects.json';
if(file_exists($jsonFile)) {
$content = file_get_contents($jsonFile);
$projects = $content ? json_decode($content, true) : [];
} else {
$projects = [];
}
// Check if project exists
$projectKey = array_search($id, array_column($projects, 'id'));
if ($projectKey === false) {
echo "<div class='alert alert-error'>Projet non trouvé.</div>";
exit;
}
// On supprime le projet
unset($projects[$projectKey]);
// Reindex the array
$projects = array_values($projects);
// Save updated projects back to the JSON file
if (file_put_contents($jsonFile, json_encode($projects, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))) {
echo "<div class='alert alert-success'>Projet supprimé avec succès !</div>";
} else {
echo "<div class='alert alert-error'>Erreur lors de la suppression du projet.</div>";
}
?>