Forums

Unfortunately no one can be told what FluxBB is - you have to see it for yourself.

You are not logged in.

#1 2013-01-06 20:15:20

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 314
Website

[Mod] GameZoo Akismet antispam w/ queue

Hello everyone,

we (gamezoo.org, gamers association providing gaming-related services) put together a mod enabling Akismet spam protection for FluxBB 1.5.* 1.5.8+ (addons support required since mod version 1.0).

Download link:
http://fluxbb.org/resources/mods/gamezoo-akismet/

Installation instructions

Follow the advice detailed in the file README.md.

# GameZoo Akismet antispam filter for FluxBB 1.5.8+

## Description

This mod brings your forum the notorious antispam filter Akismet.
It features a queue to review spams and restore hams, and a
"mark as spam" option offered to trusted users.
Spammers are automatically banned, and when their post is
judged as real spam and deleted from the review queue the spammers'
personal details are sanitized.

## Requirements

This mod uses a PHP5+ class, so it won't work on PHP4 webservers.

An API key is needed.
If you have a WordPress blog, get your personal API key here: https://apikey.wordpress.com
Otherwise, get one here: https://akismet.com/signup

## Database

The following database changes are performed:

* A new table will be installed for the queue: `$db->prefix.gz_akismet_queue`.
* A new configuration `o_gz_akismet` will be inserted into `$db->prefix.config`.


## Achievements unlocked

* _Only If I Need To_: the posts are reviewed only if the user belongs in an untrusted group.
* _Captain Hook_: thanks to FluxBB's new hooks system (introduced with v1.5.8), installing this mod is a real joke.
* _Unforgiving_: apart from banning the spammer, its profile is cleared. Many spammers fill the signature with, well, spam.
* _Safe For Kids_: to avoid false positives you can skip checking short posts or posts without links.
* _I Remember Everything_: all spam is put in a queue that admins and mods can review to restore hams.
* _Safe For Kids 2_: restoring hams puts everything back where it should be. Even subscribers are notified.
* _Power To The People_: users in a trusted group can mark posts as spam while you're enjoying your holidays. And they are shown a confirmation page to think more about it!
* _Silent Weep_: if the akismet server is unreachable the post will be accepted and no error will be shown to the user.
* _Self Test_: there's a testing mode where every new post will be marked as spam but the post author won't be banned. The akismet request string is displayed in the message put in the spam queue.

## Tips

### Prevent bots from registering

This mod does not prevent spammers from __registering__: it prevents them from __posting__.
Use another mod (e.g. recaptcha, honeypot, question/answer) to prevent bots from registering, and let this one nail human spammers.

### Don't check old members

Checking every post is a waste of resources. You need to check only posts made by new members.
Create a "newly registered" group, and make it the default group after registration.
Then use the auto-promotion feature to make them members after some posts.
Configure this mod to check only posts coming from guests and newly registered.

## Installation

### Upload files

* Upload `addons/gamezoo_akismet.php` to the forum `addons` folder.
* Upload `lang/English/gamezoo_akismet_lang.php` to the forum `lang/English` folder.
* Upload `plugins/AP_GZ_Akismet_cfg.php` to the forum `plugins` folder.
* Upload `plugins/AMP_GZ_Akismet_queue.php` to the forum `plugins` folder.
* Upload `include/Akismet.class.php` to the forum `include` folder.
* Upload `gamezoo_akismet_spam.php` to the forum root folder.

### (optional) Edit `viewtopic.php`

This step enables the 'mark as spam' feature in FluxBB 1.5.8.

