Browse Source

Enforce spam and minimum character policies

yumi 4 months ago
parent
commit
d769f01fe8
1 changed files with 21 additions and 4 deletions
  1. 21
    4
      www/composer.php

+ 21
- 4
www/composer.php View File

@@ -30,19 +30,36 @@ if (@$_POST['post']) {
30 30
 		header($_SERVER["SERVER_PROTOCOL"]." 400 Bad Request"); 
31 31
 		header("Refresh: $until; url=$page");
32 32
 		include "{$ROOT}template/PostFailure.php";
33
+		die;
33 34
 	} else if (!isset($_POST['robocheck'])) {
34 35
 		$reason = "Did you forget to verify your humanity?";
35 36
 		header("Refresh: $until; url=$page");
36 37
 		include "{$ROOT}template/PostFailure.php";
38
+		die;
37 39
 	} else if (empty(@$_POST['content'])) {
38 40
 		$reason = "Just what are you trying to do?";
39 41
 		header("Refresh: $until; url=$page");
40 42
 		include "{$ROOT}template/PostFailure.php";
41
-	} else {
42
-		$iterator->post($_POST['content'], $_COOKIE['id']);
43
+		die;
44
+	} else if (strlen($_POST['content']) < CONFIG_MIN_POST_BYTES) {
45
+		$reason = "Your post is too short... please write some more!";
43 46
 		header("Refresh: $until; url=$page");
44
-		include "{$ROOT}template/PostSuccess.php";
45
-	} die;
47
+		include "{$ROOT}template/PostFailure.php";
48
+		die;
49
+	}
50
+
51
+	$b8 = $RM->getb8();
52
+	$spamminess = $b8->classify($RM->asHtml($_POST['content']));
53
+	if ($spamminess > CONFIG_SPAM_THRESHOLD) {
54
+		$reason = "Hmm... error code: " . round($spamminess * 100);
55
+		header("Refresh: $until; url=$page");
56
+		include "{$ROOT}template/PostFailure.php";
57
+		die;
58
+	}
59
+
60
+	$iterator->post($_POST['content'], $_COOKIE['id']);
61
+	header("Refresh: $until; url=$page");
62
+	include "{$ROOT}template/PostSuccess.php";
46 63
 }
47 64
 ?>
48 65
 <!DOCTYPE HTML>