cvs: php-master-web /entry user-note.php
| From: | Nuno Lopes | Date: | Thu, 26 Jan 2006 17:02:37 +0000 |
| Subject: | cvs: php-master-web /entry user-note.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-30503@lists.php.net to get a copy of this message | ||
nlopess Thu Jan 26 17:02:37 2006 UTC
Modified files:
/php-master-web/entry user-note.php
Log:
implement a temporary SPAM words blacklist. we need to implement a bayesian filter..
http://cvs.php.net/viewcvs.cgi/php-master-web/entry/user-note.php?r1=1.39&r2=1.40&diff_format=u
Index: php-master-web/entry/user-note.php
diff -u php-master-web/entry/user-note.php:1.39 php-master-web/entry/user-note.php:1.40
--- php-master-web/entry/user-note.php:1.39 Mon Jan 23 13:50:37 2006
+++ php-master-web/entry/user-note.php Thu Jan 26 17:02:37 2006
@@ -5,9 +5,40 @@
$mailto = 'php-notes@lists.php.net';
$failto = 'jimw@php.net, alindeman@php.net';
+// list of usual SPAM words
+$worlds_backlist = array(
+ 'alprazolam',
+ 'arimidex',
+ 'carisoprodol',
+ 'ciprofloxacin',
+ 'ephedra',
+ 'esomeprazole',
+ 'glucophage',
+ 'hydrocodone',
+ 'metronidazole',
+ 'nexium',
+ 'testosterone',
+ 'vicoprofen',
+ 'xanax',
+ 'zanaflex',
+);
+
+
if (!isset($user) || empty($note) || empty($sect) || empty($ip) || !isset($redirip))
die("missing some parameters.");
+// check if the IP is blacklisted
+if (is_spammer($_SERVER['REMOTE_ADDR']) || is_spammer($redirip)) {
+ die ('[SPAMMER]');
+}
+
+// check if the note contains some prohibited words
+foreach($worlds_backlist as $bad_word) {
+ if (strpos($note, $bad_word) !== false) {
+ die('[SPAM WORD]');
+ }
+}
+
@mysql_connect("localhost","nobody", "")
or die("failed to connect to database");
@mysql_select_db("phpmasterdb")
@@ -51,11 +82,6 @@
die ('[TOO MANY NOTES]');
}
-// check if the IP is blacklisted
-if (is_spammer($_SERVER['REMOTE_ADDR']) || is_spammer($redirip)) {
- die ('[SPAMMER]');
-}
-
$sect = ereg_replace("\.php$","",$sect);
$query = "INSERT INTO note (user, note, sect, ts, status) VALUES ";