Open `viewtopic.php` and find the snippet (line 225-226):

    // Retrieve the posts (and their respective poster/online status)
    $result = $db->query('SELECT u.email, u.title, u.url, u.location, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, g.g_promote_next_group, o.user_id AS is_online FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id LEFT JOIN '.$db->prefix.'online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.id IN ('.implode(',', $post_ids).') ORDER BY p.id', true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

We must add the user `group_id` to the query. __Replace__ the previous snippet with this one:

    // Retrieve the posts (and their respective poster/online status) - akismet mod: fetch the group_id too.
    $result = $db->query('SELECT u.email, u.group_id, u.title, u.url, u.location, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, g.g_promote_next_group, o.user_id AS is_online FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id LEFT JOIN '.$db->prefix.'online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.id IN ('.implode(',', $post_ids).') ORDER BY p.id', true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

Still in `viewtopic.php`, find the snippet (lines 353-363):
    
    // Do signature parsing/caching
    if ($pun_config['o_signatures'] == '1' && $cur_post['signature'] != '' && $pun_user['show_sig'] != '0')
    {
        if (isset($signature_cache[$cur_post['poster_id']]))
            $signature = $signature_cache[$cur_post['poster_id']];
        else
        {
            $signature = parse_signature($cur_post['signature']);
            $signature_cache[$cur_post['poster_id']] = $signature;
        }
    }

__After__, add this hook:

    flux_hook('viewtopic_before_display');

### Install the database table

Go to the Administration panel, and launch the plugin named `GZ Akismet cfg`. It will ask you to install the table.

## Removal

Remove the files:

* `addons/gamezoo_akismet.php`
* `lang/English/gamezoo_akismet_lang.php`
* `plugins/AP_GZ_Akismet_cfg.php`
* `plugins/AMP_GZ_Akismet_queue.php`
* `include/Akismet.class.php`
* `gamezoo_akismet_spam.php`

Manually drop the database table `$db->prefix.gz_akismet_queue`, e.g.:

    DROP TABLE gz_akismet_queue;

Manually delete from the table `$db->prefix.config` the `o_gz_akismet` row, e.g.:

    DELETE FROM config WHERE conf_name='o_gz_akismet';

Revert `viewtopic.php` undoing the changes detailed above.

Last edited by seven (2015-02-09 11:18:25)


gamezoo.org - serious gaming services for serious gamers.

Offline

#2 2013-01-06 20:54:03

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 6,686
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

This sounds really cool. Thank you very much!

Now, everybody will cheer even more if you can package this up as a mod and upload it in our modification repository on this site. smile


fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

#3 2013-01-06 20:59:30

Studio384
Developer
From: Belgium
Registered: 2012-04-11
Posts: 681
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

Looks pretty interesting. Keep on the good work, but 1 download would be nice big_smile

Offline

#4 2013-01-07 01:37:47

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 314
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

I uploaded the mod as requested, you can find it here:

http://fluxbb.org/resources/mods/gamezoo-akismet/

Have a good new year smile


gamezoo.org - serious gaming services for serious gamers.

Offline

#5 2013-01-15 15:43:35

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 314
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

Works with FluxBB 1.5.2 without modifications.


gamezoo.org - serious gaming services for serious gamers.

Offline

#6 2013-02-27 21:11:21

clm
Member
Registered: 2013-02-23
Posts: 5

Re: [Mod] GameZoo Akismet antispam w/ queue

I have installed this mod everything was fine in fluxBB 1.5.3 but after the install when i want to see one post i have this error :

Fatal error: Cannot redeclare gz_ak_post_presave_hook() (previously declared in /homez.666/forumphox/www/include/gamezoo_akismet.php:10) in /homez.666/forumphox/www/include/gamezoo_akismet.php on line 52

What i can do ?

Last edited by clm (2013-02-28 10:01:10)

Offline

#7 2013-02-28 12:38:16

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 314
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

I'm having a look.


gamezoo.org - serious gaming services for serious gamers.

Offline

#8 2013-02-28 12:55:54

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 314
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

This error is triggered because the included file is included more than once in your viewtopic.php file (that's strange). You may attempt to correct the problem by replacing every "require" with a "require_once":

#
#---------[ 1. UPLOAD ]-------------------------------------------------------
#

root/gamezoo_akismet_spam.php to /
root/include/Akismet.class.php to /include/
root/include/gamezoo_akismet.php to /include/
root/plugins/AP_GZ_Akismet_cfg.php to /plugins/
root/plugins/AMP_GZ_Akismet_queue.php to /plugins/
root/lang/English/gamezoo_akismet_lang.php to /lang/English/


#
#---------[ 2. OPEN ]---------------------------------------------------------
#

/post.php


#
#---------[ 3. FIND ]-----------------------------------------------------------
#

// Did everything go according to plan?
if (empty($errors) && !isset($_POST['preview']))
{


#
#---------[ 4. AFTER, ADD ]---------------------------------------------------
#

/******* Post: pre-save hooks BEGIN *******/

// GameZoo Akismet antispam post filter
require_once PUN_ROOT.'include/gamezoo_akismet.php';

// this is a reply to an existing topic
if($tid)
gz_ak_post_presave_hook($username, $email, $tid, $fid, NULL, $orig_message);

// set tid to NULL if we're posting a new topic
else if($fid)
gz_ak_post_presave_hook($username, $email, NULL, $fid, $subject, $orig_message);

/******** Post: pre-save hooks END ********/


#
#---------[ 5. OPEN ]---------------------------------------------------------
#

/viewtopic.php


#
#---------[ 6. FIND ]-----------------------------------------------------------
#

// Perform the main parsing of the message (BBCode, smilies, censor words etc)
$cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);


#
#---------[ 7. BEFORE, ADD ]---------------------------------------------------
#

/******* Post: pre-view hooks BEGIN *******/
	
// GameZoo Akismet antispam post filter
require_once PUN_ROOT.'include/gamezoo_akismet.php';

// insert "mark as spam" in $post_actions[] for admins and moderators
gz_ak_viewtopic_preview_hook($post_actions, $cur_post['g_id'], $cur_post['id']);

/******** Post: pre-view hooks END ********/


#
#---------[ 8. SAVE/UPLOAD ]-------------------------------------------------
#

But I think that you edited the wrong file, placing both the presave hook and the preview hook in viewtopic.php.

Please copy&paste your post.php and viewtopic.php files for further examination.

Cheers,

7


gamezoo.org - serious gaming services for serious gamers.

Offline

#9 2013-02-28 13:35:29

clm
Member
Registered: 2013-02-23
Posts: 5

Re: [Mod] GameZoo Akismet antispam w/ queue

I only have the presave hook in post.php and the preview hook in viewtopic.php.
It seems that work with require_once. I have no error.
If i find any error i'll be back.

Thanks

Offline

#10 2013-03-11 22:00:27

clm
Member
Registered: 2013-02-23
Posts: 5

Re: [Mod] GameZoo Akismet antispam w/ queue

In the config how much i have to put in the field "Post length greater than:    "

Offline

#11 2013-03-12 09:40:10

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 314
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

Well, I'd guess 5 is a reasonable upper value: "hello", "yes", "no", "OK" are the short replies some users are particularly inclined to put in a forum.

Akismet doesn't like such short responses, because spammers may use them just to put their links in the signature or profile, which can't be read by Akismet. So I offered a way to bypass the check and avoid banning legitimate users.

Keep it between 0 and 5.


gamezoo.org - serious gaming services for serious gamers.

Offline

#12 2013-04-04 14:37:51

Backtogeek
New member
Registered: 2013-04-04
Posts: 1

Re: [Mod] GameZoo Akismet antispam w/ queue

Not sure why it is an issue but when ever I insert

/******* Post: pre-view hooks BEGIN *******/

// GameZoo Akismet antispam post filter
require PUN_ROOT.'include/gamezoo_akismet.php';

// insert "mark as spam" in $post_actions[] for admins and moderators
gz_ak_viewtopic_preview_hook($post_actions, $cur_post['g_id'], $cur_post['id']);

/******** Post: pre-view hooks END ********/

that goes in viewtopic.php as per the instructions here: forum.gamezoo.it/viewtopic.php?pid=14#p14

If I do that then when you go to read a post it turns text only for some reason as if the connection to the database is broken when those lines are active.

If I comment out the 2 active lines it all displays normal again.

I have checked and checked again is in th right place and I have double checked all files are in the right place, I am on 1.5.2

Offline

#13 2013-04-04 16:30:25

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 6,686
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

Welcome to the forums! smile

What do you mean with "turning text-only"? Do you see the PHP source code in the browser?


fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

#14 2013-05-03 04:09:29

Jack
Member
Registered: 2010-12-24
Posts: 485
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

clm wrote:

I have installed this mod everything was fine in fluxBB 1.5.3 but after the install when i want to see one post i have this error :

Fatal error: Cannot redeclare gz_ak_post_presave_hook() (previously declared in /include/gamezoo_akismet.php:10) in /include/gamezoo_akismet.php on line 52

What i can do ?

I was having exactly the same issue, and I solved using your suggestion (required_once instead of require).

Anyway, this is strange. The forum has always worked with no problem, as soon as I changed my host (no code change, nothing at all) I started to get this error. Would be interesting to understand why...

J


Sorry I don't speak English smile
FluxBB Italy

Offline

#15 2013-05-03 12:21:42

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 314
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

Yeah, this is really strange. I don't find a codepath where that function can be declared twice. Maybe there is a cache somewhere.

I'm using nginx+php-fpm+apc on gentoo x86, usually on that environment errors come up pretty quick.

Well, maybe the safest thing to do would be a big mod rewrite putting all these functions in a PHP class, and checking if the class is already present (e.g. in APC cache) before including the file. No errors could ever happen with that approach. But I lack the time now...


gamezoo.org - serious gaming services for serious gamers.

Offline

#16 2014-01-26 14:01:06

Jack
Member
Registered: 2010-12-24
Posts: 485
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

Hmmm.. I am having a problem with this (great) plugin.

A moderator has been blocked!

As soon as he tries to login, he faces this:

"Akismet zapped you. You must wait until admins or moderators review the queue. Do NOT attempt to get unbanned. Do NOT write us. Do NOTHING."

There are no reason why (his ip is a normal dinamic ip). And, most of all, I don't see any message about this thing anywher (nor in the admin section, nor in the aski-queue, nor in my email). What can I do (except asking him to reboot his router big_smile)?

Thansk!


Sorry I don't speak English smile
FluxBB Italy

Offline

#17 2014-01-27 08:06:35

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 314
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

Hello,

Akismet (http://akismet.com/) doesn't work only with IPs, but parses the message string instead. Therefore it can generate false positives, like what appened to your moderator.

Moreover, the queue only lasts X days (10 days is the default config option). After that time, the queue is emptied automatically (well, to be honest, instead of providing a crontab script I chose to do the check the first time an admin opens the queue page...). So you should either set that to 0 or view the queue more often. No mail is sent to the board admin.

You should really flag the Moderator group as trusted user group. What's the point of running Akismet on every post made by Moderators? Are you letting spammers to run your forum? :-)

Sooo... to solve the problem:

1) set the "Days in spam queue" config option to 0;
2) make sure the Administrators and Moderators groups are on the "trusted groups" list;
3) unban the moderator using FluxBB's tools. He'll need to build his profile again though, since the plugin clears his profile (because some spammers subscribe only to put a link in their profile rather than posting).


I'll remove from a future version of the plugin the spam queue days, because it's needed to unban an user and tell akismet not to ban him again.
----

versione in italiano... akismet analizza il messaggio e può generare falsi positivi. Non vedi nulla nella coda perché dopo tot giorni (configurabile) la coda si svuota automaticamente e tutti quelli che ci sono dentro vengono bannati. In più non vedo l'utilità di controllare con akismet i messaggi di quelli che hai designato come moderatori. Per risolvere il problema, oltre a settare i giorni in coda a 0 (= mantiene sempre i messaggi), dovrai rimettere i moderatori tra i trusted users e unbannarlo tramite gli strumenti fluxbb standard.

Last edited by seven (2014-01-27 08:17:23)


gamezoo.org - serious gaming services for serious gamers.

Offline

#18 2014-02-10 00:52:31

cstromme
Member
Registered: 2014-02-09
Posts: 8

Re: [Mod] GameZoo Akismet antispam w/ queue

I've been having some problems installing this on the latest version of FluxBB. I've followed the procedures exactly, but when I click the button to create the gz_akismet_queue table I just get a screen saying "Error: Unable to create table fl_gz_akismet_queue. Please check your settings and try again.."

So I went through the php source and copies out the create table query, and replaced the db prefix variable with fl_. Created the table manually in phpmyadmin, and verified that it looked ok. Returned to FluxBB and the plugin page, but it still has the "Create table" button. How do I make it move on from this after manually adding the table?

Offline

#19 2014-02-10 08:19:12

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 314
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

That's weird. Could you look at the server logs to determine exactly why it isn't letting you to create the table? Try enabling debug mode: http://fluxbb.org/forums/viewtopic.php?id=6078

To go on with the mod install script you'll have to edit AP_GZ_Akismet_cfg.php, line 36, from:

// ok, here you go...
function gz_ak_first_time()
{
    // query FluxBB for akismet configuration options.
    [..CUT..]

to:

// ok, here you go...
function gz_ak_first_time()
{
    return false;
    // query FluxBB for akismet configuration options.
    [..CUT..]

Still, I'd be grateful if you could debug it a little.


gamezoo.org - serious gaming services for serious gamers.

Offline

#20 2014-02-10 08:42:11

cstromme
Member
Registered: 2014-02-09
Posts: 8

Re: [Mod] GameZoo Akismet antispam w/ queue

File: /home/airwebap/public_html/forums2/plugins/AP_GZ_Akismet_cfg.php
Line: 140

FluxBB reported: Unable to create table fl_gz_akismet_queue. Please check your settings and try again.

Database reported: Query was empty (Errno: 1065)

Offline

#21 2014-02-10 09:19:10

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 314
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

cstromme wrote:

Database reported: Query was empty (Errno: 1065)

Ah yes, I missed the 'default' label in the switch statement...

default:
    error('\''.$db_type.'\' is not a valid database type. Please check settings in config.php.', __FILE__, __LINE__);
    break;

BTW, the error is most likely due to the fact that you're using mysqli_innodb instead of plain mysqli. Thanks for reporting, I'll fix it ASAP.


gamezoo.org - serious gaming services for serious gamers.

Offline

#22 2014-02-10 09:23:06

cstromme
Member
Registered: 2014-02-09
Posts: 8

Re: [Mod] GameZoo Akismet antispam w/ queue

Having some additional issues here now. If I visit a thread I just get:

$cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
Index
» Bug Reports
» A few bugs
Pages: 1

Did I mess something up somewhere?

Offline

#23 2014-02-10 09:24:02

cstromme
Member
Registered: 2014-02-09
Posts: 8

Re: [Mod] GameZoo Akismet antispam w/ queue

And if I try to delete a user and mark as spam I get:
Error: Unable to fetch group.

Offline

#24 2014-02-10 10:16:06

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 314
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

Hold on now. smile

I fixed the install + config script and released v0.2...

Then I got back here and remembered to fix the 'require' vs 'require_once' issue, and released v0.3: http://fluxbb.org/resources/mods/gamezoo-akismet/

Could you start from scratch? You have to:
1) drop the table gz_akismet_queue;
2) delete the row o_gz_akismet from the table config;
3) download and apply the new 0.3 release;
4) delete all PHP scripts in the /cache/ directory.

