commit 0c9996065a79216c9650a963102d810b3edbc40a Author: root Date: Sat Jan 10 00:36:22 2026 +0000 [forum] source code diff --git a/flag.php b/flag.php new file mode 100644 index 0000000..4d41514 --- /dev/null +++ b/flag.php @@ -0,0 +1,14 @@ + +

FLAG

+

+setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + diff --git a/includes/footer.php b/includes/footer.php new file mode 100644 index 0000000..308b1d0 --- /dev/null +++ b/includes/footer.php @@ -0,0 +1,2 @@ + + diff --git a/includes/header.php b/includes/header.php new file mode 100644 index 0000000..61be0cb --- /dev/null +++ b/includes/header.php @@ -0,0 +1,18 @@ + + + + + Mini Forum YEAH! + + + + +
diff --git a/index.php b/index.php new file mode 100644 index 0000000..4292ab9 --- /dev/null +++ b/index.php @@ -0,0 +1,117 @@ +prepare("SELECT last_post FROM rate_limit WHERE ip = ?"); + $stmt->execute([$ip]); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($row && ($now - $row['last_post']) < 60) { + die("Alerte au spam ! Un post par minute maximum"); + } + + if (empty($_POST['comment'])) { + die("On aime pas trop les muets sur ce forum deso pas deso"); + } + + $comment = trim($_POST['comment']); + + $imageName = null; + + if (!empty($_FILES['image']['name'])) { + + if ($_FILES['image']['size'] > 2 * 1024 * 1024) { + die("Ah-ah Image trop lourde (2 Mo maximum)"); + } + + $mime = mime_content_type($_FILES['image']['tmp_name']); + $allowedMime = ['image/png', 'image/jpeg']; + + if (!in_array($mime, $allowedMime, true)) { + die("Format interdit (PNG / JPEG uniquement)"); + } + + $ext = strtolower(pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION)); + if (!in_array($ext, ['png', 'jpeg', 'jpg'], true)) { + die("On accepte que les chèques ici, et les png..."); + } + + $imageName = uniqid('img_', true) . '.' . $ext; + + if (!move_uploaded_file( + $_FILES['image']['tmp_name'], + __DIR__ . "/upload/images/$imageName" + )) { + die("Whoooops ! Échec de l'upload"); + } + } + + $stmt = $db->prepare( + "INSERT INTO posts (comment, image, ip) VALUES (?, ?, ?)" + ); + $stmt->execute([ + htmlspecialchars($comment, ENT_QUOTES, 'UTF-8'), + $imageName, + $ip + ]); + + $db->prepare("REPLACE INTO rate_limit (ip, last_post) VALUES (?, ?)") + ->execute([$ip, $now]); + + header("Location: index.php"); + exit; +} +?> + +

Nouveau post

+ +
+ + + + + +
+ +
+ +

Posts récents

+ +query("SELECT * FROM posts ORDER BY id DESC"); +foreach ($posts as $post): +?> +
+
+ IP: + | +
+ +
+ + + + image postée + +
+
+ + + + diff --git a/login.php b/login.php new file mode 100644 index 0000000..2460db2 --- /dev/null +++ b/login.php @@ -0,0 +1,20 @@ + +
+ + + +
+ + diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..fda681e --- /dev/null +++ b/logout.php @@ -0,0 +1,4 @@ +