October 12, 2005Previous : Canon EOS 350D review (Digital Rebel XT) Next : Free Web Content is Duplicate Content
Filed under: PHP Stuff — Gede @ 4:06 pm Maybe you are like me, a phpBB Forum Administrator, and you are plagued by spammers. First you have those who register only to create a backlink in the member list. Several methods are available already to stop those.
And then there are phpBB forums where anonymous posting is allowed and get plagued by automated post bots, through anonymous proxies. Usually forum administrators close there anonymous posting, or build in a check so that bots cannot post. But this doesn’t stop the manual phpBB spam posts.
But it may be that you, like me, would like to keep the possibilty for anonymous posters to use your phpBB forum. Not all people that have something to say may want to go through the registration process, and you may loose some valueable input, and a future, possible registered contributor.
In “includes/functions_post.php” there is a function “function submit_post” where we can build some nice checks for spam, before the message is allowed into the database. At first I programmed something there to detect certain domains or certain words, like gambling or drug related terms, but after a while the list became too long, and it was too much work to keep the list up to date.
So I decided to build something that would not allow links to be posted by anonymous posters, while they are still able to use the forum.
Here it is:
First find the function “function submit_post” in “includes/functions_post.php”.
Then find the line “global $userdata, $user_ip;”
Add after that:
if (!$userdata['session_logged_in']) {
$allow_p = 0;
$chck = stristr($post_message, 'url');
if ($chck <> FALSE) {
$allow_p=1;
}
$chck = stristr($post_message, ‘http:’);
if ($chck <> FALSE) {
$allow_p=1;
}
$chck = stristr($post_message, ‘www.’);
if ($chck <> FALSE) {
$allow_p=1;
}
$chck = stristr($post_message, ‘.com’);
if ($chck <> FALSE) {
$allow_p=1;
}
$chck = stristr($post_message, ‘.net’);
if ($chck <> FALSE) {
$allow_p=1;
}
$chck = stristr($post_message, ‘.org’);
if ($chck <> FALSE) {
$allow_p=1;
}
$chck = stristr($post_message, ‘.ru’);
if ($chck <> FALSE) {
$allow_p=1;
}
$chck = stristr($post_message, ‘.ro’);
if ($chck <> FALSE) {
$allow_p=1;
}
$chck = stristr($post_message, ‘.pl’);
if ($chck <> FALSE) {
$allow_p=1;
}
if ($allow_p == 1) {
message_die(GENERAL_MESSAGE, ‘Due to frequent spamming, the posting of links by Anonymous Users is prohibited on this forum. Please register to post links, sorry for the trouble.’);
}
}
This should stop most spam posts of links by anonymous users. Of course you can adjust the error message to one that is suitable for you.
If you need more to be blocked just add extra of these:
$chck = stristr($post_message, 'TO BE BLOCKED TERM HERE');
if ($chck <> FALSE) {
$allow_p=1;
}
Of course some spammers are willing to get registered to post their spam links, if you want to discourage those you can set a limit of posts before a registered user can post links:
Change this:
if (!$userdata['session_logged_in']) {
To:
if ((!$userdata['session_logged_in']) OR ($userdata['user_posts'] < 3) ) {
Change the 3 to the number of posts you think is suitable. Of course you have to change the error message in this case, something like:
message_die(GENERAL_MESSAGE, 'Due to frequent spamming, the posting of links by Anonymous Users or registered users with fewer then 3 posts is prohibited on this forum. Sorry for the trouble.’);
Hope this is useful for you !
No Comments
No comments yet.
Leave a comment
You must be logged in to post a comment.
|