For Programmers: Free Programming Magazines  


Home > Archive > PHP Mirrors > January 2006 > 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
Nuno Lopes

2006-01-21, 6:56 pm

nlopess Sat Jan 21 20:53:00 2006 UTC

Modified files:
/php-master-web/entry user-note.php
Log:
add a simple is_spammer() function, which checks if the submitter is listed at SORBS or DSBL

http://cvs.php.net/viewcvs.cgi/php-...8&diff_format=u
Index: php-master-web/entry/user-note.php
diff -u php-master-web/entry/user-note.php:1.37 php-master-web/entry/user-note.php:1.38
--- php-master-web/entry/user-note.php:1.37 Thu Jan 19 11:55:01 2006
+++ php-master-web/entry/user-note.php Sat Jan 21 20:53:00 2006
@@ -51,6 +51,11 @@
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 ";
@@ -108,3 +113,30 @@
'From: webmaster@php.net');
die("failed to insert record");
}
+
+
+
+/* check if an IP is marked as spammer.
+ test with 127.0.0.2 for positive and 127.0.0.1 for negative
+*/
+function is_spammer($ip) {
+ $reverse_ip = implode('.', array_reverse(explode('.', $ip)));
+
+ // spammers lists
+ $lists[] = 'list.dsbl.org';
+ $lists[] = 'dnsbl.sorbs.net';
+
+ foreach ($lists as $list) {
+ $host = $reverse_ip . '.' . $list;
+
+ if (gethostbyname($host) != $host) {
+ 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