function deleteEvent($id) { $details = getEvents($id); if ($details) { $requete = 'DELETE FROM evenement WHERE id = :id; DELETE FROM invitation WHERE id_evenement= :id; DELETE FROM commentaire WHERE id_evenement= :id; DELETE FROM modere WHERE id_evenement = :id;'; $execution = [':id' => $id]; // Supprime les Images if ($details["id_media_principal"]) { unlink(PHOTO_EVENT . $details['id_media_principal']); } $images = getImagesAndId($id); if (isset($images[0][0])) { foreach ($images as $key => $value) { removeEventMedia($id, $images[$key][0]); unlink(PHOTO_EVENT . $images[$key][1]); } } $bdd = new PDO(DSN, DBUSER, DBPASS); $query = $bdd->prepare($requete); if ($query->execute($execution)) { return True; } else { var_dump($query->errorInfo()); return False; } } else { return False; } }
exit; } // Fonction qui check s'il a le droit de modifier. if (connected() && (checkOrganiser($_SESSION['id'], $_GET['id']) or $_SESSION['niveau'] == 2 or $_SESSION['niveau'] == 3)) { } else { if (!connected()) { alert("error", "Vous devez être connecté !"); header("Location: " . getLink(["membres", "connexion"])); exit; } else { alert("error", "Vous n'avez pas le droit de modifier cet évènement!"); header("Location: " . getLink(["accueil"])); exit; } } $contents["images"] = getImagesAndId($_GET['id']); foreach ($contents['images'] as $key => $value) { $contents['images'][$key] = [$contents['images'][$key][0], $contents['images'][$key][1]]; } $contents['img_number'] = count($contents["images"]); $validExtensions = array(".jpg", ".png", ".jpeg"); $maxsize = 2097152; $max_height = 2000; $max_width = $max_height; $count = 0; $contents['errorMessage'] = ''; //Suppression d'image if (!empty($_POST) && $contents['img_number'] > 0) { foreach ($_POST as $key => $value) { if (removeEventMedia($_GET['id'], $contents['images'][$key][0])) { unlink(PHOTO_EVENT . $contents['images'][$key][1]);