Forum - Partagez vos commentaires
Commentaires récents
Aucun commentaire pour le moment.
Connexion
Flag
🚩 Vous êtes connecté !
Accès refusé
Veuillez vous connecter.
query("SELECT last_post_time FROM rate_limit WHERE ip = '" . $mysqli->real_escape_string($clientIp) . "'"); if ($result && $result->num_rows > 0) { $row = $result->fetch_assoc(); if (time() - $row['last_post_time'] < 60) { $error = 'Attendre ' . (60 - (time() - $row['last_post_time'])) . 's avant de poster.'; } } if (empty($error)) { $comment = trim($_POST['comment'] ?? ''); $imagePath = null; if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) { $fileSize = $_FILES['image']['size']; $fileName = $_FILES['image']['name']; $fileExt = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); if ($fileSize < $minFileSize) { $error = 'Min 2 Mo.'; } elseif ($fileSize > $maxFileSize) { $error = 'Max 5 Mo.'; } elseif (!in_array($fileExt, $allowedExtensions)) { $error = 'PNG/JPEG seulement.'; } else { $uploadDir = __DIR__ . '/uploads/'; if (!is_dir($uploadDir)) { mkdir($uploadDir, 0755, true); } $newFileName = uniqid() . '.' . $fileExt; $uploadPath = $uploadDir . $newFileName; if (move_uploaded_file($_FILES['image']['tmp_name'], $uploadPath)) { $imagePath = 'uploads/' . $newFileName; } else { $error = 'Erreur upload.'; } } } if (empty($error) && !empty($comment)) { $comment = htmlspecialchars($comment, ENT_QUOTES, 'UTF-8'); $stmt = $mysqli->prepare('INSERT INTO posts (comment, image_path, poster_ip) VALUES (?, ?, ?)'); $stmt->bind_param('sss', $comment, $imagePath, $clientIp); if ($stmt->execute()) { $mysqli->query("INSERT INTO rate_limit (ip, last_post_time) VALUES ('" . $mysqli->real_escape_string($clientIp) . "', " . time() . ") ON DUPLICATE KEY UPDATE last_post_time = " . time()); $success = 'Posté !'; } $stmt->close(); } elseif (empty($error)) { $error = 'Commentaire vide.'; } } } } $posts = []; $result = $mysqli->query('SELECT id, comment, image_path, poster_ip, created_at FROM posts ORDER BY created_at DESC'); if ($result) { while ($row = $result->fetch_assoc()) { $posts[] = $row; } } ?>
Aucun commentaire pour le moment.
Veuillez vous connecter.