For Programmers: Free Programming Magazines  


Home > Archive > PHP Mirrors > February 2007 > cvs: php-master-web /entry user-note.php









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author cvs: php-master-web /entry user-note.php
Philip Olson

2007-02-10, 4:01 am

philip Sat Feb 10 03:39:27 2007 UTC

Modified files:
/php-master-web/entry user-note.php
Log:
More SPAM checking: bbcode links, and too many http://'s


http://cvs.php.net/viewvc.cgi/php-m...3&diff_format=u
Index: php-master-web/entry/user-note.php
diff -u php-master-web/entry/user-note.php:1.62 php-master-web/entry/user-note.php:1.63
--- php-master-web/entry/user-note.php:1.62 Mon Feb 5 03:13:13 2007
+++ php-master-web/entry/user-note.php Sat Feb 10 03:39:27 2007
@@ -65,12 +65,19 @@
}

// check if the note contains some prohibited words
+$note_lc = strtolower($note);
foreach($worlds_backlist as $bad_word) {
- if (strpos($note, $bad_word) !== false) {
+ if (strpos($note_lc, $bad_word) !== false) {
die('[SPAM WORD]');
}
}

+// run a few more spam checks
+if (is_spam($note_lc)) {
+ die ('[SPAM WORD]');
+}
+unset($note_lc);
+
// check with spamassassin if the note is spam or not
/*
$spam = shell_exec('echo ' . escapeshellarg($note) . " | $spamassassin -L -e 8");
@@ -211,6 +218,16 @@
return false;
}

+function is_spam ($text) {
+ if (preg_match('/\[(url|link)=[^]]+\]/', $text)) {
+ return true;
+ }
+ if (substr_count($text, 'http://') > 4) {
+ return true;
+ }
+ return false;
+}
+
//var_dump(is_spammer('127.0.0.1')); // false
//var_dump(is_spammer('127.0.0.2')); // true

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com