The error you reported in post #22 is due to the presence of 'require' instead of 'require_once', an issue that appears on apache and has been solved now.

And post #23: don't delete an user before marking the post as spam. The mod will ban the user and clean the profile, but if you deleted it before the mod will fail.


gamezoo.org - serious gaming services for serious gamers.

Offline

#25 2015-02-09 11:06:18

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 314
Website

Re: [Mod] GameZoo Akismet antispam w/ queue

Hello,

I managed to find the time to update this mod to the new addons system used in FluxBB 1.5.8.

Here's the changelog:

  • adapted to the new hook+addons system (hence the major revision change).

  • the spammer's user profile is sanitized immediately, instead of waiting for some admin to review the queue.

  • added 'testing mode' for devs wishing to edit this plugin: every post is marked as spam by akismet, but the user will not be banned. The request sent to Akismet is prepended to the message put in the spam queue

  • admins and mods cannot be marked as untrusted users for the 'mark as spam' option.

  • admins are always trusted users for the 'mark as spam' option.

  • if the language file doesn't exist in the language directory (e.g. 'Italian'), the English file is loaded instead.

Grab the new release here: http://fluxbb.org/resources/mods/gamezo … eases/1.0/

PS: I edited the first post.

Last edited by seven (2015-02-09 11:16:38)


gamezoo.org - serious gaming services for serious gamers.

Offline

Board footer

Powered by FluxBB