Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Checking for blacklisted IP in saveComment()
Hi,
I’m wondering why the check for blacklisted IP is not done first and then are form fields checked and form is processed.
Current process:
1.) get global vars
2.) extract post data
3.) check form data
4.) check IP for blaclisting !!!
5.) do some things with form fields
6.) finally: check IP ban and if the IP is blaklisted
7.) save to db
Better process:
1.) check IP for blkalisting
2.) check IP for ban
3.) do all the funny stuff with form fields
7.) save to db
function saveComment() { $ip = serverset(‘REMOTE_ADDR’);
if($is_blacklisted($ip)) { txp_die(gTxt(‘your_ip_is_blacklisted_by’.’ ‘.$blacklisted), ’403 Forbidden’); // end check blacklist } else if (checkBan($ip)) { txp_die(gTxt(‘you_have_been_banned’), ’403 Forbidden’); // end check site ban } else {
global $siteurl,$comments_moderate,$comments_sendmail,$txpcfg, $comments_disallow_images,$prefs;
$ref = serverset(‘HTTP_REFERRER’);
$in = psa( array( ‘parentid’, ‘name’, ‘email’, ‘web’, ‘message’, ‘backpage’, ‘nonce’, ‘remember’ ) );
// ….
}
}
Offline
Re: Checking for blacklisted IP in saveComment()
Offline
#3 2005-10-28 15:42:10
- alice_c
- Plugin Author
- From: Karlsruhe, Germany
- Registered: 2004-07-03
- Posts: 33
Re: Checking for blacklisted IP in saveComment()
Very good idea! It’s annoying to write a long comment, and then the message appears that my IP is blacklisted. In Germany with a big DSL-provider this happens very offen…
Pleace include this patch.
Offline