Update Less Coms

This commit is contained in:
2026-05-13 19:59:13 +02:00
parent 3f004d77c4
commit 7463cc698a
3 changed files with 61 additions and 47 deletions
+13
View File
@@ -343,3 +343,16 @@ COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
--
-- Structure de la table `CONTACT`
--
CREATE TABLE `CONTACT` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL,
`objet` varchar(255) NOT NULL,
`demande` text NOT NULL,
`fichier` varchar(255) DEFAULT NULL,
`date_demande` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+29 -43
View File
@@ -3,24 +3,21 @@ session_start();
$message_status = ''; $message_status = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$to = 'openplanetsmaps@gmail.com';
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$subject = htmlspecialchars($_POST['objet']); $subject = htmlspecialchars($_POST['objet']);
$message = htmlspecialchars($_POST['demande']); $message = htmlspecialchars($_POST['demande']);
$has_error = false; $has_error = false;
$attachment = ''; $file_path = null;
// Gestion du fichier uploadé (téléversement)
if (isset($_FILES['televersement']) && $_FILES['televersement']['error'] == UPLOAD_ERR_OK) { if (isset($_FILES['televersement']) && $_FILES['televersement']['error'] == UPLOAD_ERR_OK) {
$file_tmp_name = $_FILES['televersement']['tmp_name']; $file_tmp_name = $_FILES['televersement']['tmp_name'];
$file_name = $_FILES['televersement']['name']; $file_name = $_FILES['televersement']['name'];
$file_size = $_FILES['televersement']['size']; $file_size = $_FILES['televersement']['size'];
// Sécurisation : Vérification du type MIME réel et de la taille
$file_type = mime_content_type($file_tmp_name); $file_type = mime_content_type($file_tmp_name);
$allowed_types = ['image/jpeg', 'image/png', 'application/pdf']; $allowed_types = ['image/jpeg', 'image/png', 'application/pdf'];
$max_size = 5 * 1024 * 1024; // Limite à 5 Mo $max_size = 5 * 1024 * 1024;
if (!in_array($file_type, $allowed_types)) { if (!in_array($file_type, $allowed_types)) {
$message_status = "<p style='color: #f87171; text-align: center; margin-bottom: 1rem;'>Format non autorisé. Seuls les fichiers JPG, PNG et PDF sont acceptés.</p>"; $message_status = "<p style='color: #f87171; text-align: center; margin-bottom: 1rem;'>Format non autorisé. Seuls les fichiers JPG, PNG et PDF sont acceptés.</p>";
@@ -29,34 +26,40 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$message_status = "<p style='color: #f87171; text-align: center; margin-bottom: 1rem;'>Le fichier est trop volumineux (maximum 5 Mo).</p>"; $message_status = "<p style='color: #f87171; text-align: center; margin-bottom: 1rem;'>Le fichier est trop volumineux (maximum 5 Mo).</p>";
$has_error = true; $has_error = true;
} else { } else {
$content = file_get_contents($file_tmp_name); $upload_dir = 'UPLOADS/';
$encoded_content = chunk_split(base64_encode($content)); if (!is_dir($upload_dir)) {
mkdir($upload_dir, 0777, true);
}
$attachment = "Content-Type: $file_type; name=\"$file_name\"\r\n"; $safe_file_name = time() . '_' . preg_replace('/[^a-zA-Z0-9.\-_]/', '', $file_name);
$attachment .= "Content-Disposition: attachment; filename=\"$file_name\"\r\n"; $target_path = $upload_dir . $safe_file_name;
$attachment .= "Content-Transfer-Encoding: base64\r\n\r\n";
$attachment .= $encoded_content . "\r\n\r\n"; if (move_uploaded_file($file_tmp_name, $target_path)) {
$file_path = $target_path;
} else {
$message_status = "<p style='color: #f87171; text-align: center; margin-bottom: 1rem;'>Erreur lors de la sauvegarde du fichier.</p>";
$has_error = true;
}
} }
} }
if (!$has_error) { if (!$has_error) {
// Générer une frontière (boundary) unique pour séparer le texte de la pièce jointe try {
$boundary = md5(uniqid(time())); $host = '172.22.0.3';
$dbname = 'OpenPlanetsMaps';
$db_user = 'root';
$db_pass = 'admin123';
$headers = "From: $email\r\nReply-To: $email\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"$boundary\"\r\n"; $options = [PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8", PDO::ATTR_EMULATE_PREPARES => false];
$pdo = new PDO("mysql:host=$host;port=3306;dbname=$dbname;charset=utf8;protocol=tcp", $db_user, $db_pass, $options);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$body = "--$boundary\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: 8bit\r\n\r\n"; $stmt = $pdo->prepare("INSERT INTO CONTACT (email, objet, demande, fichier, date_demande) VALUES (?, ?, ?, ?, NOW())");
$body .= "Email: $email\nObjet: $subject\n\nDemande:\n$message\r\n\r\n"; $stmt->execute([$email, $subject, $message, $file_path]);
if (!empty($attachment)) { $message_status = "<p style='color: #4ade80; text-align: center; margin-bottom: 1rem;'>Votre demande a été enregistrée avec succès dans la base de données !</p>";
$body .= "--$boundary\r\n" . $attachment; } catch (PDOException $e) {
} $message_status = "<p style='color: #f87171; text-align: center; margin-bottom: 1rem;'>Erreur de base de données : " . htmlspecialchars($e->getMessage()) . "</p>";
$body .= "--$boundary--\r\n";
if (@mail($to, $subject, $body, $headers)) {
$message_status = "<p style='color: #4ade80; text-align: center; margin-bottom: 1rem;'>Votre message a été envoyé avec succès !</p>";
} else {
$message_status = "<p style='color: #f87171; text-align: center; margin-bottom: 1rem;'>Erreur lors de l'envoi du message. Veuillez vérifier la configuration de votre serveur.</p>";
} }
} }
} }
@@ -67,28 +70,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Contact - OpenPlanetsMaps</title> <title>Contact - OpenPlanetsMaps</title>
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
<style>
body { background-color: #0f172a; color: #e0e0e0; display: flex; justify-content: center; align-items: center; padding: 2rem; min-height: 100vh; }
.admin-box { background-color: #1e293b; padding: 2rem; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.5); width: 100%; max-width: 500px; border: 1px solid #334155; }
.admin-box h1 { color: #00bfff; text-align: center; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.5rem; color: #b9bbbe; font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 0.75rem; background: #0f172a; border: 1px solid #334155; border-radius: 4px; color: white; font-family: inherit; }
.btn-submit { width: 100%; padding: 0.75rem; background-color: #00bfff; color: white; border: none; border-radius: 4px; font-weight: 600; cursor: pointer; margin-top: 1rem; transition: background 0.2s; }
.btn-submit:hover { background-color: #009acd; }
.links { text-align: center; margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.links a { color: #94a3b8; text-decoration: none; font-size: 0.9rem; transition: color 0.2s; }
.links a:hover { color: #ffffff; }
input[type="file"] { cursor: pointer; padding: 0.6rem; }
input[type="file"]::file-selector-button { background: #334155; color: white; border: none; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; margin-right: 1rem; transition: background 0.2s; }
input[type="file"]::file-selector-button:hover { background: #475569; }
</style>
</head> </head>
<body> <body class="page-form">
<div class="admin-box"> <div class="admin-box">
<h1>Contact</h1> <h1>Contact</h1>
<?= $message_status ?> <?= $message_status ?>
<!-- L'attribut enctype est requis pour envoyer des fichiers -->
<form method="POST" action="contact.php" enctype="multipart/form-data"> <form method="POST" action="contact.php" enctype="multipart/form-data">
<div class="form-group"><label>Votre E-mail</label><input type="email" name="email" placeholder="nom@exemple.com" required></div> <div class="form-group"><label>Votre E-mail</label><input type="email" name="email" placeholder="nom@exemple.com" required></div>
<div class="form-group"><label>Objet</label><input type="text" name="objet" placeholder="Sujet de votre demande" required></div> <div class="form-group"><label>Objet</label><input type="text" name="objet" placeholder="Sujet de votre demande" required></div>
+15
View File
@@ -561,3 +561,18 @@ header h1:hover { animation:glitch .4s steps(1) forwards; }
#quiz-img-preview.visible { max-height:none; margin-bottom:1rem; text-align:center; } #quiz-img-preview.visible { max-height:none; margin-bottom:1rem; text-align:center; }
#quiz-img-preview img, #quiz-img-preview video { max-height:160px; width:auto; max-width:100%; margin:0 auto; } #quiz-img-preview img, #quiz-img-preview video { max-height:160px; width:auto; max-width:100%; margin:0 auto; }
} }
body.page-form { background-color: #0f172a; color: #e0e0e0; display: flex; flex-direction: row; justify-content: center; align-items: center; padding: 2rem; min-height: 100vh; overflow-x: auto; }
.admin-box { background-color: #1e293b; padding: 2rem; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.5); width: 100%; max-width: 500px; border: 1px solid #334155; }
.admin-box h1 { color: #00bfff; text-align: center; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.5rem; color: #b9bbbe; font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 0.75rem; background: #0f172a; border: 1px solid #334155; border-radius: 4px; color: white; font-family: inherit; }
.btn-submit { width: 100%; padding: 0.75rem; background-color: #00bfff; color: white; border: none; border-radius: 4px; font-weight: 600; cursor: pointer; margin-top: 1rem; transition: background 0.2s; }
.btn-submit:hover { background-color: #009acd; }
.links { text-align: center; margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.links a { color: #94a3b8; text-decoration: none; font-size: 0.9rem; transition: color 0.2s; }
.links a:hover { color: #ffffff; }
input[type="file"] { cursor: pointer; padding: 0.6rem; }
input[type="file"]::file-selector-button { background: #334155; color: white; border: none; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; margin-right: 1rem; transition: background 0.2s; }
input[type="file"]::file-selector-button:hover { background: #475569; }